summaryrefslogtreecommitdiffstats
path: root/remoting/base
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 19:45:02 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 19:45:02 +0000
commit125444b5adec00c029d1c80f8aed6a3faad34f59 (patch)
tree47cb54e01a679c2242cf44c10f3b81f8d7eb2b00 /remoting/base
parenta2371af49ec916dc7b62c8303567dce170bd832f (diff)
downloadchromium_src-125444b5adec00c029d1c80f8aed6a3faad34f59.zip
chromium_src-125444b5adec00c029d1c80f8aed6a3faad34f59.tar.gz
chromium_src-125444b5adec00c029d1c80f8aed6a3faad34f59.tar.bz2
Move us fully from gfx:: over to skia types for consistency.
BUG=NONE TEST=BUILD Review URL: http://codereview.chromium.org/7992011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r--remoting/base/DEPS1
-rw-r--r--remoting/base/capture_data.cc2
-rw-r--r--remoting/base/capture_data.h7
-rw-r--r--remoting/base/codec_test.cc12
-rw-r--r--remoting/base/decoder.h12
-rw-r--r--remoting/base/decoder_row_based.cc10
-rw-r--r--remoting/base/decoder_row_based.h8
-rw-r--r--remoting/base/decoder_vp8.cc58
-rw-r--r--remoting/base/decoder_vp8.h31
-rw-r--r--remoting/base/encoder_row_based.cc4
-rw-r--r--remoting/base/encoder_row_based.h2
-rw-r--r--remoting/base/encoder_vp8.cc46
-rw-r--r--remoting/base/encoder_vp8.h15
-rw-r--r--remoting/base/encoder_vp8_unittest.cc14
-rw-r--r--remoting/base/util.cc58
-rw-r--r--remoting/base/util.h15
16 files changed, 147 insertions, 148 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..7e3ca48 100644
--- a/remoting/base/encoder_row_based.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -42,7 +42,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 +51,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..3faa5f5 100644
--- a/remoting/base/encoder_row_based.h
+++ b/remoting/base/encoder_row_based.h
@@ -62,7 +62,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,