Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2410)

Unified Diff: remoting/host/capturer_mac_unittest.cc

Issue 7491070: Switch over to using SkRegions to calculate dirty areas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/capturer_mac_unittest.cc
diff --git a/remoting/host/capturer_mac_unittest.cc b/remoting/host/capturer_mac_unittest.cc
index e28b841786b17256e1a0d47f7183f8b4c477b393..681282b68e563dcf32bd93969a7e4631807be90c 100644
--- a/remoting/host/capturer_mac_unittest.cc
+++ b/remoting/host/capturer_mac_unittest.cc
@@ -10,7 +10,6 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
-#include "remoting/base/types.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
@@ -22,11 +21,12 @@ class CapturerMacTest : public testing::Test {
}
void AddDirtyRect() {
- rects_.insert(gfx::Rect(0, 0, 10, 10));
+ SkIRect rect = SkIRect::MakeXYWH(0, 0, 10, 10);
+ region_.op(rect, SkRegion::kUnion_Op);
}
scoped_ptr<Capturer> capturer_;
- InvalidRects rects_;
+ SkRegion region_;
};
// CapturerCallback1 verifies that the whole screen is initially dirty.
@@ -44,21 +44,20 @@ void CapturerCallback1::CaptureDoneCallback(
CGDirectDisplayID mainDevice = CGMainDisplayID();
int width = CGDisplayPixelsWide(mainDevice);
int height = CGDisplayPixelsHigh(mainDevice);
- InvalidRects initial_rect;
- initial_rect.insert(gfx::Rect(0, 0, width, height));
- EXPECT_EQ(initial_rect, capture_data->dirty_rects());
+ SkRegion initial_region(SkIRect::MakeXYWH(0, 0, width, height));
+ EXPECT_EQ(initial_region, capture_data->dirty_region());
}
// CapturerCallback2 verifies that a rectangle explicitly marked as dirty is
// propagated correctly.
class CapturerCallback2 {
public:
- explicit CapturerCallback2(const InvalidRects& expected_dirty_rects)
- : expected_dirty_rects_(expected_dirty_rects) { }
+ explicit CapturerCallback2(const SkRegion& expected_dirty_region)
+ : expected_dirty_region_(expected_dirty_region) { }
void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data);
protected:
- InvalidRects expected_dirty_rects_;
+ SkRegion expected_dirty_region_;
private:
DISALLOW_COPY_AND_ASSIGN(CapturerCallback2);
@@ -70,7 +69,7 @@ void CapturerCallback2::CaptureDoneCallback(
int width = CGDisplayPixelsWide(mainDevice);
int height = CGDisplayPixelsHigh(mainDevice);
- EXPECT_EQ(expected_dirty_rects_, capture_data->dirty_rects());
+ EXPECT_EQ(expected_dirty_region_, capture_data->dirty_region());
EXPECT_EQ(width, capture_data->size().width());
EXPECT_EQ(height, capture_data->size().height());
const DataPlanes &planes = capture_data->data_planes();
@@ -89,13 +88,13 @@ TEST_F(CapturerMacTest, Capture) {
SCOPED_TRACE("");
// Check that we get an initial full-screen updated.
CapturerCallback1 callback1;
- capturer_->CaptureInvalidRects(
+ capturer_->CaptureInvalidRegion(
NewCallback(&callback1, &CapturerCallback1::CaptureDoneCallback));
// Check that subsequent dirty rects are propagated correctly.
AddDirtyRect();
- CapturerCallback2 callback2(rects_);
- capturer_->InvalidateRects(rects_);
- capturer_->CaptureInvalidRects(
+ CapturerCallback2 callback2(region_);
+ capturer_->InvalidateRegion(region_);
+ capturer_->CaptureInvalidRegion(
NewCallback(&callback2, &CapturerCallback2::CaptureDoneCallback));
}
@@ -103,13 +102,14 @@ TEST_F(CapturerMacTest, Capture) {
namespace gfx {
-std::ostream& operator<<(std::ostream& out,
- const remoting::InvalidRects& rects) {
- for (remoting::InvalidRects::const_iterator i = rects.begin();
- i != rects.end();
- ++i) {
- out << *i << std::endl;
+std::ostream& operator<<(std::ostream& out, const SkRegion& region) {
Wez 2011/08/08 20:49:34 Is there not already such an override?
dmac 2011/08/10 20:30:36 Not that I am aware of. There is a "tostring" but
+ out << "SkRegion(";
+ for (SkRegion::Iterator i(region); !i.done(); i.next()) {
+ const SkIRect& r = i.rect();
+ out << "(" << r.fLeft << "," << r.fTop << ","
+ << r.fRight << "," << r.fBottom << ")";
}
+ out << ")";
return out;
}

Powered by Google App Engine
This is Rietveld 408576698