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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 563523002: cc: Change LayerTreeHost unit tests to use impl painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: break down into smaller CLs Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index c5dbe0d79a624d9e346e5ca84cc1a325c892f27f..fdff692e7fcdd477870fe54e6a1635822d9d5011 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -274,12 +274,14 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw);
class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest {
public:
LayerTreeHostTestSetNeedsRedrawRect()
- : num_draws_(0),
- bounds_(50, 50),
- invalid_rect_(10, 10, 20, 20),
- root_layer_(ContentLayer::Create(&client_)) {}
+ : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
virtual void BeginTest() override {
+ if (layer_tree_host()->settings().impl_side_painting)
+ root_layer_ = FakePictureLayer::Create(&client_);
+ else
+ root_layer_ = ContentLayer::Create(&client_);
+
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(bounds_);
layer_tree_host()->SetRootLayer(root_layer_);
@@ -324,7 +326,7 @@ class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest {
const gfx::Size bounds_;
const gfx::Rect invalid_rect_;
FakeContentLayerClient client_;
- scoped_refptr<ContentLayer> root_layer_;
+ scoped_refptr<Layer> root_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect);
@@ -339,7 +341,10 @@ class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
root_layer_ = Layer::Create();
root_layer_->SetBounds(gfx::Size(10, 20));
- scaled_layer_ = FakeContentLayer::Create(&client_);
+ if (layer_tree_host()->settings().impl_side_painting)
+ scaled_layer_ = FakePictureLayer::Create(&client_);
+ else
+ scaled_layer_ = FakeContentLayer::Create(&client_);
scaled_layer_->SetBounds(gfx::Size(1, 1));
root_layer_->AddChild(scaled_layer_);
@@ -360,7 +365,10 @@ class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
// Changing the device scale factor causes a commit. It also changes
danakj 2014/10/18 19:39:26 move this comment into the else block
sohanjg 2014/10/20 07:10:03 Done.
// the content bounds of |scaled_layer_|, which should not generate
// a second commit as a result.
- layer_tree_host()->SetDeviceScaleFactor(4.f);
+ if (layer_tree_host()->settings().impl_side_painting)
+ scaled_layer_->SetBounds(gfx::Size(4, 4));
danakj 2014/10/18 19:39:26 comment saying SetBounds grows the layer and expos
sohanjg 2014/10/20 07:10:03 Done.
+ else
+ layer_tree_host()->SetDeviceScaleFactor(4.f);
break;
default:
// No extra commits.
@@ -376,7 +384,7 @@ class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
private:
FakeContentLayerClient client_;
scoped_refptr<Layer> root_layer_;
- scoped_refptr<FakeContentLayer> scaled_layer_;
+ scoped_refptr<Layer> scaled_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate);
@@ -443,12 +451,14 @@ SINGLE_AND_MULTI_THREAD_TEST_F(
class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
public:
LayerTreeHostTestSetNextCommitForcesRedraw()
- : num_draws_(0),
- bounds_(50, 50),
- invalid_rect_(10, 10, 20, 20),
- root_layer_(ContentLayer::Create(&client_)) {}
+ : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
virtual void BeginTest() override {
+ if (layer_tree_host()->settings().impl_side_painting)
+ root_layer_ = FakePictureLayer::Create(&client_);
+ else
+ root_layer_ = ContentLayer::Create(&client_);
+
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(bounds_);
layer_tree_host()->SetRootLayer(root_layer_);
@@ -526,7 +536,7 @@ class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
const gfx::Size bounds_;
const gfx::Rect invalid_rect_;
FakeContentLayerClient client_;
- scoped_refptr<ContentLayer> root_layer_;
+ scoped_refptr<Layer> root_layer_;
};
SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
@@ -536,22 +546,34 @@ SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
// its damage is preserved until the next time it is drawn.
class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
public:
- LayerTreeHostTestUndrawnLayersDamageLater()
- : root_layer_(ContentLayer::Create(&client_)) {}
+ LayerTreeHostTestUndrawnLayersDamageLater() {}
virtual void SetupTree() override {
+ if (layer_tree_host()->settings().impl_side_painting)
+ root_layer_ = FakePictureLayer::Create(&client_);
+ else
+ root_layer_ = ContentLayer::Create(&client_);
+
root_layer_->SetIsDrawable(true);
root_layer_->SetBounds(gfx::Size(50, 50));
layer_tree_host()->SetRootLayer(root_layer_);
// The initially transparent layer has a larger child layer, which is
// not initially drawn because of the this (parent) layer.
- parent_layer_ = FakeContentLayer::Create(&client_);
+ if (layer_tree_host()->settings().impl_side_painting)
+ parent_layer_ = FakePictureLayer::Create(&client_);
+ else
+ parent_layer_ = FakeContentLayer::Create(&client_);
+
parent_layer_->SetBounds(gfx::Size(15, 15));
parent_layer_->SetOpacity(0.0f);
root_layer_->AddChild(parent_layer_);
- child_layer_ = FakeContentLayer::Create(&client_);
+ if (layer_tree_host()->settings().impl_side_painting)
+ child_layer_ = FakePictureLayer::Create(&client_);
+ else
+ child_layer_ = FakeContentLayer::Create(&client_);
+
child_layer_->SetBounds(gfx::Size(25, 25));
parent_layer_->AddChild(child_layer_);
@@ -617,9 +639,9 @@ class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
private:
FakeContentLayerClient client_;
- scoped_refptr<ContentLayer> root_layer_;
- scoped_refptr<FakeContentLayer> parent_layer_;
- scoped_refptr<FakeContentLayer> child_layer_;
+ scoped_refptr<Layer> root_layer_;
+ scoped_refptr<Layer> parent_layer_;
+ scoped_refptr<Layer> child_layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater);
@@ -994,8 +1016,8 @@ class LayerTreeHostTestOpacityChange : public LayerTreeHostTest {
public:
LayerTreeHostTestOpacityChange()
: test_opacity_change_delegate_(),
- update_check_layer_(ContentLayerWithUpdateTracking::Create(
- &test_opacity_change_delegate_)) {
+ update_check_layer_(
+ FakePictureLayer::Create(&test_opacity_change_delegate_)) {
test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get());
}
@@ -1012,45 +1034,34 @@ class LayerTreeHostTestOpacityChange : public LayerTreeHostTest {
virtual void AfterTest() override {
// Update() should have been called once.
- EXPECT_EQ(1, update_check_layer_->PaintContentsCount());
+ EXPECT_EQ(1, (int)update_check_layer_->update_count());
danakj 2014/10/18 19:39:26 don't cast with c-style cast ever, you should use
sohanjg 2014/10/20 07:10:03 Done.
}
private:
TestOpacityChangeLayerDelegate test_opacity_change_delegate_;
- scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_;
+ scoped_refptr<FakePictureLayer> update_check_layer_;
};
-MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange);
-
-class NoScaleContentLayer : public ContentLayer {
- public:
- static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) {
- return make_scoped_refptr(new NoScaleContentLayer(client));
- }
-
- virtual void CalculateContentsScale(float ideal_contents_scale,
- float* contents_scale_x,
- float* contents_scale_y,
- gfx::Size* contentBounds) override {
- // Skip over the ContentLayer's method to the base Layer class.
- Layer::CalculateContentsScale(ideal_contents_scale,
- contents_scale_x,
- contents_scale_y,
- contentBounds);
- }
-
- private:
- explicit NoScaleContentLayer(ContentLayerClient* client)
- : ContentLayer(client) {}
- virtual ~NoScaleContentLayer() {}
-};
+TEST_F(LayerTreeHostTestOpacityChange,
+ RunMultiThread_DirectRenderer_ImplSidePaint) {
+ RunTest(true, false, true);
danakj 2014/10/18 19:39:26 Just make the test work with/without implside for
sohanjg 2014/10/20 07:10:03 Done.
+}
+TEST_F(LayerTreeHostTestOpacityChange,
+ RunMultiThread_DelegatingRenderer_ImplSidePaint) {
+ RunTest(true, true, true);
+}
class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
: public LayerTreeHostTest {
public:
- LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers()
- : root_layer_(NoScaleContentLayer::Create(&client_)),
- child_layer_(ContentLayer::Create(&client_)) {}
+ LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() {
+ // Paint non-solid color.
danakj 2014/10/18 19:39:26 You can use this now https://code.google.com/p/chr
sohanjg 2014/10/20 07:10:03 Moved to BeginTest, but set_fill_with_nonsolid_col
danakj 2014/10/22 15:10:19 Why does it not work?
sohanjg 2014/10/29 08:31:00 Because CanHaveTilings fail for solid color check
danakj 2014/10/29 14:27:47 Are you saying PictureLayer::Update never happens?
sohanjg 2014/10/31 10:58:52 No, commit is happening just the DetermineIfSolidC
+ SkPaint paint;
+ paint.setColor(SkColorSetARGB(100, 80, 200, 200));
+ client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint);
+ root_layer_ = FakePictureLayer::Create(&client_);
+ child_layer_ = FakePictureLayer::Create(&client_);
+ }
virtual void BeginTest() override {
layer_tree_host()->SetViewportSize(gfx::Size(60, 60));
@@ -1083,8 +1094,10 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
// Device viewport is scaled.
EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize());
- LayerImpl* root = impl->active_tree()->root_layer();
- LayerImpl* child = impl->active_tree()->root_layer()->children()[0];
+ FakePictureLayerImpl* root =
+ static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer());
+ FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>(
+ impl->active_tree()->root_layer()->children()[0]);
// Positions remain in layout pixels.
EXPECT_EQ(gfx::Point(0, 0), root->position());
@@ -1108,10 +1121,8 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60),
root->render_surface()->content_rect());
- // The content bounds of the child should be scaled.
- gfx::Size child_bounds_scaled =
- gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5));
- EXPECT_EQ(child_bounds_scaled, child->content_bounds());
+ // The max tiling scale of the child should be scaled.
+ EXPECT_EQ(1.5, child->MaximumTilingContentsScale());
danakj 2014/10/18 19:39:26 MaxTilingContentsScale is a float isn't it? 1.5f?
sohanjg 2014/10/20 07:10:03 Acknowledged.
gfx::Transform scale_transform;
scale_transform.Scale(impl->device_scale_factor(),
@@ -1125,13 +1136,14 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
EXPECT_EQ(root_screen_space_transform, root->screen_space_transform());
// The child is at position 2,2, which is transformed to 3,3 after the scale
- gfx::Transform child_screen_space_transform;
- child_screen_space_transform.Translate(3.f, 3.f);
- gfx::Transform child_draw_transform = child_screen_space_transform;
+ gfx::Transform child_transform;
+ child_transform.Translate(3.f, 3.f);
+
danakj 2014/10/18 19:39:26 drop whitespace
sohanjg 2014/10/20 07:10:03 Done.
+ child_transform.Scale(child->MaximumTilingContentsScale(),
+ child->MaximumTilingContentsScale());
- EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform,
- child->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform,
+ EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, child->draw_transform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform,
child->screen_space_transform());
EndTest();
@@ -1141,12 +1153,20 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
private:
FakeContentLayerClient client_;
- scoped_refptr<NoScaleContentLayer> root_layer_;
- scoped_refptr<ContentLayer> child_layer_;
+ scoped_refptr<FakePictureLayer> root_layer_;
+ scoped_refptr<FakePictureLayer> child_layer_;
};
-MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers);
+TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers,
danakj 2014/10/18 19:39:26 Keep using the macro please. You can just override
sohanjg 2014/10/20 07:10:03 Done.
+ RunMultiThread_DirectRenderer_ImplSidePaint) {
+ RunTest(true, false, true);
+}
+TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers,
+ RunMultiThread_DelegatingRenderer_ImplSidePaint) {
+ RunTest(true, true, true);
+}
+// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
// Verify atomicity of commits and reuse of textures.
class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest {
public:
@@ -1255,6 +1275,7 @@ class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest {
MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
LayerTreeHostTestDirectRendererAtomicCommit);
+// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
class LayerTreeHostTestDelegatingRendererAtomicCommit
: public LayerTreeHostTestDirectRendererAtomicCommit {
public:
@@ -1322,6 +1343,7 @@ static void SetLayerPropertiesForTesting(Layer* layer,
layer->SetContentsOpaque(opaque);
}
+// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
class LayerTreeHostTestAtomicCommitWithPartialUpdate
: public LayerTreeHostTest {
public:
@@ -1817,11 +1839,15 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10));
- content_layer_ = ContentLayer::Create(&client_);
- content_layer_->SetBounds(gfx::Size(10, 10));
- content_layer_->SetPosition(gfx::PointF(0.f, 0.f));
- content_layer_->SetIsDrawable(true);
- layer_tree_host()->root_layer()->AddChild(content_layer_);
+ if (layer_tree_host()->settings().impl_side_painting)
+ layer_ = FakePictureLayer::Create(&client_);
+ else
+ layer_ = FakeContentLayer::Create(&client_);
+
+ layer_->SetBounds(gfx::Size(10, 10));
+ layer_->SetPosition(gfx::PointF(0.f, 0.f));
+ layer_->SetIsDrawable(true);
+ layer_tree_host()->root_layer()->AddChild(layer_);
PostSetNeedsCommitToMainThread();
}
@@ -1829,7 +1855,7 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
virtual void DidCommitAndDrawFrame() override {
if (num_draw_layers_ == 2)
return;
- content_layer_->SetNeedsDisplay();
+ layer_->SetNeedsDisplay();
}
virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
@@ -1850,12 +1876,12 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
private:
FakeContentLayerClient client_;
- scoped_refptr<Layer> content_layer_;
+ scoped_refptr<Layer> layer_;
int num_commit_complete_;
int num_draw_layers_;
};
-MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestContinuousInvalidate);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate);
class LayerTreeHostTestDeferCommits : public LayerTreeHostTest {
public:
@@ -2054,6 +2080,7 @@ TEST(LayerTreeHostTest,
EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
}
+// TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
: public LayerTreeHostTest {
public:
@@ -4370,7 +4397,11 @@ class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
}
virtual void SetupTree() override {
- root_ = FakeContentLayer::Create(&client_);
+ if (layer_tree_host()->settings().impl_side_painting)
+ root_ = FakePictureLayer::Create(&client_);
+ else
+ root_ = FakeContentLayer::Create(&client_);
+
root_->SetBounds(gfx::Size(20, 20));
layer_tree_host()->SetRootLayer(root_);
LayerTreeHostTest::SetupTree();
@@ -4413,10 +4444,9 @@ class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
size_t first_output_surface_memory_limit_;
size_t second_output_surface_memory_limit_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> root_;
+ scoped_refptr<Layer> root_;
};
-// No output to copy for delegated renderers.
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698