diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 20:35:26 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 20:35:26 +0000 |
commit | bcad2686e10ff2ff31c21e2cc77bd1cee6482e9e (patch) | |
tree | 6000696a564ee1d3c005c63947d38e9486d75143 /remoting | |
parent | a31de5292f5facfeec460cd2defc0b131851fb7a (diff) | |
download | chromium_src-bcad2686e10ff2ff31c21e2cc77bd1cee6482e9e.zip chromium_src-bcad2686e10ff2ff31c21e2cc77bd1cee6482e9e.tar.gz chromium_src-bcad2686e10ff2ff31c21e2cc77bd1cee6482e9e.tar.bz2 |
Move us fully from gfx:: over to skia types for consistency.
BUG=92085
TEST=BUILD
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=103523
Review URL: http://codereview.chromium.org/7992011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
49 files changed, 311 insertions, 319 deletions
diff --git a/remoting/base/DEPS b/remoting/base/DEPS index baabd9b..d7cdc30 100644 --- a/remoting/base/DEPS +++ b/remoting/base/DEPS @@ -2,5 +2,4 @@ include_rules = [ "+google/protobuf", "+net", "+third_party/zlib", - "+ui/gfx", ] diff --git a/remoting/base/capture_data.cc b/remoting/base/capture_data.cc index b66b239..4daa8dd 100644 --- a/remoting/base/capture_data.cc +++ b/remoting/base/capture_data.cc @@ -14,7 +14,7 @@ DataPlanes::DataPlanes() { } CaptureData::CaptureData(const DataPlanes &data_planes, - const gfx::Size& size, + const SkISize& size, media::VideoFrame::Format format) : data_planes_(data_planes), size_(size), diff --git a/remoting/base/capture_data.h b/remoting/base/capture_data.h index ae5b89e..61bc2e8 100644 --- a/remoting/base/capture_data.h +++ b/remoting/base/capture_data.h @@ -11,7 +11,6 @@ #include "base/memory/ref_counted.h" #include "media/base/video_frame.h" #include "third_party/skia/include/core/SkRegion.h" -#include "ui/gfx/size.h" namespace remoting { @@ -28,7 +27,7 @@ struct DataPlanes { class CaptureData : public base::RefCountedThreadSafe<CaptureData> { public: CaptureData(const DataPlanes &data_planes, - const gfx::Size& size, + const SkISize& size, media::VideoFrame::Format format); // Get the data_planes data of the previous capture. @@ -38,7 +37,7 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> { const SkRegion& dirty_region() const { return dirty_region_; } // Return the size of the image captured. - gfx::Size size() const { return size_; } + SkISize size() const { return size_; } // Get the pixel format of the image captured. media::VideoFrame::Format pixel_format() const { return pixel_format_; } @@ -63,7 +62,7 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> { private: const DataPlanes data_planes_; SkRegion dirty_region_; - gfx::Size size_; + SkISize size_; media::VideoFrame::Format pixel_format_; // Time spent in capture. Unit is in milliseconds. diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc index 0b62a63..6754a08 100644 --- a/remoting/base/codec_test.cc +++ b/remoting/base/codec_test.cc @@ -165,14 +165,12 @@ class DecoderTester { // Test the content of the update rect. ASSERT_EQ(rects_.size(), update_rects_.size()); for (size_t i = 0; i < update_rects_.size(); ++i) { - SkIRect &r = rects_[i]; - gfx::Rect rect(r.fLeft, r.fTop, r.width(), r.height()); - EXPECT_EQ(rect, update_rects_[i]); + EXPECT_EQ(rects_[i], update_rects_[i]); EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]); const int stride = frame_->stride(0); - const int offset = stride * update_rects_[i].y() + - kBytesPerPixel * update_rects_[i].x(); + const int offset = stride * update_rects_[i].fTop + + kBytesPerPixel * update_rects_[i].fLeft; const uint8* original = capture_data_->data_planes().data[0] + offset; const uint8* decoded = frame_->data(0) + offset; const int row_size = kBytesPerPixel * update_rects_[i].width(); @@ -188,7 +186,7 @@ class DecoderTester { private: bool strict_; std::deque<SkIRect> rects_; - UpdatedRects update_rects_; + RectVector update_rects_; Decoder* decoder_; scoped_refptr<media::VideoFrame> frame_; scoped_refptr<CaptureData> capture_data_; @@ -257,7 +255,7 @@ scoped_refptr<CaptureData> PrepareEncodeData(media::VideoFrame::Format format, planes.strides[0] = kWidth * kBytesPerPixel; scoped_refptr<CaptureData> data = - new CaptureData(planes, gfx::Size(kWidth, kHeight), format); + new CaptureData(planes, SkISize::Make(kWidth, kHeight), format); return data; } diff --git a/remoting/base/decoder.h b/remoting/base/decoder.h index b13483f..dded484 100644 --- a/remoting/base/decoder.h +++ b/remoting/base/decoder.h @@ -11,11 +11,11 @@ #include "base/task.h" #include "media/base/video_frame.h" #include "remoting/proto/video.pb.h" -#include "ui/gfx/rect.h" +#include "third_party/skia/include/core/SkRect.h" namespace remoting { -typedef std::vector<gfx::Rect> UpdatedRects; +typedef std::vector<SkIRect> RectVector; // Interface for a decoder that takes a stream of bytes from the network and // outputs frames of data. @@ -46,9 +46,7 @@ class Decoder { // Returns rects that were updated in the last frame. Can be called only // after DecodePacket returned DECODE_DONE. Caller keeps ownership of // |rects|. |rects| is kept empty if whole screen needs to be updated. - // TODO(dmaclach): Move this over to using SkRegion. - // http://crbug.com/92085 - virtual void GetUpdatedRects(UpdatedRects* rects) = 0; + virtual void GetUpdatedRects(RectVector* rects) = 0; // Reset the decoder to an uninitialized state. Release all references to // the initialized |frame|. Initialize() must be called before the decoder @@ -71,13 +69,13 @@ class Decoder { // effective on the next decoded video frame. // // When scaling is enabled clipping rectangles are ignored. - virtual void SetClipRect(const gfx::Rect& clip_rect) {} + virtual void SetClipRect(const SkIRect& clip_rect) {} // Force decoder to output a video frame with content in |rects| using the // last decoded video frame. // // Coordinates of rectangles supplied here are before scaling. - virtual void RefreshRects(const std::vector<gfx::Rect>& rects) {} + virtual void RefreshRects(const RectVector& rects) {} }; } // namespace remoting diff --git a/remoting/base/decoder_row_based.cc b/remoting/base/decoder_row_based.cc index f349272..e6fcf95 100644 --- a/remoting/base/decoder_row_based.cc +++ b/remoting/base/decoder_row_based.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -88,8 +88,8 @@ Decoder::DecodeResult DecoderRowBased::DecodePacket(const VideoPacket* packet) { int stride = frame_->stride(media::VideoFrame::kRGBPlane); uint8* rect_begin = frame_->data(media::VideoFrame::kRGBPlane); - uint8* out = rect_begin + stride * (clip_.y() + row_y_) + - kBytesPerPixel * clip_.x(); + uint8* out = rect_begin + stride * (clip_.fTop + row_y_) + + kBytesPerPixel * clip_.fLeft; // Consume all the data in the message. bool decompress_again = true; @@ -151,7 +151,7 @@ void DecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) { state_ = kProcessing; // Reset the buffer location status variables on the first packet. - clip_.SetRect(packet->format().x(), packet->format().y(), + clip_.setXYWH(packet->format().x(), packet->format().y(), packet->format().width(), packet->format().height()); row_pos_ = 0; row_y_ = 0; @@ -184,7 +184,7 @@ void DecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) { return; } -void DecoderRowBased::GetUpdatedRects(UpdatedRects* rects) { +void DecoderRowBased::GetUpdatedRects(RectVector* rects) { rects->swap(updated_rects_); updated_rects_.clear(); } diff --git a/remoting/base/decoder_row_based.h b/remoting/base/decoder_row_based.h index 2afd60e..e47ed89 100644 --- a/remoting/base/decoder_row_based.h +++ b/remoting/base/decoder_row_based.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,7 +22,7 @@ class DecoderRowBased : public Decoder { virtual bool IsReadyForData(); virtual void Initialize(scoped_refptr<media::VideoFrame> frame); virtual DecodeResult DecodePacket(const VideoPacket* packet); - virtual void GetUpdatedRects(UpdatedRects* rects); + virtual void GetUpdatedRects(RectVector* rects); virtual void Reset(); virtual VideoPacketFormat::Encoding Encoding(); @@ -46,7 +46,7 @@ class DecoderRowBased : public Decoder { State state_; // Keeps track of the updating rect. - gfx::Rect clip_; + SkIRect clip_; // The video frame to write to. scoped_refptr<media::VideoFrame> frame_; @@ -63,7 +63,7 @@ class DecoderRowBased : public Decoder { // The current row in the rect that we are updaing. int row_y_; - UpdatedRects updated_rects_; + RectVector updated_rects_; DISALLOW_COPY_AND_ASSIGN(DecoderRowBased); }; diff --git a/remoting/base/decoder_vp8.cc b/remoting/base/decoder_vp8.cc index 234fc07..4befd69 100644 --- a/remoting/base/decoder_vp8.cc +++ b/remoting/base/decoder_vp8.cc @@ -89,13 +89,14 @@ Decoder::DecodeResult DecoderVp8::DecodePacket(const VideoPacket* packet) { } last_image_ = image; - std::vector<gfx::Rect> rects; + RectVector rects; + rects.reserve(packet->dirty_rects_size()); for (int i = 0; i < packet->dirty_rects_size(); ++i) { - gfx::Rect r = gfx::Rect(packet->dirty_rects(i).x(), - packet->dirty_rects(i).y(), - packet->dirty_rects(i).width(), - packet->dirty_rects(i).height()); - rects.push_back(r); + Rect remoting_rect = packet->dirty_rects(i); + rects.push_back(SkIRect::MakeXYWH(remoting_rect.x(), + remoting_rect.y(), + remoting_rect.width(), + remoting_rect.height())); } if (!DoScaling()) @@ -105,7 +106,7 @@ Decoder::DecodeResult DecoderVp8::DecodePacket(const VideoPacket* packet) { return DECODE_DONE; } -void DecoderVp8::GetUpdatedRects(UpdatedRects* rects) { +void DecoderVp8::GetUpdatedRects(RectVector* rects) { rects->swap(updated_rects_); } @@ -136,11 +137,11 @@ void DecoderVp8::SetScaleRatios(double horizontal_ratio, vertical_scale_ratio_ = vertical_ratio; } -void DecoderVp8::SetClipRect(const gfx::Rect& clip_rect) { +void DecoderVp8::SetClipRect(const SkIRect& clip_rect) { clip_rect_ = clip_rect; } -void DecoderVp8::RefreshRects(const std::vector<gfx::Rect>& rects) { +void DecoderVp8::RefreshRects(const RectVector& rects) { if (!DoScaling()) ConvertRects(rects, &updated_rects_); else @@ -151,8 +152,8 @@ bool DecoderVp8::DoScaling() const { return horizontal_scale_ratio_ != 1.0 || vertical_scale_ratio_ != 1.0; } -void DecoderVp8::ConvertRects(const UpdatedRects& rects, - UpdatedRects* output_rects) { +void DecoderVp8::ConvertRects(const RectVector& rects, + RectVector* output_rects) { if (!last_image_) return; @@ -160,24 +161,24 @@ void DecoderVp8::ConvertRects(const UpdatedRects& rects, const int stride = frame_->stride(media::VideoFrame::kRGBPlane); output_rects->clear(); + output_rects->reserve(rects.size()); for (size_t i = 0; i < rects.size(); ++i) { + // Clip by the clipping rectangle first. + SkIRect dest_rect = rects[i]; + if (!dest_rect.intersect(clip_rect_)) + continue; + // Round down the image width and height. int image_width = RoundToTwosMultiple(last_image_->d_w); int image_height = RoundToTwosMultiple(last_image_->d_h); - // Clip by the clipping rectangle first. - gfx::Rect dest_rect = rects[i].Intersect(clip_rect_); - // Then clip by the rounded down dimension of the image for safety. - dest_rect = dest_rect.Intersect( - gfx::Rect(0, 0, image_width, image_height)); + if (!dest_rect.intersect(SkIRect::MakeWH(image_width, image_height))) + continue; // Align the rectangle to avoid artifacts in color space conversion. dest_rect = AlignRect(dest_rect); - if (dest_rect.IsEmpty()) - continue; - ConvertYUVToRGB32WithRect(last_image_->planes[0], last_image_->planes[1], last_image_->planes[2], @@ -190,8 +191,8 @@ void DecoderVp8::ConvertRects(const UpdatedRects& rects, } } -void DecoderVp8::ScaleAndConvertRects(const UpdatedRects& rects, - UpdatedRects* output_rects) { +void DecoderVp8::ScaleAndConvertRects(const RectVector& rects, + RectVector* output_rects) { if (!last_image_) return; @@ -199,24 +200,23 @@ void DecoderVp8::ScaleAndConvertRects(const UpdatedRects& rects, const int stride = frame_->stride(media::VideoFrame::kRGBPlane); output_rects->clear(); + output_rects->reserve(rects.size()); for (size_t i = 0; i < rects.size(); ++i) { // Round down the image width and height. int image_width = RoundToTwosMultiple(last_image_->d_w); int image_height = RoundToTwosMultiple(last_image_->d_h); // Clip by the rounded down dimension of the image for safety. - gfx::Rect dest_rect = - rects[i].Intersect(gfx::Rect(0, 0, image_width, image_height)); + SkIRect dest_rect = rects[i]; + if (!dest_rect.intersect(SkIRect::MakeWH(image_width, image_height))) + continue; // Align the rectangle to avoid artifacts in color space conversion. dest_rect = AlignRect(dest_rect); - if (dest_rect.IsEmpty()) - continue; - - gfx::Rect scaled_rect = ScaleRect(dest_rect, - horizontal_scale_ratio_, - vertical_scale_ratio_); + SkIRect scaled_rect = ScaleRect(dest_rect, + horizontal_scale_ratio_, + vertical_scale_ratio_); ScaleYUVToRGB32WithRect(last_image_->planes[0], last_image_->planes[1], diff --git a/remoting/base/decoder_vp8.h b/remoting/base/decoder_vp8.h index 7aab0fb..33ec147 100644 --- a/remoting/base/decoder_vp8.h +++ b/remoting/base/decoder_vp8.h @@ -18,15 +18,16 @@ class DecoderVp8 : public Decoder { virtual ~DecoderVp8(); // Decoder implementations. - virtual void Initialize(scoped_refptr<media::VideoFrame> frame); - virtual DecodeResult DecodePacket(const VideoPacket* packet); - virtual void GetUpdatedRects(UpdatedRects* rects); - virtual bool IsReadyForData(); - virtual void Reset(); - virtual VideoPacketFormat::Encoding Encoding(); - virtual void SetScaleRatios(double horizontal_ratio, double vertical_ratio); - virtual void SetClipRect(const gfx::Rect& clip_rect); - virtual void RefreshRects(const std::vector<gfx::Rect>& rects); + virtual void Initialize(scoped_refptr<media::VideoFrame> frame) OVERRIDE; + virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; + virtual void GetUpdatedRects(RectVector* rects) OVERRIDE; + virtual bool IsReadyForData() OVERRIDE; + virtual void Reset() OVERRIDE; + virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; + virtual void SetScaleRatios(double horizontal_ratio, + double vertical_ratio) OVERRIDE; + virtual void SetClipRect(const SkIRect& clip_rect) OVERRIDE; + virtual void RefreshRects(const RectVector& rects) OVERRIDE; private: enum State { @@ -40,14 +41,14 @@ class DecoderVp8 : public Decoder { // Perform color space conversion on the specified rectangles. // Write the updated rectangles to |output_rects|. - void ConvertRects(const UpdatedRects& rects, - UpdatedRects* output_rects); + void ConvertRects(const RectVector& rects, + RectVector* output_rects); // Perform scaling and color space conversion on the specified // rectangles. // Write the updated rectangles to |output_rects|. - void ScaleAndConvertRects(const UpdatedRects& rects, - UpdatedRects* output_rects); + void ScaleAndConvertRects(const RectVector& rects, + RectVector* output_rects); // The internal state of the decoder. State state_; @@ -61,10 +62,10 @@ class DecoderVp8 : public Decoder { vpx_image_t* last_image_; // Record the updated rects in the last decode. - UpdatedRects updated_rects_; + RectVector updated_rects_; // Clipping rect for the output of the decoder. - gfx::Rect clip_rect_; + SkIRect clip_rect_; // Scale factors of the decoded output. double horizontal_scale_ratio_; diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc index 75af34a..c8a801f 100644 --- a/remoting/base/encoder_row_based.cc +++ b/remoting/base/encoder_row_based.cc @@ -10,7 +10,6 @@ #include "remoting/base/compressor_zlib.h" #include "remoting/base/util.h" #include "remoting/proto/video.pb.h" -#include "ui/gfx/rect.h" namespace remoting { @@ -42,7 +41,7 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor, VideoPacketFormat::Encoding encoding) : encoding_(encoding), compressor_(compressor), - screen_size_(0, 0), + screen_size_(SkISize::Make(0,0)), packet_size_(kPacketSize) { } @@ -51,7 +50,7 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor, int packet_size) : encoding_(encoding), compressor_(compressor), - screen_size_(0, 0), + screen_size_(SkISize::Make(0,0)), packet_size_(packet_size) { } diff --git a/remoting/base/encoder_row_based.h b/remoting/base/encoder_row_based.h index 6da2cd5..c510a41 100644 --- a/remoting/base/encoder_row_based.h +++ b/remoting/base/encoder_row_based.h @@ -8,7 +8,6 @@ #include "remoting/base/encoder.h" #include "remoting/proto/video.pb.h" #include "third_party/skia/include/core/SkRect.h" -#include "ui/gfx/size.h" namespace remoting { @@ -62,7 +61,7 @@ class EncoderRowBased : public Encoder { scoped_ptr<DataAvailableCallback> callback_; // The most recent screen size. - gfx::Size screen_size_; + SkISize screen_size_; int packet_size_; }; diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc index 4aae550..eea1a52 100644 --- a/remoting/base/encoder_vp8.cc +++ b/remoting/base/encoder_vp8.cc @@ -33,7 +33,7 @@ EncoderVp8::EncoderVp8() active_map_width_(0), active_map_height_(0), last_timestamp_(0), - size_(0, 0) { + size_(SkISize::Make(0, 0)) { } EncoderVp8::~EncoderVp8() { @@ -48,7 +48,7 @@ void EncoderVp8::Destroy() { } } -bool EncoderVp8::Init(const gfx::Size& size) { +bool EncoderVp8::Init(const SkISize& size) { Destroy(); size_ = size; codec_.reset(new vpx_codec_ctx_t()); @@ -134,14 +134,18 @@ bool EncoderVp8::Init(const gfx::Size& size) { } // static -gfx::Rect EncoderVp8::AlignAndClipRect(const gfx::Rect& rect, - int width, int height) { - gfx::Rect screen(RoundToTwosMultiple(width), RoundToTwosMultiple(height)); - return screen.Intersect(AlignRect(rect)); +SkIRect EncoderVp8::AlignAndClipRect(const SkIRect& rect, + int width, int height) { + SkIRect screen(SkIRect::MakeWH(RoundToTwosMultiple(width), + RoundToTwosMultiple(height))); + if (!screen.intersect(AlignRect(rect))) { + screen = SkIRect::MakeWH(0, 0); + } + return screen; } bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data, - std::vector<gfx::Rect>* updated_rects) { + RectVector* updated_rects) { // Perform RGB->YUV conversion. if (capture_data->pixel_format() != media::VideoFrame::RGB32) { LOG(ERROR) << "Only RGB32 is supported"; @@ -162,18 +166,17 @@ bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data, DCHECK(updated_rects->empty()); for (SkRegion::Iterator r(region); !r.done(); r.next()) { // Align the rectangle, report it as updated. - SkIRect skRect = r.rect(); - gfx::Rect rect(skRect.fLeft, skRect.fTop, skRect.width(), skRect.height()); + SkIRect rect = r.rect(); rect = AlignAndClipRect(rect, image_->w, image_->h); - if (!rect.IsEmpty()) + if (!rect.isEmpty()) updated_rects->push_back(rect); ConvertRGB32ToYUVWithRect(in, y_out, u_out, v_out, - rect.x(), - rect.y(), + rect.fLeft, + rect.fTop, rect.width(), rect.height(), in_stride, @@ -183,20 +186,19 @@ bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data, return true; } -void EncoderVp8::PrepareActiveMap( - const std::vector<gfx::Rect>& updated_rects) { +void EncoderVp8::PrepareActiveMap(const RectVector& updated_rects) { // Clear active map first. memset(active_map_.get(), 0, active_map_width_ * active_map_height_); // Mark blocks at active. for (size_t i = 0; i < updated_rects.size(); ++i) { - const gfx::Rect& r = updated_rects[i]; + const SkIRect& r = updated_rects[i]; CHECK(r.width() && r.height()); - int left = r.x() / kMacroBlockSize; - int right = (r.right() - 1) / kMacroBlockSize; - int top = r.y() / kMacroBlockSize; - int bottom = (r.bottom() - 1) / kMacroBlockSize; + int left = r.fLeft / kMacroBlockSize; + int right = (r.fRight - 1) / kMacroBlockSize; + int top = r.fTop / kMacroBlockSize; + int bottom = (r.fBottom - 1) / kMacroBlockSize; CHECK(right < active_map_width_); CHECK(bottom < active_map_height_); @@ -219,7 +221,7 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, initialized_ = ret; } - std::vector<gfx::Rect> updated_rects; + RectVector updated_rects; if (!PrepareImage(capture_data, &updated_rects)) { NOTREACHED() << "Can't image data for encoding"; } @@ -282,8 +284,8 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, message->set_client_sequence_number(capture_data->client_sequence_number()); for (size_t i = 0; i < updated_rects.size(); ++i) { Rect* rect = message->add_dirty_rects(); - rect->set_x(updated_rects[i].x()); - rect->set_y(updated_rects[i].y()); + rect->set_x(updated_rects[i].fLeft); + rect->set_y(updated_rects[i].fTop); rect->set_width(updated_rects[i].width()); rect->set_height(updated_rects[i].height()); } diff --git a/remoting/base/encoder_vp8.h b/remoting/base/encoder_vp8.h index a74d9f9..1d145e8 100644 --- a/remoting/base/encoder_vp8.h +++ b/remoting/base/encoder_vp8.h @@ -9,7 +9,7 @@ #include "base/gtest_prod_util.h" #include "remoting/base/encoder.h" -#include "ui/gfx/rect.h" +#include "third_party/skia/include/core/SkRect.h" typedef struct vpx_codec_ctx vpx_codec_ctx_t; typedef struct vpx_image vpx_image_t; @@ -27,10 +27,12 @@ class EncoderVp8 : public Encoder { DataAvailableCallback* data_available_callback); private: + typedef std::vector<SkIRect> RectVector; + FRIEND_TEST_ALL_PREFIXES(EncoderVp8Test, AlignAndClipRect); // Initialize the encoder. Returns true if successful. - bool Init(const gfx::Size& size); + bool Init(const SkISize& size); // Destroy the encoder. void Destroy(); @@ -38,11 +40,11 @@ class EncoderVp8 : public Encoder { // Prepare |image_| for encoding. Write updated rectangles into // |updated_rects|. Returns true if successful. bool PrepareImage(scoped_refptr<CaptureData> capture_data, - std::vector<gfx::Rect>* updated_rects); + RectVector* updated_rects); // Update the active map according to |updated_rects|. Active map is then // given to the encoder to speed up encoding. - void PrepareActiveMap(const std::vector<gfx::Rect>& updated_rects); + void PrepareActiveMap(const RectVector& updated_rects); // Align the sides of the rectangle to multiples of 2 (expanding outwards), // but ensuring the result stays within the screen area (width, height). @@ -50,8 +52,7 @@ class EncoderVp8 : public Encoder { // // TODO(lambroslambrou): Pull this out if it's useful for other things than // VP8-encoding? - static gfx::Rect AlignAndClipRect(const gfx::Rect& rect, - int width, int height); + static SkIRect AlignAndClipRect(const SkIRect& rect, int width, int height); // True if the encoder is initialized. bool initialized_; @@ -67,7 +68,7 @@ class EncoderVp8 : public Encoder { scoped_array<uint8> yuv_image_; // The current frame size. - gfx::Size size_; + SkISize size_; DISALLOW_COPY_AND_ASSIGN(EncoderVp8); }; diff --git a/remoting/base/encoder_vp8_unittest.cc b/remoting/base/encoder_vp8_unittest.cc index 0be53d5..73fb157 100644 --- a/remoting/base/encoder_vp8_unittest.cc +++ b/remoting/base/encoder_vp8_unittest.cc @@ -49,12 +49,12 @@ TEST(EncoderVp8Test, TestSizeChangeNoLeak) { planes.strides[0] = width; scoped_refptr<CaptureData> capture_data(new CaptureData( - planes, gfx::Size(width, height), media::VideoFrame::RGB32)); + planes, SkISize::Make(width, height), media::VideoFrame::RGB32)); encoder.Encode(capture_data, false, NewCallback(&callback, &EncoderCallback::DataAvailable)); height /= 2; - capture_data = new CaptureData(planes, gfx::Size(width, height), + capture_data = new CaptureData(planes, SkISize::Make(width, height), media::VideoFrame::RGB32); encoder.Encode(capture_data, false, NewCallback(&callback, &EncoderCallback::DataAvailable)); @@ -62,25 +62,25 @@ TEST(EncoderVp8Test, TestSizeChangeNoLeak) { TEST(EncoderVp8Test, AlignAndClipRect) { // Simple test case (no clipping). - gfx::Rect r1(100, 200, 300, 400); + SkIRect r1(SkIRect::MakeXYWH(100, 200, 300, 400)); EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, kIntMax, kIntMax), r1); // Should expand outward to r1. - gfx::Rect r2(101, 201, 298, 398); + SkIRect r2(SkIRect::MakeXYWH(101, 201, 298, 398)); EXPECT_EQ(EncoderVp8::AlignAndClipRect(r2, kIntMax, kIntMax), r1); // Test clipping to screen size. EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, 110, 220), - gfx::Rect(100, 200, 10, 20)); + SkIRect::MakeXYWH(100, 200, 10, 20)); // Rectangle completely off-screen. - EXPECT_TRUE(EncoderVp8::AlignAndClipRect(r1, 50, 50).IsEmpty()); + EXPECT_TRUE(EncoderVp8::AlignAndClipRect(r1, 50, 50).isEmpty()); // Clipping to odd-sized screen. An unlikely case, and we might not deal // with it cleanly in the encoder (we possibly lose 1px at right & bottom // of screen). EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, 199, 299), - gfx::Rect(100, 200, 98, 98)); + SkIRect::MakeXYWH(100, 200, 98, 98)); } } // namespace remoting diff --git a/remoting/base/util.cc b/remoting/base/util.cc index 483d97f..e960f09 100644 --- a/remoting/base/util.cc +++ b/remoting/base/util.cc @@ -54,13 +54,13 @@ void ConvertYUVToRGB32WithRect(const uint8* y_plane, const uint8* u_plane, const uint8* v_plane, uint8* rgb_plane, - const gfx::Rect& rect, + const SkIRect& rect, int y_stride, int uv_stride, int rgb_stride) { - int rgb_offset = CalculateRGBOffset(rect.x(), rect.y(), rgb_stride); - int y_offset = CalculateYOffset(rect.x(), rect.y(), y_stride); - int uv_offset = CalculateUVOffset(rect.x(), rect.y(), uv_stride); + int rgb_offset = CalculateRGBOffset(rect.fLeft, rect.fTop, rgb_stride); + int y_offset = CalculateYOffset(rect.fLeft, rect.fTop, y_stride); + int uv_offset = CalculateUVOffset(rect.fLeft, rect.fTop, uv_stride); media::ConvertYUVToRGB32(y_plane + y_offset, u_plane + uv_offset, @@ -78,15 +78,20 @@ void ScaleYUVToRGB32WithRect(const uint8* y_plane, const uint8* u_plane, const uint8* v_plane, uint8* rgb_plane, - const gfx::Rect& source_rect, - const gfx::Rect& dest_rect, + const SkIRect& source_rect, + const SkIRect& dest_rect, int y_stride, int uv_stride, int rgb_stride) { - int rgb_offset = CalculateRGBOffset(dest_rect.x(), dest_rect.y(), rgb_stride); - int y_offset = CalculateYOffset(source_rect.x(), source_rect.y(), y_stride); - int uv_offset = CalculateUVOffset(source_rect.x(), - source_rect.y(), uv_stride); + int rgb_offset = CalculateRGBOffset(dest_rect.fLeft, + dest_rect.fTop, + rgb_stride); + int y_offset = CalculateYOffset(source_rect.fLeft, + source_rect.fTop, + y_stride); + int uv_offset = CalculateUVOffset(source_rect.fLeft, + source_rect.fTop, + uv_stride); media::ScaleYUVToRGB32(y_plane + y_offset, u_plane + uv_offset, @@ -134,26 +139,23 @@ int RoundToTwosMultiple(int x) { return x & (~1); } -gfx::Rect AlignRect(const gfx::Rect& rect) { - int x = RoundToTwosMultiple(rect.x()); - int y = RoundToTwosMultiple(rect.y()); - int right = RoundToTwosMultiple(rect.right() + 1); - int bottom = RoundToTwosMultiple(rect.bottom() + 1); - return gfx::Rect(x, y, right - x, bottom - y); +SkIRect AlignRect(const SkIRect& rect) { + int x = RoundToTwosMultiple(rect.fLeft); + int y = RoundToTwosMultiple(rect.fTop); + int right = RoundToTwosMultiple(rect.fRight + 1); + int bottom = RoundToTwosMultiple(rect.fBottom + 1); + return SkIRect::MakeXYWH(x, y, right - x, bottom - y); } -gfx::Rect ScaleRect(const gfx::Rect& rect, - double horizontal_ratio, - double vertical_ratio) { - gfx::Rect scaled_rect(rect.x() * horizontal_ratio, - rect.y() * vertical_ratio, - 0, - 0); - scaled_rect.set_width( - rect.right() * horizontal_ratio - scaled_rect.x()); - scaled_rect.set_height( - rect.bottom() * vertical_ratio - scaled_rect.y()); - return scaled_rect; +SkIRect ScaleRect(const SkIRect& rect, + double horizontal_ratio, + double vertical_ratio) { + int x = rect.fLeft * horizontal_ratio; + int y = rect.fTop * vertical_ratio; + int w = rect.fRight * horizontal_ratio - x; + int h = rect.fBottom * vertical_ratio - y; + + return SkIRect::MakeXYWH(x, y, w, h); } void CopyRect(const uint8* src_plane, diff --git a/remoting/base/util.h b/remoting/base/util.h index 262b551..b60e072 100644 --- a/remoting/base/util.h +++ b/remoting/base/util.h @@ -7,7 +7,6 @@ #include "media/base/video_frame.h" #include "third_party/skia/include/core/SkRect.h" -#include "ui/gfx/rect.h" namespace remoting { @@ -21,7 +20,7 @@ void ConvertYUVToRGB32WithRect(const uint8* y_plane, const uint8* u_plane, const uint8* v_plane, uint8* rgb_plane, - const gfx::Rect& rect, + const SkIRect& rect, int y_stride, int uv_stride, int rgb_stride); @@ -30,8 +29,8 @@ void ScaleYUVToRGB32WithRect(const uint8* y_plane, const uint8* u_plane, const uint8* v_plane, uint8* rgb_plane, - const gfx::Rect& source_rect, - const gfx::Rect& dest_rect, + const SkIRect& source_rect, + const SkIRect& dest_rect, int y_stride, int uv_stride, int rgb_stride); @@ -51,13 +50,13 @@ void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane, int RoundToTwosMultiple(int x); // Align the sides of the rectangle to multiples of 2 (expanding outwards). -gfx::Rect AlignRect(const gfx::Rect& rect); +SkIRect AlignRect(const SkIRect& rect); // Return a scaled rectangle using the horizontal and vertical scale // factors. -gfx::Rect ScaleRect(const gfx::Rect& rect, - double horizontal_ratio, - double vertical_ratio); +SkIRect ScaleRect(const SkIRect& rect, + double horizontal_ratio, + double vertical_ratio); // Copy pixels in the rectangle from source to destination. void CopyRect(const uint8* src_plane, diff --git a/remoting/client/DEPS b/remoting/client/DEPS index e50aa3e..03cd3a6 100644 --- a/remoting/client/DEPS +++ b/remoting/client/DEPS @@ -2,7 +2,6 @@ include_rules = [ "+ppapi", "+jingle/glue", "+net", - "+ui/gfx", "+remoting/protocol", "+remoting/jingle_glue", diff --git a/remoting/client/chromoting_view.h b/remoting/client/chromoting_view.h index 3f6c655..6911489 100644 --- a/remoting/client/chromoting_view.h +++ b/remoting/client/chromoting_view.h @@ -9,7 +9,6 @@ #include "base/memory/ref_counted.h" #include "media/base/video_frame.h" -#include "ui/gfx/point.h" class MessageLoop; diff --git a/remoting/client/frame_consumer.h b/remoting/client/frame_consumer.h index 90f5e55..339b3a4 100644 --- a/remoting/client/frame_consumer.h +++ b/remoting/client/frame_consumer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -51,7 +51,7 @@ class FrameConsumer { // Both |frame| and |rects| are guaranteed to be valid until the |done| // callback is invoked. virtual void OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, + RectVector* rects, Task* done) = 0; private: diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index d4176ed..1fc4573 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -211,7 +211,7 @@ void ChromotingInstance::DidChangeView(const pp::Rect& position, const pp::Rect& clip) { DCHECK(plugin_message_loop_->BelongsToCurrentThread()); - view_->SetPluginSize(gfx::Size(position.width(), position.height())); + view_->SetPluginSize(SkISize::Make(position.width(), position.height())); // TODO(wez): Pass the dimensions of the plugin to the RectangleDecoder // and let it generate the necessary refresh events. @@ -225,7 +225,7 @@ void ChromotingInstance::DidChangeView(const pp::Rect& position, // Notify the RectangleDecoder of the new clip rect. rectangle_decoder_->UpdateClipRect( - gfx::Rect(clip.x(), clip.y(), clip.width(), clip.height())); + SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height())); } bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc index a018b7e..e07ff43 100644 --- a/remoting/client/plugin/pepper_input_handler.cc +++ b/remoting/client/plugin/pepper_input_handler.cc @@ -40,7 +40,7 @@ void PepperInputHandler::HandleCharacterEvent( void PepperInputHandler::HandleMouseMoveEvent( const pp::MouseInputEvent& event) { - gfx::Point p(event.GetPosition().x(), event.GetPosition().y()); + SkIPoint p(SkIPoint::Make(event.GetPosition().x(), event.GetPosition().y())); // Pepper gives co-ordinates in the plugin instance's co-ordinate system, // which may be different from the host desktop's co-ordinate system. double horizontal_ratio = view_->GetHorizontalScaleRatio(); diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index d05a22e..6a58c78 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -74,7 +74,7 @@ void PepperView::Paint() { } } -void PepperView::SetHostSize(const gfx::Size& host_size) { +void PepperView::SetHostSize(const SkISize& host_size) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); if (host_size_ == host_size) @@ -87,10 +87,10 @@ void PepperView::SetHostSize(const gfx::Size& host_size) { host_size.width(), host_size.height()); } -void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) { +void PepperView::PaintFrame(media::VideoFrame* frame, RectVector* rects) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); - SetHostSize(gfx::Size(frame->width(), frame->height())); + SetHostSize(SkISize::Make(frame->width(), frame->height())); if (!backing_store_.get() || backing_store_->is_null()) { LOG(ERROR) << "Backing store is not available."; @@ -108,26 +108,26 @@ void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) { FlushGraphics(start_time); } -bool PepperView::PaintRect(media::VideoFrame* frame, const gfx::Rect& r) { +bool PepperView::PaintRect(media::VideoFrame* frame, const SkIRect& r) { const uint8* frame_data = frame->data(media::VideoFrame::kRGBPlane); const int kFrameStride = frame->stride(media::VideoFrame::kRGBPlane); const int kBytesPerPixel = GetBytesPerPixel(media::VideoFrame::RGB32); pp::Size backing_store_size = backing_store_->size(); - gfx::Rect rect = r.Intersect(gfx::Rect(0, 0, backing_store_size.width(), - backing_store_size.height())); - - if (rect.IsEmpty()) + SkIRect rect(r); + if (!rect.intersect(SkIRect::MakeWH(backing_store_size.width(), + backing_store_size.height()))) { return false; + } const uint8* in = frame_data + - kFrameStride * rect.y() + // Y offset. - kBytesPerPixel * rect.x(); // X offset. + kFrameStride * rect.fTop + // Y offset. + kBytesPerPixel * rect.fLeft; // X offset. uint8* out = reinterpret_cast<uint8*>(backing_store_->data()) + - backing_store_->stride() * rect.y() + // Y offset. - kBytesPerPixel * rect.x(); // X offset. + backing_store_->stride() * rect.fTop + // Y offset. + kBytesPerPixel * rect.fLeft; // X offset. // TODO(hclam): We really should eliminate this memory copy. for (int j = 0; j < rect.height(); ++j) { @@ -141,7 +141,7 @@ bool PepperView::PaintRect(media::VideoFrame* frame, const gfx::Rect& r) { graphics2d_.PaintImageData( *backing_store_.get(), pp::Point(0, 0), - pp::Rect(rect.x(), rect.y(), rect.width(), rect.height())); + pp::Rect(rect.fLeft, rect.fTop, rect.width(), rect.height())); return true; } @@ -239,7 +239,7 @@ void PepperView::UpdateLoginStatus(bool success, const std::string& info) { scriptable_obj->SignalLoginChallenge(); } -bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { +bool PepperView::SetPluginSize(const SkISize& plugin_size) { if (plugin_size_ == plugin_size) return false; plugin_size_ = plugin_size; @@ -252,7 +252,7 @@ bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { return false; } - if (plugin_size.IsEmpty()) + if (plugin_size.isEmpty()) return false; // Allocate the backing store to save the desktop image. @@ -271,7 +271,7 @@ bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { double PepperView::GetHorizontalScaleRatio() const { if (instance_->DoScaling()) { - DCHECK(!host_size_.IsEmpty()); + DCHECK(!host_size_.isEmpty()); return 1.0 * plugin_size_.width() / host_size_.width(); } return 1.0; @@ -279,7 +279,7 @@ double PepperView::GetHorizontalScaleRatio() const { double PepperView::GetVerticalScaleRatio() const { if (instance_->DoScaling()) { - DCHECK(!host_size_.IsEmpty()); + DCHECK(!host_size_.isEmpty()); return 1.0 * plugin_size_.height() / host_size_.height(); } return 1.0; @@ -311,7 +311,7 @@ void PepperView::ReleaseFrame(media::VideoFrame* frame) { } void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, + RectVector* rects, Task* done) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h index 030f70b..1d52cff 100644 --- a/remoting/client/plugin/pepper_view.h +++ b/remoting/client/plugin/pepper_view.h @@ -19,7 +19,6 @@ #include "ppapi/cpp/point.h" #include "remoting/client/chromoting_view.h" #include "remoting/client/frame_consumer.h" -#include "ui/gfx/size.h" namespace remoting { @@ -56,24 +55,24 @@ class PepperView : public ChromotingView, Task* done); virtual void ReleaseFrame(media::VideoFrame* frame); virtual void OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, + RectVector* rects, Task* done); // This is called when the dimension of the plugin element has changed. // Return true if plugin size has changed, false otherwise. - bool SetPluginSize(const gfx::Size& plugin_size); + bool SetPluginSize(const SkISize& plugin_size); private: void OnPaintDone(base::Time paint_start); // Set the dimension of the entire host screen. - void SetHostSize(const gfx::Size& host_size); + void SetHostSize(const SkISize& host_size); - void PaintFrame(media::VideoFrame* frame, UpdatedRects* rects); + void PaintFrame(media::VideoFrame* frame, RectVector* rects); // Render the rectangle of |frame| to the backing store. // Returns true if this rectangle is not clipped. - bool PaintRect(media::VideoFrame* frame, const gfx::Rect& rect); + bool PaintRect(media::VideoFrame* frame, const SkIRect& rect); // Blanks out a rectangle in an image. void BlankRect(pp::ImageData& image_data, const pp::Rect& rect); @@ -99,10 +98,10 @@ class PepperView : public ChromotingView, bool flush_blocked_; // The size of the plugin element. - gfx::Size plugin_size_; + SkISize plugin_size_; // The size of the host screen. - gfx::Size host_size_; + SkISize host_size_; bool is_static_fill_; uint32 static_fill_color_; diff --git a/remoting/client/plugin/pepper_view_proxy.cc b/remoting/client/plugin/pepper_view_proxy.cc index 3e4bb35..be37706 100644 --- a/remoting/client/plugin/pepper_view_proxy.cc +++ b/remoting/client/plugin/pepper_view_proxy.cc @@ -146,7 +146,7 @@ void PepperViewProxy::ReleaseFrame(media::VideoFrame* frame) { } void PepperViewProxy::OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, + RectVector* rects, Task* done) { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { plugin_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( diff --git a/remoting/client/plugin/pepper_view_proxy.h b/remoting/client/plugin/pepper_view_proxy.h index 4f65ce6..e6b7d0a 100644 --- a/remoting/client/plugin/pepper_view_proxy.h +++ b/remoting/client/plugin/pepper_view_proxy.h @@ -61,7 +61,7 @@ class PepperViewProxy : public base::RefCountedThreadSafe<PepperViewProxy>, Task* done); virtual void ReleaseFrame(media::VideoFrame* frame); virtual void OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, + RectVector* rects, Task* done); // Remove the reference to |instance_| and |view_| by setting the value to diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index b96b7ba..b653e27 100644 --- a/remoting/client/rectangle_update_decoder.cc +++ b/remoting/client/rectangle_update_decoder.cc @@ -20,7 +20,7 @@ namespace remoting { class PartialFrameCleanup : public Task { public: - PartialFrameCleanup(media::VideoFrame* frame, UpdatedRects* rects, + PartialFrameCleanup(media::VideoFrame* frame, RectVector* rects, RectangleUpdateDecoder* decoder) : frame_(frame), rects_(rects), decoder_(decoder) { } @@ -36,7 +36,7 @@ class PartialFrameCleanup : public Task { private: scoped_refptr<media::VideoFrame> frame_; - UpdatedRects* rects_; + RectVector* rects_; scoped_refptr<RectangleUpdateDecoder> decoder_; }; @@ -52,8 +52,8 @@ RectangleUpdateDecoder::~RectangleUpdateDecoder() { } void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { - initial_screen_size_ = gfx::Size(config.initial_resolution().width, - config.initial_resolution().height); + initial_screen_size_ = SkISize::Make(config.initial_resolution().width, + config.initial_resolution().height); // Initialize decoder based on the selected codec. ChannelConfig::Codec codec = config.video_config().codec; @@ -98,16 +98,20 @@ void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet, // Find the required frame size. bool has_screen_size = packet->format().has_screen_width() && packet->format().has_screen_height(); - gfx::Size screen_size(packet->format().screen_width(), - packet->format().screen_height()); + SkISize screen_size(SkISize::Make(packet->format().screen_width(), + packet->format().screen_height())); if (!has_screen_size) screen_size = initial_screen_size_; // Find the current frame size. - gfx::Size frame_size(0, 0); - if (frame_) - frame_size = gfx::Size(static_cast<int>(frame_->width()), - static_cast<int>(frame_->height())); + int width = 0; + int height = 0; + if (frame_) { + width = static_cast<int>(frame_->width()); + height = static_cast<int>(frame_->height()); + } + + SkISize frame_size(SkISize::Make(width, height)); // Allocate a new frame, if necessary. if ((!frame_) || (has_screen_size && (screen_size != frame_size))) { @@ -175,7 +179,7 @@ void RectangleUpdateDecoder::SetScaleRatios(double horizontal_ratio, decoder_->SetScaleRatios(horizontal_ratio, vertical_ratio); } -void RectangleUpdateDecoder::UpdateClipRect(const gfx::Rect& new_clip_rect) { +void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) { if (message_loop_ != MessageLoop::current()) { message_loop_->PostTask( FROM_HERE, @@ -189,36 +193,36 @@ void RectangleUpdateDecoder::UpdateClipRect(const gfx::Rect& new_clip_rect) { return; // Find out the rectangles to show because of clip rect is updated. - if (new_clip_rect.y() < clip_rect_.y()) { + if (new_clip_rect.fTop < clip_rect_.fTop) { refresh_rects_.push_back( - gfx::Rect(new_clip_rect.x(), - new_clip_rect.y(), - new_clip_rect.width(), - clip_rect_.y() - new_clip_rect.y())); + SkIRect::MakeXYWH(new_clip_rect.fLeft, + new_clip_rect.fTop, + new_clip_rect.width(), + clip_rect_.fTop - new_clip_rect.fTop)); } - if (new_clip_rect.x() < clip_rect_.x()) { + if (new_clip_rect.fLeft < clip_rect_.fLeft) { refresh_rects_.push_back( - gfx::Rect(new_clip_rect.x(), - clip_rect_.y(), - clip_rect_.x() - new_clip_rect.x(), - clip_rect_.height())); + SkIRect::MakeXYWH(new_clip_rect.fLeft, + clip_rect_.fTop, + clip_rect_.fLeft - new_clip_rect.fLeft, + clip_rect_.height())); } - if (new_clip_rect.right() > clip_rect_.right()) { + if (new_clip_rect.fRight > clip_rect_.fRight) { refresh_rects_.push_back( - gfx::Rect(clip_rect_.right(), - clip_rect_.y(), - new_clip_rect.right() - clip_rect_.right(), - new_clip_rect.height())); + SkIRect::MakeXYWH(clip_rect_.fRight, + clip_rect_.fTop, + new_clip_rect.fRight - clip_rect_.fRight, + new_clip_rect.height())); } - if (new_clip_rect.bottom() > clip_rect_.bottom()) { + if (new_clip_rect.fBottom > clip_rect_.fBottom) { refresh_rects_.push_back( - gfx::Rect(new_clip_rect.x(), - clip_rect_.bottom(), - new_clip_rect.width(), - new_clip_rect.bottom() - clip_rect_.bottom())); + SkIRect::MakeXYWH(new_clip_rect.fLeft, + clip_rect_.fBottom, + new_clip_rect.width(), + new_clip_rect.fBottom - clip_rect_.fBottom)); } clip_rect_ = new_clip_rect; @@ -240,8 +244,8 @@ void RectangleUpdateDecoder::RefreshFullFrame() { return; refresh_rects_.push_back( - gfx::Rect(0, 0, static_cast<int>(frame_->width()), - static_cast<int>(frame_->height()))); + SkIRect::MakeWH(static_cast<int>(frame_->width()), + static_cast<int>(frame_->height()))); DoRefresh(); } @@ -251,7 +255,7 @@ void RectangleUpdateDecoder::SubmitToConsumer() { if (!frame_) return; - UpdatedRects* dirty_rects = new UpdatedRects(); + RectVector* dirty_rects = new RectVector(); decoder_->GetUpdatedRects(dirty_rects); frame_is_consuming_ = true; diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index 7394bd4..d44bb6f 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -9,8 +9,6 @@ #include "base/task.h" #include "media/base/video_frame.h" #include "remoting/base/decoder.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" class MessageLoop; @@ -54,7 +52,7 @@ class RectangleUpdateDecoder : // report dirty rectangles accordingly to enhance performance. // // If scale ratio is not 1.0 then clipping rectangle is ignored. - void UpdateClipRect(const gfx::Rect& clip_rect); + void UpdateClipRect(const SkIRect& clip_rect); // Force the decoder to output the last decoded video frame without any // clipping. @@ -68,7 +66,7 @@ class RectangleUpdateDecoder : void AllocateFrame(const VideoPacket* packet, Task* done); void ProcessPacketData(const VideoPacket* packet, Task* done); - void RefreshRects(const std::vector<gfx::Rect>& rects); + void RefreshRects(const RectVector& rects); // Obtain updated rectangles from decoder and submit it to the consumer. void SubmitToConsumer(); @@ -85,9 +83,9 @@ class RectangleUpdateDecoder : MessageLoop* message_loop_; FrameConsumer* consumer_; - gfx::Size initial_screen_size_; - gfx::Rect clip_rect_; - std::vector<gfx::Rect> refresh_rects_; + SkISize initial_screen_size_; + SkIRect clip_rect_; + RectVector refresh_rects_; scoped_ptr<Decoder> decoder_; diff --git a/remoting/host/capturer.h b/remoting/host/capturer.h index 7d74c17..e29b7f5 100644 --- a/remoting/host/capturer.h +++ b/remoting/host/capturer.h @@ -58,7 +58,7 @@ class Capturer { virtual void InvalidateRegion(const SkRegion& invalid_region) = 0; // Invalidate the entire screen, of a given size. - virtual void InvalidateScreen(const gfx::Size& size) = 0; + virtual void InvalidateScreen(const SkISize& size) = 0; // Invalidate the entire screen, using the size of the most recently // captured screen. @@ -76,7 +76,7 @@ class Capturer { virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) = 0; // Get the size of the most recently captured screen. - virtual const gfx::Size& size_most_recent() const = 0; + virtual const SkISize& size_most_recent() const = 0; }; } // namespace remoting diff --git a/remoting/host/capturer_fake.cc b/remoting/host/capturer_fake.cc index 717e0ad..88bac10 100644 --- a/remoting/host/capturer_fake.cc +++ b/remoting/host/capturer_fake.cc @@ -4,8 +4,6 @@ #include "remoting/host/capturer_fake.h" -#include "ui/gfx/rect.h" - namespace remoting { // CapturerFake generates a white picture of size kWidth x kHeight with a @@ -39,7 +37,7 @@ CapturerFake::~CapturerFake() { } void CapturerFake::ScreenConfigurationChanged() { - size_ = gfx::Size(kWidth, kHeight); + size_ = SkISize::Make(kWidth, kHeight); bytes_per_row_ = size_.width() * kBytesPerPixel; pixel_format_ = media::VideoFrame::RGB32; @@ -62,7 +60,7 @@ void CapturerFake::InvalidateRegion(const SkRegion& invalid_region) { helper.InvalidateRegion(invalid_region); } -void CapturerFake::InvalidateScreen(const gfx::Size& size) { +void CapturerFake::InvalidateScreen(const SkISize& size) { helper.InvalidateScreen(size); } @@ -94,7 +92,7 @@ void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) { callback->Run(capture_data); } -const gfx::Size& CapturerFake::size_most_recent() const { +const SkISize& CapturerFake::size_most_recent() const { return helper.size_most_recent(); } diff --git a/remoting/host/capturer_fake.h b/remoting/host/capturer_fake.h index 61f41283..252fd40 100644 --- a/remoting/host/capturer_fake.h +++ b/remoting/host/capturer_fake.h @@ -25,17 +25,17 @@ class CapturerFake : public Capturer { virtual media::VideoFrame::Format pixel_format() const OVERRIDE; virtual void ClearInvalidRegion() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; - virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; + virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) OVERRIDE; - virtual const gfx::Size& size_most_recent() const OVERRIDE; + virtual const SkISize& size_most_recent() const OVERRIDE; private: // Generates an image in the front buffer. void GenerateImage(); - gfx::Size size_; + SkISize size_; int bytes_per_row_; int box_pos_x_; int box_pos_y_; diff --git a/remoting/host/capturer_fake_ascii.cc b/remoting/host/capturer_fake_ascii.cc index e24bebd..f2bb5d2 100644 --- a/remoting/host/capturer_fake_ascii.cc +++ b/remoting/host/capturer_fake_ascii.cc @@ -4,8 +4,6 @@ #include "remoting/host/capturer_fake_ascii.h" -#include "ui/gfx/rect.h" - namespace remoting { static const int kWidth = 32; @@ -45,7 +43,7 @@ void CapturerFakeAscii::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void CapturerFakeAscii::InvalidateScreen(const gfx::Size& size) { +void CapturerFakeAscii::InvalidateScreen(const SkISize& size) { helper_.InvalidateScreen(size); } @@ -63,14 +61,14 @@ void CapturerFakeAscii::CaptureInvalidRegion( current_buffer_ = (current_buffer_ + 1) % kNumBuffers; planes.strides[0] = bytes_per_row_; scoped_refptr<CaptureData> capture_data(new CaptureData( - planes, gfx::Size(width_, height_), pixel_format_)); + planes, SkISize::Make(width_, height_), pixel_format_)); helper_.set_size_most_recent(capture_data->size()); callback->Run(capture_data); } -const gfx::Size& CapturerFakeAscii::size_most_recent() const { +const SkISize& CapturerFakeAscii::size_most_recent() const { return helper_.size_most_recent(); } diff --git a/remoting/host/capturer_fake_ascii.h b/remoting/host/capturer_fake_ascii.h index a7c0d3c..8902cee 100644 --- a/remoting/host/capturer_fake_ascii.h +++ b/remoting/host/capturer_fake_ascii.h @@ -26,11 +26,11 @@ class CapturerFakeAscii : public Capturer { virtual media::VideoFrame::Format pixel_format() const OVERRIDE; virtual void ClearInvalidRegion() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; - virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; + virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) OVERRIDE; - virtual const gfx::Size& size_most_recent() const; + virtual const SkISize& size_most_recent() const; private: // Generates an image in the front buffer. diff --git a/remoting/host/capturer_helper.cc b/remoting/host/capturer_helper.cc index 12e7d86..cd7c465 100644 --- a/remoting/host/capturer_helper.cc +++ b/remoting/host/capturer_helper.cc @@ -6,7 +6,7 @@ namespace remoting { -CapturerHelper::CapturerHelper() : size_most_recent_(0, 0) { +CapturerHelper::CapturerHelper() : size_most_recent_(SkISize::Make(0, 0)) { } CapturerHelper::~CapturerHelper() { @@ -22,14 +22,14 @@ void CapturerHelper::InvalidateRegion(const SkRegion& invalid_region) { invalid_region_.op(invalid_region, SkRegion::kUnion_Op); } -void CapturerHelper::InvalidateScreen(const gfx::Size& size) { +void CapturerHelper::InvalidateScreen(const SkISize& size) { base::AutoLock auto_invalid_region_lock(invalid_region_lock_); invalid_region_.op(SkIRect::MakeWH(size.width(), size.height()), SkRegion::kUnion_Op); } void CapturerHelper::InvalidateFullScreen() { - if (size_most_recent_ != gfx::Size(0, 0)) + if (!size_most_recent_.isZero()) InvalidateScreen(size_most_recent_); } @@ -38,11 +38,11 @@ void CapturerHelper::SwapInvalidRegion(SkRegion* invalid_region) { invalid_region->swap(invalid_region_); } -const gfx::Size& CapturerHelper::size_most_recent() const { +const SkISize& CapturerHelper::size_most_recent() const { return size_most_recent_; } -void CapturerHelper::set_size_most_recent(const gfx::Size& size) { +void CapturerHelper::set_size_most_recent(const SkISize& size) { size_most_recent_ = size; } diff --git a/remoting/host/capturer_helper.h b/remoting/host/capturer_helper.h index e9479e5..10c95db 100644 --- a/remoting/host/capturer_helper.h +++ b/remoting/host/capturer_helper.h @@ -7,7 +7,6 @@ #include "base/synchronization/lock.h" #include "third_party/skia/include/core/SkRegion.h" -#include "ui/gfx/size.h" namespace remoting { @@ -26,7 +25,7 @@ class CapturerHelper { void InvalidateRegion(const SkRegion& invalid_region); // Invalidate the entire screen, of a given size. - void InvalidateScreen(const gfx::Size& size); + void InvalidateScreen(const SkISize& size); // Invalidate the entire screen, using the size of the most recently // captured screen. @@ -36,8 +35,8 @@ class CapturerHelper { void SwapInvalidRegion(SkRegion* invalid_region); // Access the size of the most recently captured screen. - const gfx::Size& size_most_recent() const; - void set_size_most_recent(const gfx::Size& size); + const SkISize& size_most_recent() const; + void set_size_most_recent(const SkISize& size); private: // A region that has been manually invalidated (through InvalidateRegion). @@ -49,7 +48,7 @@ class CapturerHelper { base::Lock invalid_region_lock_; // The size of the most recently captured screen. - gfx::Size size_most_recent_; + SkISize size_most_recent_; DISALLOW_COPY_AND_ASSIGN(CapturerHelper); }; diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc index 825e724..062f259 100644 --- a/remoting/host/capturer_linux.cc +++ b/remoting/host/capturer_linux.cc @@ -41,7 +41,7 @@ class VideoFrameBuffer { XGetWindowAttributes(display, root_window, &root_attr); if (root_attr.width != size_.width() || root_attr.height != size_.height()) { - size_.SetSize(root_attr.width, root_attr.height); + size_.set(root_attr.width, root_attr.height); bytes_per_row_ = size_.width() * kBytesPerPixel; size_t buffer_size = size_.width() * size_.height() * kBytesPerPixel; ptr_.reset(new uint8[buffer_size]); @@ -49,14 +49,14 @@ class VideoFrameBuffer { } } - gfx::Size size() const { return size_; } + SkISize size() const { return size_; } int bytes_per_row() const { return bytes_per_row_; } uint8* ptr() const { return ptr_.get(); } void set_needs_update() { needs_update_ = true; } private: - gfx::Size size_; + SkISize size_; int bytes_per_row_; scoped_array<uint8> ptr_; bool needs_update_; @@ -77,11 +77,11 @@ class CapturerLinux : public Capturer { virtual media::VideoFrame::Format pixel_format() const OVERRIDE; virtual void ClearInvalidRegion() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; - virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; + virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) OVERRIDE; - virtual const gfx::Size& size_most_recent() const OVERRIDE; + virtual const SkISize& size_most_recent() const OVERRIDE; private: void InitXDamage(); @@ -254,7 +254,7 @@ void CapturerLinux::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void CapturerLinux::InvalidateScreen(const gfx::Size& size) { +void CapturerLinux::InvalidateScreen(const SkISize& size) { helper_.InvalidateScreen(size); } @@ -499,7 +499,7 @@ void CapturerLinux::SlowBlit(uint8* image, const SkIRect& rect, } } -const gfx::Size& CapturerLinux::size_most_recent() const { +const SkISize& CapturerLinux::size_most_recent() const { return helper_.size_most_recent(); } diff --git a/remoting/host/capturer_mac.cc b/remoting/host/capturer_mac.cc index 8b91c45..49e9319 100644 --- a/remoting/host/capturer_mac.cc +++ b/remoting/host/capturer_mac.cc @@ -102,7 +102,7 @@ class VideoFrameBuffer { int width = CGDisplayPixelsWide(mainDevice); int height = CGDisplayPixelsHigh(mainDevice); if (width != size_.width() || height != size_.height()) { - size_.SetSize(width, height); + size_.set(width, height); bytes_per_row_ = width * sizeof(uint32_t); size_t buffer_size = width * height * sizeof(uint32_t); ptr_.reset(new uint8[buffer_size]); @@ -110,14 +110,14 @@ class VideoFrameBuffer { } } - gfx::Size size() const { return size_; } + SkISize size() const { return size_; } int bytes_per_row() const { return bytes_per_row_; } uint8* ptr() const { return ptr_.get(); } void set_needs_update() { needs_update_ = true; } private: - gfx::Size size_; + SkISize size_; int bytes_per_row_; scoped_array<uint8> ptr_; bool needs_update_; @@ -138,11 +138,11 @@ class CapturerMac : public Capturer { virtual media::VideoFrame::Format pixel_format() const OVERRIDE; virtual void ClearInvalidRegion() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; - virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; + virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) OVERRIDE; - virtual const gfx::Size& size_most_recent() const OVERRIDE; + virtual const SkISize& size_most_recent() const OVERRIDE; private: void GlBlitFast(const VideoFrameBuffer& buffer, const SkRegion& region); @@ -262,7 +262,7 @@ void CapturerMac::ScreenConfigurationChanged() { CGDirectDisplayID mainDevice = CGMainDisplayID(); int width = CGDisplayPixelsWide(mainDevice); int height = CGDisplayPixelsHigh(mainDevice); - InvalidateScreen(gfx::Size(width, height)); + InvalidateScreen(SkISize::Make(width, height)); if (!CGDisplayUsesOpenGLAcceleration(mainDevice)) { VLOG(3) << "OpenGL support not available."; @@ -303,7 +303,7 @@ void CapturerMac::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void CapturerMac::InvalidateScreen(const gfx::Size& size) { +void CapturerMac::InvalidateScreen(const SkISize& size) { helper_.InvalidateScreen(size); } @@ -346,8 +346,7 @@ void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) { (current_buffer.size().height() - 1) * current_buffer.bytes_per_row(); } - data = new CaptureData(planes, gfx::Size(current_buffer.size()), - pixel_format()); + data = new CaptureData(planes, current_buffer.size(), pixel_format()); data->mutable_dirty_region() = region; current_buffer_ = (current_buffer_ + 1) % kNumBuffers; @@ -473,7 +472,7 @@ void CapturerMac::CgBlit(const VideoFrameBuffer& buffer, } } -const gfx::Size& CapturerMac::size_most_recent() const { +const SkISize& CapturerMac::size_most_recent() const { return helper_.size_most_recent(); } diff --git a/remoting/host/capturer_win.cc b/remoting/host/capturer_win.cc index b8c46e6..b92459f 100644 --- a/remoting/host/capturer_win.cc +++ b/remoting/host/capturer_win.cc @@ -28,37 +28,37 @@ class CapturerGdi : public Capturer { virtual media::VideoFrame::Format pixel_format() const OVERRIDE; virtual void ClearInvalidRegion() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; - virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; + virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) OVERRIDE; - virtual const gfx::Size& size_most_recent() const OVERRIDE; + virtual const SkISize& size_most_recent() const OVERRIDE; private: struct VideoFrameBuffer { - VideoFrameBuffer(void* data, const gfx::Size& size, int bytes_per_pixel, + VideoFrameBuffer(void* data, const SkISize& size, int bytes_per_pixel, int bytes_per_row) : data(data), size(size), bytes_per_pixel(bytes_per_pixel), bytes_per_row(bytes_per_row) { } VideoFrameBuffer() { data = 0; - size = gfx::Size(0, 0); + size = SkISize::Make(0, 0); bytes_per_pixel = 0; bytes_per_row = 0; } void* data; - gfx::Size size; + SkISize size; int bytes_per_pixel; int bytes_per_row; }; // Make sure that the current buffer has the same size as the screen. - void UpdateBufferCapture(const gfx::Size& size); + void UpdateBufferCapture(const SkISize& size); // Allocate memory for a buffer of a given size, freeing any memory previously // allocated for that buffer. - void ReallocateBuffer(int buffer_index, const gfx::Size& size); + void ReallocateBuffer(int buffer_index, const SkISize& size); void CalculateInvalidRegion(); void CaptureRegion(const SkRegion& region, @@ -73,7 +73,7 @@ class CapturerGdi : public Capturer { void MaybeChangeScreenConfiguration(); // Gets the screen size. - gfx::Size GetScreenSize(); + SkISize GetScreenSize(); // A thread-safe list of invalid rectangles, and the size of the most // recently captured screen. @@ -90,7 +90,7 @@ class CapturerGdi : public Capturer { // The screen size attached to the device contexts through which the screen // is captured. - gfx::Size dc_size_; + SkISize dc_size_; // The current buffer with valid data for reading. int current_buffer_; @@ -112,7 +112,7 @@ static const int kBytesPerPixel = 4; CapturerGdi::CapturerGdi() : desktop_dc_(NULL), memory_dc_(NULL), - dc_size_(0, 0), + dc_size_(SkISize::Make(0, 0)), current_buffer_(0), pixel_format_(media::VideoFrame::RGB32) { memset(target_bitmap_, 0, sizeof(target_bitmap_)); @@ -136,7 +136,7 @@ void CapturerGdi::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void CapturerGdi::InvalidateScreen(const gfx::Size& size) { +void CapturerGdi::InvalidateScreen(const SkISize& size) { helper_.InvalidateScreen(size); } @@ -151,7 +151,7 @@ void CapturerGdi::CaptureInvalidRegion(CaptureCompletedCallback* callback) { CaptureRegion(invalid_region, callback); } -const gfx::Size& CapturerGdi::size_most_recent() const { +const SkISize& CapturerGdi::size_most_recent() const { return helper_.size_most_recent(); } @@ -178,7 +178,7 @@ void CapturerGdi::ScreenConfigurationChanged() { // We poll for screen configuration changes, so ignore notifications. } -void CapturerGdi::UpdateBufferCapture(const gfx::Size& size) { +void CapturerGdi::UpdateBufferCapture(const SkISize& size) { // Make sure the DCs have the correct dimensions. if (size != dc_size_) { // TODO(simonmorris): screen dimensions changing isn't equivalent to needing @@ -197,7 +197,7 @@ void CapturerGdi::UpdateBufferCapture(const gfx::Size& size) { } } -void CapturerGdi::ReallocateBuffer(int buffer_index, const gfx::Size& size) { +void CapturerGdi::ReallocateBuffer(int buffer_index, const SkISize& size) { // Delete any previously constructed bitmap. if (target_bitmap_[buffer_index]) { DeleteObject(target_bitmap_[buffer_index]); @@ -232,8 +232,8 @@ void CapturerGdi::ReallocateBuffer(int buffer_index, const gfx::Size& size) { CreateDIBSection(desktop_dc_, &bmi, DIB_RGB_COLORS, static_cast<void**>(&buffers_[buffer_index].data), NULL, 0); - buffers_[buffer_index].size = gfx::Size(bmi.bmiHeader.biWidth, - std::abs(bmi.bmiHeader.biHeight)); + buffers_[buffer_index].size = SkISize::Make(bmi.bmiHeader.biWidth, + std::abs(bmi.bmiHeader.biHeight)); buffers_[buffer_index].bytes_per_pixel = bmi.bmiHeader.biBitCount / 8; buffers_[buffer_index].bytes_per_row = bmi.bmiHeader.biSizeImage / std::abs(bmi.bmiHeader.biHeight); @@ -310,9 +310,9 @@ void CapturerGdi::CaptureImage() { SRCCOPY | CAPTUREBLT); } -gfx::Size CapturerGdi::GetScreenSize() { - return gfx::Size(GetSystemMetrics(SM_CXSCREEN), - GetSystemMetrics(SM_CYSCREEN)); +SkISize CapturerGdi::GetScreenSize() { + return SkISize::Make(GetSystemMetrics(SM_CXSCREEN), + GetSystemMetrics(SM_CYSCREEN)); } } // namespace diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index f11ce8d..8eb6b33 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -321,7 +321,7 @@ void ChromotingHost::set_protocol_config( protocol_config_.reset(config); } -void ChromotingHost::LocalMouseMoved(const gfx::Point& new_pos) { +void ChromotingHost::LocalMouseMoved(const SkIPoint& new_pos) { if (!context_->network_message_loop()->BelongsToCurrentThread()) { context_->network_message_loop()->PostTask( FROM_HERE, base::Bind(&ChromotingHost::LocalMouseMoved, this, new_pos)); diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 3f34233..270c9ba 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -144,7 +144,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, // Notify all active client sessions that local input has been detected, and // that remote input should be ignored for a short time. - void LocalMouseMoved(const gfx::Point& new_pos); + void LocalMouseMoved(const SkIPoint& new_pos); // Pause or unpause the session. While the session is paused, remote input // is ignored. diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 3416069..36bb89c 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -94,10 +94,10 @@ void ClientSession::InjectMouseEvent(const MouseEvent& event) { // the event to lie within the current screen area. This is better than // simply discarding the event, which might lose a button-up event at the // end of a drag'n'drop (or cause other related problems). - gfx::Point pos(event.x(), event.y()); - const gfx::Size& screen = capturer_->size_most_recent(); - pos.set_x(std::max(0, std::min(screen.width() - 1, pos.x()))); - pos.set_y(std::max(0, std::min(screen.height() - 1, pos.y()))); + SkIPoint pos(SkIPoint::Make(event.x(), event.y())); + const SkISize& screen = capturer_->size_most_recent(); + pos.setX(std::max(0, std::min(screen.width() - 1, pos.x()))); + pos.setY(std::max(0, std::min(screen.height() - 1, pos.y()))); event_to_inject.set_x(pos.x()); event_to_inject.set_y(pos.y()); @@ -121,11 +121,11 @@ void ClientSession::OnDisconnected() { authenticated_ = false; } -void ClientSession::LocalMouseMoved(const gfx::Point& mouse_pos) { +void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { // If this is a genuine local input event (rather than an echo of a remote // input event that we've just injected), then ignore remote inputs for a // short time. - std::list<gfx::Point>::iterator found_position = + std::list<SkIPoint>::iterator found_position = std::find(injected_mouse_positions_.begin(), injected_mouse_positions_.end(), mouse_pos); if (found_position != injected_mouse_positions_.end()) { diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h index b387984..bc35a45 100644 --- a/remoting/host/client_session.h +++ b/remoting/host/client_session.h @@ -12,7 +12,7 @@ #include "remoting/protocol/connection_to_client.h" #include "remoting/protocol/host_stub.h" #include "remoting/protocol/input_stub.h" -#include "ui/gfx/point.h" +#include "third_party/skia/include/core/SkPoint.h" namespace remoting { @@ -80,7 +80,7 @@ class ClientSession : public protocol::HostStub, // Indicate that local mouse activity has been detected. This causes remote // inputs to be ignored for a short time so that the local user will always // have the upper hand in 'pointer wars'. - void LocalMouseMoved(const gfx::Point& new_pos); + void LocalMouseMoved(const SkIPoint& new_pos); bool ShouldIgnoreRemoteMouseInput(const protocol::MouseEvent& event) const; bool ShouldIgnoreRemoteKeyboardInput(const protocol::KeyEvent& event) const; @@ -130,12 +130,12 @@ class ClientSession : public protocol::HostStub, // Current location of the mouse pointer. This is used to provide appropriate // coordinates when we release the mouse buttons after a user disconnects. - gfx::Point remote_mouse_pos_; + SkIPoint remote_mouse_pos_; // Queue of recently-injected mouse positions. This is used to detect whether // mouse events from the local input monitor are echoes of injected positions, // or genuine mouse movements of a local input device. - std::list<gfx::Point> injected_mouse_positions_; + std::list<SkIPoint> injected_mouse_positions_; base::Time latest_local_input_time_; diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc index cd621e8..be66a80 100644 --- a/remoting/host/client_session_unittest.cc +++ b/remoting/host/client_session_unittest.cc @@ -45,7 +45,7 @@ class ClientSessionTest : public testing::Test { EXPECT_CALL(*connection_, session()).WillRepeatedly(Return(&session_)); // Set up a large default screen size that won't affect most tests. - default_screen_size_.SetSize(1000, 1000); + default_screen_size_.set(1000, 1000); ON_CALL(capturer_, size_most_recent()).WillByDefault(ReturnRef( default_screen_size_)); @@ -59,7 +59,7 @@ class ClientSessionTest : public testing::Test { } protected: - gfx::Size default_screen_size_; + SkISize default_screen_size_; MessageLoop message_loop_; std::string client_jid_; MockSession session_; @@ -170,12 +170,12 @@ TEST_F(ClientSessionTest, LocalInputTest) { // This event should get through to the input stub. client_session_->InjectMouseEvent(mouse_event1); // This one should too because the local event echoes the remote one. - client_session_->LocalMouseMoved(gfx::Point(mouse_event1.x(), - mouse_event1.y())); + client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), + mouse_event1.y())); client_session_->InjectMouseEvent(mouse_event2); // This one should not. - client_session_->LocalMouseMoved(gfx::Point(mouse_event1.x(), - mouse_event1.y())); + client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), + mouse_event1.y())); client_session_->InjectMouseEvent(mouse_event3); // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually // (via dependency injection, not sleep!) @@ -208,7 +208,7 @@ TEST_F(ClientSessionTest, RestoreEventState) { } TEST_F(ClientSessionTest, ClampMouseEvents) { - gfx::Size screen(200, 100); + SkISize screen(SkISize::Make(200, 100)); EXPECT_CALL(capturer_, size_most_recent()) .WillRepeatedly(ReturnRef(screen)); diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc index 0ca50af..512d763 100644 --- a/remoting/host/event_executor_mac.cc +++ b/remoting/host/event_executor_mac.cc @@ -231,7 +231,7 @@ void EventExecutorMac::InjectMouseEvent(const MouseEvent& event) { // TODO(wez): This code assumes that MouseEvent(0,0) (top-left of client view) // corresponds to local (0,0) (top-left of primary monitor). That won't in // general be true on multi-monitor systems, though. - gfx::Size size = capturer_->size_most_recent(); + SkISize size = capturer_->size_most_recent(); if (event.x() >= 0 || event.y() >= 0 || event.x() < size.width() || event.y() < size.height()) { VLOG(3) << "Moving mouse to " << event.x() << "," << event.y(); diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc index bf6fead..ebedf25 100644 --- a/remoting/host/event_executor_win.cc +++ b/remoting/host/event_executor_win.cc @@ -109,7 +109,7 @@ void EventExecutorWin::HandleMouse(const MouseEvent& event) { INPUT input; input.type = INPUT_MOUSE; input.mi.time = 0; - gfx::Size screen_size = capturer_->size_most_recent(); + SkISize screen_size = capturer_->size_most_recent(); if ((screen_size.width() > 0) && (screen_size.height() > 0)) { input.mi.dx = static_cast<int>((x * 65535) / screen_size.width()); input.mi.dy = static_cast<int>((y * 65535) / screen_size.height()); diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h index 5503ca8..a70693a 100644 --- a/remoting/host/host_mock_objects.h +++ b/remoting/host/host_mock_objects.h @@ -28,10 +28,10 @@ class MockCapturer : public Capturer { MOCK_CONST_METHOD0(pixel_format, media::VideoFrame::Format()); MOCK_METHOD0(ClearInvalidRegion, void()); MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region)); - MOCK_METHOD1(InvalidateScreen, void(const gfx::Size&)); + MOCK_METHOD1(InvalidateScreen, void(const SkISize&)); MOCK_METHOD0(InvalidateFullScreen, void()); MOCK_METHOD1(CaptureInvalidRegion, void(CaptureCompletedCallback* callback)); - MOCK_CONST_METHOD0(size_most_recent, const gfx::Size&()); + MOCK_CONST_METHOD0(size_most_recent, const SkISize&()); private: DISALLOW_COPY_AND_ASSIGN(MockCapturer); diff --git a/remoting/host/local_input_monitor_thread_linux.cc b/remoting/host/local_input_monitor_thread_linux.cc index 8bfdd36..2f429d6 100644 --- a/remoting/host/local_input_monitor_thread_linux.cc +++ b/remoting/host/local_input_monitor_thread_linux.cc @@ -50,8 +50,8 @@ static void ProcessReply(XPointer thread, if (data->category == XRecordFromServer) { xEvent* event = reinterpret_cast<xEvent*>(data->data); if (event->u.u.type == MotionNotify) { - gfx::Point pos(event->u.keyButtonPointer.rootX, - event->u.keyButtonPointer.rootY); + SkIPoint pos(SkIPoint::Make(event->u.keyButtonPointer.rootX, + event->u.keyButtonPointer.rootY)); reinterpret_cast<LocalInputMonitorThread*>(thread)->LocalMouseMoved(pos); } else { reinterpret_cast<LocalInputMonitorThread*>(thread)->LocalKeyPressed( @@ -162,7 +162,7 @@ void LocalInputMonitorThread::Run() { display_ = NULL; } -void LocalInputMonitorThread::LocalMouseMoved(const gfx::Point& pos) { +void LocalInputMonitorThread::LocalMouseMoved(const SkIPoint& pos) { host_->LocalMouseMoved(pos); } diff --git a/remoting/host/local_input_monitor_thread_linux.h b/remoting/host/local_input_monitor_thread_linux.h index d87470d..567882c 100644 --- a/remoting/host/local_input_monitor_thread_linux.h +++ b/remoting/host/local_input_monitor_thread_linux.h @@ -6,7 +6,7 @@ #define LOCAL_INPUT_MONITOR_THREAD_LINUX_H_ #include "base/threading/simple_thread.h" -#include "ui/gfx/point.h" +#include "third_party/skia/include/core/SkPoint.h" typedef struct _XDisplay Display; @@ -22,7 +22,7 @@ class LocalInputMonitorThread : public base::SimpleThread { void Stop(); virtual void Run(); - void LocalMouseMoved(const gfx::Point& pos); + void LocalMouseMoved(const SkIPoint& pos); void LocalKeyPressed(int key_code, bool down); private: diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc index f501a62..4a821e9 100644 --- a/remoting/host/screen_recorder_unittest.cc +++ b/remoting/host/screen_recorder_unittest.cc @@ -112,7 +112,7 @@ TEST_F(ScreenRecorderTest, OneRecordCycle) { planes.data[i] = reinterpret_cast<uint8*>(i); planes.strides[i] = kWidth * 4; } - gfx::Size size(kWidth, kHeight); + SkISize size(SkISize::Make(kWidth, kHeight)); scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); EXPECT_CALL(capturer_, InvalidateFullScreen()); @@ -161,7 +161,7 @@ TEST_F(ScreenRecorderTest, StartAndStop) { planes.strides[i] = kWidth * 4; } - gfx::Size size(kWidth, kHeight); + SkISize size(SkISize::Make(kWidth, kHeight)); scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); EXPECT_CALL(capturer_, InvalidateFullScreen()); diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index d79b8bb..bc8087a7 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -461,8 +461,10 @@ 'host/in_memory_host_config.h', 'host/json_host_config.cc', 'host/json_host_config.h', + 'host/local_input_monitor.h', 'host/local_input_monitor_linux.cc', 'host/local_input_monitor_mac.mm', + 'host/local_input_monitor_thread_linux.h', 'host/local_input_monitor_thread_linux.cc', 'host/local_input_monitor_win.cc', 'host/register_support_host_request.cc', |