summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-19 21:24:28 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-19 21:24:28 +0000
commitb4e50594c117da39d9d65beed489acc3ce4cd35e (patch)
treeeb321c268adbabfc85ad3dae6931be64c2f92150
parentc45d12c0186dbf6a1ffdbb7cb45a15c2366d9dcf (diff)
downloadchromium_src-b4e50594c117da39d9d65beed489acc3ce4cd35e.zip
chromium_src-b4e50594c117da39d9d65beed489acc3ce4cd35e.tar.gz
chromium_src-b4e50594c117da39d9d65beed489acc3ce4cd35e.tar.bz2
Revert 224101 "Remove dependency on Skia from chromoting client."
> Remove dependency on Skia from chromoting client. > > Now DesktopRegion, DesktopRect and DesktopSize are used instead of > corresponding skia types. > > TBR=reed@google.com (for _moved_ skia dependency) > > Review URL: https://chromiumcodereview.appspot.com/23440046 TBR=sergeyu@chromium.org Review URL: https://codereview.chromium.org/24217003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224205 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/DEPS4
-rw-r--r--remoting/base/util.cc137
-rw-r--r--remoting/base/util.h44
-rw-r--r--remoting/base/util_unittest.cc61
-rw-r--r--remoting/client/DEPS1
-rw-r--r--remoting/client/frame_consumer.h17
-rw-r--r--remoting/client/frame_consumer_proxy.cc13
-rw-r--r--remoting/client/frame_consumer_proxy.h10
-rw-r--r--remoting/client/frame_producer.h14
-rw-r--r--remoting/client/jni/jni_frame_consumer.cc17
-rw-r--r--remoting/client/jni/jni_frame_consumer.h15
-rw-r--r--remoting/client/plugin/chromoting_instance.cc18
-rw-r--r--remoting/client/plugin/chromoting_instance.h16
-rw-r--r--remoting/client/plugin/pepper_view.cc60
-rw-r--r--remoting/client/plugin/pepper_view.h34
-rw-r--r--remoting/client/rectangle_update_decoder.cc46
-rw-r--r--remoting/client/rectangle_update_decoder.h18
-rw-r--r--remoting/codec/codec_test.cc31
-rw-r--r--remoting/codec/video_decoder.h23
-rw-r--r--remoting/codec/video_decoder_verbatim.cc63
-rw-r--r--remoting/codec/video_decoder_verbatim.h20
-rw-r--r--remoting/codec/video_decoder_vp8.cc163
-rw-r--r--remoting/codec/video_decoder_vp8.h32
-rw-r--r--remoting/codec/video_encoder_vp8.cc46
-rw-r--r--remoting/codec/video_encoder_vp8.h6
-rw-r--r--remoting/host/DEPS2
-rw-r--r--remoting/host/mouse_clamping_filter.cc5
-rw-r--r--remoting/protocol/input_event_tracker.cc3
-rw-r--r--remoting/protocol/input_event_tracker.h4
-rw-r--r--remoting/protocol/mouse_input_filter.cc12
-rw-r--r--remoting/protocol/mouse_input_filter.h11
-rw-r--r--remoting/protocol/mouse_input_filter_unittest.cc38
32 files changed, 474 insertions, 510 deletions
diff --git a/remoting/DEPS b/remoting/DEPS
index 66f4af9..6e5ae99 100644
--- a/remoting/DEPS
+++ b/remoting/DEPS
@@ -15,11 +15,13 @@ include_rules = [
"-remoting",
"+remoting/base",
"+remoting/proto",
+ "+skia/config",
+ "+skia/ext",
"+third_party/GTM",
"+third_party/GTM/AppKit",
"+third_party/libjingle",
"+third_party/libvpx",
"+third_party/libyuv",
- "+third_party/webrtc/modules/desktop_capture",
+ "+third_party/skia/include/core",
"+ui/base/keycodes",
]
diff --git a/remoting/base/util.cc b/remoting/base/util.cc
index d27b651..0a0a529 100644
--- a/remoting/base/util.cc
+++ b/remoting/base/util.cc
@@ -12,7 +12,7 @@
#include "media/base/video_frame.h"
#include "media/base/yuv_convert.h"
#include "third_party/libyuv/include/libyuv/convert.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
+#include "third_party/skia/include/core/SkRegion.h"
#if defined(OS_POSIX)
#include <pwd.h>
@@ -73,56 +73,54 @@ void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
width, height);
}
-void ConvertAndScaleYUVToRGB32Rect(
- const uint8* source_yplane,
- const uint8* source_uplane,
- const uint8* source_vplane,
- int source_ystride,
- int source_uvstride,
- const webrtc::DesktopSize& source_size,
- const webrtc::DesktopRect& source_buffer_rect,
- uint8* dest_buffer,
- int dest_stride,
- const webrtc::DesktopSize& dest_size,
- const webrtc::DesktopRect& dest_buffer_rect,
- const webrtc::DesktopRect& dest_rect) {
+void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
+ const uint8* source_uplane,
+ const uint8* source_vplane,
+ int source_ystride,
+ int source_uvstride,
+ const SkISize& source_size,
+ const SkIRect& source_buffer_rect,
+ uint8* dest_buffer,
+ int dest_stride,
+ const SkISize& dest_size,
+ const SkIRect& dest_buffer_rect,
+ const SkIRect& dest_rect) {
// N.B. It is caller's responsibility to check if strides are large enough. We
// cannot do it here anyway.
- DCHECK(DoesRectContain(webrtc::DesktopRect::MakeSize(source_size),
- source_buffer_rect));
- DCHECK(DoesRectContain(webrtc::DesktopRect::MakeSize(dest_size),
- dest_buffer_rect));
- DCHECK(DoesRectContain(dest_buffer_rect, dest_rect));
- DCHECK(DoesRectContain(ScaleRect(source_buffer_rect, source_size, dest_size),
- dest_rect));
+ DCHECK(SkIRect::MakeSize(source_size).contains(source_buffer_rect));
+ DCHECK(SkIRect::MakeSize(dest_size).contains(dest_buffer_rect));
+ DCHECK(dest_buffer_rect.contains(dest_rect));
+ DCHECK(ScaleRect(source_buffer_rect, source_size, dest_size).
+ contains(dest_rect));
// If the source and/or destination buffers don't start at (0, 0)
// offset the pointers to pretend we have complete buffers.
- int y_offset = - CalculateYOffset(source_buffer_rect.left(),
- source_buffer_rect.top(),
+ int y_offset = - CalculateYOffset(source_buffer_rect.x(),
+ source_buffer_rect.y(),
source_ystride);
- int uv_offset = - CalculateUVOffset(source_buffer_rect.left(),
- source_buffer_rect.top(),
+ int uv_offset = - CalculateUVOffset(source_buffer_rect.x(),
+ source_buffer_rect.y(),
source_uvstride);
- int rgb_offset = - CalculateRGBOffset(dest_buffer_rect.left(),
- dest_buffer_rect.top(),
+ int rgb_offset = - CalculateRGBOffset(dest_buffer_rect.x(),
+ dest_buffer_rect.y(),
dest_stride);
// See if scaling is needed.
- if (source_size.equals(dest_size)) {
+ if (source_size == dest_size) {
// Calculate the inner rectangle that can be copied by the optimized
// libyuv::I420ToARGB().
- webrtc::DesktopRect inner_rect =
- webrtc::DesktopRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left() + 1),
- RoundToTwosMultiple(dest_rect.top() + 1),
- dest_rect.right(), dest_rect.bottom());
+ SkIRect inner_rect =
+ SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left() + 1),
+ RoundToTwosMultiple(dest_rect.top() + 1),
+ dest_rect.right(),
+ dest_rect.bottom());
// Offset pointers to point to the top left corner of the inner rectangle.
- y_offset += CalculateYOffset(inner_rect.left(), inner_rect.top(),
+ y_offset += CalculateYOffset(inner_rect.x(), inner_rect.y(),
source_ystride);
- uv_offset += CalculateUVOffset(inner_rect.left(), inner_rect.top(),
+ uv_offset += CalculateUVOffset(inner_rect.x(), inner_rect.y(),
source_uvstride);
- rgb_offset += CalculateRGBOffset(inner_rect.left(), inner_rect.top(),
+ rgb_offset += CalculateRGBOffset(inner_rect.x(), inner_rect.y(),
dest_stride);
libyuv::I420ToARGB(source_yplane + y_offset, source_ystride,
@@ -132,14 +130,15 @@ void ConvertAndScaleYUVToRGB32Rect(
inner_rect.width(), inner_rect.height());
// Now see if some pixels weren't copied due to alignment.
- if (!dest_rect.equals(inner_rect)) {
- webrtc::DesktopRect outer_rect =
- webrtc::DesktopRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left()),
- RoundToTwosMultiple(dest_rect.top()),
- dest_rect.right(), dest_rect.bottom());
+ if (dest_rect != inner_rect) {
+ SkIRect outer_rect =
+ SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left()),
+ RoundToTwosMultiple(dest_rect.top()),
+ dest_rect.right(),
+ dest_rect.bottom());
- webrtc::DesktopVector offset(outer_rect.left() - inner_rect.left(),
- outer_rect.top() - inner_rect.top());
+ SkIPoint offset = SkIPoint::Make(outer_rect.x() - inner_rect.x(),
+ outer_rect.y() - inner_rect.y());
// Offset the pointers to point to the top left corner of the outer
// rectangle.
@@ -148,12 +147,11 @@ void ConvertAndScaleYUVToRGB32Rect(
rgb_offset += CalculateRGBOffset(offset.x(), offset.y(), dest_stride);
// Draw unaligned edges.
- webrtc::DesktopRegion edges(dest_rect);
- edges.Subtract(inner_rect);
- for (webrtc::DesktopRegion::Iterator i(edges); !i.IsAtEnd();
- i.Advance()) {
- webrtc::DesktopRect rect = i.rect();
- rect.Translate(-outer_rect.left(), -outer_rect.top());
+ SkRegion edges(dest_rect);
+ edges.op(inner_rect, SkRegion::kDifference_Op);
+ for (SkRegion::Iterator i(edges); !i.done(); i.next()) {
+ SkIRect rect(i.rect());
+ rect.offset(- outer_rect.left(), - outer_rect.top());
media::ScaleYUVToRGB32WithRect(source_yplane + y_offset,
source_uplane + uv_offset,
source_vplane + uv_offset,
@@ -194,45 +192,43 @@ int RoundToTwosMultiple(int x) {
return x & (~1);
}
-webrtc::DesktopRect AlignRect(const webrtc::DesktopRect& rect) {
+SkIRect AlignRect(const SkIRect& rect) {
int x = RoundToTwosMultiple(rect.left());
int y = RoundToTwosMultiple(rect.top());
int right = RoundToTwosMultiple(rect.right() + 1);
int bottom = RoundToTwosMultiple(rect.bottom() + 1);
- return webrtc::DesktopRect::MakeLTRB(x, y, right, bottom);
+ return SkIRect::MakeLTRB(x, y, right, bottom);
}
-webrtc::DesktopRect ScaleRect(const webrtc::DesktopRect& rect,
- const webrtc::DesktopSize& in_size,
- const webrtc::DesktopSize& out_size) {
+SkIRect ScaleRect(const SkIRect& rect,
+ const SkISize& in_size,
+ const SkISize& out_size) {
int left = (rect.left() * out_size.width()) / in_size.width();
int top = (rect.top() * out_size.height()) / in_size.height();
int right = (rect.right() * out_size.width() + in_size.width() - 1) /
in_size.width();
int bottom = (rect.bottom() * out_size.height() + in_size.height() - 1) /
in_size.height();
- return webrtc::DesktopRect::MakeLTRB(left, top, right, bottom);
+ return SkIRect::MakeLTRB(left, top, right, bottom);
}
void CopyRGB32Rect(const uint8* source_buffer,
int source_stride,
- const webrtc::DesktopRect& source_buffer_rect,
+ const SkIRect& source_buffer_rect,
uint8* dest_buffer,
int dest_stride,
- const webrtc::DesktopRect& dest_buffer_rect,
- const webrtc::DesktopRect& dest_rect) {
- DCHECK(DoesRectContain(dest_buffer_rect, dest_rect));
- DCHECK(DoesRectContain(source_buffer_rect, dest_rect));
+ const SkIRect& dest_buffer_rect,
+ const SkIRect& dest_rect) {
+ DCHECK(dest_buffer_rect.contains(dest_rect));
+ DCHECK(source_buffer_rect.contains(dest_rect));
// Get the address of the starting point.
- source_buffer += CalculateRGBOffset(
- dest_rect.left() - source_buffer_rect.left(),
- dest_rect.top() - source_buffer_rect.top(),
- source_stride);
- dest_buffer += CalculateRGBOffset(
- dest_rect.left() - dest_buffer_rect.left(),
- dest_rect.top() - dest_buffer_rect.top(),
- source_stride);
+ source_buffer += CalculateRGBOffset(dest_rect.x() - source_buffer_rect.x(),
+ dest_rect.y() - source_buffer_rect.y(),
+ source_stride);
+ dest_buffer += CalculateRGBOffset(dest_rect.x() - dest_buffer_rect.x(),
+ dest_rect.y() - dest_buffer_rect.y(),
+ source_stride);
// Copy pixels in the rectangle line by line.
const int bytes_per_line = kBytesPerPixelRGB32 * dest_rect.width();
@@ -332,11 +328,4 @@ std::string GetUsername() {
#endif // defined(OS_POSIX)
}
-bool DoesRectContain(const webrtc::DesktopRect& a,
- const webrtc::DesktopRect& b) {
- webrtc::DesktopRect intersection(a);
- intersection.IntersectWith(b);
- return intersection.equals(b);
-}
-
} // namespace remoting
diff --git a/remoting/base/util.h b/remoting/base/util.h
index 5478c7f..8f70005 100644
--- a/remoting/base/util.h
+++ b/remoting/base/util.h
@@ -8,7 +8,7 @@
#include <string>
#include "media/base/video_frame.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+#include "third_party/skia/include/core/SkRect.h"
namespace remoting {
@@ -36,19 +36,18 @@ int CalculateUVOffset(int x, int y, int stride);
//
// N.B. The top left corner coordinates of YUV buffer should have even X and Y
// coordinates.
-void ConvertAndScaleYUVToRGB32Rect(
- const uint8* source_yplane,
- const uint8* source_uplane,
- const uint8* source_vplane,
- int source_ystride,
- int source_uvstride,
- const webrtc::DesktopSize& source_size,
- const webrtc::DesktopRect& source_buffer_rect,
- uint8* dest_buffer,
- int dest_stride,
- const webrtc::DesktopSize& dest_size,
- const webrtc::DesktopRect& dest_buffer_rect,
- const webrtc::DesktopRect& dest_rect);
+void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
+ const uint8* source_uplane,
+ const uint8* source_vplane,
+ int source_ystride,
+ int source_uvstride,
+ const SkISize& source_size,
+ const SkIRect& source_buffer_rect,
+ uint8* dest_buffer,
+ int dest_stride,
+ const SkISize& dest_size,
+ const SkIRect& dest_buffer_rect,
+ const SkIRect& dest_rect);
// Convert RGB32 to YUV on a specific rectangle.
void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
@@ -66,23 +65,23 @@ void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
int RoundToTwosMultiple(int x);
// Align the sides of the rectangle to multiples of 2 (expanding outwards).
-webrtc::DesktopRect AlignRect(const webrtc::DesktopRect& rect);
+SkIRect AlignRect(const SkIRect& rect);
// Scales the supplied rectangle from |in_size| coordinates to |out_size|.
// If the result has non-integer coordinates then the smallest integer-
// coordinate rectangle that wholly encloses it is returned.
-webrtc::DesktopRect ScaleRect(const webrtc::DesktopRect& rect,
- const webrtc::DesktopSize& in_size,
- const webrtc::DesktopSize& out_size);
+SkIRect ScaleRect(const SkIRect& rect,
+ const SkISize& in_size,
+ const SkISize& out_size);
// Copy content of a rectangle in a RGB32 image.
void CopyRGB32Rect(const uint8* source_buffer,
int source_stride,
- const webrtc::DesktopRect& source_buffer_rect,
+ const SkIRect& source_buffer_rect,
uint8* dest_buffer,
int dest_stride,
- const webrtc::DesktopRect& dest_buffer_rect,
- const webrtc::DesktopRect& dest_rect);
+ const SkIRect& dest_buffer_rect,
+ const SkIRect& dest_rect);
// Replaces every occurrence of "\n" in a string by "\r\n".
std::string ReplaceLfByCrLf(const std::string& in);
@@ -97,9 +96,6 @@ bool StringIsUtf8(const char* data, size_t length);
// error or if not implemented.
std::string GetUsername();
-bool DoesRectContain(const webrtc::DesktopRect& a,
- const webrtc::DesktopRect& b);
-
} // namespace remoting
#endif // REMOTING_BASE_UTIL_H_
diff --git a/remoting/base/util_unittest.cc b/remoting/base/util_unittest.cc
index 1dad9aa..a269c07 100644
--- a/remoting/base/util_unittest.cc
+++ b/remoting/base/util_unittest.cc
@@ -6,7 +6,8 @@
#include "remoting/base/util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+#include "third_party/skia/include/core/SkRect.h"
+#include "third_party/skia/include/core/SkSize.h"
static const int kWidth = 32 ;
static const int kHeight = 24 ;
@@ -44,7 +45,7 @@ class YuvToRgbTester {
memset(rgb_buffer_.get(), 0, rgb_buffer_size_);
}
- void FillRgbBuffer(const webrtc::DesktopRect& rect) {
+ void FillRgbBuffer(const SkIRect& rect) {
uint32* ptr = reinterpret_cast<uint32*>(
rgb_buffer_.get() + (rect.top() * kRgbStride) +
(rect.left() * kBytesPerPixel));
@@ -56,7 +57,7 @@ class YuvToRgbTester {
}
// Check the the desination buffer is filled within expected bounds.
- void CheckRgbBuffer(const webrtc::DesktopRect& rect) {
+ void CheckRgbBuffer(const SkIRect& rect) {
uint32* ptr = reinterpret_cast<uint32*>(rgb_buffer_.get());
for (int y = 0; y < kHeight; ++y) {
if (y < rect.top() || rect.bottom() <= y) {
@@ -80,10 +81,8 @@ class YuvToRgbTester {
}
}
- void RunTest(const webrtc::DesktopSize dest_size,
- const webrtc::DesktopRect& rect) {
- ASSERT_TRUE(
- DoesRectContain(webrtc::DesktopRect::MakeSize(dest_size), rect));
+ void RunTest(const SkISize dest_size, const SkIRect& rect) {
+ ASSERT_TRUE(SkIRect::MakeSize(dest_size).contains(rect));
// Reset buffers.
ResetYuvBuffer();
@@ -110,12 +109,12 @@ class YuvToRgbTester {
vplane_,
kYStride,
kUvStride,
- webrtc::DesktopSize(kWidth, kHeight),
- webrtc::DesktopRect::MakeWH(kWidth, kHeight),
+ SkISize::Make(kWidth, kHeight),
+ SkIRect::MakeWH(kWidth, kHeight),
rgb_buffer_.get(),
kRgbStride,
dest_size,
- webrtc::DesktopRect::MakeSize(dest_size),
+ SkIRect::MakeSize(dest_size),
rect);
// Check if it worked out.
@@ -124,8 +123,7 @@ class YuvToRgbTester {
void TestBasicConversion() {
// Whole buffer.
- RunTest(webrtc::DesktopSize(kWidth, kHeight),
- webrtc::DesktopRect::MakeWH(kWidth, kHeight));
+ RunTest(SkISize::Make(kWidth, kHeight), SkIRect::MakeWH(kWidth, kHeight));
}
private:
@@ -149,15 +147,18 @@ TEST(YuvToRgbTest, BasicConversion) {
TEST(YuvToRgbTest, Clipping) {
YuvToRgbTester tester;
- webrtc::DesktopSize dest_size = webrtc::DesktopSize(kWidth, kHeight);
- webrtc::DesktopRect rect =
- webrtc::DesktopRect::MakeLTRB(0, 0, kWidth - 1, kHeight - 1);
+ SkISize dest_size = SkISize::Make(kWidth, kHeight);
+ SkIRect rect = SkIRect::MakeLTRB(0, 0, kWidth - 1, kHeight - 1);
for (int i = 0; i < 16; ++i) {
- webrtc::DesktopRect dest_rect = webrtc::DesktopRect::MakeLTRB(
- rect.left() + ((i & 1) ? 1 : 0),
- rect.top() + ((i & 2) ? 1 : 0),
- rect.right() + ((i & 4) ? 1 : 0),
- rect.bottom() + ((i & 8) ? 1 : 0));
+ SkIRect dest_rect = rect;
+ if ((i & 1) != 0)
+ dest_rect.fLeft += 1;
+ if ((i & 2) != 0)
+ dest_rect.fTop += 1;
+ if ((i & 4) != 0)
+ dest_rect.fRight += 1;
+ if ((i & 8) != 0)
+ dest_rect.fBottom += 1;
tester.RunTest(dest_size, dest_rect);
}
@@ -166,16 +167,18 @@ TEST(YuvToRgbTest, Clipping) {
TEST(YuvToRgbTest, ClippingAndScaling) {
YuvToRgbTester tester;
- webrtc::DesktopSize dest_size =
- webrtc::DesktopSize(kWidth - 10, kHeight - 10);
- webrtc::DesktopRect rect =
- webrtc::DesktopRect::MakeLTRB(5, 5, kWidth - 11, kHeight - 11);
+ SkISize dest_size = SkISize::Make(kWidth - 10, kHeight - 10);
+ SkIRect rect = SkIRect::MakeLTRB(5, 5, kWidth - 11, kHeight - 11);
for (int i = 0; i < 16; ++i) {
- webrtc::DesktopRect dest_rect = webrtc::DesktopRect::MakeLTRB(
- rect.left() + ((i & 1) ? 1 : 0),
- rect.top() + ((i & 2) ? 1 : 0),
- rect.right() + ((i & 4) ? 1 : 0),
- rect.bottom() + ((i & 8) ? 1 : 0));
+ SkIRect dest_rect = rect;
+ if ((i & 1) != 0)
+ dest_rect.fLeft += 1;
+ if ((i & 2) != 0)
+ dest_rect.fTop += 1;
+ if ((i & 4) != 0)
+ dest_rect.fRight += 1;
+ if ((i & 8) != 0)
+ dest_rect.fBottom += 1;
tester.RunTest(dest_size, dest_rect);
}
diff --git a/remoting/client/DEPS b/remoting/client/DEPS
index 235d972..4b52eec 100644
--- a/remoting/client/DEPS
+++ b/remoting/client/DEPS
@@ -2,6 +2,7 @@ include_rules = [
"+ppapi",
"+jingle/glue",
"+net",
+ "+third_party/webrtc",
"+remoting/codec",
"+remoting/protocol",
diff --git a/remoting/client/frame_consumer.h b/remoting/client/frame_consumer.h
index 4df7595..b5f937c 100644
--- a/remoting/client/frame_consumer.h
+++ b/remoting/client/frame_consumer.h
@@ -6,13 +6,12 @@
#define REMOTING_CLIENT_FRAME_CONSUMER_H_
#include "base/basictypes.h"
+#include "third_party/skia/include/core/SkRect.h"
+#include "third_party/skia/include/core/SkRegion.h"
+#include "third_party/skia/include/core/SkSize.h"
namespace webrtc {
class DesktopFrame;
-class DesktopRect;
-class DesktopRegion;
-class DesktopSize;
-class DesktopVector;
} // namespace webrtc
namespace remoting {
@@ -27,10 +26,10 @@ class FrameConsumer {
//
// N.B. Both |clip_area| and |region| are in output coordinates relative to
// the frame.
- virtual void ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) = 0;
+ const SkRegion& region) = 0;
// Accepts a buffer that couldn't be used for drawing for any reason (shutdown
// is in progress, the view area has changed, etc.). The accepted buffer can
@@ -38,8 +37,8 @@ class FrameConsumer {
virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) = 0;
// Set the dimension of the entire host screen.
- virtual void SetSourceSize(const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& dpi) = 0;
+ virtual void SetSourceSize(const SkISize& source_size,
+ const SkIPoint& dpi) = 0;
protected:
FrameConsumer() {}
diff --git a/remoting/client/frame_consumer_proxy.cc b/remoting/client/frame_consumer_proxy.cc
index 4c7d79f..070130c 100644
--- a/remoting/client/frame_consumer_proxy.cc
+++ b/remoting/client/frame_consumer_proxy.cc
@@ -8,8 +8,6 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
@@ -18,10 +16,10 @@ FrameConsumerProxy::FrameConsumerProxy(
: task_runner_(task_runner) {
}
-void FrameConsumerProxy::ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) {
+ const SkRegion& region) {
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::ApplyBuffer, this,
@@ -44,9 +42,8 @@ void FrameConsumerProxy::ReturnBuffer(webrtc::DesktopFrame* buffer) {
frame_consumer_->ReturnBuffer(buffer);
}
-void FrameConsumerProxy::SetSourceSize(
- const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& source_dpi) {
+void FrameConsumerProxy::SetSourceSize(const SkISize& source_size,
+ const SkIPoint& source_dpi) {
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi));
diff --git a/remoting/client/frame_consumer_proxy.h b/remoting/client/frame_consumer_proxy.h
index 21e8fe4..e39d156 100644
--- a/remoting/client/frame_consumer_proxy.h
+++ b/remoting/client/frame_consumer_proxy.h
@@ -29,13 +29,13 @@ class FrameConsumerProxy
FrameConsumerProxy(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
// FrameConsumer implementation.
- virtual void ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) OVERRIDE;
+ const SkRegion& region) OVERRIDE;
virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE;
- virtual void SetSourceSize(const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& dpi) OVERRIDE;
+ virtual void SetSourceSize(const SkISize& source_size,
+ const SkIPoint& dpi) OVERRIDE;
// Attaches to |frame_consumer_|.
// This must only be called from |frame_consumer_message_loop_|.
diff --git a/remoting/client/frame_producer.h b/remoting/client/frame_producer.h
index aa7e63d..14bf283 100644
--- a/remoting/client/frame_producer.h
+++ b/remoting/client/frame_producer.h
@@ -6,12 +6,12 @@
#define REMOTING_CLIENT_FRAME_PRODUCER_H_
#include "base/callback_forward.h"
+#include "third_party/skia/include/core/SkRect.h"
+#include "third_party/skia/include/core/SkRegion.h"
+#include "third_party/skia/include/core/SkSize.h"
namespace webrtc {
class DesktopFrame;
-class DesktopRect;
-class DesktopRegion;
-class DesktopSize;
} // namespace webrtc
namespace remoting {
@@ -31,7 +31,7 @@ class FrameProducer {
// Requests repainting of the specified |region| of the frame as soon as
// possible. |region| is specified in output coordinates relative to
// the beginning of the frame.
- virtual void InvalidateRegion(const webrtc::DesktopRegion& region) = 0;
+ virtual void InvalidateRegion(const SkRegion& region) = 0;
// Requests returing of all pending buffers to the consumer via
// FrameConsumer::ReturnBuffer() calls.
@@ -39,11 +39,11 @@ class FrameProducer {
// Notifies the producer of changes to the output view size or clipping area.
// Implementations must cope with empty |view_size| or |clip_area|.
- virtual void SetOutputSizeAndClip(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area) = 0;
+ virtual void SetOutputSizeAndClip(const SkISize& view_size,
+ const SkIRect& clip_area) = 0;
// Returns a reference to the shape of the most recently drawn buffer.
- virtual const webrtc::DesktopRegion* GetBufferShape() = 0;
+ virtual const SkRegion* GetBufferShape() = 0;
protected:
virtual ~FrameProducer() {}
diff --git a/remoting/client/jni/jni_frame_consumer.cc b/remoting/client/jni/jni_frame_consumer.cc
index 3b4e763..8f8cfc6 100644
--- a/remoting/client/jni/jni_frame_consumer.cc
+++ b/remoting/client/jni/jni_frame_consumer.cc
@@ -10,7 +10,6 @@
#include "remoting/client/frame_producer.h"
#include "remoting/client/jni/chromoting_jni_runtime.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace {
@@ -63,10 +62,10 @@ void JniFrameConsumer::set_frame_producer(FrameProducer* producer) {
frame_producer_ = producer;
}
-void JniFrameConsumer::ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+void JniFrameConsumer::ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) {
+ const SkRegion& region) {
DCHECK(jni_runtime_->display_task_runner()->BelongsToCurrentThread());
scoped_ptr<webrtc::DesktopFrame> buffer_scoped(buffer);
@@ -94,14 +93,14 @@ void JniFrameConsumer::ReturnBuffer(webrtc::DesktopFrame* buffer) {
delete buffer;
}
-void JniFrameConsumer::SetSourceSize(const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& dpi) {
+void JniFrameConsumer::SetSourceSize(const SkISize& source_size,
+ const SkIPoint& dpi) {
DCHECK(jni_runtime_->display_task_runner()->BelongsToCurrentThread());
// We currently render the desktop 1:1 and perform pan/zoom scaling
// and cropping on the managed canvas.
view_size_ = source_size;
- clip_area_ = webrtc::DesktopRect::MakeSize(view_size_);
+ clip_area_ = SkIRect::MakeSize(view_size_);
frame_producer_->SetOutputSizeAndClip(view_size_, clip_area_);
// Unless being destructed, allocate buffer and start drawing frames onto it.
@@ -124,8 +123,8 @@ void JniFrameConsumer::AllocateBuffer() {
// Update Java's reference to the buffer and record of its dimensions.
jni_runtime_->UpdateImageBuffer(view_size_.width(),
- view_size_.height(),
- buffer->buffer());
+ view_size_.height(),
+ buffer->buffer());
frame_producer_->DrawBuffer(buffer);
}
diff --git a/remoting/client/jni/jni_frame_consumer.h b/remoting/client/jni/jni_frame_consumer.h
index 14155a1..38ff86c 100644
--- a/remoting/client/jni/jni_frame_consumer.h
+++ b/remoting/client/jni/jni_frame_consumer.h
@@ -8,7 +8,6 @@
#include "remoting/client/frame_consumer.h"
#include "base/compiler_specific.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
namespace webrtc {
class DesktopFrame;
@@ -30,13 +29,13 @@ class JniFrameConsumer : public FrameConsumer {
void set_frame_producer(FrameProducer* producer);
// FrameConsumer implementation.
- virtual void ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) OVERRIDE;
+ const SkRegion& region) OVERRIDE;
virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE;
- virtual void SetSourceSize(const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& dpi) OVERRIDE;
+ virtual void SetSourceSize(const SkISize& source_size,
+ const SkIPoint& dpi) OVERRIDE;
private:
// Variables are to be used from the display thread.
@@ -49,8 +48,8 @@ class JniFrameConsumer : public FrameConsumer {
bool in_dtor_;
FrameProducer* frame_producer_;
- webrtc::DesktopSize view_size_;
- webrtc::DesktopRect clip_area_;
+ SkISize view_size_;
+ SkIRect clip_area_;
// If |provide_buffer_|, allocates a new buffer of |view_size_|, informs
// Java about it, and tells the producer to draw onto it. Otherwise, no-op.
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 6cecbaa..066d132 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -351,8 +351,8 @@ bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
return input_handler_.HandleInputEvent(event);
}
-void ChromotingInstance::SetDesktopSize(const webrtc::DesktopSize& size,
- const webrtc::DesktopVector& dpi) {
+void ChromotingInstance::SetDesktopSize(const SkISize& size,
+ const SkIPoint& dpi) {
mouse_input_filter_.set_output_size(size);
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
@@ -365,18 +365,18 @@ void ChromotingInstance::SetDesktopSize(const webrtc::DesktopSize& size,
PostChromotingMessage("onDesktopSize", data.Pass());
}
-void ChromotingInstance::SetDesktopShape(const webrtc::DesktopRegion& shape) {
- if (desktop_shape_ && shape.Equals(*desktop_shape_))
+void ChromotingInstance::SetDesktopShape(const SkRegion& shape) {
+ if (desktop_shape_ && shape == *desktop_shape_)
return;
- desktop_shape_.reset(new webrtc::DesktopRegion(shape));
+ desktop_shape_.reset(new SkRegion(shape));
scoped_ptr<base::ListValue> rects_value(new base::ListValue());
- for (webrtc::DesktopRegion::Iterator i(shape); !i.IsAtEnd(); i.Advance()) {
- const webrtc::DesktopRect& rect = i.rect();
+ for (SkRegion::Iterator i(shape); !i.done(); i.next()) {
+ SkIRect rect = i.rect();
scoped_ptr<base::ListValue> rect_value(new base::ListValue());
- rect_value->AppendInteger(rect.left());
- rect_value->AppendInteger(rect.top());
+ rect_value->AppendInteger(rect.x());
+ rect_value->AppendInteger(rect.y());
rect_value->AppendInteger(rect.width());
rect_value->AppendInteger(rect.height());
rects_value->Append(rect_value.release());
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index 7b120a8..227bcac 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -33,6 +33,9 @@
#include "remoting/protocol/mouse_input_filter.h"
#include "remoting/protocol/negotiating_client_authenticator.h"
#include "remoting/protocol/third_party_client_authenticator.h"
+#include "third_party/skia/include/core/SkPoint.h"
+#include "third_party/skia/include/core/SkRegion.h"
+#include "third_party/skia/include/core/SkSize.h"
namespace base {
class DictionaryValue;
@@ -43,12 +46,6 @@ class InputEvent;
class Module;
} // namespace pp
-namespace webrtc {
-class DesktopRegion;
-class DesktopSize;
-class DesktopVector;
-} // namespace webrtc
-
namespace remoting {
class ChromotingClient;
@@ -135,9 +132,8 @@ class ChromotingInstance :
const protocol::CursorShapeInfo& cursor_shape) OVERRIDE;
// Called by PepperView.
- void SetDesktopSize(const webrtc::DesktopSize& size,
- const webrtc::DesktopVector& dpi);
- void SetDesktopShape(const webrtc::DesktopRegion& shape);
+ void SetDesktopSize(const SkISize& size, const SkIPoint& dpi);
+ void SetDesktopShape(const SkRegion& shape);
void OnFirstFrameReceived();
// Return statistics record by ChromotingClient.
@@ -243,7 +239,7 @@ class ChromotingInstance :
pp::View plugin_view_;
// Contains the most-recently-reported desktop shape, if any.
- scoped_ptr<webrtc::DesktopRegion> desktop_shape_;
+ scoped_ptr<SkRegion> desktop_shape_;
scoped_ptr<DelegatingSignalStrategy> signal_strategy_;
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index a0f6ac4..c412316 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -67,8 +67,14 @@ PepperView::PepperView(ChromotingInstance* instance,
context_(context),
producer_(producer),
merge_buffer_(NULL),
+ merge_clip_area_(SkIRect::MakeEmpty()),
+ dips_size_(SkISize::Make(0, 0)),
dips_to_device_scale_(1.0f),
+ view_size_(SkISize::Make(0, 0)),
dips_to_view_scale_(1.0f),
+ clip_area_(SkIRect::MakeEmpty()),
+ source_size_(SkISize::Make(0, 0)),
+ source_dpi_(SkIPoint::Make(0, 0)),
flush_pending_(false),
is_initialized_(false),
frame_received_(false),
@@ -95,10 +101,10 @@ void PepperView::SetView(const pp::View& view) {
bool view_changed = false;
pp::Rect pp_size = view.GetRect();
- webrtc::DesktopSize new_dips_size(pp_size.width(), pp_size.height());
+ SkISize new_dips_size = SkISize::Make(pp_size.width(), pp_size.height());
float new_dips_to_device_scale = view.GetDeviceScale();
- if (!dips_size_.equals(new_dips_size) ||
+ if (dips_size_ != new_dips_size ||
dips_to_device_scale_ != new_dips_to_device_scale) {
view_changed = true;
dips_to_device_scale_ = new_dips_to_device_scale;
@@ -114,10 +120,11 @@ void PepperView::SetView(const pp::View& view) {
// If the view's DIP dimensions don't match the source then let the frame
// producer do the scaling, and render at device resolution.
- if (!dips_size_.equals(source_size_)) {
+ if (dips_size_ != source_size_) {
dips_to_view_scale_ = dips_to_device_scale_;
- view_size_.set(ceilf(dips_size_.width() * dips_to_view_scale_),
- ceilf(dips_size_.height() * dips_to_view_scale_));
+ view_size_ = SkISize::Make(
+ ceilf(dips_size_.width() * dips_to_view_scale_),
+ ceilf(dips_size_.height() * dips_to_view_scale_));
}
// Create a 2D rendering context at the chosen frame dimensions.
@@ -134,18 +141,18 @@ void PepperView::SetView(const pp::View& view) {
}
pp::Rect pp_clip = view.GetClipRect();
- webrtc::DesktopRect new_clip = webrtc::DesktopRect::MakeLTRB(
+ SkIRect new_clip = SkIRect::MakeLTRB(
floorf(pp_clip.x() * dips_to_view_scale_),
floorf(pp_clip.y() * dips_to_view_scale_),
ceilf(pp_clip.right() * dips_to_view_scale_),
ceilf(pp_clip.bottom() * dips_to_view_scale_));
- if (!clip_area_.equals(new_clip)) {
+ if (clip_area_ != new_clip) {
view_changed = true;
// YUV to RGB conversion may require even X and Y coordinates for
// the top left corner of the clipping area.
clip_area_ = AlignRect(new_clip);
- clip_area_.IntersectWith(webrtc::DesktopRect::MakeSize(view_size_));
+ clip_area_.intersect(SkIRect::MakeSize(view_size_));
}
if (view_changed) {
@@ -154,10 +161,10 @@ void PepperView::SetView(const pp::View& view) {
}
}
-void PepperView::ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+void PepperView::ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) {
+ const SkRegion& region) {
DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
if (!frame_received_) {
@@ -169,7 +176,7 @@ void PepperView::ApplyBuffer(const webrtc::DesktopSize& view_size,
// TODO(alexeypa): We could rescale and draw it (or even draw it without
// rescaling) to reduce the perceived lag while we are waiting for
// the properly scaled data.
- if (!view_size_.equals(view_size)) {
+ if (view_size_ != view_size) {
FreeBuffer(buffer);
InitiateDrawing();
} else {
@@ -191,11 +198,11 @@ void PepperView::ReturnBuffer(webrtc::DesktopFrame* buffer) {
}
}
-void PepperView::SetSourceSize(const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& source_dpi) {
+void PepperView::SetSourceSize(const SkISize& source_size,
+ const SkIPoint& source_dpi) {
DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
- if (source_size_.equals(source_size) && source_dpi_.equals(source_dpi))
+ if (source_size_ == source_size && source_dpi_ == source_dpi)
return;
source_size_ = source_size;
@@ -243,9 +250,9 @@ void PepperView::InitiateDrawing() {
}
}
-void PepperView::FlushBuffer(const webrtc::DesktopRect& clip_area,
+void PepperView::FlushBuffer(const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) {
+ const SkRegion& region) {
// Defer drawing if the flush is already in progress.
if (flush_pending_) {
// |merge_buffer_| is guaranteed to be free here because we allocate only
@@ -262,17 +269,16 @@ void PepperView::FlushBuffer(const webrtc::DesktopRect& clip_area,
// Notify Pepper API about the updated areas and flush pixels to the screen.
base::Time start_time = base::Time::Now();
- for (webrtc::DesktopRegion::Iterator i(region); !i.IsAtEnd(); i.Advance()) {
- webrtc::DesktopRect rect = i.rect();
+ for (SkRegion::Iterator i(region); !i.done(); i.next()) {
+ SkIRect rect = i.rect();
// Re-clip |region| with the current clipping area |clip_area_| because
// the latter could change from the time the buffer was drawn.
- rect.IntersectWith(clip_area_);
- if (rect.is_empty())
+ if (!rect.intersect(clip_area_))
continue;
// Specify the rectangle coordinates relative to the clipping area.
- rect.Translate(-clip_area.left(), -clip_area.top());
+ rect.offset(-clip_area.left(), -clip_area.top());
// Pepper Graphics 2D has a strange and badly documented API that the
// point here is the offset from the source rect. Why?
@@ -284,10 +290,10 @@ void PepperView::FlushBuffer(const webrtc::DesktopRect& clip_area,
// Notify the producer that some parts of the region weren't painted because
// the clipping area has changed already.
- if (!clip_area.equals(clip_area_)) {
- webrtc::DesktopRegion not_painted = region;
- not_painted.Subtract(clip_area_);
- if (!not_painted.is_empty()) {
+ if (clip_area != clip_area_) {
+ SkRegion not_painted = region;
+ not_painted.op(clip_area_, SkRegion::kDifference_Op);
+ if (!not_painted.isEmpty()) {
producer_->InvalidateRegion(not_painted);
}
}
@@ -302,7 +308,7 @@ void PepperView::FlushBuffer(const webrtc::DesktopRect& clip_area,
flush_pending_ = true;
// If the buffer we just rendered has a shape then pass that to JavaScript.
- const webrtc::DesktopRegion* buffer_shape = producer_->GetBufferShape();
+ const SkRegion* buffer_shape = producer_->GetBufferShape();
if (buffer_shape)
instance_->SetDesktopShape(*buffer_shape);
}
diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h
index 4027b620..4848a8e 100644
--- a/remoting/client/plugin/pepper_view.h
+++ b/remoting/client/plugin/pepper_view.h
@@ -16,8 +16,6 @@
#include "ppapi/cpp/point.h"
#include "ppapi/utility/completion_callback_factory.h"
#include "remoting/client/frame_consumer.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace base {
class Time;
@@ -43,26 +41,26 @@ class PepperView : public FrameConsumer {
virtual ~PepperView();
// FrameConsumer implementation.
- virtual void ApplyBuffer(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void ApplyBuffer(const SkISize& view_size,
+ const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region) OVERRIDE;
+ const SkRegion& region) OVERRIDE;
virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE;
- virtual void SetSourceSize(const webrtc::DesktopSize& source_size,
- const webrtc::DesktopVector& dpi) OVERRIDE;
+ virtual void SetSourceSize(const SkISize& source_size,
+ const SkIPoint& dpi) OVERRIDE;
// Updates the PepperView's size & clipping area, taking into account the
// DIP-to-device scale factor.
void SetView(const pp::View& view);
// Returns the dimensions of the most recently displayed frame, in pixels.
- const webrtc::DesktopSize& get_source_size() const {
+ const SkISize& get_source_size() const {
return source_size_;
}
// Return the dimensions of the view in Density Independent Pixels (DIPs).
// Note that there may be multiple device pixels per DIP.
- const webrtc::DesktopSize& get_view_size_dips() const {
+ const SkISize& get_view_size_dips() const {
return dips_size_;
}
@@ -82,9 +80,9 @@ class PepperView : public FrameConsumer {
// clip area of the view has changed since the buffer was generated then
// FrameProducer is supplied the missed parts of |region|. The FrameProducer
// will be supplied a new buffer when FlushBuffer() completes.
- void FlushBuffer(const webrtc::DesktopRect& clip_area,
+ void FlushBuffer(const SkIRect& clip_area,
webrtc::DesktopFrame* buffer,
- const webrtc::DesktopRegion& region);
+ const SkRegion& region);
// Handles completion of FlushBuffer(), triggering a new buffer to be
// returned to FrameProducer for rendering.
@@ -109,11 +107,11 @@ class PepperView : public FrameConsumer {
// Queued buffer to paint, with clip area and dirty region in device pixels.
webrtc::DesktopFrame* merge_buffer_;
- webrtc::DesktopRect merge_clip_area_;
- webrtc::DesktopRegion merge_region_;
+ SkIRect merge_clip_area_;
+ SkRegion merge_region_;
// View size in Density Independent Pixels (DIPs).
- webrtc::DesktopSize dips_size_;
+ SkISize dips_size_;
// Scale factor from DIPs to device pixels.
float dips_to_device_scale_;
@@ -121,19 +119,19 @@ class PepperView : public FrameConsumer {
// View size in output pixels. This is the size at which FrameProducer must
// render frames. It usually matches the DIPs size of the view, but may match
// the size in device pixels when scaling is in effect, to reduce artefacts.
- webrtc::DesktopSize view_size_;
+ SkISize view_size_;
// Scale factor from output pixels to device pixels.
float dips_to_view_scale_;
// Visible area of the view, in output pixels.
- webrtc::DesktopRect clip_area_;
+ SkIRect clip_area_;
// Size of the most recent source frame in pixels.
- webrtc::DesktopSize source_size_;
+ SkISize source_size_;
// Resolution of the most recent source frame dots-per-inch.
- webrtc::DesktopVector source_dpi_;
+ SkIPoint source_dpi_;
// True if there is already a Flush() pending on the Graphics2D context.
bool flush_pending_;
diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc
index e7c2f2f..106c993 100644
--- a/remoting/client/rectangle_update_decoder.cc
+++ b/remoting/client/rectangle_update_decoder.cc
@@ -31,6 +31,10 @@ RectangleUpdateDecoder::RectangleUpdateDecoder(
: main_task_runner_(main_task_runner),
decode_task_runner_(decode_task_runner),
consumer_(consumer),
+ source_size_(SkISize::Make(0, 0)),
+ source_dpi_(SkIPoint::Make(0, 0)),
+ view_size_(SkISize::Make(0, 0)),
+ clip_area_(SkIRect::MakeEmpty()),
paint_scheduled_(false),
latest_sequence_number_(0) {
}
@@ -62,25 +66,25 @@ void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet,
// If the packet includes screen size or DPI information, store them.
if (packet->format().has_screen_width() &&
packet->format().has_screen_height()) {
- webrtc::DesktopSize source_size(packet->format().screen_width(),
- packet->format().screen_height());
- if (!source_size_.equals(source_size)) {
+ SkISize source_size = SkISize::Make(packet->format().screen_width(),
+ packet->format().screen_height());
+ if (source_size_ != source_size) {
source_size_ = source_size;
decoder_needs_reset = true;
notify_size_or_dpi_change = true;
}
}
if (packet->format().has_x_dpi() && packet->format().has_y_dpi()) {
- webrtc::DesktopVector source_dpi(packet->format().x_dpi(),
- packet->format().y_dpi());
- if (!source_dpi.equals(source_dpi_)) {
+ SkIPoint source_dpi(SkIPoint::Make(packet->format().x_dpi(),
+ packet->format().y_dpi()));
+ if (source_dpi != source_dpi_) {
source_dpi_ = source_dpi;
notify_size_or_dpi_change = true;
}
}
// If we've never seen a screen size, ignore the packet.
- if (source_size_.is_empty())
+ if (source_size_.isZero())
return;
if (decoder_needs_reset)
@@ -111,23 +115,23 @@ void RectangleUpdateDecoder::DoPaint() {
paint_scheduled_ = false;
// If the view size is empty or we have no output buffers ready, return.
- if (buffers_.empty() || view_size_.is_empty())
+ if (buffers_.empty() || view_size_.isEmpty())
return;
// If no Decoder is initialized, or the host dimensions are empty, return.
- if (!decoder_.get() || source_size_.is_empty())
+ if (!decoder_.get() || source_size_.isEmpty())
return;
// Draw the invalidated region to the buffer.
webrtc::DesktopFrame* buffer = buffers_.front();
- webrtc::DesktopRegion output_region;
+ SkRegion output_region;
decoder_->RenderFrame(view_size_, clip_area_,
buffer->data(),
buffer->stride(),
&output_region);
// Notify the consumer that painting is done.
- if (!output_region.is_empty()) {
+ if (!output_region.isEmpty()) {
buffers_.pop_front();
consumer_->ApplyBuffer(view_size_, clip_area_, buffer, output_region);
}
@@ -165,8 +169,7 @@ void RectangleUpdateDecoder::DrawBuffer(webrtc::DesktopFrame* buffer) {
SchedulePaint();
}
-void RectangleUpdateDecoder::InvalidateRegion(
- const webrtc::DesktopRegion& region) {
+void RectangleUpdateDecoder::InvalidateRegion(const SkRegion& region) {
if (!decode_task_runner_->BelongsToCurrentThread()) {
decode_task_runner_->PostTask(
FROM_HERE, base::Bind(&RectangleUpdateDecoder::InvalidateRegion,
@@ -180,9 +183,8 @@ void RectangleUpdateDecoder::InvalidateRegion(
}
}
-void RectangleUpdateDecoder::SetOutputSizeAndClip(
- const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area) {
+void RectangleUpdateDecoder::SetOutputSizeAndClip(const SkISize& view_size,
+ const SkIRect& clip_area) {
if (!decode_task_runner_->BelongsToCurrentThread()) {
decode_task_runner_->PostTask(
FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetOutputSizeAndClip,
@@ -191,14 +193,14 @@ void RectangleUpdateDecoder::SetOutputSizeAndClip(
}
// The whole frame needs to be repainted if the scaling factor has changed.
- if (!view_size_.equals(view_size) && decoder_.get()) {
- webrtc::DesktopRegion region;
- region.AddRect(webrtc::DesktopRect::MakeSize(view_size));
+ if (view_size_ != view_size && decoder_.get()) {
+ SkRegion region;
+ region.op(SkIRect::MakeSize(view_size), SkRegion::kUnion_Op);
decoder_->Invalidate(view_size, region);
}
- if (!view_size_.equals(view_size) ||
- !clip_area_.equals(clip_area)) {
+ if (view_size_ != view_size ||
+ clip_area_ != clip_area) {
view_size_ = view_size;
clip_area_ = clip_area;
@@ -219,7 +221,7 @@ void RectangleUpdateDecoder::SetOutputSizeAndClip(
}
}
-const webrtc::DesktopRegion* RectangleUpdateDecoder::GetBufferShape() {
+const SkRegion* RectangleUpdateDecoder::GetBufferShape() {
return decoder_->GetImageShape();
}
diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h
index 3c7468a..6d46a1e 100644
--- a/remoting/client/rectangle_update_decoder.h
+++ b/remoting/client/rectangle_update_decoder.h
@@ -15,7 +15,6 @@
#include "remoting/client/frame_consumer_proxy.h"
#include "remoting/client/frame_producer.h"
#include "remoting/protocol/video_stub.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
namespace base {
class SingleThreadTaskRunner;
@@ -53,12 +52,11 @@ class RectangleUpdateDecoder
// FrameProducer implementation. These methods may be called before we are
// Initialize()d, or we know the source screen size.
virtual void DrawBuffer(webrtc::DesktopFrame* buffer) OVERRIDE;
- virtual void InvalidateRegion(const webrtc::DesktopRegion& region) OVERRIDE;
+ virtual void InvalidateRegion(const SkRegion& region) OVERRIDE;
virtual void RequestReturnBuffers(const base::Closure& done) OVERRIDE;
- virtual void SetOutputSizeAndClip(
- const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area) OVERRIDE;
- virtual const webrtc::DesktopRegion* GetBufferShape() OVERRIDE;
+ virtual void SetOutputSizeAndClip(const SkISize& view_size,
+ const SkIRect& clip_area) OVERRIDE;
+ virtual const SkRegion* GetBufferShape() OVERRIDE;
// VideoStub implementation.
virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
@@ -91,14 +89,14 @@ class RectangleUpdateDecoder
scoped_ptr<VideoDecoder> decoder_;
// Remote screen size in pixels.
- webrtc::DesktopSize source_size_;
+ SkISize source_size_;
// Vertical and horizontal DPI of the remote screen.
- webrtc::DesktopVector source_dpi_;
+ SkIPoint source_dpi_;
// The current dimensions of the frame consumer view.
- webrtc::DesktopSize view_size_;
- webrtc::DesktopRect clip_area_;
+ SkISize view_size_;
+ SkIRect clip_area_;
// The drawing buffers supplied by the frame consumer.
std::list<webrtc::DesktopFrame*> buffers_;
diff --git a/remoting/codec/codec_test.cc b/remoting/codec/codec_test.cc
index 26bd84c..83d1035 100644
--- a/remoting/codec/codec_test.cc
+++ b/remoting/codec/codec_test.cc
@@ -64,12 +64,12 @@ class VideoDecoderTester {
view_size_.width() * view_size_.height() * kBytesPerPixel]);
EXPECT_TRUE(image_data_.get());
decoder_->Initialize(
- webrtc::DesktopSize(screen_size_.width(), screen_size_.height()));
+ SkISize::Make(screen_size_.width(), screen_size_.height()));
}
void Reset() {
expected_region_.Clear();
- update_region_.Clear();
+ update_region_.setEmpty();
}
void ResetRenderedData() {
@@ -89,9 +89,10 @@ class VideoDecoderTester {
void RenderFrame() {
decoder_->RenderFrame(
- webrtc::DesktopSize(view_size_.width(), view_size_.height()),
- webrtc::DesktopRect::MakeWH(view_size_.width(), view_size_.height()),
- image_data_.get(), view_size_.width() * kBytesPerPixel,
+ SkISize::Make(view_size_.width(), view_size_.height()),
+ SkIRect::MakeWH(view_size_.width(), view_size_.height()),
+ image_data_.get(),
+ view_size_.width() * kBytesPerPixel,
&update_region_);
}
@@ -124,10 +125,14 @@ class VideoDecoderTester {
ASSERT_TRUE(frame_);
// Test the content of the update region.
- EXPECT_TRUE(expected_region_.Equals(update_region_));
+ webrtc::DesktopRegion update_region;
+ for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
+ update_region.AddRect(webrtc::DesktopRect::MakeXYWH(
+ i.rect().x(), i.rect().y(), i.rect().width(), i.rect().height()));
+ }
+ EXPECT_TRUE(expected_region_.Equals(update_region));
- for (webrtc::DesktopRegion::Iterator i(update_region_); !i.IsAtEnd();
- i.Advance()) {
+ for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
const int stride = view_size_.width() * kBytesPerPixel;
EXPECT_EQ(stride, frame_->stride());
const int offset = stride * i.rect().top() +
@@ -152,8 +157,7 @@ class VideoDecoderTester {
double max_error = 0.0;
double sum_error = 0.0;
int error_num = 0;
- for (webrtc::DesktopRegion::Iterator i(update_region_); !i.IsAtEnd();
- i.Advance()) {
+ for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
const int stride = view_size_.width() * kBytesPerPixel;
const int offset = stride * i.rect().top() +
kBytesPerPixel * i.rect().left();
@@ -195,7 +199,7 @@ class VideoDecoderTester {
DesktopSize view_size_;
bool strict_;
webrtc::DesktopRegion expected_region_;
- webrtc::DesktopRegion update_region_;
+ SkRegion update_region_;
VideoDecoder* decoder_;
scoped_ptr<uint8[]> image_data_;
webrtc::DesktopFrame* frame_;
@@ -377,9 +381,8 @@ void TestVideoEncoderDecoderGradient(VideoEncoder* encoder,
// invalidates the frame.
decoder_tester.ResetRenderedData();
decoder->Invalidate(
- webrtc::DesktopSize(view_size.width(), view_size.height()),
- webrtc::DesktopRegion(
- webrtc::DesktopRect::MakeWH(view_size.width(), view_size.height())));
+ SkISize::Make(view_size.width(), view_size.height()),
+ SkRegion(SkIRect::MakeWH(view_size.width(), view_size.height())));
decoder_tester.RenderFrame();
decoder_tester.VerifyResultsApprox(expected_result->data(),
max_error_limit, mean_error_limit);
diff --git a/remoting/codec/video_decoder.h b/remoting/codec/video_decoder.h
index 83197b8..4730d3a 100644
--- a/remoting/codec/video_decoder.h
+++ b/remoting/codec/video_decoder.h
@@ -7,12 +7,9 @@
#include "base/basictypes.h"
#include "remoting/proto/video.pb.h"
-
-namespace webrtc {
-class DesktopRect;
-class DesktopRegion;
-class DesktopSize;
-} // namespace webrtc
+#include "third_party/skia/include/core/SkRect.h"
+#include "third_party/skia/include/core/SkRegion.h"
+#include "third_party/skia/include/core/SkSize.h"
namespace remoting {
@@ -34,7 +31,7 @@ class VideoDecoder {
// Initializes the decoder and sets the output dimensions.
// |screen size| must not be empty.
- virtual void Initialize(const webrtc::DesktopSize& screen_size) = 0;
+ virtual void Initialize(const SkISize& screen_size) = 0;
// Feeds more data into the decoder.
virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0;
@@ -47,8 +44,8 @@ class VideoDecoder {
// Marks the specified |region| of the view for update the next time
// RenderFrame() is called. |region| is expressed in |view_size| coordinates.
// |view_size| must not be empty.
- virtual void Invalidate(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRegion& region) = 0;
+ virtual void Invalidate(const SkISize& view_size,
+ const SkRegion& region) = 0;
// Copies invalidated pixels within |clip_area| to |image_buffer|. Pixels are
// invalidated either by new data received in DecodePacket(), or by explicit
@@ -62,15 +59,15 @@ class VideoDecoder {
//
// On return, |output_region| contains the updated area, in |view_size|
// coordinates.
- virtual void RenderFrame(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void RenderFrame(const SkISize& view_size,
+ const SkIRect& clip_area,
uint8* image_buffer,
int image_stride,
- webrtc::DesktopRegion* output_region) = 0;
+ SkRegion* output_region) = 0;
// Returns the "shape", if any, of the most recently rendered frame.
// The shape is returned in source dimensions.
- virtual const webrtc::DesktopRegion* GetImageShape() = 0;
+ virtual const SkRegion* GetImageShape() = 0;
};
} // namespace remoting
diff --git a/remoting/codec/video_decoder_verbatim.cc b/remoting/codec/video_decoder_verbatim.cc
index 81c3b48..b6b2179 100644
--- a/remoting/codec/video_decoder_verbatim.cc
+++ b/remoting/codec/video_decoder_verbatim.cc
@@ -14,7 +14,8 @@ namespace {
const int kBytesPerPixel = 4;
} // namespace
-VideoDecoderVerbatim::VideoDecoderVerbatim() {}
+VideoDecoderVerbatim::VideoDecoderVerbatim()
+ : screen_size_(SkISize::Make(0, 0)) {}
VideoDecoderVerbatim::~VideoDecoderVerbatim() {}
@@ -22,13 +23,13 @@ bool VideoDecoderVerbatim::IsReadyForData() {
return true;
}
-void VideoDecoderVerbatim::Initialize(const webrtc::DesktopSize& screen_size) {
- updated_region_.Clear();
+void VideoDecoderVerbatim::Initialize(const SkISize& screen_size) {
+ updated_region_.setEmpty();
screen_buffer_.reset();
screen_size_ = screen_size;
// Allocate the screen buffer, if necessary.
- if (!screen_size_.is_empty()) {
+ if (!screen_size_.isEmpty()) {
screen_buffer_.reset(
new uint8
[screen_size_.width() * screen_size_.height() * kBytesPerPixel]);
@@ -37,26 +38,27 @@ void VideoDecoderVerbatim::Initialize(const webrtc::DesktopSize& screen_size) {
VideoDecoder::DecodeResult VideoDecoderVerbatim::DecodePacket(
const VideoPacket* packet) {
- webrtc::DesktopRegion region;
+ SkRegion region;
const char* in = packet->data().data();
int stride = kBytesPerPixel * screen_size_.width();
for (int i = 0; i < packet->dirty_rects_size(); ++i) {
Rect proto_rect = packet->dirty_rects(i);
- webrtc::DesktopRect rect =
- webrtc::DesktopRect::MakeXYWH(proto_rect.x(), proto_rect.y(),
- proto_rect.width(), proto_rect.height());
- region.AddRect(rect);
+ SkIRect rect = SkIRect::MakeXYWH(proto_rect.x(),
+ proto_rect.y(),
+ proto_rect.width(),
+ proto_rect.height());
+ region.op(rect, SkRegion::kUnion_Op);
- if (!DoesRectContain(webrtc::DesktopRect::MakeSize(screen_size_), rect)) {
+ if (!SkIRect::MakeSize(screen_size_).contains(rect)) {
LOG(ERROR) << "Invalid packet received";
return DECODE_ERROR;
}
int rect_row_size = kBytesPerPixel * rect.width();
- uint8_t* out = screen_buffer_.get() + rect.top() * stride +
- rect.left() * kBytesPerPixel;
- for (int y = rect.top(); y < rect.top() + rect.height(); ++y) {
+ uint8_t* out = screen_buffer_.get() + rect.y() * stride +
+ rect.x() * kBytesPerPixel;
+ for (int y = rect.y(); y < rect.y() + rect.height(); ++y) {
if (in + rect_row_size > packet->data().data() + packet->data().size()) {
LOG(ERROR) << "Invalid packet received";
return DECODE_ERROR;
@@ -72,7 +74,7 @@ VideoDecoder::DecodeResult VideoDecoderVerbatim::DecodePacket(
return DECODE_ERROR;
}
- updated_region_.AddRegion(region);
+ updated_region_.op(region, SkRegion::kUnion_Op);
return DECODE_DONE;
}
@@ -81,31 +83,28 @@ VideoPacketFormat::Encoding VideoDecoderVerbatim::Encoding() {
return VideoPacketFormat::ENCODING_VERBATIM;
}
-void VideoDecoderVerbatim::Invalidate(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRegion& region) {
- updated_region_.AddRegion(region);
+void VideoDecoderVerbatim::Invalidate(const SkISize& view_size,
+ const SkRegion& region) {
+ updated_region_.op(region, SkRegion::kUnion_Op);
}
-void VideoDecoderVerbatim::RenderFrame(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+void VideoDecoderVerbatim::RenderFrame(const SkISize& view_size,
+ const SkIRect& clip_area,
uint8* image_buffer,
int image_stride,
- webrtc::DesktopRegion* output_region) {
- output_region->Clear();
+ SkRegion* output_region) {
+ output_region->setEmpty();
// TODO(alexeypa): scaling is not implemented.
- webrtc::DesktopRect clip_rect = webrtc::DesktopRect::MakeSize(screen_size_);
- clip_rect.IntersectWith(clip_area);
- if (clip_rect.is_empty())
+ SkIRect clip_rect = SkIRect::MakeSize(screen_size_);
+ if (!clip_rect.intersect(clip_area))
return;
int screen_stride = screen_size_.width() * kBytesPerPixel;
- for (webrtc::DesktopRegion::Iterator i(updated_region_);
- !i.IsAtEnd(); i.Advance()) {
- webrtc::DesktopRect rect(i.rect());
- rect.IntersectWith(clip_rect);
- if (rect.is_empty())
+ for (SkRegion::Iterator i(updated_region_); !i.done(); i.next()) {
+ SkIRect rect(i.rect());
+ if (!rect.intersect(clip_rect))
continue;
CopyRGB32Rect(screen_buffer_.get(), screen_stride,
@@ -113,13 +112,13 @@ void VideoDecoderVerbatim::RenderFrame(const webrtc::DesktopSize& view_size,
image_buffer, image_stride,
clip_area,
rect);
- output_region->AddRect(rect);
+ output_region->op(rect, SkRegion::kUnion_Op);
}
- updated_region_.Clear();
+ updated_region_.setEmpty();
}
-const webrtc::DesktopRegion* VideoDecoderVerbatim::GetImageShape() {
+const SkRegion* VideoDecoderVerbatim::GetImageShape() {
return NULL;
}
diff --git a/remoting/codec/video_decoder_verbatim.h b/remoting/codec/video_decoder_verbatim.h
index ae72379..96b75e21 100644
--- a/remoting/codec/video_decoder_verbatim.h
+++ b/remoting/codec/video_decoder_verbatim.h
@@ -8,8 +8,6 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/codec/video_decoder.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
@@ -24,24 +22,24 @@ class VideoDecoderVerbatim : public VideoDecoder {
// VideoDecoder implementation.
virtual bool IsReadyForData() OVERRIDE;
- virtual void Initialize(const webrtc::DesktopSize& screen_size) OVERRIDE;
+ virtual void Initialize(const SkISize& screen_size) OVERRIDE;
virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE;
virtual VideoPacketFormat::Encoding Encoding() OVERRIDE;
- virtual void Invalidate(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRegion& region) OVERRIDE;
- virtual void RenderFrame(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void Invalidate(const SkISize& view_size,
+ const SkRegion& region) OVERRIDE;
+ virtual void RenderFrame(const SkISize& view_size,
+ const SkIRect& clip_area,
uint8* image_buffer,
int image_stride,
- webrtc::DesktopRegion* output_region) OVERRIDE;
- virtual const webrtc::DesktopRegion* GetImageShape() OVERRIDE;
+ SkRegion* output_region) OVERRIDE;
+ virtual const SkRegion* GetImageShape() OVERRIDE;
private:
// The region updated that hasn't been copied to the screen yet.
- webrtc::DesktopRegion updated_region_;
+ SkRegion updated_region_;
// Size of the remote screen.
- webrtc::DesktopSize screen_size_;
+ SkISize screen_size_;
// The bitmap holding the remote screen bits.
scoped_ptr<uint8[]> screen_buffer_;
diff --git a/remoting/codec/video_decoder_vp8.cc b/remoting/codec/video_decoder_vp8.cc
index 617df93..33896fb 100644
--- a/remoting/codec/video_decoder_vp8.cc
+++ b/remoting/codec/video_decoder_vp8.cc
@@ -28,7 +28,8 @@ const uint32 kTransparent = 0;
VideoDecoderVp8::VideoDecoderVp8()
: state_(kUninitialized),
codec_(NULL),
- last_image_(NULL) {
+ last_image_(NULL),
+ screen_size_(SkISize::Make(0, 0)) {
}
VideoDecoderVp8::~VideoDecoderVp8() {
@@ -39,17 +40,13 @@ VideoDecoderVp8::~VideoDecoderVp8() {
delete codec_;
}
-bool VideoDecoderVp8::IsReadyForData() {
- return state_ == kReady;
-}
-
-void VideoDecoderVp8::Initialize(const webrtc::DesktopSize& screen_size) {
- DCHECK(!screen_size.is_empty());
+void VideoDecoderVp8::Initialize(const SkISize& screen_size) {
+ DCHECK(!screen_size.isEmpty());
screen_size_ = screen_size;
state_ = kReady;
- transparent_region_.SetRect(webrtc::DesktopRect::MakeSize(screen_size_));
+ transparent_region_.setRect(SkIRect::MakeSize(screen_size_));
}
VideoDecoder::DecodeResult VideoDecoderVp8::DecodePacket(
@@ -67,7 +64,8 @@ VideoDecoder::DecodeResult VideoDecoderVp8::DecodePacket(
config.h = 0;
config.threads = 2;
vpx_codec_err_t ret =
- vpx_codec_dec_init(codec_, vpx_codec_vp8_dx(), &config, 0);
+ vpx_codec_dec_init(
+ codec_, vpx_codec_vp8_dx(), &config, 0);
if (ret != VPX_CODEC_OK) {
LOG(INFO) << "Cannot initialize codec.";
delete codec_;
@@ -97,30 +95,33 @@ VideoDecoder::DecodeResult VideoDecoderVp8::DecodePacket(
}
last_image_ = image;
- webrtc::DesktopRegion region;
+ SkRegion region;
for (int i = 0; i < packet->dirty_rects_size(); ++i) {
Rect remoting_rect = packet->dirty_rects(i);
- region.AddRect(webrtc::DesktopRect::MakeXYWH(
- remoting_rect.x(), remoting_rect.y(),
- remoting_rect.width(), remoting_rect.height()));
+ SkIRect rect = SkIRect::MakeXYWH(remoting_rect.x(),
+ remoting_rect.y(),
+ remoting_rect.width(),
+ remoting_rect.height());
+ region.op(rect, SkRegion::kUnion_Op);
}
- updated_region_.AddRegion(region);
+ updated_region_.op(region, SkRegion::kUnion_Op);
// Update the desktop shape region.
- webrtc::DesktopRegion desktop_shape_region;
+ SkRegion desktop_shape_region;
if (packet->has_use_desktop_shape()) {
for (int i = 0; i < packet->desktop_shape_rects_size(); ++i) {
Rect remoting_rect = packet->desktop_shape_rects(i);
- desktop_shape_region.AddRect(webrtc::DesktopRect::MakeXYWH(
- remoting_rect.x(), remoting_rect.y(),
- remoting_rect.width(), remoting_rect.height()));
+ SkIRect rect = SkIRect::MakeXYWH(remoting_rect.x(),
+ remoting_rect.y(),
+ remoting_rect.width(),
+ remoting_rect.height());
+ desktop_shape_region.op(rect, SkRegion::kUnion_Op);
}
} else {
// Fallback for the case when the host didn't include the desktop shape
// region.
- desktop_shape_region =
- webrtc::DesktopRegion(webrtc::DesktopRect::MakeSize(screen_size_));
+ desktop_shape_region = SkRegion(SkIRect::MakeSize(screen_size_));
}
UpdateImageShapeRegion(&desktop_shape_region);
@@ -128,69 +129,72 @@ VideoDecoder::DecodeResult VideoDecoderVp8::DecodePacket(
return DECODE_DONE;
}
+bool VideoDecoderVp8::IsReadyForData() {
+ return state_ == kReady;
+}
+
VideoPacketFormat::Encoding VideoDecoderVp8::Encoding() {
return VideoPacketFormat::ENCODING_VP8;
}
-void VideoDecoderVp8::Invalidate(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRegion& region) {
+void VideoDecoderVp8::Invalidate(const SkISize& view_size,
+ const SkRegion& region) {
DCHECK_EQ(kReady, state_);
- DCHECK(!view_size.is_empty());
+ DCHECK(!view_size.isEmpty());
- for (webrtc::DesktopRegion::Iterator i(region); !i.IsAtEnd(); i.Advance()) {
- updated_region_.AddRect(ScaleRect(i.rect(), view_size, screen_size_));
+ for (SkRegion::Iterator i(region); !i.done(); i.next()) {
+ SkIRect rect = i.rect();
+ rect = ScaleRect(rect, view_size, screen_size_);
+ updated_region_.op(rect, SkRegion::kUnion_Op);
}
// Updated areas outside of the new desktop shape region should be made
// transparent, not repainted.
- webrtc::DesktopRegion difference = updated_region_;
- difference.Subtract(desktop_shape_);
- updated_region_.Subtract(difference);
- transparent_region_.AddRegion(difference);
+ SkRegion difference = updated_region_;
+ difference.op(desktop_shape_, SkRegion::kDifference_Op);
+ updated_region_.op(difference, SkRegion::kDifference_Op);
+ transparent_region_.op(difference, SkRegion::kUnion_Op);
}
-void VideoDecoderVp8::RenderFrame(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+void VideoDecoderVp8::RenderFrame(const SkISize& view_size,
+ const SkIRect& clip_area,
uint8* image_buffer,
int image_stride,
- webrtc::DesktopRegion* output_region) {
+ SkRegion* output_region) {
DCHECK_EQ(kReady, state_);
- DCHECK(!view_size.is_empty());
+ DCHECK(!view_size.isEmpty());
// Early-return and do nothing if we haven't yet decoded any frames.
if (!last_image_)
return;
- webrtc::DesktopRect source_clip =
- webrtc::DesktopRect::MakeWH(last_image_->d_w, last_image_->d_h);
+ SkIRect source_clip = SkIRect::MakeWH(last_image_->d_w, last_image_->d_h);
// ScaleYUVToRGB32WithRect does not currently support up-scaling. We won't
// be asked to up-scale except during resizes or if page zoom is >100%, so
// we work-around the limitation by using the slower ScaleYUVToRGB32.
// TODO(wez): Remove this hack if/when ScaleYUVToRGB32WithRect can up-scale.
- if (!updated_region_.is_empty() &&
+ if (!updated_region_.isEmpty() &&
(source_clip.width() < view_size.width() ||
source_clip.height() < view_size.height())) {
// We're scaling only |clip_area| into the |image_buffer|, so we need to
// work out which source rectangle that corresponds to.
- webrtc::DesktopRect source_rect =
- ScaleRect(clip_area, view_size, screen_size_);
- source_rect = webrtc::DesktopRect::MakeLTRB(
- RoundToTwosMultiple(source_rect.left()),
- RoundToTwosMultiple(source_rect.top()),
- source_rect.right(),
- source_rect.bottom());
+ SkIRect source_rect = ScaleRect(clip_area, view_size, screen_size_);
+ source_rect = SkIRect::MakeLTRB(RoundToTwosMultiple(source_rect.left()),
+ RoundToTwosMultiple(source_rect.top()),
+ source_rect.right(),
+ source_rect.bottom());
// If there were no changes within the clip source area then don't render.
- webrtc::DesktopRegion intersection(source_rect);
- intersection.IntersectWith(updated_region_);
- if (intersection.is_empty())
+ if (!updated_region_.intersects(source_rect))
return;
// Scale & convert the entire clip area.
- int y_offset = CalculateYOffset(source_rect.left(), source_rect.top(),
+ int y_offset = CalculateYOffset(source_rect.x(),
+ source_rect.y(),
last_image_->stride[0]);
- int uv_offset = CalculateUVOffset(source_rect.left(), source_rect.top(),
+ int uv_offset = CalculateUVOffset(source_rect.x(),
+ source_rect.y(),
last_image_->stride[1]);
ScaleYUVToRGB32(last_image_->planes[0] + y_offset,
last_image_->planes[1] + uv_offset,
@@ -207,21 +211,18 @@ void VideoDecoderVp8::RenderFrame(const webrtc::DesktopSize& view_size,
media::ROTATE_0,
media::FILTER_BILINEAR);
- output_region->AddRect(clip_area);
- updated_region_.Subtract(source_rect);
+ output_region->op(clip_area, SkRegion::kUnion_Op);
+ updated_region_.op(source_rect, SkRegion::kDifference_Op);
return;
}
- for (webrtc::DesktopRegion::Iterator i(updated_region_);
- !i.IsAtEnd(); i.Advance()) {
+ for (SkRegion::Iterator i(updated_region_); !i.done(); i.next()) {
// Determine the scaled area affected by this rectangle changing.
- webrtc::DesktopRect rect = i.rect();
- rect.IntersectWith(source_clip);
- if (rect.is_empty())
+ SkIRect rect = i.rect();
+ if (!rect.intersect(source_clip))
continue;
rect = ScaleRect(rect, screen_size_, view_size);
- rect.IntersectWith(clip_area);
- if (rect.is_empty())
+ if (!rect.intersect(clip_area))
continue;
ConvertAndScaleYUVToRGB32Rect(last_image_->planes[0],
@@ -237,41 +238,38 @@ void VideoDecoderVp8::RenderFrame(const webrtc::DesktopSize& view_size,
clip_area,
rect);
- output_region->AddRect(rect);
+ output_region->op(rect, SkRegion::kUnion_Op);
}
- updated_region_.Subtract(ScaleRect(clip_area, view_size, screen_size_));
+ updated_region_.op(ScaleRect(clip_area, view_size, screen_size_),
+ SkRegion::kDifference_Op);
- for (webrtc::DesktopRegion::Iterator i(transparent_region_);
- !i.IsAtEnd(); i.Advance()) {
+ for (SkRegion::Iterator i(transparent_region_); !i.done(); i.next()) {
// Determine the scaled area affected by this rectangle changing.
- webrtc::DesktopRect rect = i.rect();
- rect.IntersectWith(source_clip);
- if (rect.is_empty())
+ SkIRect rect = i.rect();
+ if (!rect.intersect(source_clip))
continue;
rect = ScaleRect(rect, screen_size_, view_size);
- rect.IntersectWith(clip_area);
- if (rect.is_empty())
+ if (!rect.intersect(clip_area))
continue;
// Fill the rectange with transparent pixels.
FillRect(image_buffer, image_stride, rect, kTransparent);
- output_region->AddRect(rect);
+ output_region->op(rect, SkRegion::kUnion_Op);
}
- webrtc::DesktopRect scaled_clip_area =
- ScaleRect(clip_area, view_size, screen_size_);
- updated_region_.Subtract(scaled_clip_area);
- transparent_region_.Subtract(scaled_clip_area);
+ SkIRect scaled_clip_area = ScaleRect(clip_area, view_size, screen_size_);
+ updated_region_.op(scaled_clip_area, SkRegion::kDifference_Op);
+ transparent_region_.op(scaled_clip_area, SkRegion::kDifference_Op);
}
-const webrtc::DesktopRegion* VideoDecoderVp8::GetImageShape() {
+const SkRegion* VideoDecoderVp8::GetImageShape() {
return &desktop_shape_;
}
void VideoDecoderVp8::FillRect(uint8* buffer,
int stride,
- const webrtc::DesktopRect& rect,
+ const SkIRect& rect,
uint32 color) {
uint32* ptr = reinterpret_cast<uint32*>(buffer + (rect.top() * stride) +
(rect.left() * kBytesPerPixelRGB32));
@@ -282,23 +280,22 @@ void VideoDecoderVp8::FillRect(uint8* buffer,
}
}
-void VideoDecoderVp8::UpdateImageShapeRegion(
- webrtc::DesktopRegion* new_desktop_shape) {
+void VideoDecoderVp8::UpdateImageShapeRegion(SkRegion* new_desktop_shape) {
// Add all areas that have been updated or become transparent to the
// transparent region. Exclude anything within the new desktop shape.
- transparent_region_.AddRegion(desktop_shape_);
- transparent_region_.AddRegion(updated_region_);
- transparent_region_.Subtract(*new_desktop_shape);
+ transparent_region_.op(desktop_shape_, SkRegion::kUnion_Op);
+ transparent_region_.op(updated_region_, SkRegion::kUnion_Op);
+ transparent_region_.op(*new_desktop_shape, SkRegion::kDifference_Op);
// Add newly exposed areas to the update region and limit updates to the new
// desktop shape.
- webrtc::DesktopRegion difference = *new_desktop_shape;
- difference.Subtract(desktop_shape_);
- updated_region_.AddRegion(difference);
- updated_region_.IntersectWith(*new_desktop_shape);
+ SkRegion difference = *new_desktop_shape;
+ difference.op(desktop_shape_, SkRegion::kDifference_Op);
+ updated_region_.op(difference, SkRegion::kUnion_Op);
+ updated_region_.op(*new_desktop_shape, SkRegion::kIntersect_Op);
// Set the new desktop shape region.
- desktop_shape_.Swap(new_desktop_shape);
+ desktop_shape_.swap(*new_desktop_shape);
}
} // namespace remoting
diff --git a/remoting/codec/video_decoder_vp8.h b/remoting/codec/video_decoder_vp8.h
index 719ae77..2efbd22 100644
--- a/remoting/codec/video_decoder_vp8.h
+++ b/remoting/codec/video_decoder_vp8.h
@@ -7,8 +7,6 @@
#include "base/compiler_specific.h"
#include "remoting/codec/video_decoder.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
typedef struct vpx_codec_ctx vpx_codec_ctx_t;
typedef struct vpx_image vpx_image_t;
@@ -21,18 +19,18 @@ class VideoDecoderVp8 : public VideoDecoder {
virtual ~VideoDecoderVp8();
// VideoDecoder implementations.
- virtual bool IsReadyForData() OVERRIDE;
- virtual void Initialize(const webrtc::DesktopSize& screen_size) OVERRIDE;
+ virtual void Initialize(const SkISize& screen_size) OVERRIDE;
virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE;
+ virtual bool IsReadyForData() OVERRIDE;
virtual VideoPacketFormat::Encoding Encoding() OVERRIDE;
- virtual void Invalidate(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRegion& region) OVERRIDE;
- virtual void RenderFrame(const webrtc::DesktopSize& view_size,
- const webrtc::DesktopRect& clip_area,
+ virtual void Invalidate(const SkISize& view_size,
+ const SkRegion& region) OVERRIDE;
+ virtual void RenderFrame(const SkISize& view_size,
+ const SkIRect& clip_area,
uint8* image_buffer,
int image_stride,
- webrtc::DesktopRegion* output_region) OVERRIDE;
- virtual const webrtc::DesktopRegion* GetImageShape() OVERRIDE;
+ SkRegion* output_region) OVERRIDE;
+ virtual const SkRegion* GetImageShape() OVERRIDE;
private:
enum State {
@@ -42,14 +40,12 @@ class VideoDecoderVp8 : public VideoDecoder {
};
// Fills the rectangle |rect| with the given ARGB color |color| in |buffer|.
- void FillRect(uint8* buffer, int stride,
- const webrtc::DesktopRect& rect,
- uint32 color);
+ void FillRect(uint8* buffer, int stride, const SkIRect& rect, uint32 color);
// Calculates the difference between the desktop shape regions in two
// consecutive frames and updates |updated_region_| and |transparent_region_|
// accordingly.
- void UpdateImageShapeRegion(webrtc::DesktopRegion* new_desktop_shape);
+ void UpdateImageShapeRegion(SkRegion* new_desktop_shape);
// The internal state of the decoder.
State state_;
@@ -60,16 +56,16 @@ class VideoDecoderVp8 : public VideoDecoder {
vpx_image_t* last_image_;
// The region updated that hasn't been copied to the screen yet.
- webrtc::DesktopRegion updated_region_;
+ SkRegion updated_region_;
// Output dimensions.
- webrtc::DesktopSize screen_size_;
+ SkISize screen_size_;
// The region occupied by the top level windows.
- webrtc::DesktopRegion desktop_shape_;
+ SkRegion desktop_shape_;
// The region that should be make transparent.
- webrtc::DesktopRegion transparent_region_;
+ SkRegion transparent_region_;
DISALLOW_COPY_AND_ASSIGN(VideoDecoderVp8);
};
diff --git a/remoting/codec/video_encoder_vp8.cc b/remoting/codec/video_encoder_vp8.cc
index 077bdd1..179483d 100644
--- a/remoting/codec/video_encoder_vp8.cc
+++ b/remoting/codec/video_encoder_vp8.cc
@@ -12,7 +12,6 @@
#include "remoting/proto/video.pb.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
extern "C" {
#define VPX_CODEC_DISABLE_COMPAT 1
@@ -146,31 +145,30 @@ bool VideoEncoderVp8::Init(const webrtc::DesktopSize& size) {
}
void VideoEncoderVp8::PrepareImage(const webrtc::DesktopFrame& frame,
- webrtc::DesktopRegion* updated_region) {
+ SkRegion* updated_region) {
if (frame.updated_region().is_empty()) {
- updated_region->Clear();
+ updated_region->setEmpty();
return;
}
// Align the region to macroblocks, to avoid encoding artefacts.
// This also ensures that all rectangles have even-aligned top-left, which
// is required for ConvertRGBToYUVWithRect() to work.
- std::vector<webrtc::DesktopRect> aligned_rects;
+ std::vector<SkIRect> aligned_rects;
for (webrtc::DesktopRegion::Iterator r(frame.updated_region());
!r.IsAtEnd(); r.Advance()) {
const webrtc::DesktopRect& rect = r.rect();
- aligned_rects.push_back(AlignRect(webrtc::DesktopRect::MakeLTRB(
- rect.left(), rect.top(), rect.right(), rect.bottom())));
+ aligned_rects.push_back(AlignRect(
+ SkIRect::MakeLTRB(rect.left(), rect.top(), rect.right(), rect.bottom())));
}
DCHECK(!aligned_rects.empty());
- updated_region->Clear();
- updated_region->AddRects(&aligned_rects[0], aligned_rects.size());
+ updated_region->setRects(&aligned_rects[0], aligned_rects.size());
// Clip back to the screen dimensions, in case they're not macroblock aligned.
// The conversion routines don't require even width & height, so this is safe
// even if the source dimensions are not even.
- updated_region->IntersectWith(
- webrtc::DesktopRect::MakeWH(image_->w, image_->h));
+ updated_region->op(SkIRect::MakeWH(image_->w, image_->h),
+ SkRegion::kIntersect_Op);
// Convert the updated region to YUV ready for encoding.
const uint8* rgb_data = frame.data();
@@ -181,25 +179,22 @@ void VideoEncoderVp8::PrepareImage(const webrtc::DesktopFrame& frame,
uint8* y_data = image_->planes[0];
uint8* u_data = image_->planes[1];
uint8* v_data = image_->planes[2];
- for (webrtc::DesktopRegion::Iterator r(*updated_region); !r.IsAtEnd();
- r.Advance()) {
- const webrtc::DesktopRect& rect = r.rect();
+ for (SkRegion::Iterator r(*updated_region); !r.done(); r.next()) {
+ const SkIRect& rect = r.rect();
ConvertRGB32ToYUVWithRect(
rgb_data, y_data, u_data, v_data,
- rect.left(), rect.top(), rect.width(), rect.height(),
+ rect.x(), rect.y(), rect.width(), rect.height(),
rgb_stride, y_stride, uv_stride);
}
}
-void VideoEncoderVp8::PrepareActiveMap(
- const webrtc::DesktopRegion& updated_region) {
+void VideoEncoderVp8::PrepareActiveMap(const SkRegion& updated_region) {
// Clear active map first.
memset(active_map_.get(), 0, active_map_width_ * active_map_height_);
// Mark updated areas active.
- for (webrtc::DesktopRegion::Iterator r(updated_region); !r.IsAtEnd();
- r.Advance()) {
- const webrtc::DesktopRect& rect = r.rect();
+ for (SkRegion::Iterator r(updated_region); !r.done(); r.next()) {
+ const SkIRect& rect = r.rect();
int left = rect.left() / kMacroBlockSize;
int right = (rect.right() - 1) / kMacroBlockSize;
int top = rect.top() / kMacroBlockSize;
@@ -232,7 +227,7 @@ scoped_ptr<VideoPacket> VideoEncoderVp8::Encode(
}
// Convert the updated capture data ready for encode.
- webrtc::DesktopRegion updated_region;
+ SkRegion updated_region;
PrepareImage(frame, &updated_region);
// Update active map based on updated region.
@@ -268,8 +263,8 @@ scoped_ptr<VideoPacket> VideoEncoderVp8::Encode(
scoped_ptr<VideoPacket> packet(new VideoPacket());
while (!got_data) {
- const vpx_codec_cx_pkt_t* vpx_packet =
- vpx_codec_get_cx_data(codec_.get(), &iter);
+ const vpx_codec_cx_pkt_t* vpx_packet = vpx_codec_get_cx_data(codec_.get(),
+ &iter);
if (!vpx_packet)
continue;
@@ -295,11 +290,10 @@ scoped_ptr<VideoPacket> VideoEncoderVp8::Encode(
packet->mutable_format()->set_x_dpi(frame.dpi().x());
packet->mutable_format()->set_y_dpi(frame.dpi().y());
}
- for (webrtc::DesktopRegion::Iterator r(updated_region); !r.IsAtEnd();
- r.Advance()) {
+ for (SkRegion::Iterator r(updated_region); !r.done(); r.next()) {
Rect* rect = packet->add_dirty_rects();
- rect->set_x(r.rect().left());
- rect->set_y(r.rect().top());
+ rect->set_x(r.rect().x());
+ rect->set_y(r.rect().y());
rect->set_width(r.rect().width());
rect->set_height(r.rect().height());
}
diff --git a/remoting/codec/video_encoder_vp8.h b/remoting/codec/video_encoder_vp8.h
index 25b00b3..2e1ade1 100644
--- a/remoting/codec/video_encoder_vp8.h
+++ b/remoting/codec/video_encoder_vp8.h
@@ -7,12 +7,12 @@
#include "base/gtest_prod_util.h"
#include "remoting/codec/video_encoder.h"
+#include "third_party/skia/include/core/SkRegion.h"
typedef struct vpx_codec_ctx vpx_codec_ctx_t;
typedef struct vpx_image vpx_image_t;
namespace webrtc {
-class DesktopRegion;
class DesktopSize;
} // namespace webrtc
@@ -42,11 +42,11 @@ class VideoEncoderVp8 : public VideoEncoder {
//
// TODO(sergeyu): Update this code to use webrtc::DesktopRegion.
void PrepareImage(const webrtc::DesktopFrame& frame,
- webrtc::DesktopRegion* updated_region);
+ SkRegion* updated_region);
// Update the active map according to |updated_region|. Active map is then
// given to the encoder to speed up encoding.
- void PrepareActiveMap(const webrtc::DesktopRegion& updated_region);
+ void PrepareActiveMap(const SkRegion& updated_region);
// True if the encoder is initialized.
bool initialized_;
diff --git a/remoting/host/DEPS b/remoting/host/DEPS
index 6a82636..90d75ca 100644
--- a/remoting/host/DEPS
+++ b/remoting/host/DEPS
@@ -4,11 +4,9 @@ include_rules = [
"+remoting/codec",
"+remoting/jingle_glue",
"+remoting/protocol",
- "+skia/ext",
"+third_party/jsoncpp",
"+third_party/modp_b64",
"+third_party/npapi",
- "+third_party/skia/include/core",
"+third_party/webrtc",
"+ui",
]
diff --git a/remoting/host/mouse_clamping_filter.cc b/remoting/host/mouse_clamping_filter.cc
index 91462fa..db01c10 100644
--- a/remoting/host/mouse_clamping_filter.cc
+++ b/remoting/host/mouse_clamping_filter.cc
@@ -24,9 +24,8 @@ void MouseClampingFilter::ProcessVideoPacket(
// Configure the MouseInputFilter to clamp to the video dimensions.
if (video_packet->format().has_screen_width() &&
video_packet->format().has_screen_height()) {
- webrtc::DesktopSize screen_size =
- webrtc::DesktopSize(video_packet->format().screen_width(),
- video_packet->format().screen_height());
+ SkISize screen_size = SkISize::Make(video_packet->format().screen_width(),
+ video_packet->format().screen_height());
input_filter_.set_input_size(screen_size);
input_filter_.set_output_size(screen_size);
}
diff --git a/remoting/protocol/input_event_tracker.cc b/remoting/protocol/input_event_tracker.cc
index 331546a..7090d4d 100644
--- a/remoting/protocol/input_event_tracker.cc
+++ b/remoting/protocol/input_event_tracker.cc
@@ -12,6 +12,7 @@ namespace protocol {
InputEventTracker::InputEventTracker(InputStub* input_stub)
: input_stub_(input_stub),
+ mouse_pos_(SkIPoint::Make(0, 0)),
mouse_button_state_(0) {
}
@@ -73,7 +74,7 @@ void InputEventTracker::InjectKeyEvent(const KeyEvent& event) {
void InputEventTracker::InjectMouseEvent(const MouseEvent& event) {
if (event.has_x() && event.has_y()) {
- mouse_pos_ = webrtc::DesktopVector(event.x(), event.y());
+ mouse_pos_ = SkIPoint::Make(event.x(), event.y());
}
if (event.has_button() && event.has_button_down()) {
// Button values are defined in remoting/proto/event.proto.
diff --git a/remoting/protocol/input_event_tracker.h b/remoting/protocol/input_event_tracker.h
index 8e0bda7..794fffe9 100644
--- a/remoting/protocol/input_event_tracker.h
+++ b/remoting/protocol/input_event_tracker.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "remoting/protocol/input_stub.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+#include "third_party/skia/include/core/SkPoint.h"
namespace remoting {
namespace protocol {
@@ -42,7 +42,7 @@ class InputEventTracker : public InputStub {
std::set<uint32> pressed_keys_;
- webrtc::DesktopVector mouse_pos_;
+ SkIPoint mouse_pos_;
uint32 mouse_button_state_;
DISALLOW_COPY_AND_ASSIGN(InputEventTracker);
diff --git a/remoting/protocol/mouse_input_filter.cc b/remoting/protocol/mouse_input_filter.cc
index f394341..5a11fa8 100644
--- a/remoting/protocol/mouse_input_filter.cc
+++ b/remoting/protocol/mouse_input_filter.cc
@@ -14,13 +14,15 @@ MouseInputFilter::MouseInputFilter() {
MouseInputFilter::MouseInputFilter(InputStub* input_stub)
: InputFilter(input_stub) {
+ input_max_.setEmpty();
+ output_max_.setEmpty();
}
MouseInputFilter::~MouseInputFilter() {
}
void MouseInputFilter::InjectMouseEvent(const MouseEvent& event) {
- if (input_max_.is_empty() || output_max_.is_empty())
+ if (input_max_.isEmpty() || output_max_.isEmpty())
return;
// We scale based on the maximum input & output coordinates, rather than the
@@ -42,12 +44,12 @@ void MouseInputFilter::InjectMouseEvent(const MouseEvent& event) {
InputFilter::InjectMouseEvent(out_event);
}
-void MouseInputFilter::set_input_size(const webrtc::DesktopSize& size) {
- input_max_.set(size.width() - 1, size.height() - 1);
+void MouseInputFilter::set_input_size(const SkISize& size) {
+ input_max_ = SkISize::Make(size.width() - 1, size.height() - 1);
}
-void MouseInputFilter::set_output_size(const webrtc::DesktopSize& size) {
- output_max_.set(size.width() - 1, size.height() - 1);
+void MouseInputFilter::set_output_size(const SkISize& size) {
+ output_max_ = SkISize::Make(size.width() - 1, size.height() - 1);
}
} // namespace protocol
diff --git a/remoting/protocol/mouse_input_filter.h b/remoting/protocol/mouse_input_filter.h
index 47dae11..f83af93 100644
--- a/remoting/protocol/mouse_input_filter.h
+++ b/remoting/protocol/mouse_input_filter.h
@@ -7,7 +7,8 @@
#include "base/compiler_specific.h"
#include "remoting/protocol/input_filter.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+#include "third_party/skia/include/core/SkTypes.h"
+#include "third_party/skia/include/core/SkSize.h"
namespace remoting {
namespace protocol {
@@ -22,17 +23,17 @@ class MouseInputFilter : public InputFilter {
virtual ~MouseInputFilter();
// Specify the input dimensions for mouse events.
- void set_input_size(const webrtc::DesktopSize& size);
+ void set_input_size(const SkISize& size);
// Specify the output dimensions.
- void set_output_size(const webrtc::DesktopSize& size);
+ void set_output_size(const SkISize& size);
// InputStub overrides.
virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE;
private:
- webrtc::DesktopSize input_max_;
- webrtc::DesktopSize output_max_;
+ SkISize input_max_;
+ SkISize output_max_;
DISALLOW_COPY_AND_ASSIGN(MouseInputFilter);
};
diff --git a/remoting/protocol/mouse_input_filter_unittest.cc b/remoting/protocol/mouse_input_filter_unittest.cc
index 6c98930..376decd 100644
--- a/remoting/protocol/mouse_input_filter_unittest.cc
+++ b/remoting/protocol/mouse_input_filter_unittest.cc
@@ -8,7 +8,7 @@
#include "remoting/protocol/protocol_mock_objects.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+#include "third_party/skia/include/core/SkPoint.h"
using ::testing::_;
using ::testing::InSequence;
@@ -28,22 +28,16 @@ static MouseEvent MouseMoveEvent(int x, int y) {
}
static void InjectTestSequence(InputStub* input_stub) {
- struct Point {
- int x;
- int y;
- };
- static const Point input_sequence[] = {
+ static const SkIPoint input_sequence[] = {
{-5, 10}, {0, 10}, {-1, 10}, {15, 40}, {15, 45}, {15, 39}, {15, 25}
};
- // arraysize() cannot be used here, becase Point is declared inside of a
- // function.
- for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(input_sequence); ++i) {
- const Point& point = input_sequence[i];
- input_stub->InjectMouseEvent(MouseMoveEvent(point.x, point.y));
+ for (unsigned int i=0; i<arraysize(input_sequence); ++i) {
+ const SkIPoint& point = input_sequence[i];
+ input_stub->InjectMouseEvent(MouseMoveEvent(point.x(), point.y()));
}
- for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(input_sequence); ++i) {
- const Point& point = input_sequence[i];
- input_stub->InjectMouseEvent(MouseMoveEvent(point.y, point.x));
+ for (unsigned int i=0; i<arraysize(input_sequence); ++i) {
+ const SkIPoint& point = input_sequence[i];
+ input_stub->InjectMouseEvent(MouseMoveEvent(point.y(), point.x()));
}
}
@@ -62,7 +56,7 @@ TEST(MouseInputFilterTest, BothDimensionsZero) {
TEST(MouseInputFilterTest, InputDimensionsZero) {
MockInputStub mock_stub;
MouseInputFilter mouse_filter(&mock_stub);
- mouse_filter.set_output_size(webrtc::DesktopSize(50, 50));
+ mouse_filter.set_output_size(SkISize::Make(50,50));
EXPECT_CALL(mock_stub, InjectMouseEvent(_))
.Times(0);
@@ -74,7 +68,7 @@ TEST(MouseInputFilterTest, InputDimensionsZero) {
TEST(MouseInputFilterTest, OutputDimensionsZero) {
MockInputStub mock_stub;
MouseInputFilter mouse_filter(&mock_stub);
- mouse_filter.set_input_size(webrtc::DesktopSize(50, 50));
+ mouse_filter.set_input_size(SkISize::Make(50,50));
EXPECT_CALL(mock_stub, InjectMouseEvent(_))
.Times(0);
@@ -86,8 +80,8 @@ TEST(MouseInputFilterTest, OutputDimensionsZero) {
TEST(MouseInputFilterTest, NoScalingOrClipping) {
MockInputStub mock_stub;
MouseInputFilter mouse_filter(&mock_stub);
- mouse_filter.set_output_size(webrtc::DesktopSize(40,40));
- mouse_filter.set_input_size(webrtc::DesktopSize(40,40));
+ mouse_filter.set_output_size(SkISize::Make(40,40));
+ mouse_filter.set_input_size(SkISize::Make(40,40));
{
InSequence s;
@@ -114,8 +108,8 @@ TEST(MouseInputFilterTest, NoScalingOrClipping) {
TEST(MouseInputFilterTest, UpScalingAndClamping) {
MockInputStub mock_stub;
MouseInputFilter mouse_filter(&mock_stub);
- mouse_filter.set_output_size(webrtc::DesktopSize(80, 80));
- mouse_filter.set_input_size(webrtc::DesktopSize(40, 40));
+ mouse_filter.set_output_size(SkISize::Make(80,80));
+ mouse_filter.set_input_size(SkISize::Make(40,40));
{
InSequence s;
@@ -142,8 +136,8 @@ TEST(MouseInputFilterTest, UpScalingAndClamping) {
TEST(MouseInputFilterTest, DownScalingAndClamping) {
MockInputStub mock_stub;
MouseInputFilter mouse_filter(&mock_stub);
- mouse_filter.set_output_size(webrtc::DesktopSize(30, 30));
- mouse_filter.set_input_size(webrtc::DesktopSize(40, 40));
+ mouse_filter.set_output_size(SkISize::Make(30,30));
+ mouse_filter.set_input_size(SkISize::Make(40,40));
{
InSequence s;