Make MouseCursor mutable
MouseCursor objects were previous immutable which makes it harder to implement deserializers when MouseCursor is sent over IPC in Chromium. R=dcaiafa@chromium.org Review URL: https://webrtc-codereview.appspot.com/6059005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5310 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -81,7 +81,7 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(DesktopFrame* frame,
|
|||||||
mutable_updated_region()->Swap(frame->mutable_updated_region());
|
mutable_updated_region()->Swap(frame->mutable_updated_region());
|
||||||
|
|
||||||
DesktopVector image_pos = position.subtract(cursor.hotspot());
|
DesktopVector image_pos = position.subtract(cursor.hotspot());
|
||||||
DesktopRect target_rect = DesktopRect::MakeSize(cursor.image().size());
|
DesktopRect target_rect = DesktopRect::MakeSize(cursor.image()->size());
|
||||||
target_rect.Translate(image_pos);
|
target_rect.Translate(image_pos);
|
||||||
DesktopVector target_origin = target_rect.top_left();
|
DesktopVector target_origin = target_rect.top_left();
|
||||||
target_rect.IntersectWith(DesktopRect::MakeSize(size()));
|
target_rect.IntersectWith(DesktopRect::MakeSize(size()));
|
||||||
@@ -101,10 +101,10 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(DesktopFrame* frame,
|
|||||||
target_rect.left() * DesktopFrame::kBytesPerPixel;
|
target_rect.left() * DesktopFrame::kBytesPerPixel;
|
||||||
DesktopVector origin_shift = target_rect.top_left().subtract(target_origin);
|
DesktopVector origin_shift = target_rect.top_left().subtract(target_origin);
|
||||||
AlphaBlend(target_rect_data, stride(),
|
AlphaBlend(target_rect_data, stride(),
|
||||||
cursor.image().data() +
|
cursor.image()->data() +
|
||||||
origin_shift.y() * cursor.image().stride() +
|
origin_shift.y() * cursor.image()->stride() +
|
||||||
origin_shift.x() * DesktopFrame::kBytesPerPixel,
|
origin_shift.x() * DesktopFrame::kBytesPerPixel,
|
||||||
cursor.image().stride(),
|
cursor.image()->stride(),
|
||||||
target_rect.size());
|
target_rect.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
MouseCursor::MouseCursor() {}
|
||||||
|
|
||||||
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
|
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
|
||||||
: image_(image),
|
: image_(image),
|
||||||
hotspot_(hotspot) {
|
hotspot_(hotspot) {
|
||||||
@@ -25,8 +27,9 @@ MouseCursor::~MouseCursor() {}
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
MouseCursor* MouseCursor::CopyOf(const MouseCursor& cursor) {
|
MouseCursor* MouseCursor::CopyOf(const MouseCursor& cursor) {
|
||||||
return new MouseCursor(BasicDesktopFrame::CopyOf(cursor.image()),
|
return new MouseCursor(
|
||||||
cursor.hotspot());
|
cursor.image() ? NULL : BasicDesktopFrame::CopyOf(*cursor.image()),
|
||||||
|
cursor.hotspot());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@@ -21,13 +21,19 @@ class DesktopFrame;
|
|||||||
|
|
||||||
class MouseCursor {
|
class MouseCursor {
|
||||||
public:
|
public:
|
||||||
|
MouseCursor();
|
||||||
|
|
||||||
// Takes ownership of |image|. |hotspot| must be within |image| boundaries.
|
// Takes ownership of |image|. |hotspot| must be within |image| boundaries.
|
||||||
MouseCursor(DesktopFrame* image, const DesktopVector& hotspot);
|
MouseCursor(DesktopFrame* image, const DesktopVector& hotspot);
|
||||||
|
|
||||||
~MouseCursor();
|
~MouseCursor();
|
||||||
|
|
||||||
static MouseCursor* CopyOf(const MouseCursor& cursor);
|
static MouseCursor* CopyOf(const MouseCursor& cursor);
|
||||||
|
|
||||||
const DesktopFrame& image() const { return *image_; }
|
void set_image(DesktopFrame* image) { image_.reset(image); }
|
||||||
|
const DesktopFrame* image() const { return image_.get(); }
|
||||||
|
|
||||||
|
void set_hotspot(const DesktopVector& hotspot ) { hotspot_ = hotspot; }
|
||||||
const DesktopVector& hotspot() const { return hotspot_; }
|
const DesktopVector& hotspot() const { return hotspot_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -66,10 +66,10 @@ TEST_F(MouseCursorMonitorTest, MAYBE(FromScreen)) {
|
|||||||
EXPECT_TRUE(cursor_image_.get());
|
EXPECT_TRUE(cursor_image_.get());
|
||||||
EXPECT_GE(cursor_image_->hotspot().x(), 0);
|
EXPECT_GE(cursor_image_->hotspot().x(), 0);
|
||||||
EXPECT_LE(cursor_image_->hotspot().x(),
|
EXPECT_LE(cursor_image_->hotspot().x(),
|
||||||
cursor_image_->image().size().width());
|
cursor_image_->image()->size().width());
|
||||||
EXPECT_GE(cursor_image_->hotspot().y(), 0);
|
EXPECT_GE(cursor_image_->hotspot().y(), 0);
|
||||||
EXPECT_LE(cursor_image_->hotspot().y(),
|
EXPECT_LE(cursor_image_->hotspot().y(),
|
||||||
cursor_image_->image().size().height());
|
cursor_image_->image()->size().height());
|
||||||
|
|
||||||
EXPECT_TRUE(position_received_);
|
EXPECT_TRUE(position_received_);
|
||||||
EXPECT_EQ(MouseCursorMonitor::INSIDE, state_);
|
EXPECT_EQ(MouseCursorMonitor::INSIDE, state_);
|
||||||
|
Reference in New Issue
Block a user