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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2828353003: Determine mask UVs based on texture size (Closed)
Patch Set: nit Created 3 years, 7 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 | « cc/trees/layer_tree_host_pixeltest_masks.cc ('k') | 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 6e428798b878b8715e9d463534c0f109db5d52f2..95a60497f10553d30ae49661594e596f5574d417 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -7053,6 +7053,82 @@ class LayerTreeTestMultiTextureMaskLayerWithDifferentBounds
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeTestMultiTextureMaskLayerWithDifferentBounds);
+class LayerTreeTestMaskWithNonExactTextureSize : public LayerTreeTest {
+ protected:
+ void SetupTree() override {
+ // The masked layer has bounds 100x100, but is allocated a 120x150 texture.
+
+ scoped_refptr<Layer> root = Layer::Create();
+
+ scoped_refptr<FakePictureLayer> content_layer =
+ FakePictureLayer::Create(&client_);
+ root->AddChild(content_layer);
+
+ std::unique_ptr<RecordingSource> recording_source =
+ FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100));
+ PaintFlags paint1, paint2;
+ static_cast<FakeRecordingSource*>(recording_source.get())
+ ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1);
+ static_cast<FakeRecordingSource*>(recording_source.get())
+ ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2);
+ client_.set_fill_with_nonsolid_color(true);
+ static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord();
+
+ scoped_refptr<FakePictureLayer> mask_layer =
+ FakePictureLayer::CreateWithRecordingSource(
+ &client_, std::move(recording_source));
+ content_layer->SetMaskLayer(mask_layer.get());
+
+ gfx::Size root_size(100, 100);
+ root->SetBounds(root_size);
+
+ gfx::Size layer_size(100, 100);
+ content_layer->SetBounds(layer_size);
+
+ gfx::Size mask_size(100, 100);
+ gfx::Size mask_texture_size(120, 150);
+ mask_layer->SetBounds(mask_size);
+ mask_layer->SetLayerMaskType(Layer::LayerMaskType::SINGLE_TEXTURE_MASK);
+ mask_layer->set_fixed_tile_size(mask_texture_size);
+
+ layer_tree_host()->SetRootLayer(root);
+ LayerTreeTest::SetupTree();
+ client_.set_bounds(root->bounds());
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
+ LayerTreeHostImpl::FrameData* frame_data,
+ DrawResult draw_result) override {
+ EXPECT_EQ(2u, frame_data->render_passes.size());
+ RenderPass* root_pass = frame_data->render_passes.back().get();
+ EXPECT_EQ(2u, root_pass->quad_list.size());
+
+ // There's a solid color quad under everything.
+ EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material);
+
+ // The surface is 100x100
+ EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material);
+ const RenderPassDrawQuad* render_pass_quad =
+ RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
+ render_pass_quad->rect.ToString());
+ // The mask layer is 100x100, but is backed by a 120x150 image.
+ EXPECT_EQ(gfx::RectF(0.0f, 0.0f, 100.f / 120.0f, 100.f / 150.0f).ToString(),
+ render_pass_quad->mask_uv_rect.ToString());
+ EndTest();
+ return draw_result;
+ }
+
+ void AfterTest() override {}
+
+ int mask_layer_id_;
+ FakeContentLayerClient client_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestMaskWithNonExactTextureSize);
+
class LayerTreeTestPageScaleFlags : public LayerTreeTest {
protected:
void SetupTree() override {
« no previous file with comments | « cc/trees/layer_tree_host_pixeltest_masks.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698