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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 &proxy_, 175 &proxy_,
176 &stats_instrumentation_, 176 &stats_instrumentation_,
177 shared_bitmap_manager_.get(), 177 shared_bitmap_manager_.get(),
178 0); 178 0);
179 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); 179 bool init = host_impl_->InitializeRenderer(output_surface.Pass());
180 host_impl_->SetViewportSize(gfx::Size(10, 10)); 180 host_impl_->SetViewportSize(gfx::Size(10, 10));
181 return init; 181 return init;
182 } 182 }
183 183
184 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 184 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
185 root->SetAnchorPoint(gfx::PointF());
186 root->SetPosition(gfx::PointF()); 185 root->SetPosition(gfx::PointF());
187 root->SetBounds(gfx::Size(10, 10)); 186 root->SetBounds(gfx::Size(10, 10));
188 root->SetContentBounds(gfx::Size(10, 10)); 187 root->SetContentBounds(gfx::Size(10, 10));
189 root->SetDrawsContent(true); 188 root->SetDrawsContent(true);
190 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 189 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
191 host_impl_->active_tree()->SetRootLayer(root.Pass()); 190 host_impl_->active_tree()->SetRootLayer(root.Pass());
192 } 191 }
193 192
194 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { 193 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) {
195 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); 194 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, 226 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl,
228 const gfx::Size& content_size) { 227 const gfx::Size& content_size) {
229 const int kInnerViewportScrollLayerId = 2; 228 const int kInnerViewportScrollLayerId = 2;
230 const int kInnerViewportClipLayerId = 4; 229 const int kInnerViewportClipLayerId = 4;
231 const int kPageScaleLayerId = 5; 230 const int kPageScaleLayerId = 5;
232 scoped_ptr<LayerImpl> root = 231 scoped_ptr<LayerImpl> root =
233 LayerImpl::Create(layer_tree_impl, 1); 232 LayerImpl::Create(layer_tree_impl, 1);
234 root->SetBounds(content_size); 233 root->SetBounds(content_size);
235 root->SetContentBounds(content_size); 234 root->SetContentBounds(content_size);
236 root->SetPosition(gfx::PointF()); 235 root->SetPosition(gfx::PointF());
237 root->SetAnchorPoint(gfx::PointF());
238 236
239 scoped_ptr<LayerImpl> scroll = 237 scoped_ptr<LayerImpl> scroll =
240 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); 238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
241 LayerImpl* scroll_layer = scroll.get(); 239 LayerImpl* scroll_layer = scroll.get();
242 scroll->SetIsContainerForFixedPositionLayers(true); 240 scroll->SetIsContainerForFixedPositionLayers(true);
243 scroll->SetScrollOffset(gfx::Vector2d()); 241 scroll->SetScrollOffset(gfx::Vector2d());
244 242
245 scoped_ptr<LayerImpl> clip = 243 scoped_ptr<LayerImpl> clip =
246 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
247 clip->SetBounds( 245 clip->SetBounds(
248 gfx::Size(content_size.width() / 2, content_size.height() / 2)); 246 gfx::Size(content_size.width() / 2, content_size.height() / 2));
249 247
250 scoped_ptr<LayerImpl> page_scale = 248 scoped_ptr<LayerImpl> page_scale =
251 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); 249 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId);
252 250
253 scroll->SetScrollClipLayer(clip->id()); 251 scroll->SetScrollClipLayer(clip->id());
254 scroll->SetBounds(content_size); 252 scroll->SetBounds(content_size);
255 scroll->SetContentBounds(content_size); 253 scroll->SetContentBounds(content_size);
256 scroll->SetPosition(gfx::PointF()); 254 scroll->SetPosition(gfx::PointF());
257 scroll->SetAnchorPoint(gfx::PointF());
258 scroll->SetIsContainerForFixedPositionLayers(true); 255 scroll->SetIsContainerForFixedPositionLayers(true);
259 256
260 scoped_ptr<LayerImpl> contents = 257 scoped_ptr<LayerImpl> contents =
261 LayerImpl::Create(layer_tree_impl, 3); 258 LayerImpl::Create(layer_tree_impl, 3);
262 contents->SetDrawsContent(true); 259 contents->SetDrawsContent(true);
263 contents->SetBounds(content_size); 260 contents->SetBounds(content_size);
264 contents->SetContentBounds(content_size); 261 contents->SetContentBounds(content_size);
265 contents->SetPosition(gfx::PointF()); 262 contents->SetPosition(gfx::PointF());
266 contents->SetAnchorPoint(gfx::PointF());
267 263
268 scroll->AddChild(contents.Pass()); 264 scroll->AddChild(contents.Pass());
269 page_scale->AddChild(scroll.Pass()); 265 page_scale->AddChild(scroll.Pass());
270 clip->AddChild(page_scale.Pass()); 266 clip->AddChild(page_scale.Pass());
271 root->AddChild(clip.Pass()); 267 root->AddChild(clip.Pass());
272 268
273 layer_tree_impl->SetRootLayer(root.Pass()); 269 layer_tree_impl->SetRootLayer(root.Pass());
274 layer_tree_impl->SetViewportLayersFromIds( 270 layer_tree_impl->SetViewportLayersFromIds(
275 kPageScaleLayerId, kInnerViewportScrollLayerId, Layer::INVALID_ID); 271 kPageScaleLayerId, kInnerViewportScrollLayerId, Layer::INVALID_ID);
276 272
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 host_impl_->SetViewportSize(gfx::Size(100, 100)); 834 host_impl_->SetViewportSize(gfx::Size(100, 100));
839 835
840 gfx::Size overflow_size(400, 400); 836 gfx::Size overflow_size(400, 400);
841 ASSERT_EQ(1u, scroll_layer->children().size()); 837 ASSERT_EQ(1u, scroll_layer->children().size());
842 LayerImpl* overflow = scroll_layer->children()[0]; 838 LayerImpl* overflow = scroll_layer->children()[0];
843 overflow->SetBounds(overflow_size); 839 overflow->SetBounds(overflow_size);
844 overflow->SetContentBounds(overflow_size); 840 overflow->SetContentBounds(overflow_size);
845 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); 841 overflow->SetScrollClipLayer(scroll_layer->parent()->id());
846 overflow->SetScrollOffset(gfx::Vector2d()); 842 overflow->SetScrollOffset(gfx::Vector2d());
847 overflow->SetPosition(gfx::PointF()); 843 overflow->SetPosition(gfx::PointF());
848 overflow->SetAnchorPoint(gfx::PointF());
849 844
850 DrawFrame(); 845 DrawFrame();
851 gfx::Point scroll_position(10, 10); 846 gfx::Point scroll_position(10, 10);
852 847
853 EXPECT_EQ(InputHandler::ScrollStarted, 848 EXPECT_EQ(InputHandler::ScrollStarted,
854 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); 849 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel));
855 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); 850 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset());
856 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset()); 851 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset());
857 852
858 gfx::Vector2dF scroll_delta(10, 10); 853 gfx::Vector2dF scroll_delta(10, 10);
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 did_draw_called_ = false; 1679 did_draw_called_ = false;
1685 } 1680 }
1686 1681
1687 protected: 1682 protected:
1688 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) 1683 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id)
1689 : TiledLayerImpl(tree_impl, id), 1684 : TiledLayerImpl(tree_impl, id),
1690 will_draw_returns_false_(false), 1685 will_draw_returns_false_(false),
1691 will_draw_called_(false), 1686 will_draw_called_(false),
1692 append_quads_called_(false), 1687 append_quads_called_(false),
1693 did_draw_called_(false) { 1688 did_draw_called_(false) {
1694 SetAnchorPoint(gfx::PointF());
1695 SetBounds(gfx::Size(10, 10)); 1689 SetBounds(gfx::Size(10, 10));
1696 SetContentBounds(gfx::Size(10, 10)); 1690 SetContentBounds(gfx::Size(10, 10));
1697 SetDrawsContent(true); 1691 SetDrawsContent(true);
1698 set_skips_draw(false); 1692 set_skips_draw(false);
1699 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 1693 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
1700 1694
1701 scoped_ptr<LayerTilingData> tiler = 1695 scoped_ptr<LayerTilingData> tiler =
1702 LayerTilingData::Create(gfx::Size(100, 100), 1696 LayerTilingData::Create(gfx::Size(100, 100),
1703 LayerTilingData::HAS_BORDER_TEXELS); 1697 LayerTilingData::HAS_BORDER_TEXELS);
1704 tiler->SetTilingRect(gfx::Rect(content_bounds())); 1698 tiler->SetTilingRect(gfx::Rect(content_bounds()));
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 2122
2129 scoped_ptr<LayerImpl> root = 2123 scoped_ptr<LayerImpl> root =
2130 LayerImpl::Create(host_impl_->active_tree(), 1); 2124 LayerImpl::Create(host_impl_->active_tree(), 1);
2131 scoped_ptr<LayerImpl> root_clip = 2125 scoped_ptr<LayerImpl> root_clip =
2132 LayerImpl::Create(host_impl_->active_tree(), 2); 2126 LayerImpl::Create(host_impl_->active_tree(), 2);
2133 root_clip->SetBounds(clip_size_); 2127 root_clip->SetBounds(clip_size_);
2134 root->SetScrollClipLayer(root_clip->id()); 2128 root->SetScrollClipLayer(root_clip->id());
2135 root->SetBounds(layer_size_); 2129 root->SetBounds(layer_size_);
2136 root->SetContentBounds(layer_size_); 2130 root->SetContentBounds(layer_size_);
2137 root->SetPosition(gfx::PointF()); 2131 root->SetPosition(gfx::PointF());
2138 root->SetAnchorPoint(gfx::PointF());
2139 root->SetDrawsContent(false); 2132 root->SetDrawsContent(false);
2140 root->SetIsContainerForFixedPositionLayers(true); 2133 root->SetIsContainerForFixedPositionLayers(true);
2141 int inner_viewport_scroll_layer_id = root->id(); 2134 int inner_viewport_scroll_layer_id = root->id();
2142 int page_scale_layer_id = root_clip->id(); 2135 int page_scale_layer_id = root_clip->id();
2143 root_clip->AddChild(root.Pass()); 2136 root_clip->AddChild(root.Pass());
2144 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 2137 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
2145 host_impl_->active_tree()->SetViewportLayersFromIds( 2138 host_impl_->active_tree()->SetViewportLayersFromIds(
2146 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); 2139 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID);
2147 // Set a viewport size that is large enough to contain both the top controls 2140 // Set a viewport size that is large enough to contain both the top controls
2148 // and some content. 2141 // and some content.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { 2260 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
2268 // Test the configuration where a non-composited root layer is embedded in a 2261 // Test the configuration where a non-composited root layer is embedded in a
2269 // scrollable outer layer. 2262 // scrollable outer layer.
2270 gfx::Size surface_size(10, 10); 2263 gfx::Size surface_size(10, 10);
2271 gfx::Size contents_size(20, 20); 2264 gfx::Size contents_size(20, 20);
2272 2265
2273 scoped_ptr<LayerImpl> content_layer = 2266 scoped_ptr<LayerImpl> content_layer =
2274 LayerImpl::Create(host_impl_->active_tree(), 1); 2267 LayerImpl::Create(host_impl_->active_tree(), 1);
2275 content_layer->SetDrawsContent(true); 2268 content_layer->SetDrawsContent(true);
2276 content_layer->SetPosition(gfx::PointF()); 2269 content_layer->SetPosition(gfx::PointF());
2277 content_layer->SetAnchorPoint(gfx::PointF());
2278 content_layer->SetBounds(contents_size); 2270 content_layer->SetBounds(contents_size);
2279 content_layer->SetContentBounds(contents_size); 2271 content_layer->SetContentBounds(contents_size);
2280 content_layer->SetContentsScale(2.f, 2.f); 2272 content_layer->SetContentsScale(2.f, 2.f);
2281 2273
2282 scoped_ptr<LayerImpl> scroll_clip_layer = 2274 scoped_ptr<LayerImpl> scroll_clip_layer =
2283 LayerImpl::Create(host_impl_->active_tree(), 3); 2275 LayerImpl::Create(host_impl_->active_tree(), 3);
2284 scroll_clip_layer->SetBounds(surface_size); 2276 scroll_clip_layer->SetBounds(surface_size);
2285 2277
2286 scoped_ptr<LayerImpl> scroll_layer = 2278 scoped_ptr<LayerImpl> scroll_layer =
2287 LayerImpl::Create(host_impl_->active_tree(), 2); 2279 LayerImpl::Create(host_impl_->active_tree(), 2);
2288 scroll_layer->SetScrollClipLayer(3); 2280 scroll_layer->SetScrollClipLayer(3);
2289 scroll_layer->SetBounds(contents_size); 2281 scroll_layer->SetBounds(contents_size);
2290 scroll_layer->SetContentBounds(contents_size); 2282 scroll_layer->SetContentBounds(contents_size);
2291 scroll_layer->SetPosition(gfx::PointF()); 2283 scroll_layer->SetPosition(gfx::PointF());
2292 scroll_layer->SetAnchorPoint(gfx::PointF());
2293 scroll_layer->AddChild(content_layer.Pass()); 2284 scroll_layer->AddChild(content_layer.Pass());
2294 scroll_clip_layer->AddChild(scroll_layer.Pass()); 2285 scroll_clip_layer->AddChild(scroll_layer.Pass());
2295 2286
2296 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); 2287 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass());
2297 host_impl_->SetViewportSize(surface_size); 2288 host_impl_->SetViewportSize(surface_size);
2298 DrawFrame(); 2289 DrawFrame();
2299 2290
2300 EXPECT_EQ(InputHandler::ScrollStarted, 2291 EXPECT_EQ(InputHandler::ScrollStarted,
2301 host_impl_->ScrollBegin(gfx::Point(5, 5), 2292 host_impl_->ScrollBegin(gfx::Point(5, 5),
2302 InputHandler::Wheel)); 2293 InputHandler::Wheel));
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 child_layer_id, scroll_layer->content_bounds(), clip_layer.get()); 2884 child_layer_id, scroll_layer->content_bounds(), clip_layer.get());
2894 gfx::Transform rotate_transform; 2885 gfx::Transform rotate_transform;
2895 rotate_transform.Translate(-50.0, -50.0); 2886 rotate_transform.Translate(-50.0, -50.0);
2896 rotate_transform.Rotate(child_layer_angle); 2887 rotate_transform.Rotate(child_layer_angle);
2897 rotate_transform.Translate(50.0, 50.0); 2888 rotate_transform.Translate(50.0, 50.0);
2898 clip_layer->SetTransform(rotate_transform); 2889 clip_layer->SetTransform(rotate_transform);
2899 2890
2900 // Only allow vertical scrolling. 2891 // Only allow vertical scrolling.
2901 clip_layer->SetBounds( 2892 clip_layer->SetBounds(
2902 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); 2893 gfx::Size(child->bounds().width(), child->bounds().height() / 2));
2903 // The rotation depends on the layer's anchor point, and the child layer is a 2894 // The rotation depends on the layer's transform origin, and the child layer
2904 // different size than the clip, so make sure the clip layer's anchor lines 2895 // is a different size than the clip, so make sure the clip layer's origin
2905 // up over the child. 2896 // lines up over the child.
2906 clip_layer->SetAnchorPoint(gfx::PointF(0.5, 1.0)); 2897 clip_layer->SetTransformOrigin(gfx::Point3F(
2898 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f));
2907 LayerImpl* child_ptr = child.get(); 2899 LayerImpl* child_ptr = child.get();
2908 clip_layer->AddChild(child.Pass()); 2900 clip_layer->AddChild(child.Pass());
2909 scroll_layer->AddChild(clip_layer.Pass()); 2901 scroll_layer->AddChild(clip_layer.Pass());
2910 2902
2911 gfx::Size surface_size(50, 50); 2903 gfx::Size surface_size(50, 50);
2912 host_impl_->SetViewportSize(surface_size); 2904 host_impl_->SetViewportSize(surface_size);
2913 DrawFrame(); 2905 DrawFrame();
2914 { 2906 {
2915 // Scroll down in screen coordinates with a gesture. 2907 // Scroll down in screen coordinates with a gesture.
2916 gfx::Vector2d gesture_scroll_delta(0, 10); 2908 gfx::Vector2d gesture_scroll_delta(0, 10);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 has_render_surface_(false), 3480 has_render_surface_(false),
3489 quads_appended_(false), 3481 quads_appended_(false),
3490 quad_rect_(5, 5, 5, 5), 3482 quad_rect_(5, 5, 5, 5),
3491 quad_visible_rect_(5, 5, 5, 5), 3483 quad_visible_rect_(5, 5, 5, 5),
3492 resource_id_(resource_provider->CreateResource( 3484 resource_id_(resource_provider->CreateResource(
3493 gfx::Size(1, 1), 3485 gfx::Size(1, 1),
3494 GL_CLAMP_TO_EDGE, 3486 GL_CLAMP_TO_EDGE,
3495 ResourceProvider::TextureUsageAny, 3487 ResourceProvider::TextureUsageAny,
3496 RGBA_8888)) { 3488 RGBA_8888)) {
3497 resource_provider->AllocateForTesting(resource_id_); 3489 resource_provider->AllocateForTesting(resource_id_);
3498 SetAnchorPoint(gfx::PointF());
3499 SetBounds(gfx::Size(10, 10)); 3490 SetBounds(gfx::Size(10, 10));
3500 SetContentBounds(gfx::Size(10, 10)); 3491 SetContentBounds(gfx::Size(10, 10));
3501 SetDrawsContent(true); 3492 SetDrawsContent(true);
3502 } 3493 }
3503 3494
3504 bool blend_; 3495 bool blend_;
3505 bool has_render_surface_; 3496 bool has_render_surface_;
3506 bool quads_appended_; 3497 bool quads_appended_;
3507 gfx::Rect quad_rect_; 3498 gfx::Rect quad_rect_;
3508 gfx::Rect opaque_content_rect_; 3499 gfx::Rect opaque_content_rect_;
3509 gfx::Rect quad_visible_rect_; 3500 gfx::Rect quad_visible_rect_;
3510 ResourceProvider::ResourceId resource_id_; 3501 ResourceProvider::ResourceId resource_id_;
3511 }; 3502 };
3512 3503
3513 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { 3504 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
3514 { 3505 {
3515 scoped_ptr<LayerImpl> root = 3506 scoped_ptr<LayerImpl> root =
3516 LayerImpl::Create(host_impl_->active_tree(), 1); 3507 LayerImpl::Create(host_impl_->active_tree(), 1);
3517 root->SetAnchorPoint(gfx::PointF());
3518 root->SetBounds(gfx::Size(10, 10)); 3508 root->SetBounds(gfx::Size(10, 10));
3519 root->SetContentBounds(root->bounds()); 3509 root->SetContentBounds(root->bounds());
3520 root->SetDrawsContent(false); 3510 root->SetDrawsContent(false);
3521 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3511 host_impl_->active_tree()->SetRootLayer(root.Pass());
3522 } 3512 }
3523 LayerImpl* root = host_impl_->active_tree()->root_layer(); 3513 LayerImpl* root = host_impl_->active_tree()->root_layer();
3524 3514
3525 root->AddChild( 3515 root->AddChild(
3526 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3516 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3527 2, 3517 2,
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
4034 // can leave the window at the wrong size if we never draw and the proper 4024 // can leave the window at the wrong size if we never draw and the proper
4035 // viewport size is never set. 4025 // viewport size is never set.
4036 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { 4026 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
4037 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 4027 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
4038 scoped_ptr<OutputSurface> output_surface( 4028 scoped_ptr<OutputSurface> output_surface(
4039 FakeOutputSurface::Create3d(provider)); 4029 FakeOutputSurface::Create3d(provider));
4040 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 4030 CreateHostImpl(DefaultSettings(), output_surface.Pass());
4041 4031
4042 scoped_ptr<LayerImpl> root = 4032 scoped_ptr<LayerImpl> root =
4043 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4033 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4044 root->SetAnchorPoint(gfx::PointF());
4045 root->SetBounds(gfx::Size(10, 10)); 4034 root->SetBounds(gfx::Size(10, 10));
4046 root->SetContentBounds(gfx::Size(10, 10)); 4035 root->SetContentBounds(gfx::Size(10, 10));
4047 root->SetDrawsContent(true); 4036 root->SetDrawsContent(true);
4048 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4037 host_impl_->active_tree()->SetRootLayer(root.Pass());
4049 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 4038 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
4050 provider->TestContext3d()->clear_reshape_called(); 4039 provider->TestContext3d()->clear_reshape_called();
4051 4040
4052 LayerTreeHostImpl::FrameData frame; 4041 LayerTreeHostImpl::FrameData frame;
4053 host_impl_->SetViewportSize(gfx::Size(10, 10)); 4042 host_impl_->SetViewportSize(gfx::Size(10, 10));
4054 host_impl_->SetDeviceScaleFactor(1.f); 4043 host_impl_->SetDeviceScaleFactor(1.f);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4107 shared_bitmap_manager.get(), 4096 shared_bitmap_manager.get(),
4108 0); 4097 0);
4109 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); 4098 layer_tree_host_impl->InitializeRenderer(output_surface.Pass());
4110 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 4099 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
4111 4100
4112 scoped_ptr<LayerImpl> root = 4101 scoped_ptr<LayerImpl> root =
4113 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 4102 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
4114 scoped_ptr<LayerImpl> child = 4103 scoped_ptr<LayerImpl> child =
4115 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 4104 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
4116 child->SetPosition(gfx::PointF(12.f, 13.f)); 4105 child->SetPosition(gfx::PointF(12.f, 13.f));
4117 child->SetAnchorPoint(gfx::PointF());
4118 child->SetBounds(gfx::Size(14, 15)); 4106 child->SetBounds(gfx::Size(14, 15));
4119 child->SetContentBounds(gfx::Size(14, 15)); 4107 child->SetContentBounds(gfx::Size(14, 15));
4120 child->SetDrawsContent(true); 4108 child->SetDrawsContent(true);
4121 root->SetAnchorPoint(gfx::PointF());
4122 root->SetBounds(gfx::Size(500, 500)); 4109 root->SetBounds(gfx::Size(500, 500));
4123 root->SetContentBounds(gfx::Size(500, 500)); 4110 root->SetContentBounds(gfx::Size(500, 500));
4124 root->SetDrawsContent(true); 4111 root->SetDrawsContent(true);
4125 root->AddChild(child.Pass()); 4112 root->AddChild(child.Pass());
4126 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 4113 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
4127 4114
4128 LayerTreeHostImpl::FrameData frame; 4115 LayerTreeHostImpl::FrameData frame;
4129 4116
4130 // First frame, the entire screen should get swapped. 4117 // First frame, the entire screen should get swapped.
4131 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 4118 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4167 4154
4168 EXPECT_EQ(TestContextSupport::SWAP, 4155 EXPECT_EQ(TestContextSupport::SWAP,
4169 context_provider->support()->last_swap_type()); 4156 context_provider->support()->last_swap_type());
4170 } 4157 }
4171 4158
4172 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 4159 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
4173 scoped_ptr<LayerImpl> root = 4160 scoped_ptr<LayerImpl> root =
4174 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4161 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4175 scoped_ptr<LayerImpl> child = 4162 scoped_ptr<LayerImpl> child =
4176 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 4163 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
4177 child->SetAnchorPoint(gfx::PointF());
4178 child->SetBounds(gfx::Size(10, 10)); 4164 child->SetBounds(gfx::Size(10, 10));
4179 child->SetContentBounds(gfx::Size(10, 10)); 4165 child->SetContentBounds(gfx::Size(10, 10));
4180 child->SetDrawsContent(true); 4166 child->SetDrawsContent(true);
4181 root->SetAnchorPoint(gfx::PointF());
4182 root->SetBounds(gfx::Size(10, 10)); 4167 root->SetBounds(gfx::Size(10, 10));
4183 root->SetContentBounds(gfx::Size(10, 10)); 4168 root->SetContentBounds(gfx::Size(10, 10));
4184 root->SetDrawsContent(true); 4169 root->SetDrawsContent(true);
4185 root->SetForceRenderSurface(true); 4170 root->SetForceRenderSurface(true);
4186 root->AddChild(child.Pass()); 4171 root->AddChild(child.Pass());
4187 4172
4188 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4173 host_impl_->active_tree()->SetRootLayer(root.Pass());
4189 4174
4190 LayerTreeHostImpl::FrameData frame; 4175 LayerTreeHostImpl::FrameData frame;
4191 4176
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
4427 scoped_ptr<LayerImpl> child = 4412 scoped_ptr<LayerImpl> child =
4428 LayerImpl::Create(my_host_impl->active_tree(), 2); 4413 LayerImpl::Create(my_host_impl->active_tree(), 2);
4429 scoped_ptr<LayerImpl> grand_child = 4414 scoped_ptr<LayerImpl> grand_child =
4430 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); 4415 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3);
4431 4416
4432 gfx::Rect root_rect(0, 0, 100, 100); 4417 gfx::Rect root_rect(0, 0, 100, 100);
4433 gfx::Rect child_rect(10, 10, 50, 50); 4418 gfx::Rect child_rect(10, 10, 50, 50);
4434 gfx::Rect grand_child_rect(5, 5, 150, 150); 4419 gfx::Rect grand_child_rect(5, 5, 150, 150);
4435 4420
4436 root->CreateRenderSurface(); 4421 root->CreateRenderSurface();
4437 root->SetAnchorPoint(gfx::PointF());
4438 root->SetPosition(root_rect.origin()); 4422 root->SetPosition(root_rect.origin());
4439 root->SetBounds(root_rect.size()); 4423 root->SetBounds(root_rect.size());
4440 root->SetContentBounds(root->bounds()); 4424 root->SetContentBounds(root->bounds());
4441 root->draw_properties().visible_content_rect = root_rect; 4425 root->draw_properties().visible_content_rect = root_rect;
4442 root->SetDrawsContent(false); 4426 root->SetDrawsContent(false);
4443 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); 4427 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
4444 4428
4445 child->SetAnchorPoint(gfx::PointF());
4446 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); 4429 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
4447 child->SetOpacity(0.5f); 4430 child->SetOpacity(0.5f);
4448 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); 4431 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
4449 child->SetContentBounds(child->bounds()); 4432 child->SetContentBounds(child->bounds());
4450 child->draw_properties().visible_content_rect = child_rect; 4433 child->draw_properties().visible_content_rect = child_rect;
4451 child->SetDrawsContent(false); 4434 child->SetDrawsContent(false);
4452 child->SetForceRenderSurface(true); 4435 child->SetForceRenderSurface(true);
4453 4436
4454 grand_child->SetAnchorPoint(gfx::PointF());
4455 grand_child->SetPosition(grand_child_rect.origin()); 4437 grand_child->SetPosition(grand_child_rect.origin());
4456 grand_child->SetBounds(grand_child_rect.size()); 4438 grand_child->SetBounds(grand_child_rect.size());
4457 grand_child->SetContentBounds(grand_child->bounds()); 4439 grand_child->SetContentBounds(grand_child->bounds());
4458 grand_child->draw_properties().visible_content_rect = grand_child_rect; 4440 grand_child->draw_properties().visible_content_rect = grand_child_rect;
4459 grand_child->SetDrawsContent(true); 4441 grand_child->SetDrawsContent(true);
4460 4442
4461 child->AddChild(grand_child.Pass()); 4443 child->AddChild(grand_child.Pass());
4462 root->AddChild(child.Pass()); 4444 root->AddChild(child.Pass());
4463 4445
4464 my_host_impl->active_tree()->SetRootLayer(root.Pass()); 4446 my_host_impl->active_tree()->SetRootLayer(root.Pass());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 scoped_ptr<TestWebGraphicsContext3D> context = 4505 scoped_ptr<TestWebGraphicsContext3D> context =
4524 TestWebGraphicsContext3D::Create(); 4506 TestWebGraphicsContext3D::Create();
4525 TestWebGraphicsContext3D* context3d = context.get(); 4507 TestWebGraphicsContext3D* context3d = context.get();
4526 scoped_ptr<OutputSurface> output_surface( 4508 scoped_ptr<OutputSurface> output_surface(
4527 FakeOutputSurface::Create3d(context.Pass())); 4509 FakeOutputSurface::Create3d(context.Pass()));
4528 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 4510 CreateHostImpl(DefaultSettings(), output_surface.Pass());
4529 4511
4530 scoped_ptr<LayerImpl> root_layer = 4512 scoped_ptr<LayerImpl> root_layer =
4531 LayerImpl::Create(host_impl_->active_tree(), 1); 4513 LayerImpl::Create(host_impl_->active_tree(), 1);
4532 root_layer->SetBounds(gfx::Size(10, 10)); 4514 root_layer->SetBounds(gfx::Size(10, 10));
4533 root_layer->SetAnchorPoint(gfx::PointF());
4534 4515
4535 scoped_refptr<VideoFrame> softwareFrame = 4516 scoped_refptr<VideoFrame> softwareFrame =
4536 media::VideoFrame::CreateColorFrame( 4517 media::VideoFrame::CreateColorFrame(
4537 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); 4518 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
4538 FakeVideoFrameProvider provider; 4519 FakeVideoFrameProvider provider;
4539 provider.set_frame(softwareFrame); 4520 provider.set_frame(softwareFrame);
4540 scoped_ptr<VideoLayerImpl> video_layer = 4521 scoped_ptr<VideoLayerImpl> video_layer =
4541 VideoLayerImpl::Create(host_impl_->active_tree(), 4, &provider); 4522 VideoLayerImpl::Create(host_impl_->active_tree(), 4, &provider);
4542 video_layer->SetBounds(gfx::Size(10, 10)); 4523 video_layer->SetBounds(gfx::Size(10, 10));
4543 video_layer->SetAnchorPoint(gfx::PointF());
4544 video_layer->SetContentBounds(gfx::Size(10, 10)); 4524 video_layer->SetContentBounds(gfx::Size(10, 10));
4545 video_layer->SetDrawsContent(true); 4525 video_layer->SetDrawsContent(true);
4546 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 4526 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
4547 4527
4548 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = 4528 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer =
4549 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); 4529 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5);
4550 io_surface_layer->SetBounds(gfx::Size(10, 10)); 4530 io_surface_layer->SetBounds(gfx::Size(10, 10));
4551 io_surface_layer->SetAnchorPoint(gfx::PointF());
4552 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); 4531 io_surface_layer->SetContentBounds(gfx::Size(10, 10));
4553 io_surface_layer->SetDrawsContent(true); 4532 io_surface_layer->SetDrawsContent(true);
4554 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4533 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4555 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4534 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4556 4535
4557 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4536 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4558 4537
4559 EXPECT_EQ(0u, context3d->NumTextures()); 4538 EXPECT_EQ(0u, context3d->NumTextures());
4560 4539
4561 LayerTreeHostImpl::FrameData frame; 4540 LayerTreeHostImpl::FrameData frame;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4698 4677
4699 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4678 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4700 host_impl_->DidDrawAllLayers(frame); 4679 host_impl_->DidDrawAllLayers(frame);
4701 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); 4680 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
4702 } 4681 }
4703 }; 4682 };
4704 4683
4705 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 4684 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
4706 scoped_ptr<SolidColorLayerImpl> root = 4685 scoped_ptr<SolidColorLayerImpl> root =
4707 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 4686 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
4708 root->SetAnchorPoint(gfx::PointF());
4709 root->SetPosition(gfx::PointF()); 4687 root->SetPosition(gfx::PointF());
4710 root->SetBounds(gfx::Size(10, 10)); 4688 root->SetBounds(gfx::Size(10, 10));
4711 root->SetContentBounds(gfx::Size(10, 10)); 4689 root->SetContentBounds(gfx::Size(10, 10));
4712 root->SetDrawsContent(true); 4690 root->SetDrawsContent(true);
4713 4691
4714 // Child layer is in the bottom right corner. 4692 // Child layer is in the bottom right corner.
4715 scoped_ptr<SolidColorLayerImpl> child = 4693 scoped_ptr<SolidColorLayerImpl> child =
4716 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); 4694 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
4717 child->SetAnchorPoint(gfx::PointF(0.f, 0.f));
4718 child->SetPosition(gfx::PointF(9.f, 9.f)); 4695 child->SetPosition(gfx::PointF(9.f, 9.f));
4719 child->SetBounds(gfx::Size(1, 1)); 4696 child->SetBounds(gfx::Size(1, 1));
4720 child->SetContentBounds(gfx::Size(1, 1)); 4697 child->SetContentBounds(gfx::Size(1, 1));
4721 child->SetDrawsContent(true); 4698 child->SetDrawsContent(true);
4722 root->AddChild(child.PassAs<LayerImpl>()); 4699 root->AddChild(child.PassAs<LayerImpl>());
4723 4700
4724 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); 4701 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>());
4725 4702
4726 // Draw a frame. In the first frame, the entire viewport should be damaged. 4703 // Draw a frame. In the first frame, the entire viewport should be damaged.
4727 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 4704 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4790 4767
4791 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 4768 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
4792 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 4769 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
4793 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 4770 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
4794 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 4771 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
4795 4772
4796 gfx::Size root_size(100, 100); 4773 gfx::Size root_size(100, 100);
4797 root->SetBounds(root_size); 4774 root->SetBounds(root_size);
4798 root->SetContentBounds(root_size); 4775 root->SetContentBounds(root_size);
4799 root->SetPosition(gfx::PointF()); 4776 root->SetPosition(gfx::PointF());
4800 root->SetAnchorPoint(gfx::PointF());
4801 4777
4802 gfx::Size scaling_layer_size(50, 50); 4778 gfx::Size scaling_layer_size(50, 50);
4803 scaling_layer->SetBounds(scaling_layer_size); 4779 scaling_layer->SetBounds(scaling_layer_size);
4804 scaling_layer->SetContentBounds(scaling_layer_size); 4780 scaling_layer->SetContentBounds(scaling_layer_size);
4805 scaling_layer->SetPosition(gfx::PointF()); 4781 scaling_layer->SetPosition(gfx::PointF());
4806 scaling_layer->SetAnchorPoint(gfx::PointF());
4807 gfx::Transform scale; 4782 gfx::Transform scale;
4808 scale.Scale(2.f, 2.f); 4783 scale.Scale(2.f, 2.f);
4809 scaling_layer->SetTransform(scale); 4784 scaling_layer->SetTransform(scale);
4810 4785
4811 content_layer->SetBounds(scaling_layer_size); 4786 content_layer->SetBounds(scaling_layer_size);
4812 content_layer->SetContentBounds(scaling_layer_size); 4787 content_layer->SetContentBounds(scaling_layer_size);
4813 content_layer->SetPosition(gfx::PointF()); 4788 content_layer->SetPosition(gfx::PointF());
4814 content_layer->SetAnchorPoint(gfx::PointF());
4815 content_layer->SetDrawsContent(true); 4789 content_layer->SetDrawsContent(true);
4816 4790
4817 mask_layer->SetBounds(scaling_layer_size); 4791 mask_layer->SetBounds(scaling_layer_size);
4818 mask_layer->SetContentBounds(scaling_layer_size); 4792 mask_layer->SetContentBounds(scaling_layer_size);
4819 mask_layer->SetPosition(gfx::PointF()); 4793 mask_layer->SetPosition(gfx::PointF());
4820 mask_layer->SetAnchorPoint(gfx::PointF());
4821 mask_layer->SetDrawsContent(true); 4794 mask_layer->SetDrawsContent(true);
4822 4795
4823 4796
4824 // Check that the tree scaling is correctly taken into account for the mask, 4797 // Check that the tree scaling is correctly taken into account for the mask,
4825 // that should fully map onto the quad. 4798 // that should fully map onto the quad.
4826 float device_scale_factor = 1.f; 4799 float device_scale_factor = 1.f;
4827 host_impl_->SetViewportSize(root_size); 4800 host_impl_->SetViewportSize(root_size);
4828 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4801 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4829 { 4802 {
4830 LayerTreeHostImpl::FrameData frame; 4803 LayerTreeHostImpl::FrameData frame;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
4920 4893
4921 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 4894 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
4922 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 4895 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
4923 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 4896 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
4924 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 4897 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
4925 4898
4926 gfx::Size root_size(100, 100); 4899 gfx::Size root_size(100, 100);
4927 root->SetBounds(root_size); 4900 root->SetBounds(root_size);
4928 root->SetContentBounds(root_size); 4901 root->SetContentBounds(root_size);
4929 root->SetPosition(gfx::PointF()); 4902 root->SetPosition(gfx::PointF());
4930 root->SetAnchorPoint(gfx::PointF());
4931 4903
4932 gfx::Size layer_size(50, 50); 4904 gfx::Size layer_size(50, 50);
4933 content_layer->SetBounds(layer_size); 4905 content_layer->SetBounds(layer_size);
4934 content_layer->SetContentBounds(layer_size); 4906 content_layer->SetContentBounds(layer_size);
4935 content_layer->SetPosition(gfx::PointF()); 4907 content_layer->SetPosition(gfx::PointF());
4936 content_layer->SetAnchorPoint(gfx::PointF());
4937 content_layer->SetDrawsContent(true); 4908 content_layer->SetDrawsContent(true);
4938 4909
4939 gfx::Size mask_size(100, 100); 4910 gfx::Size mask_size(100, 100);
4940 mask_layer->SetBounds(mask_size); 4911 mask_layer->SetBounds(mask_size);
4941 mask_layer->SetContentBounds(mask_size); 4912 mask_layer->SetContentBounds(mask_size);
4942 mask_layer->SetPosition(gfx::PointF()); 4913 mask_layer->SetPosition(gfx::PointF());
4943 mask_layer->SetAnchorPoint(gfx::PointF());
4944 mask_layer->SetDrawsContent(true); 4914 mask_layer->SetDrawsContent(true);
4945 4915
4946 // Check that the mask fills the surface. 4916 // Check that the mask fills the surface.
4947 float device_scale_factor = 1.f; 4917 float device_scale_factor = 1.f;
4948 host_impl_->SetViewportSize(root_size); 4918 host_impl_->SetViewportSize(root_size);
4949 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4919 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4950 { 4920 {
4951 LayerTreeHostImpl::FrameData frame; 4921 LayerTreeHostImpl::FrameData frame;
4952 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4922 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4953 4923
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5070 5040
5071 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5041 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5072 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 5042 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
5073 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5043 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5074 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 5044 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
5075 5045
5076 gfx::Size root_size(100, 100); 5046 gfx::Size root_size(100, 100);
5077 root->SetBounds(root_size); 5047 root->SetBounds(root_size);
5078 root->SetContentBounds(root_size); 5048 root->SetContentBounds(root_size);
5079 root->SetPosition(gfx::PointF()); 5049 root->SetPosition(gfx::PointF());
5080 root->SetAnchorPoint(gfx::PointF());
5081 5050
5082 gfx::Size layer_size(50, 50); 5051 gfx::Size layer_size(50, 50);
5083 content_layer->SetBounds(layer_size); 5052 content_layer->SetBounds(layer_size);
5084 content_layer->SetContentBounds(layer_size); 5053 content_layer->SetContentBounds(layer_size);
5085 content_layer->SetPosition(gfx::PointF()); 5054 content_layer->SetPosition(gfx::PointF());
5086 content_layer->SetAnchorPoint(gfx::PointF());
5087 content_layer->SetDrawsContent(true); 5055 content_layer->SetDrawsContent(true);
5088 5056
5089 gfx::Size mask_size(100, 100); 5057 gfx::Size mask_size(100, 100);
5090 mask_layer->SetBounds(mask_size); 5058 mask_layer->SetBounds(mask_size);
5091 mask_layer->SetContentBounds(mask_size); 5059 mask_layer->SetContentBounds(mask_size);
5092 mask_layer->SetPosition(gfx::PointF()); 5060 mask_layer->SetPosition(gfx::PointF());
5093 mask_layer->SetAnchorPoint(gfx::PointF());
5094 mask_layer->SetDrawsContent(true); 5061 mask_layer->SetDrawsContent(true);
5095 5062
5096 // Check that the mask fills the surface. 5063 // Check that the mask fills the surface.
5097 float device_scale_factor = 1.f; 5064 float device_scale_factor = 1.f;
5098 host_impl_->SetViewportSize(root_size); 5065 host_impl_->SetViewportSize(root_size);
5099 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5066 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5100 { 5067 {
5101 LayerTreeHostImpl::FrameData frame; 5068 LayerTreeHostImpl::FrameData frame;
5102 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5069 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5103 5070
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5229 5196
5230 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5197 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5231 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); 5198 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5);
5232 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5199 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5233 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 5200 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
5234 5201
5235 gfx::Size root_size(100, 100); 5202 gfx::Size root_size(100, 100);
5236 root->SetBounds(root_size); 5203 root->SetBounds(root_size);
5237 root->SetContentBounds(root_size); 5204 root->SetContentBounds(root_size);
5238 root->SetPosition(gfx::PointF()); 5205 root->SetPosition(gfx::PointF());
5239 root->SetAnchorPoint(gfx::PointF());
5240 5206
5241 gfx::Size layer_size(50, 50); 5207 gfx::Size layer_size(50, 50);
5242 content_layer->SetBounds(layer_size); 5208 content_layer->SetBounds(layer_size);
5243 content_layer->SetContentBounds(layer_size); 5209 content_layer->SetContentBounds(layer_size);
5244 content_layer->SetPosition(gfx::PointF()); 5210 content_layer->SetPosition(gfx::PointF());
5245 content_layer->SetAnchorPoint(gfx::PointF());
5246 content_layer->SetDrawsContent(true); 5211 content_layer->SetDrawsContent(true);
5247 5212
5248 gfx::Size child_size(50, 50); 5213 gfx::Size child_size(50, 50);
5249 content_child_layer->SetBounds(child_size); 5214 content_child_layer->SetBounds(child_size);
5250 content_child_layer->SetContentBounds(child_size); 5215 content_child_layer->SetContentBounds(child_size);
5251 content_child_layer->SetPosition(gfx::Point(50, 0)); 5216 content_child_layer->SetPosition(gfx::Point(50, 0));
5252 content_child_layer->SetAnchorPoint(gfx::PointF());
5253 content_child_layer->SetDrawsContent(true); 5217 content_child_layer->SetDrawsContent(true);
5254 5218
5255 gfx::Size mask_size(50, 50); 5219 gfx::Size mask_size(50, 50);
5256 mask_layer->SetBounds(mask_size); 5220 mask_layer->SetBounds(mask_size);
5257 mask_layer->SetContentBounds(mask_size); 5221 mask_layer->SetContentBounds(mask_size);
5258 mask_layer->SetPosition(gfx::PointF()); 5222 mask_layer->SetPosition(gfx::PointF());
5259 mask_layer->SetAnchorPoint(gfx::PointF());
5260 mask_layer->SetDrawsContent(true); 5223 mask_layer->SetDrawsContent(true);
5261 5224
5262 float device_scale_factor = 1.f; 5225 float device_scale_factor = 1.f;
5263 host_impl_->SetViewportSize(root_size); 5226 host_impl_->SetViewportSize(root_size);
5264 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5227 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5265 { 5228 {
5266 LayerTreeHostImpl::FrameData frame; 5229 LayerTreeHostImpl::FrameData frame;
5267 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5230 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5268 5231
5269 ASSERT_EQ(1u, frame.render_passes.size()); 5232 ASSERT_EQ(1u, frame.render_passes.size());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5355 5318
5356 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5319 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5357 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); 5320 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6);
5358 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5321 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5359 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 5322 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
5360 5323
5361 gfx::Size root_size(100, 100); 5324 gfx::Size root_size(100, 100);
5362 root->SetBounds(root_size); 5325 root->SetBounds(root_size);
5363 root->SetContentBounds(root_size); 5326 root->SetContentBounds(root_size);
5364 root->SetPosition(gfx::PointF()); 5327 root->SetPosition(gfx::PointF());
5365 root->SetAnchorPoint(gfx::PointF());
5366 5328
5367 gfx::Rect clipping_rect(20, 10, 10, 20); 5329 gfx::Rect clipping_rect(20, 10, 10, 20);
5368 clipping_layer->SetBounds(clipping_rect.size()); 5330 clipping_layer->SetBounds(clipping_rect.size());
5369 clipping_layer->SetContentBounds(clipping_rect.size()); 5331 clipping_layer->SetContentBounds(clipping_rect.size());
5370 clipping_layer->SetPosition(clipping_rect.origin()); 5332 clipping_layer->SetPosition(clipping_rect.origin());
5371 clipping_layer->SetAnchorPoint(gfx::PointF());
5372 clipping_layer->SetMasksToBounds(true); 5333 clipping_layer->SetMasksToBounds(true);
5373 5334
5374 gfx::Size layer_size(50, 50); 5335 gfx::Size layer_size(50, 50);
5375 content_layer->SetBounds(layer_size); 5336 content_layer->SetBounds(layer_size);
5376 content_layer->SetContentBounds(layer_size); 5337 content_layer->SetContentBounds(layer_size);
5377 content_layer->SetPosition(gfx::Point() - clipping_rect.OffsetFromOrigin()); 5338 content_layer->SetPosition(gfx::Point() - clipping_rect.OffsetFromOrigin());
5378 content_layer->SetAnchorPoint(gfx::PointF());
5379 content_layer->SetDrawsContent(true); 5339 content_layer->SetDrawsContent(true);
5380 5340
5381 gfx::Size child_size(50, 50); 5341 gfx::Size child_size(50, 50);
5382 content_child_layer->SetBounds(child_size); 5342 content_child_layer->SetBounds(child_size);
5383 content_child_layer->SetContentBounds(child_size); 5343 content_child_layer->SetContentBounds(child_size);
5384 content_child_layer->SetPosition(gfx::Point(50, 0)); 5344 content_child_layer->SetPosition(gfx::Point(50, 0));
5385 content_child_layer->SetAnchorPoint(gfx::PointF());
5386 content_child_layer->SetDrawsContent(true); 5345 content_child_layer->SetDrawsContent(true);
5387 5346
5388 gfx::Size mask_size(100, 100); 5347 gfx::Size mask_size(100, 100);
5389 mask_layer->SetBounds(mask_size); 5348 mask_layer->SetBounds(mask_size);
5390 mask_layer->SetContentBounds(mask_size); 5349 mask_layer->SetContentBounds(mask_size);
5391 mask_layer->SetPosition(gfx::PointF()); 5350 mask_layer->SetPosition(gfx::PointF());
5392 mask_layer->SetAnchorPoint(gfx::PointF());
5393 mask_layer->SetDrawsContent(true); 5351 mask_layer->SetDrawsContent(true);
5394 5352
5395 float device_scale_factor = 1.f; 5353 float device_scale_factor = 1.f;
5396 host_impl_->SetViewportSize(root_size); 5354 host_impl_->SetViewportSize(root_size);
5397 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5355 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5398 { 5356 {
5399 LayerTreeHostImpl::FrameData frame; 5357 LayerTreeHostImpl::FrameData frame;
5400 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5358 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5401 5359
5402 ASSERT_EQ(1u, frame.render_passes.size()); 5360 ASSERT_EQ(1u, frame.render_passes.size());
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
6091 LayerImpl* page_scale_layer = 6049 LayerImpl* page_scale_layer =
6092 host_impl_->active_tree()->LayerById(page_scale_layer_id); 6050 host_impl_->active_tree()->LayerById(page_scale_layer_id);
6093 6051
6094 int occluder_layer_id = 6; 6052 int occluder_layer_id = 6;
6095 scoped_ptr<LayerImpl> occluder_layer = 6053 scoped_ptr<LayerImpl> occluder_layer =
6096 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); 6054 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
6097 occluder_layer->SetDrawsContent(true); 6055 occluder_layer->SetDrawsContent(true);
6098 occluder_layer->SetBounds(content_size); 6056 occluder_layer->SetBounds(content_size);
6099 occluder_layer->SetContentBounds(content_size); 6057 occluder_layer->SetContentBounds(content_size);
6100 occluder_layer->SetPosition(gfx::PointF()); 6058 occluder_layer->SetPosition(gfx::PointF());
6101 occluder_layer->SetAnchorPoint(gfx::PointF());
6102 6059
6103 // The parent of the occluder is *above* the scroller. 6060 // The parent of the occluder is *above* the scroller.
6104 page_scale_layer->AddChild(occluder_layer.Pass()); 6061 page_scale_layer->AddChild(occluder_layer.Pass());
6105 6062
6106 DrawFrame(); 6063 DrawFrame();
6107 6064
6108 EXPECT_EQ(InputHandler::ScrollUnknown, 6065 EXPECT_EQ(InputHandler::ScrollUnknown,
6109 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); 6066 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
6110 } 6067 }
6111 6068
6112 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { 6069 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) {
6113 // If we ray cast a scroller this is on the first layer's ancestor chain, but 6070 // If we ray cast a scroller this is on the first layer's ancestor chain, but
6114 // is not the first scroller we encounter when walking up from the layer, we 6071 // is not the first scroller we encounter when walking up from the layer, we
6115 // should also return ScrollUnknown. 6072 // should also return ScrollUnknown.
6116 gfx::Size content_size(100, 100); 6073 gfx::Size content_size(100, 100);
6117 SetupScrollAndContentsLayers(content_size); 6074 SetupScrollAndContentsLayers(content_size);
6118 6075
6119 int scroll_layer_id = 2; 6076 int scroll_layer_id = 2;
6120 LayerImpl* scroll_layer = 6077 LayerImpl* scroll_layer =
6121 host_impl_->active_tree()->LayerById(scroll_layer_id); 6078 host_impl_->active_tree()->LayerById(scroll_layer_id);
6122 scroll_layer->SetDrawsContent(true); 6079 scroll_layer->SetDrawsContent(true);
6123 6080
6124 int occluder_layer_id = 6; 6081 int occluder_layer_id = 6;
6125 scoped_ptr<LayerImpl> occluder_layer = 6082 scoped_ptr<LayerImpl> occluder_layer =
6126 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); 6083 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
6127 occluder_layer->SetDrawsContent(true); 6084 occluder_layer->SetDrawsContent(true);
6128 occluder_layer->SetBounds(content_size); 6085 occluder_layer->SetBounds(content_size);
6129 occluder_layer->SetContentBounds(content_size); 6086 occluder_layer->SetContentBounds(content_size);
6130 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); 6087 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f));
6131 occluder_layer->SetAnchorPoint(gfx::PointF());
6132 6088
6133 int child_scroll_clip_layer_id = 7; 6089 int child_scroll_clip_layer_id = 7;
6134 scoped_ptr<LayerImpl> child_scroll_clip = 6090 scoped_ptr<LayerImpl> child_scroll_clip =
6135 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); 6091 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id);
6136 6092
6137 int child_scroll_layer_id = 8; 6093 int child_scroll_layer_id = 8;
6138 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( 6094 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer(
6139 child_scroll_layer_id, content_size, child_scroll_clip.get()); 6095 child_scroll_layer_id, content_size, child_scroll_clip.get());
6140 6096
6141 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); 6097 child_scroll->SetPosition(gfx::PointF(10.f, 10.f));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6195 host_impl_->active_tree()->LayerById(scroll_layer_id); 6151 host_impl_->active_tree()->LayerById(scroll_layer_id);
6196 6152
6197 int scroll_child_id = 6; 6153 int scroll_child_id = 6;
6198 scoped_ptr<LayerImpl> scroll_child = 6154 scoped_ptr<LayerImpl> scroll_child =
6199 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); 6155 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id);
6200 scroll_child->SetDrawsContent(true); 6156 scroll_child->SetDrawsContent(true);
6201 scroll_child->SetBounds(content_size); 6157 scroll_child->SetBounds(content_size);
6202 scroll_child->SetContentBounds(content_size); 6158 scroll_child->SetContentBounds(content_size);
6203 // Move the scroll child so it's not hit by our test point. 6159 // Move the scroll child so it's not hit by our test point.
6204 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); 6160 scroll_child->SetPosition(gfx::PointF(10.f, 10.f));
6205 scroll_child->SetAnchorPoint(gfx::PointF());
6206 6161
6207 int invisible_scroll_layer_id = 7; 6162 int invisible_scroll_layer_id = 7;
6208 scoped_ptr<LayerImpl> invisible_scroll = 6163 scoped_ptr<LayerImpl> invisible_scroll =
6209 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); 6164 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root);
6210 invisible_scroll->SetDrawsContent(false); 6165 invisible_scroll->SetDrawsContent(false);
6211 6166
6212 int container_id = 8; 6167 int container_id = 8;
6213 scoped_ptr<LayerImpl> container = 6168 scoped_ptr<LayerImpl> container =
6214 LayerImpl::Create(host_impl_->active_tree(), container_id); 6169 LayerImpl::Create(host_impl_->active_tree(), container_id);
6215 6170
(...skipping 20 matching lines...) Expand all
6236 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); 6191 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
6237 6192
6238 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); 6193 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id());
6239 } 6194 }
6240 6195
6241 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed 6196 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
6242 // to CompositorFrameMetadata after SwapBuffers(); 6197 // to CompositorFrameMetadata after SwapBuffers();
6243 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { 6198 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
6244 scoped_ptr<SolidColorLayerImpl> root = 6199 scoped_ptr<SolidColorLayerImpl> root =
6245 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 6200 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
6246 root->SetAnchorPoint(gfx::PointF());
6247 root->SetPosition(gfx::PointF()); 6201 root->SetPosition(gfx::PointF());
6248 root->SetBounds(gfx::Size(10, 10)); 6202 root->SetBounds(gfx::Size(10, 10));
6249 root->SetContentBounds(gfx::Size(10, 10)); 6203 root->SetContentBounds(gfx::Size(10, 10));
6250 root->SetDrawsContent(true); 6204 root->SetDrawsContent(true);
6251 6205
6252 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); 6206 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>());
6253 6207
6254 FakeOutputSurface* fake_output_surface = 6208 FakeOutputSurface* fake_output_surface =
6255 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 6209 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
6256 6210
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
6453 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 6407 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
6454 inner_clip->SetBounds(inner_viewport); 6408 inner_clip->SetBounds(inner_viewport);
6455 6409
6456 scoped_ptr<LayerImpl> page_scale = 6410 scoped_ptr<LayerImpl> page_scale =
6457 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); 6411 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId);
6458 6412
6459 inner_scroll->SetScrollClipLayer(inner_clip->id()); 6413 inner_scroll->SetScrollClipLayer(inner_clip->id());
6460 inner_scroll->SetBounds(outer_viewport); 6414 inner_scroll->SetBounds(outer_viewport);
6461 inner_scroll->SetContentBounds(outer_viewport); 6415 inner_scroll->SetContentBounds(outer_viewport);
6462 inner_scroll->SetPosition(gfx::PointF()); 6416 inner_scroll->SetPosition(gfx::PointF());
6463 inner_scroll->SetAnchorPoint(gfx::PointF());
6464 6417
6465 scoped_ptr<LayerImpl> outer_clip = 6418 scoped_ptr<LayerImpl> outer_clip =
6466 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); 6419 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId);
6467 outer_clip->SetBounds(outer_viewport); 6420 outer_clip->SetBounds(outer_viewport);
6468 outer_clip->SetIsContainerForFixedPositionLayers(true); 6421 outer_clip->SetIsContainerForFixedPositionLayers(true);
6469 6422
6470 scoped_ptr<LayerImpl> outer_scroll = 6423 scoped_ptr<LayerImpl> outer_scroll =
6471 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); 6424 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId);
6472 outer_scroll->SetScrollClipLayer(outer_clip->id()); 6425 outer_scroll->SetScrollClipLayer(outer_clip->id());
6473 outer_scroll->SetScrollOffset(gfx::Vector2d()); 6426 outer_scroll->SetScrollOffset(gfx::Vector2d());
6474 outer_scroll->SetBounds(content_size); 6427 outer_scroll->SetBounds(content_size);
6475 outer_scroll->SetContentBounds(content_size); 6428 outer_scroll->SetContentBounds(content_size);
6476 outer_scroll->SetPosition(gfx::PointF()); 6429 outer_scroll->SetPosition(gfx::PointF());
6477 outer_scroll->SetAnchorPoint(gfx::PointF());
6478 6430
6479 scoped_ptr<LayerImpl> contents = 6431 scoped_ptr<LayerImpl> contents =
6480 LayerImpl::Create(layer_tree_impl, 8); 6432 LayerImpl::Create(layer_tree_impl, 8);
6481 contents->SetDrawsContent(true); 6433 contents->SetDrawsContent(true);
6482 contents->SetBounds(content_size); 6434 contents->SetBounds(content_size);
6483 contents->SetContentBounds(content_size); 6435 contents->SetContentBounds(content_size);
6484 contents->SetPosition(gfx::PointF()); 6436 contents->SetPosition(gfx::PointF());
6485 contents->SetAnchorPoint(gfx::PointF());
6486 6437
6487 outer_scroll->AddChild(contents.Pass()); 6438 outer_scroll->AddChild(contents.Pass());
6488 outer_clip->AddChild(outer_scroll.Pass()); 6439 outer_clip->AddChild(outer_scroll.Pass());
6489 inner_scroll->AddChild(outer_clip.Pass()); 6440 inner_scroll->AddChild(outer_clip.Pass());
6490 page_scale->AddChild(inner_scroll.Pass()); 6441 page_scale->AddChild(inner_scroll.Pass());
6491 inner_clip->AddChild(page_scale.Pass()); 6442 inner_clip->AddChild(page_scale.Pass());
6492 6443
6493 layer_tree_impl->SetRootLayer(inner_clip.Pass()); 6444 layer_tree_impl->SetRootLayer(inner_clip.Pass());
6494 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, 6445 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId,
6495 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); 6446 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
6616 FakePictureLayerImpl* active_mask_content = 6567 FakePictureLayerImpl* active_mask_content =
6617 static_cast<FakePictureLayerImpl*>( 6568 static_cast<FakePictureLayerImpl*>(
6618 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); 6569 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer());
6619 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); 6570 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority();
6620 6571
6621 ASSERT_TRUE(!r2.IsEmpty()); 6572 ASSERT_TRUE(!r2.IsEmpty());
6622 } 6573 }
6623 6574
6624 } // namespace 6575 } // namespace
6625 } // namespace cc 6576 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698