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

Side by Side Diff: cc/layers/render_surface_impl_unittest.cc

Issue 2828353003: Determine mask UVs based on texture size (Closed)
Patch Set: Add tolerance to filter_effects.html Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/test/data/mask_of_larger_layer.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/render_surface_impl.h" 5 #include "cc/layers/render_surface_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
10 #include "cc/quads/render_pass_draw_quad.h" 10 #include "cc/quads/render_pass_draw_quad.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 impl.quad_list(), occluded, &partially_occluded_count); 62 impl.quad_list(), occluded, &partially_occluded_count);
63 // The layer outputs one quad, which is partially occluded. 63 // The layer outputs one quad, which is partially occluded.
64 EXPECT_EQ(1u, impl.quad_list().size()); 64 EXPECT_EQ(1u, impl.quad_list().size());
65 EXPECT_EQ(1u, partially_occluded_count); 65 EXPECT_EQ(1u, partially_occluded_count);
66 } 66 }
67 } 67 }
68 68
69 TEST(RenderSurfaceLayerImplTest, AppendQuadsWithScaledMask) { 69 TEST(RenderSurfaceLayerImplTest, AppendQuadsWithScaledMask) {
70 gfx::Size layer_size(1000, 1000); 70 gfx::Size layer_size(1000, 1000);
71 gfx::Size viewport_size(1000, 1000); 71 gfx::Size viewport_size(1000, 1000);
72 float scale_factor = 2;
72 scoped_refptr<FakeRasterSource> raster_source = 73 scoped_refptr<FakeRasterSource> raster_source =
73 FakeRasterSource::CreateFilledSolidColor(layer_size); 74 FakeRasterSource::CreateFilledSolidColor(layer_size);
74 75
75 LayerTreeSettings settings; 76 LayerTreeSettings settings;
76 settings.layer_transforms_should_scale_layer_contents = true; 77 settings.layer_transforms_should_scale_layer_contents = true;
77 LayerTestCommon::LayerImplTest impl(settings); 78 LayerTestCommon::LayerImplTest impl(settings);
78 std::unique_ptr<LayerImpl> root = 79 std::unique_ptr<LayerImpl> root =
79 LayerImpl::Create(impl.host_impl()->active_tree(), 2); 80 LayerImpl::Create(impl.host_impl()->active_tree(), 2);
80 std::unique_ptr<LayerImpl> surface = 81 std::unique_ptr<LayerImpl> surface =
81 LayerImpl::Create(impl.host_impl()->active_tree(), 3); 82 LayerImpl::Create(impl.host_impl()->active_tree(), 3);
82 surface->SetBounds(layer_size); 83 surface->SetBounds(layer_size);
83 surface->test_properties()->force_render_surface = true; 84 surface->test_properties()->force_render_surface = true;
84 85
85 gfx::Transform scale; 86 gfx::Transform scale;
86 scale.Scale(2, 2); 87 scale.Scale(scale_factor, scale_factor);
87 surface->test_properties()->transform = scale; 88 surface->test_properties()->transform = scale;
88 89
89 surface->test_properties()->SetMaskLayer(FakeMaskLayerImpl::Create( 90 std::unique_ptr<FakeMaskLayerImpl> mask_layer = FakeMaskLayerImpl::Create(
90 impl.host_impl()->active_tree(), 4, raster_source, 91 impl.host_impl()->active_tree(), 4, raster_source,
91 Layer::LayerMaskType::SINGLE_TEXTURE_MASK)); 92 Layer::LayerMaskType::SINGLE_TEXTURE_MASK);
92 surface->test_properties()->mask_layer->SetDrawsContent(true); 93 mask_layer->set_resource_size(
93 surface->test_properties()->mask_layer->SetBounds(layer_size); 94 gfx::ScaleToCeiledSize(layer_size, scale_factor));
95 mask_layer->SetDrawsContent(true);
96 mask_layer->SetBounds(layer_size);
97 surface->test_properties()->SetMaskLayer(std::move(mask_layer));
94 98
95 std::unique_ptr<LayerImpl> child = 99 std::unique_ptr<LayerImpl> child =
96 LayerImpl::Create(impl.host_impl()->active_tree(), 5); 100 LayerImpl::Create(impl.host_impl()->active_tree(), 5);
97 child->SetDrawsContent(true); 101 child->SetDrawsContent(true);
98 child->SetBounds(layer_size); 102 child->SetBounds(layer_size);
99 103
100 surface->test_properties()->AddChild(std::move(child)); 104 surface->test_properties()->AddChild(std::move(child));
101 root->test_properties()->AddChild(std::move(surface)); 105 root->test_properties()->AddChild(std::move(surface));
102 impl.host_impl()->active_tree()->SetRootLayerForTesting(std::move(root)); 106 impl.host_impl()->active_tree()->SetRootLayerForTesting(std::move(root));
103 107
(...skipping 13 matching lines...) Expand all
117 121
118 DCHECK(render_pass->quad_list.front()); 122 DCHECK(render_pass->quad_list.front());
119 const RenderPassDrawQuad* quad = 123 const RenderPassDrawQuad* quad =
120 RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front()); 124 RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front());
121 EXPECT_EQ(gfx::RectF(0, 0, 1, 1), quad->mask_uv_rect); 125 EXPECT_EQ(gfx::RectF(0, 0, 1, 1), quad->mask_uv_rect);
122 EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), quad->filters_scale); 126 EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), quad->filters_scale);
123 } 127 }
124 128
125 } // namespace 129 } // namespace
126 } // namespace cc 130 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/test/data/mask_of_larger_layer.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698