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

Unified Diff: cc/picture_layer_impl_unittest.cc

Issue 12221077: Fixing tile grid size used by cc:Picture to make it respect current tile configuration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing clang builds Created 7 years, 10 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: cc/picture_layer_impl_unittest.cc
diff --git a/cc/picture_layer_impl_unittest.cc b/cc/picture_layer_impl_unittest.cc
index b4b9f4c2302b813235d325b69a9ce849e48a0d93..43a72fed5d87c9e42ed3b37d709582b8b6151350 100644
--- a/cc/picture_layer_impl_unittest.cc
+++ b/cc/picture_layer_impl_unittest.cc
@@ -5,6 +5,7 @@
#include "cc/picture_layer_impl.h"
#include "cc/layer_tree_impl.h"
+#include "cc/picture_layer.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
@@ -89,8 +90,7 @@ class TestablePicturePileImpl : public PicturePileImpl {
return;
gfx::Rect bounds(tiling().TileBounds(x, y));
scoped_refptr<Picture> picture(Picture::Create(bounds));
- FakeContentLayerClient client;
- picture->Record(&client, NULL);
+ picture->Record(&client_, NULL, tile_grid_info_);
picture_list_map_[std::pair<int, int>(x, y)].push_back(picture);
EXPECT_TRUE(HasRecordingAt(x, y));
@@ -111,9 +111,15 @@ class TestablePicturePileImpl : public PicturePileImpl {
UpdateRecordedRegion();
}
+ void addDrawRect(const gfx::Rect& rect) {
+ client_.addDrawRect(rect);
+ }
+
protected:
virtual ~TestablePicturePileImpl() {
}
+
+ FakeContentLayerClient client_;
};
class ImplSidePaintingSettings : public LayerTreeSettings {
@@ -123,6 +129,18 @@ class ImplSidePaintingSettings : public LayerTreeSettings {
}
};
+class MockCanvas : public SkCanvas {
+ public:
+ explicit MockCanvas(SkDevice* device) : SkCanvas(device) { }
+
+ virtual void drawRect(const SkRect& rect, const SkPaint& paint) {
+ // Capture calls before SkCanvas quickReject kicks in
+ rects_.push_back(rect);
+ }
+
+ std::vector<SkRect> rects_;
+};
+
class PictureLayerImplTest : public testing::Test {
public:
PictureLayerImplTest()
@@ -194,6 +212,64 @@ class PictureLayerImplTest : public testing::Test {
}
protected:
+ void TestTileGridAlignmentCommon() {
+ gfx::Size tile_size(1000, 1000);
+ gfx::Size layer_bounds(1000, 1000);
+
+ scoped_refptr<TestablePicturePileImpl> pending_pile =
+ TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ scoped_refptr<TestablePicturePileImpl> active_pile =
+ TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ pending_pile->ApplyLayerTreeSettings(&host_impl_);
+ active_pile->ApplyLayerTreeSettings(&host_impl_);
+
+ SetupTrees(pending_pile, active_pile);
+
+ host_impl_.activeTree()->SetPageScaleFactorAndLimits(1.f, 1.f, 1.f);
+ float result_scale_x, result_scale_y;
+ gfx::Size result_bounds;
+ active_layer_->calculateContentsScale(
+ 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
+
+ // Add 1x1 rects at the centers of each tile, then re-record pile contents
+ std::vector<Tile*> tiles =
+ active_layer_->tilings().tiling_at(0)->AllTilesForTesting();
+ EXPECT_EQ(16, tiles.size());
+ std::vector<SkRect> rects;
+ std::vector<Tile*>::const_iterator tile_iter;
+ for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
+ gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint();
+ gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1);
+ active_pile->addDrawRect(rect);
+ rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1));
+ }
+ // Force re-record with newly injected content
+ active_pile->RemoveRecordingAt(0, 0);
+ active_pile->AddRecordingAt(0, 0);
+
+ SkBitmap store;
+ store.setConfig(SkBitmap::kNo_Config, 1000, 1000);
+ SkDevice device(store);
+ int64 pixelsRasterized;
+
+ std::vector<SkRect>::const_iterator rect_iter = rects.begin();
+ for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
+ MockCanvas mock_canvas(&device);
+ active_pile->Raster(&mock_canvas, (*tile_iter)->content_rect(),
+ 1.0f, &pixelsRasterized);
+
+ // This test verifies that when drawing the contents of a specific tile
+ // at content scale 1.0, the playback canvas never receives content from
+ // neighboring tiles which indicates that the tile grid embedded in
+ // SkPicture is perfectly aligned with the compositor's tiles.
+ // Note: There are two rects: the initial clear and the explicitly
+ // recorded rect. We only care about the second one.
+ EXPECT_EQ(2, mock_canvas.rects_.size());
enne (OOO) 2013/02/25 23:59:15 This is great. Thanks for the tests.
+ EXPECT_EQ(*rect_iter, mock_canvas.rects_[1]);
+ rect_iter++;
+ }
+ }
+
FakeImplProxy proxy_;
FakeLayerTreeHostImpl host_impl_;
int id_;
@@ -203,6 +279,16 @@ class PictureLayerImplTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest);
};
+TEST_F(PictureLayerImplTest, tileGridAlignment) {
+ host_impl_.setDeviceScaleFactor(1.f);
+ TestTileGridAlignmentCommon();
+}
+
+TEST_F(PictureLayerImplTest, tileGridAlignmentHiDPI) {
+ host_impl_.setDeviceScaleFactor(2.f);
+ TestTileGridAlignmentCommon();
+}
+
TEST_F(PictureLayerImplTest, cloneNoInvalidation) {
gfx::Size tile_size(100, 100);
gfx::Size layer_bounds(400, 400);
« no previous file with comments | « cc/picture_layer.cc ('k') | cc/picture_pile.cc » ('j') | cc/picture_pile_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698