OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "cc/layers/painted_scrollbar_layer_impl.h" | 7 #include "cc/layers/painted_scrollbar_layer_impl.h" |
8 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 8 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
9 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
10 #include "cc/output/filter_operations.h" | 10 #include "cc/output/filter_operations.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 scoped_ptr<LayerImpl> root_ptr = | 94 scoped_ptr<LayerImpl> root_ptr = |
95 LayerImpl::Create(host_impl.active_tree(), 2); | 95 LayerImpl::Create(host_impl.active_tree(), 2); |
96 LayerImpl* root = root_ptr.get(); | 96 LayerImpl* root = root_ptr.get(); |
97 root_clip->AddChild(root_ptr.Pass()); | 97 root_clip->AddChild(root_ptr.Pass()); |
98 scoped_ptr<LayerImpl> scroll_parent = | 98 scoped_ptr<LayerImpl> scroll_parent = |
99 LayerImpl::Create(host_impl.active_tree(), 3); | 99 LayerImpl::Create(host_impl.active_tree(), 3); |
100 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); | 100 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); |
101 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); | 101 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); |
102 scroll_children->insert(scroll_child); | 102 scroll_children->insert(scroll_child); |
103 scroll_children->insert(root); | 103 scroll_children->insert(root); |
| 104 root->SetHasRenderSurface(true); |
104 | 105 |
105 scoped_ptr<LayerImpl> clip_parent = | 106 scoped_ptr<LayerImpl> clip_parent = |
106 LayerImpl::Create(host_impl.active_tree(), 5); | 107 LayerImpl::Create(host_impl.active_tree(), 5); |
107 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); | 108 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); |
108 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); | 109 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); |
109 clip_children->insert(clip_child); | 110 clip_children->insert(clip_child); |
110 clip_children->insert(root); | 111 clip_children->insert(root); |
111 | 112 |
112 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); | 113 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); |
113 LayerImpl* child = root->children()[0]; | 114 LayerImpl* child = root->children()[0]; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 247 } |
247 | 248 |
248 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 249 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
249 FakeImplProxy proxy; | 250 FakeImplProxy proxy; |
250 TestSharedBitmapManager shared_bitmap_manager; | 251 TestSharedBitmapManager shared_bitmap_manager; |
251 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 252 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
252 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 253 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); |
253 host_impl.active_tree()->SetRootLayer( | 254 host_impl.active_tree()->SetRootLayer( |
254 LayerImpl::Create(host_impl.active_tree(), 1)); | 255 LayerImpl::Create(host_impl.active_tree(), 1)); |
255 LayerImpl* root = host_impl.active_tree()->root_layer(); | 256 LayerImpl* root = host_impl.active_tree()->root_layer(); |
| 257 root->SetHasRenderSurface(true); |
256 scoped_ptr<LayerImpl> layer_ptr = | 258 scoped_ptr<LayerImpl> layer_ptr = |
257 LayerImpl::Create(host_impl.active_tree(), 2); | 259 LayerImpl::Create(host_impl.active_tree(), 2); |
258 LayerImpl* layer = layer_ptr.get(); | 260 LayerImpl* layer = layer_ptr.get(); |
259 root->AddChild(layer_ptr.Pass()); | 261 root->AddChild(layer_ptr.Pass()); |
260 layer->SetScrollClipLayer(root->id()); | 262 layer->SetScrollClipLayer(root->id()); |
261 DCHECK(host_impl.CanDraw()); | 263 DCHECK(host_impl.CanDraw()); |
262 | 264 |
263 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 265 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
264 float arbitrary_number = 0.352f; | 266 float arbitrary_number = 0.352f; |
265 gfx::Size arbitrary_size = gfx::Size(111, 222); | 267 gfx::Size arbitrary_size = gfx::Size(111, 222); |
266 gfx::Point arbitrary_point = gfx::Point(333, 444); | 268 gfx::Point arbitrary_point = gfx::Point(333, 444); |
267 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); | 269 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); |
268 gfx::Size large_size = gfx::Size(1000, 1000); | 270 gfx::Size large_size = gfx::Size(1000, 1000); |
269 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); | 271 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); |
270 gfx::RectF arbitrary_rect_f = | 272 gfx::RectF arbitrary_rect_f = |
271 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); | 273 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); |
272 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); | 274 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); |
273 gfx::Transform arbitrary_transform; | 275 gfx::Transform arbitrary_transform; |
274 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 276 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
275 FilterOperations arbitrary_filters; | 277 FilterOperations arbitrary_filters; |
276 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); | 278 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
277 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; | 279 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; |
278 | 280 |
| 281 // Render surface functions. |
| 282 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); |
| 283 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); |
| 284 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(false)); |
| 285 // Create a render surface, because we must have a render surface if we have |
| 286 // filters. |
| 287 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); |
| 288 |
279 // Related filter functions. | 289 // Related filter functions. |
280 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); | 290 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); |
281 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); | 291 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); |
282 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(FilterOperations())); | 292 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(FilterOperations())); |
283 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); | 293 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); |
284 | 294 |
285 // Related scrolling functions. | 295 // Related scrolling functions. |
286 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); | 296 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); |
287 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); | 297 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); |
288 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); | 298 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 | 869 |
860 ASSERT_TRUE(layer(IV_SCROLL, ACTIVE)->scrollable()); | 870 ASSERT_TRUE(layer(IV_SCROLL, ACTIVE)->scrollable()); |
861 | 871 |
862 ASSERT_TRUE(LayerHasScrollbar(OV_SCROLL, ACTIVE)); | 872 ASSERT_TRUE(LayerHasScrollbar(OV_SCROLL, ACTIVE)); |
863 ASSERT_TRUE(LayerHasScrollbar(IV_CLIP, ACTIVE)); | 873 ASSERT_TRUE(LayerHasScrollbar(IV_CLIP, ACTIVE)); |
864 ASSERT_TRUE(LayerHasScrollbar(IV_SCROLL, ACTIVE)); | 874 ASSERT_TRUE(LayerHasScrollbar(IV_SCROLL, ACTIVE)); |
865 } | 875 } |
866 | 876 |
867 } // namespace | 877 } // namespace |
868 } // namespace cc | 878 } // namespace cc |
OLD | NEW |