| 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 178 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
| 179 host_impl_->DidFinishImplFrame(); | 179 host_impl_->DidFinishImplFrame(); |
| 180 return init; | 180 return init; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 183 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
| 184 root->SetPosition(gfx::PointF()); | 184 root->SetPosition(gfx::PointF()); |
| 185 root->SetBounds(gfx::Size(10, 10)); | 185 root->SetBounds(gfx::Size(10, 10)); |
| 186 root->SetDrawsContent(true); | 186 root->SetDrawsContent(true); |
| 187 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); | 187 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); |
| 188 root->SetHasRenderSurface(true); | 188 root->SetForceRenderSurface(true); |
| 189 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 189 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 192 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
| 193 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 193 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
| 194 for (size_t i = 0; i < layer->children().size(); ++i) | 194 for (size_t i = 0; i < layer->children().size(); ++i) |
| 195 ExpectClearedScrollDeltasRecursive(layer->children()[i].get()); | 195 ExpectClearedScrollDeltasRecursive(layer->children()[i].get()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 static ::testing::AssertionResult ScrollInfoContains( | 198 static ::testing::AssertionResult ScrollInfoContains( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 const int kOuterViewportScrollLayerId = 117; | 239 const int kOuterViewportScrollLayerId = 117; |
| 240 const int kContentLayerId = 118; | 240 const int kContentLayerId = 118; |
| 241 const int kInnerViewportScrollLayerId = 2; | 241 const int kInnerViewportScrollLayerId = 2; |
| 242 const int kInnerViewportClipLayerId = 4; | 242 const int kInnerViewportClipLayerId = 4; |
| 243 const int kPageScaleLayerId = 5; | 243 const int kPageScaleLayerId = 5; |
| 244 | 244 |
| 245 scoped_ptr<LayerImpl> root = | 245 scoped_ptr<LayerImpl> root = |
| 246 LayerImpl::Create(layer_tree_impl, 1); | 246 LayerImpl::Create(layer_tree_impl, 1); |
| 247 root->SetBounds(content_size); | 247 root->SetBounds(content_size); |
| 248 root->SetPosition(gfx::PointF()); | 248 root->SetPosition(gfx::PointF()); |
| 249 root->SetHasRenderSurface(true); | 249 root->SetForceRenderSurface(true); |
| 250 | 250 |
| 251 scoped_ptr<LayerImpl> inner_scroll = | 251 scoped_ptr<LayerImpl> inner_scroll = |
| 252 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 252 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
| 253 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 253 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
| 254 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 254 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 255 | 255 |
| 256 scoped_ptr<LayerImpl> inner_clip = | 256 scoped_ptr<LayerImpl> inner_clip = |
| 257 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 257 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
| 258 inner_clip->SetBounds( | 258 inner_clip->SetBounds( |
| 259 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 259 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1092 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
| 1093 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1093 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1094 | 1094 |
| 1095 host_impl_->CreatePendingTree(); | 1095 host_impl_->CreatePendingTree(); |
| 1096 host_impl_->pending_tree()->SetRootLayer( | 1096 host_impl_->pending_tree()->SetRootLayer( |
| 1097 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1097 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
| 1098 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1098 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
| 1099 root->SetBounds(gfx::Size(50, 50)); | 1099 root->SetBounds(gfx::Size(50, 50)); |
| 1100 root->SetHasRenderSurface(true); | 1100 root->SetForceRenderSurface(true); |
| 1101 | 1101 |
| 1102 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1102 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); |
| 1103 LayerImpl* child = root->children()[0].get(); | 1103 LayerImpl* child = root->children()[0].get(); |
| 1104 child->SetBounds(gfx::Size(10, 10)); | 1104 child->SetBounds(gfx::Size(10, 10)); |
| 1105 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1105 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1106 child->SetDrawsContent(true); | 1106 child->SetDrawsContent(true); |
| 1107 AddAnimatedTransformToLayer(child, 10.0, 3, 0); | 1107 AddAnimatedTransformToLayer(child, 10.0, 3, 0); |
| 1108 | 1108 |
| 1109 EXPECT_FALSE(did_request_animate_); | 1109 EXPECT_FALSE(did_request_animate_); |
| 1110 EXPECT_FALSE(did_request_redraw_); | 1110 EXPECT_FALSE(did_request_redraw_); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1138 EXPECT_FALSE(did_request_commit_); | 1138 EXPECT_FALSE(did_request_commit_); |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { | 1141 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
| 1142 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1142 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1143 | 1143 |
| 1144 host_impl_->active_tree()->SetRootLayer( | 1144 host_impl_->active_tree()->SetRootLayer( |
| 1145 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1145 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1146 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1146 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1147 root->SetBounds(gfx::Size(50, 50)); | 1147 root->SetBounds(gfx::Size(50, 50)); |
| 1148 root->SetHasRenderSurface(true); | 1148 root->SetForceRenderSurface(true); |
| 1149 | 1149 |
| 1150 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1150 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1151 LayerImpl* child = root->children()[0].get(); | 1151 LayerImpl* child = root->children()[0].get(); |
| 1152 child->SetBounds(gfx::Size(10, 10)); | 1152 child->SetBounds(gfx::Size(10, 10)); |
| 1153 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1153 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1154 child->SetDrawsContent(true); | 1154 child->SetDrawsContent(true); |
| 1155 | 1155 |
| 1156 // Add a translate from 6,7 to 8,9. | 1156 // Add a translate from 6,7 to 8,9. |
| 1157 TransformOperations start; | 1157 TransformOperations start; |
| 1158 start.AppendTranslate(6.f, 7.f, 0.f); | 1158 start.AppendTranslate(6.f, 7.f, 0.f); |
| (...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2876 append_quads_called_ = false; | 2876 append_quads_called_ = false; |
| 2877 did_draw_called_ = false; | 2877 did_draw_called_ = false; |
| 2878 } | 2878 } |
| 2879 | 2879 |
| 2880 static void IgnoreResult(scoped_ptr<CopyOutputResult> result) {} | 2880 static void IgnoreResult(scoped_ptr<CopyOutputResult> result) {} |
| 2881 | 2881 |
| 2882 void AddCopyRequest() { | 2882 void AddCopyRequest() { |
| 2883 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 2883 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
| 2884 requests.push_back( | 2884 requests.push_back( |
| 2885 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); | 2885 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); |
| 2886 SetHasRenderSurface(true); | 2886 SetForceRenderSurface(true); |
| 2887 PassCopyRequests(&requests); | 2887 PassCopyRequests(&requests); |
| 2888 } | 2888 } |
| 2889 | 2889 |
| 2890 protected: | 2890 protected: |
| 2891 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) | 2891 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
| 2892 : LayerImpl(tree_impl, id), | 2892 : LayerImpl(tree_impl, id), |
| 2893 will_draw_returns_false_(false), | 2893 will_draw_returns_false_(false), |
| 2894 will_draw_called_(false), | 2894 will_draw_called_(false), |
| 2895 append_quads_called_(false), | 2895 append_quads_called_(false), |
| 2896 did_draw_called_(false) { | 2896 did_draw_called_(false) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2908 | 2908 |
| 2909 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 2909 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
| 2910 // The root layer is always drawn, so run this test on a child layer that | 2910 // The root layer is always drawn, so run this test on a child layer that |
| 2911 // will be masked out by the root layer's bounds. | 2911 // will be masked out by the root layer's bounds. |
| 2912 host_impl_->active_tree()->SetRootLayer( | 2912 host_impl_->active_tree()->SetRootLayer( |
| 2913 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2913 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2914 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 2914 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 2915 host_impl_->active_tree()->root_layer()); | 2915 host_impl_->active_tree()->root_layer()); |
| 2916 | 2916 |
| 2917 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2917 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2918 root->SetHasRenderSurface(true); | 2918 root->SetForceRenderSurface(true); |
| 2919 DidDrawCheckLayer* layer = | 2919 DidDrawCheckLayer* layer = |
| 2920 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); | 2920 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 2921 | 2921 |
| 2922 { | 2922 { |
| 2923 LayerTreeHostImpl::FrameData frame; | 2923 LayerTreeHostImpl::FrameData frame; |
| 2924 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 2924 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 2925 host_impl_->DrawLayers(&frame); | 2925 host_impl_->DrawLayers(&frame); |
| 2926 host_impl_->DidDrawAllLayers(frame); | 2926 host_impl_->DidDrawAllLayers(frame); |
| 2927 | 2927 |
| 2928 EXPECT_TRUE(layer->will_draw_called()); | 2928 EXPECT_TRUE(layer->will_draw_called()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2949 } | 2949 } |
| 2950 | 2950 |
| 2951 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 2951 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 2952 // The root layer is always drawn, so run this test on a child layer that | 2952 // The root layer is always drawn, so run this test on a child layer that |
| 2953 // will be masked out by the root layer's bounds. | 2953 // will be masked out by the root layer's bounds. |
| 2954 host_impl_->active_tree()->SetRootLayer( | 2954 host_impl_->active_tree()->SetRootLayer( |
| 2955 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2955 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2956 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 2956 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 2957 host_impl_->active_tree()->root_layer()); | 2957 host_impl_->active_tree()->root_layer()); |
| 2958 root->SetMasksToBounds(true); | 2958 root->SetMasksToBounds(true); |
| 2959 root->SetHasRenderSurface(true); | 2959 root->SetForceRenderSurface(true); |
| 2960 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2960 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2961 DidDrawCheckLayer* layer = | 2961 DidDrawCheckLayer* layer = |
| 2962 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); | 2962 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 2963 // Ensure visible_layer_rect for layer is empty. | 2963 // Ensure visible_layer_rect for layer is empty. |
| 2964 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 2964 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 2965 layer->SetBounds(gfx::Size(10, 10)); | 2965 layer->SetBounds(gfx::Size(10, 10)); |
| 2966 | 2966 |
| 2967 LayerTreeHostImpl::FrameData frame; | 2967 LayerTreeHostImpl::FrameData frame; |
| 2968 | 2968 |
| 2969 EXPECT_FALSE(layer->will_draw_called()); | 2969 EXPECT_FALSE(layer->will_draw_called()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3002 host_impl_->active_tree()->SetRootLayer( | 3002 host_impl_->active_tree()->SetRootLayer( |
| 3003 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3003 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3004 DidDrawCheckLayer* root = | 3004 DidDrawCheckLayer* root = |
| 3005 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3005 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3006 | 3006 |
| 3007 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3007 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3008 DidDrawCheckLayer* occluded_layer = | 3008 DidDrawCheckLayer* occluded_layer = |
| 3009 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); | 3009 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 3010 | 3010 |
| 3011 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3011 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 3012 root->SetHasRenderSurface(true); | 3012 root->SetForceRenderSurface(true); |
| 3013 DidDrawCheckLayer* top_layer = | 3013 DidDrawCheckLayer* top_layer = |
| 3014 static_cast<DidDrawCheckLayer*>(root->children()[1].get()); | 3014 static_cast<DidDrawCheckLayer*>(root->children()[1].get()); |
| 3015 // This layer covers the occluded_layer above. Make this layer large so it can | 3015 // This layer covers the occluded_layer above. Make this layer large so it can |
| 3016 // occlude. | 3016 // occlude. |
| 3017 top_layer->SetBounds(big_size); | 3017 top_layer->SetBounds(big_size); |
| 3018 top_layer->SetContentsOpaque(true); | 3018 top_layer->SetContentsOpaque(true); |
| 3019 | 3019 |
| 3020 LayerTreeHostImpl::FrameData frame; | 3020 LayerTreeHostImpl::FrameData frame; |
| 3021 | 3021 |
| 3022 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3022 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3034 EXPECT_TRUE(top_layer->did_draw_called()); | 3034 EXPECT_TRUE(top_layer->did_draw_called()); |
| 3035 } | 3035 } |
| 3036 | 3036 |
| 3037 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3037 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 3038 host_impl_->active_tree()->SetRootLayer( | 3038 host_impl_->active_tree()->SetRootLayer( |
| 3039 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3039 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3040 DidDrawCheckLayer* root = | 3040 DidDrawCheckLayer* root = |
| 3041 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3041 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3042 | 3042 |
| 3043 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3043 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3044 root->SetHasRenderSurface(true); | 3044 root->SetForceRenderSurface(true); |
| 3045 DidDrawCheckLayer* layer1 = | 3045 DidDrawCheckLayer* layer1 = |
| 3046 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); | 3046 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 3047 | 3047 |
| 3048 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3048 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 3049 DidDrawCheckLayer* layer2 = | 3049 DidDrawCheckLayer* layer2 = |
| 3050 static_cast<DidDrawCheckLayer*>(layer1->children()[0].get()); | 3050 static_cast<DidDrawCheckLayer*>(layer1->children()[0].get()); |
| 3051 | 3051 |
| 3052 layer1->SetHasRenderSurface(true); | 3052 layer1->SetForceRenderSurface(true); |
| 3053 layer1->SetShouldFlattenTransform(true); | 3053 layer1->SetShouldFlattenTransform(true); |
| 3054 | 3054 |
| 3055 EXPECT_FALSE(root->did_draw_called()); | 3055 EXPECT_FALSE(root->did_draw_called()); |
| 3056 EXPECT_FALSE(layer1->did_draw_called()); | 3056 EXPECT_FALSE(layer1->did_draw_called()); |
| 3057 EXPECT_FALSE(layer2->did_draw_called()); | 3057 EXPECT_FALSE(layer2->did_draw_called()); |
| 3058 | 3058 |
| 3059 LayerTreeHostImpl::FrameData frame; | 3059 LayerTreeHostImpl::FrameData frame; |
| 3060 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3060 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 3061 host_impl_->active_tree()->root_layer()); | 3061 host_impl_->active_tree()->root_layer()); |
| 3062 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3062 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3199 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); | 3199 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
| 3200 cases.back().high_res_required = true; | 3200 cases.back().high_res_required = true; |
| 3201 cases.back().layer_between.has_missing_tile = true; | 3201 cases.back().layer_between.has_missing_tile = true; |
| 3202 cases.back().layer_before.has_missing_tile = true; | 3202 cases.back().layer_before.has_missing_tile = true; |
| 3203 cases.back().layer_before.is_animating = true; | 3203 cases.back().layer_before.is_animating = true; |
| 3204 | 3204 |
| 3205 host_impl_->active_tree()->SetRootLayer( | 3205 host_impl_->active_tree()->SetRootLayer( |
| 3206 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3206 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3207 DidDrawCheckLayer* root = | 3207 DidDrawCheckLayer* root = |
| 3208 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3208 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3209 root->SetHasRenderSurface(true); | 3209 root->SetForceRenderSurface(true); |
| 3210 | 3210 |
| 3211 LayerTreeHostImpl::FrameData frame; | 3211 LayerTreeHostImpl::FrameData frame; |
| 3212 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3212 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 3213 host_impl_->DrawLayers(&frame); | 3213 host_impl_->DrawLayers(&frame); |
| 3214 host_impl_->DidDrawAllLayers(frame); | 3214 host_impl_->DidDrawAllLayers(frame); |
| 3215 host_impl_->SwapBuffers(frame); | 3215 host_impl_->SwapBuffers(frame); |
| 3216 | 3216 |
| 3217 for (size_t i = 0; i < cases.size(); ++i) { | 3217 for (size_t i = 0; i < cases.size(); ++i) { |
| 3218 const auto& testcase = cases[i]; | 3218 const auto& testcase = cases[i]; |
| 3219 std::vector<LayerImpl*> to_remove; | 3219 std::vector<LayerImpl*> to_remove; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3292 cases.back().layer_between.has_incomplete_tile = true; | 3292 cases.back().layer_between.has_incomplete_tile = true; |
| 3293 // 3. High res required with missing tile. | 3293 // 3. High res required with missing tile. |
| 3294 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); | 3294 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
| 3295 cases.back().high_res_required = true; | 3295 cases.back().high_res_required = true; |
| 3296 cases.back().layer_between.has_missing_tile = true; | 3296 cases.back().layer_between.has_missing_tile = true; |
| 3297 | 3297 |
| 3298 host_impl_->active_tree()->SetRootLayer( | 3298 host_impl_->active_tree()->SetRootLayer( |
| 3299 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3299 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3300 DidDrawCheckLayer* root = | 3300 DidDrawCheckLayer* root = |
| 3301 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3301 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3302 root->SetHasRenderSurface(true); | 3302 root->SetForceRenderSurface(true); |
| 3303 | 3303 |
| 3304 LayerTreeHostImpl::FrameData frame; | 3304 LayerTreeHostImpl::FrameData frame; |
| 3305 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3305 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 3306 host_impl_->DrawLayers(&frame); | 3306 host_impl_->DrawLayers(&frame); |
| 3307 host_impl_->DidDrawAllLayers(frame); | 3307 host_impl_->DidDrawAllLayers(frame); |
| 3308 host_impl_->SwapBuffers(frame); | 3308 host_impl_->SwapBuffers(frame); |
| 3309 | 3309 |
| 3310 for (size_t i = 0; i < cases.size(); ++i) { | 3310 for (size_t i = 0; i < cases.size(); ++i) { |
| 3311 const auto& testcase = cases[i]; | 3311 const auto& testcase = cases[i]; |
| 3312 std::vector<LayerImpl*> to_remove; | 3312 std::vector<LayerImpl*> to_remove; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3353 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); | 3353 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); |
| 3354 host_impl_->DrawLayers(&frame); | 3354 host_impl_->DrawLayers(&frame); |
| 3355 host_impl_->DidDrawAllLayers(frame); | 3355 host_impl_->DidDrawAllLayers(frame); |
| 3356 host_impl_->SwapBuffers(frame); | 3356 host_impl_->SwapBuffers(frame); |
| 3357 } | 3357 } |
| 3358 } | 3358 } |
| 3359 | 3359 |
| 3360 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3360 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 3361 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3361 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3362 root->SetScrollClipLayer(Layer::INVALID_ID); | 3362 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 3363 root->SetHasRenderSurface(true); | 3363 root->SetForceRenderSurface(true); |
| 3364 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 3364 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 3365 DrawFrame(); | 3365 DrawFrame(); |
| 3366 | 3366 |
| 3367 // Scroll event is ignored because layer is not scrollable. | 3367 // Scroll event is ignored because layer is not scrollable. |
| 3368 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 3368 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
| 3369 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3369 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
| 3370 EXPECT_FALSE(did_request_redraw_); | 3370 EXPECT_FALSE(did_request_redraw_); |
| 3371 EXPECT_FALSE(did_request_commit_); | 3371 EXPECT_FALSE(did_request_commit_); |
| 3372 } | 3372 } |
| 3373 | 3373 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 LayerImpl::Create(host_impl_->active_tree(), 4); | 3436 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 3437 scoped_ptr<LayerImpl> outer_clip = | 3437 scoped_ptr<LayerImpl> outer_clip = |
| 3438 LayerImpl::Create(host_impl_->active_tree(), 5); | 3438 LayerImpl::Create(host_impl_->active_tree(), 5); |
| 3439 | 3439 |
| 3440 root_clip->SetBounds(inner_viewport_size); | 3440 root_clip->SetBounds(inner_viewport_size); |
| 3441 root->SetScrollClipLayer(root_clip->id()); | 3441 root->SetScrollClipLayer(root_clip->id()); |
| 3442 root->SetBounds(outer_viewport_size); | 3442 root->SetBounds(outer_viewport_size); |
| 3443 root->SetPosition(gfx::PointF()); | 3443 root->SetPosition(gfx::PointF()); |
| 3444 root->SetDrawsContent(false); | 3444 root->SetDrawsContent(false); |
| 3445 root->SetIsContainerForFixedPositionLayers(true); | 3445 root->SetIsContainerForFixedPositionLayers(true); |
| 3446 root_clip->SetHasRenderSurface(true); | 3446 root_clip->SetForceRenderSurface(true); |
| 3447 outer_clip->SetBounds(outer_viewport_size); | 3447 outer_clip->SetBounds(outer_viewport_size); |
| 3448 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 3448 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 3449 outer_scroll->SetBounds(scroll_layer_size); | 3449 outer_scroll->SetBounds(scroll_layer_size); |
| 3450 outer_scroll->SetPosition(gfx::PointF()); | 3450 outer_scroll->SetPosition(gfx::PointF()); |
| 3451 outer_scroll->SetDrawsContent(false); | 3451 outer_scroll->SetDrawsContent(false); |
| 3452 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 3452 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
| 3453 | 3453 |
| 3454 int inner_viewport_scroll_layer_id = root->id(); | 3454 int inner_viewport_scroll_layer_id = root->id(); |
| 3455 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 3455 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
| 3456 int page_scale_layer_id = page_scale->id(); | 3456 int page_scale_layer_id = page_scale->id(); |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4120 scroll_clip_layer->SetBounds(surface_size); | 4120 scroll_clip_layer->SetBounds(surface_size); |
| 4121 | 4121 |
| 4122 scoped_ptr<LayerImpl> scroll_layer = | 4122 scoped_ptr<LayerImpl> scroll_layer = |
| 4123 LayerImpl::Create(host_impl_->active_tree(), 2); | 4123 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 4124 scroll_layer->SetScrollClipLayer(3); | 4124 scroll_layer->SetScrollClipLayer(3); |
| 4125 scroll_layer->SetBounds(contents_size); | 4125 scroll_layer->SetBounds(contents_size); |
| 4126 scroll_layer->SetPosition(gfx::PointF()); | 4126 scroll_layer->SetPosition(gfx::PointF()); |
| 4127 scroll_layer->AddChild(std::move(content_layer)); | 4127 scroll_layer->AddChild(std::move(content_layer)); |
| 4128 scroll_clip_layer->AddChild(std::move(scroll_layer)); | 4128 scroll_clip_layer->AddChild(std::move(scroll_layer)); |
| 4129 | 4129 |
| 4130 scroll_clip_layer->SetHasRenderSurface(true); | 4130 scroll_clip_layer->SetForceRenderSurface(true); |
| 4131 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); | 4131 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); |
| 4132 host_impl_->SetViewportSize(surface_size); | 4132 host_impl_->SetViewportSize(surface_size); |
| 4133 DrawFrame(); | 4133 DrawFrame(); |
| 4134 | 4134 |
| 4135 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4135 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 4136 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4136 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
| 4137 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4137 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 4138 host_impl_->ScrollEnd(); | 4138 host_impl_->ScrollEnd(); |
| 4139 EXPECT_TRUE(did_request_redraw_); | 4139 EXPECT_TRUE(did_request_redraw_); |
| 4140 EXPECT_TRUE(did_request_commit_); | 4140 EXPECT_TRUE(did_request_commit_); |
| 4141 } | 4141 } |
| 4142 | 4142 |
| 4143 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4143 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 4144 gfx::Size surface_size(10, 10); | 4144 gfx::Size surface_size(10, 10); |
| 4145 gfx::Size contents_size(20, 20); | 4145 gfx::Size contents_size(20, 20); |
| 4146 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4146 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4147 root->SetBounds(surface_size); | 4147 root->SetBounds(surface_size); |
| 4148 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 4148 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 4149 root->SetHasRenderSurface(true); | 4149 root->SetForceRenderSurface(true); |
| 4150 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4150 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 4151 host_impl_->SetViewportSize(surface_size); | 4151 host_impl_->SetViewportSize(surface_size); |
| 4152 DrawFrame(); | 4152 DrawFrame(); |
| 4153 | 4153 |
| 4154 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4154 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 4155 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4155 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
| 4156 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4156 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 4157 host_impl_->ScrollEnd(); | 4157 host_impl_->ScrollEnd(); |
| 4158 EXPECT_TRUE(did_request_redraw_); | 4158 EXPECT_TRUE(did_request_redraw_); |
| 4159 EXPECT_TRUE(did_request_commit_); | 4159 EXPECT_TRUE(did_request_commit_); |
| 4160 } | 4160 } |
| 4161 | 4161 |
| 4162 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4162 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 4163 gfx::Size surface_size(10, 10); | 4163 gfx::Size surface_size(10, 10); |
| 4164 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4164 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4165 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 4165 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 4166 root->SetHasRenderSurface(true); | 4166 root->SetForceRenderSurface(true); |
| 4167 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4167 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 4168 host_impl_->SetViewportSize(surface_size); | 4168 host_impl_->SetViewportSize(surface_size); |
| 4169 DrawFrame(); | 4169 DrawFrame(); |
| 4170 | 4170 |
| 4171 // Scroll event is ignored because the input coordinate is outside the layer | 4171 // Scroll event is ignored because the input coordinate is outside the layer |
| 4172 // boundaries. | 4172 // boundaries. |
| 4173 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 4173 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
| 4174 host_impl_->ScrollBegin(gfx::Point(15, 5), InputHandler::WHEEL)); | 4174 host_impl_->ScrollBegin(gfx::Point(15, 5), InputHandler::WHEEL)); |
| 4175 EXPECT_FALSE(did_request_redraw_); | 4175 EXPECT_FALSE(did_request_redraw_); |
| 4176 EXPECT_FALSE(did_request_commit_); | 4176 EXPECT_FALSE(did_request_commit_); |
| 4177 } | 4177 } |
| 4178 | 4178 |
| 4179 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4179 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 4180 gfx::Size surface_size(10, 10); | 4180 gfx::Size surface_size(10, 10); |
| 4181 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4181 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4182 root->SetHasRenderSurface(true); | 4182 root->SetForceRenderSurface(true); |
| 4183 scoped_ptr<LayerImpl> child = | 4183 scoped_ptr<LayerImpl> child = |
| 4184 CreateScrollableLayer(2, surface_size, root.get()); | 4184 CreateScrollableLayer(2, surface_size, root.get()); |
| 4185 host_impl_->SetViewportSize(surface_size); | 4185 host_impl_->SetViewportSize(surface_size); |
| 4186 | 4186 |
| 4187 gfx::Transform matrix; | 4187 gfx::Transform matrix; |
| 4188 matrix.RotateAboutXAxis(180.0); | 4188 matrix.RotateAboutXAxis(180.0); |
| 4189 child->SetTransform(matrix); | 4189 child->SetTransform(matrix); |
| 4190 child->SetDoubleSided(false); | 4190 child->SetDoubleSided(false); |
| 4191 | 4191 |
| 4192 root->AddChild(std::move(child)); | 4192 root->AddChild(std::move(child)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4209 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 4209 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
| 4210 content_layer->SetShouldScrollOnMainThread(true); | 4210 content_layer->SetShouldScrollOnMainThread(true); |
| 4211 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 4211 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
| 4212 | 4212 |
| 4213 // Note: we can use the same clip layer for both since both calls to | 4213 // Note: we can use the same clip layer for both since both calls to |
| 4214 // CreateScrollableLayer() use the same surface size. | 4214 // CreateScrollableLayer() use the same surface size. |
| 4215 scoped_ptr<LayerImpl> scroll_layer = | 4215 scoped_ptr<LayerImpl> scroll_layer = |
| 4216 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4216 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| 4217 scroll_layer->AddChild(std::move(content_layer)); | 4217 scroll_layer->AddChild(std::move(content_layer)); |
| 4218 clip_layer->AddChild(std::move(scroll_layer)); | 4218 clip_layer->AddChild(std::move(scroll_layer)); |
| 4219 clip_layer->SetHasRenderSurface(true); | 4219 clip_layer->SetForceRenderSurface(true); |
| 4220 | 4220 |
| 4221 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); | 4221 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); |
| 4222 host_impl_->SetViewportSize(surface_size); | 4222 host_impl_->SetViewportSize(surface_size); |
| 4223 DrawFrame(); | 4223 DrawFrame(); |
| 4224 | 4224 |
| 4225 // Scrolling fails because the content layer is asking to be scrolled on the | 4225 // Scrolling fails because the content layer is asking to be scrolled on the |
| 4226 // main thread. | 4226 // main thread. |
| 4227 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 4227 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, |
| 4228 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4228 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
| 4229 } | 4229 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4411 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 4411 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
| 4412 } | 4412 } |
| 4413 | 4413 |
| 4414 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 4414 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
| 4415 // Scroll a child layer beyond its maximum scroll range and make sure the | 4415 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 4416 // parent layer isn't scrolled. | 4416 // parent layer isn't scrolled. |
| 4417 gfx::Size surface_size(10, 10); | 4417 gfx::Size surface_size(10, 10); |
| 4418 gfx::Size content_size(20, 20); | 4418 gfx::Size content_size(20, 20); |
| 4419 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4419 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4420 root->SetBounds(surface_size); | 4420 root->SetBounds(surface_size); |
| 4421 root->SetHasRenderSurface(true); | 4421 root->SetForceRenderSurface(true); |
| 4422 scoped_ptr<LayerImpl> grand_child = | 4422 scoped_ptr<LayerImpl> grand_child = |
| 4423 CreateScrollableLayer(3, content_size, root.get()); | 4423 CreateScrollableLayer(3, content_size, root.get()); |
| 4424 | 4424 |
| 4425 scoped_ptr<LayerImpl> child = | 4425 scoped_ptr<LayerImpl> child = |
| 4426 CreateScrollableLayer(2, content_size, root.get()); | 4426 CreateScrollableLayer(2, content_size, root.get()); |
| 4427 LayerImpl* grand_child_layer = grand_child.get(); | 4427 LayerImpl* grand_child_layer = grand_child.get(); |
| 4428 child->AddChild(std::move(grand_child)); | 4428 child->AddChild(std::move(grand_child)); |
| 4429 | 4429 |
| 4430 LayerImpl* child_layer = child.get(); | 4430 LayerImpl* child_layer = child.get(); |
| 4431 root->AddChild(std::move(child)); | 4431 root->AddChild(std::move(child)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4457 ExpectNone(*scroll_info.get(), child->id()); | 4457 ExpectNone(*scroll_info.get(), child->id()); |
| 4458 } | 4458 } |
| 4459 } | 4459 } |
| 4460 | 4460 |
| 4461 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 4461 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 4462 // Scroll a child layer beyond its maximum scroll range and make sure the | 4462 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 4463 // the scroll doesn't bubble up to the parent layer. | 4463 // the scroll doesn't bubble up to the parent layer. |
| 4464 gfx::Size surface_size(20, 20); | 4464 gfx::Size surface_size(20, 20); |
| 4465 gfx::Size viewport_size(10, 10); | 4465 gfx::Size viewport_size(10, 10); |
| 4466 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4466 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4467 root->SetHasRenderSurface(true); | 4467 root->SetForceRenderSurface(true); |
| 4468 scoped_ptr<LayerImpl> root_scrolling = | 4468 scoped_ptr<LayerImpl> root_scrolling = |
| 4469 CreateScrollableLayer(2, surface_size, root.get()); | 4469 CreateScrollableLayer(2, surface_size, root.get()); |
| 4470 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 4470 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 4471 | 4471 |
| 4472 scoped_ptr<LayerImpl> grand_child = | 4472 scoped_ptr<LayerImpl> grand_child = |
| 4473 CreateScrollableLayer(4, surface_size, root.get()); | 4473 CreateScrollableLayer(4, surface_size, root.get()); |
| 4474 | 4474 |
| 4475 scoped_ptr<LayerImpl> child = | 4475 scoped_ptr<LayerImpl> child = |
| 4476 CreateScrollableLayer(3, surface_size, root.get()); | 4476 CreateScrollableLayer(3, surface_size, root.get()); |
| 4477 LayerImpl* grand_child_layer = grand_child.get(); | 4477 LayerImpl* grand_child_layer = grand_child.get(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4573 gfx::Vector2d(0, 4))); | 4573 gfx::Vector2d(0, 4))); |
| 4574 } | 4574 } |
| 4575 } | 4575 } |
| 4576 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 4576 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
| 4577 // When we try to scroll a non-scrollable child layer, the scroll delta | 4577 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 4578 // should be applied to one of its ancestors if possible. | 4578 // should be applied to one of its ancestors if possible. |
| 4579 gfx::Size surface_size(10, 10); | 4579 gfx::Size surface_size(10, 10); |
| 4580 gfx::Size content_size(20, 20); | 4580 gfx::Size content_size(20, 20); |
| 4581 scoped_ptr<LayerImpl> root_clip = | 4581 scoped_ptr<LayerImpl> root_clip = |
| 4582 LayerImpl::Create(host_impl_->active_tree(), 3); | 4582 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4583 root_clip->SetHasRenderSurface(true); | 4583 root_clip->SetForceRenderSurface(true); |
| 4584 scoped_ptr<LayerImpl> root = | 4584 scoped_ptr<LayerImpl> root = |
| 4585 CreateScrollableLayer(1, content_size, root_clip.get()); | 4585 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4586 // Make 'root' the clip layer for child: since they have the same sizes the | 4586 // Make 'root' the clip layer for child: since they have the same sizes the |
| 4587 // child will have zero max_scroll_offset and scrolls will bubble. | 4587 // child will have zero max_scroll_offset and scrolls will bubble. |
| 4588 scoped_ptr<LayerImpl> child = | 4588 scoped_ptr<LayerImpl> child = |
| 4589 CreateScrollableLayer(2, content_size, root.get()); | 4589 CreateScrollableLayer(2, content_size, root.get()); |
| 4590 child->SetIsContainerForFixedPositionLayers(true); | 4590 child->SetIsContainerForFixedPositionLayers(true); |
| 4591 root->SetBounds(content_size); | 4591 root->SetBounds(content_size); |
| 4592 | 4592 |
| 4593 int root_scroll_id = root->id(); | 4593 int root_scroll_id = root->id(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4617 } | 4617 } |
| 4618 } | 4618 } |
| 4619 | 4619 |
| 4620 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 4620 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
| 4621 gfx::Size surface_size(10, 10); | 4621 gfx::Size surface_size(10, 10); |
| 4622 scoped_ptr<LayerImpl> root_clip = | 4622 scoped_ptr<LayerImpl> root_clip = |
| 4623 LayerImpl::Create(host_impl_->active_tree(), 1); | 4623 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4624 scoped_ptr<LayerImpl> root_scroll = | 4624 scoped_ptr<LayerImpl> root_scroll = |
| 4625 CreateScrollableLayer(2, surface_size, root_clip.get()); | 4625 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 4626 root_scroll->SetIsContainerForFixedPositionLayers(true); | 4626 root_scroll->SetIsContainerForFixedPositionLayers(true); |
| 4627 root_clip->SetHasRenderSurface(true); | 4627 root_clip->SetForceRenderSurface(true); |
| 4628 root_clip->AddChild(std::move(root_scroll)); | 4628 root_clip->AddChild(std::move(root_scroll)); |
| 4629 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 4629 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
| 4630 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 4630 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
| 4631 Layer::INVALID_ID); | 4631 Layer::INVALID_ID); |
| 4632 host_impl_->active_tree()->DidBecomeActive(); | 4632 host_impl_->active_tree()->DidBecomeActive(); |
| 4633 host_impl_->SetViewportSize(surface_size); | 4633 host_impl_->SetViewportSize(surface_size); |
| 4634 | 4634 |
| 4635 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 4635 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 4636 // synchronization. | 4636 // synchronization. |
| 4637 DrawFrame(); | 4637 DrawFrame(); |
| 4638 host_impl_->active_tree()->DetachLayerTree(); | 4638 host_impl_->active_tree()->DetachLayerTree(); |
| 4639 scoped_ptr<LayerImpl> root_clip2 = | 4639 scoped_ptr<LayerImpl> root_clip2 = |
| 4640 LayerImpl::Create(host_impl_->active_tree(), 3); | 4640 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4641 scoped_ptr<LayerImpl> root_scroll2 = | 4641 scoped_ptr<LayerImpl> root_scroll2 = |
| 4642 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 4642 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
| 4643 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 4643 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
| 4644 root_clip2->AddChild(std::move(root_scroll2)); | 4644 root_clip2->AddChild(std::move(root_scroll2)); |
| 4645 root_clip2->SetHasRenderSurface(true); | 4645 root_clip2->SetForceRenderSurface(true); |
| 4646 host_impl_->active_tree()->SetRootLayer(std::move(root_clip2)); | 4646 host_impl_->active_tree()->SetRootLayer(std::move(root_clip2)); |
| 4647 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 4647 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, |
| 4648 Layer::INVALID_ID); | 4648 Layer::INVALID_ID); |
| 4649 host_impl_->active_tree()->DidBecomeActive(); | 4649 host_impl_->active_tree()->DidBecomeActive(); |
| 4650 | 4650 |
| 4651 // Scrolling should still work even though we did not draw yet. | 4651 // Scrolling should still work even though we did not draw yet. |
| 4652 RebuildPropertyTrees(); | 4652 RebuildPropertyTrees(); |
| 4653 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4653 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 4654 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4654 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
| 4655 } | 4655 } |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5206 } | 5206 } |
| 5207 | 5207 |
| 5208 | 5208 |
| 5209 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 5209 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
| 5210 // Scroll child layers beyond their maximum scroll range and make sure root | 5210 // Scroll child layers beyond their maximum scroll range and make sure root |
| 5211 // overscroll does not accumulate. | 5211 // overscroll does not accumulate. |
| 5212 InputHandlerScrollResult scroll_result; | 5212 InputHandlerScrollResult scroll_result; |
| 5213 gfx::Size surface_size(10, 10); | 5213 gfx::Size surface_size(10, 10); |
| 5214 scoped_ptr<LayerImpl> root_clip = | 5214 scoped_ptr<LayerImpl> root_clip = |
| 5215 LayerImpl::Create(host_impl_->active_tree(), 4); | 5215 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5216 root_clip->SetHasRenderSurface(true); | 5216 root_clip->SetForceRenderSurface(true); |
| 5217 | 5217 |
| 5218 scoped_ptr<LayerImpl> root = | 5218 scoped_ptr<LayerImpl> root = |
| 5219 CreateScrollableLayer(1, surface_size, root_clip.get()); | 5219 CreateScrollableLayer(1, surface_size, root_clip.get()); |
| 5220 | 5220 |
| 5221 scoped_ptr<LayerImpl> grand_child = | 5221 scoped_ptr<LayerImpl> grand_child = |
| 5222 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5222 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 5223 | 5223 |
| 5224 scoped_ptr<LayerImpl> child = | 5224 scoped_ptr<LayerImpl> child = |
| 5225 CreateScrollableLayer(2, surface_size, root_clip.get()); | 5225 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 5226 LayerImpl* grand_child_layer = grand_child.get(); | 5226 LayerImpl* grand_child_layer = grand_child.get(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5463 gfx::Rect quad_visible_rect_; | 5463 gfx::Rect quad_visible_rect_; |
| 5464 ResourceId resource_id_; | 5464 ResourceId resource_id_; |
| 5465 }; | 5465 }; |
| 5466 | 5466 |
| 5467 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 5467 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
| 5468 { | 5468 { |
| 5469 scoped_ptr<LayerImpl> root = | 5469 scoped_ptr<LayerImpl> root = |
| 5470 LayerImpl::Create(host_impl_->active_tree(), 1); | 5470 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5471 root->SetBounds(gfx::Size(10, 10)); | 5471 root->SetBounds(gfx::Size(10, 10)); |
| 5472 root->SetDrawsContent(false); | 5472 root->SetDrawsContent(false); |
| 5473 root->SetHasRenderSurface(true); | 5473 root->SetForceRenderSurface(true); |
| 5474 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 5474 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 5475 } | 5475 } |
| 5476 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 5476 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 5477 | 5477 |
| 5478 root->AddChild( | 5478 root->AddChild( |
| 5479 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 5479 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 5480 2, | 5480 2, |
| 5481 host_impl_->resource_provider())); | 5481 host_impl_->resource_provider())); |
| 5482 BlendStateCheckLayer* layer1 = | 5482 BlendStateCheckLayer* layer1 = |
| 5483 static_cast<BlendStateCheckLayer*>(root->children()[0].get()); | 5483 static_cast<BlendStateCheckLayer*>(root->children()[0].get()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5573 EXPECT_TRUE(layer2->quads_appended()); | 5573 EXPECT_TRUE(layer2->quads_appended()); |
| 5574 host_impl_->DidDrawAllLayers(frame); | 5574 host_impl_->DidDrawAllLayers(frame); |
| 5575 | 5575 |
| 5576 // Parent layer with translucent opacity and opaque content. Since it has a | 5576 // Parent layer with translucent opacity and opaque content. Since it has a |
| 5577 // drawing child, it's drawn to a render surface which carries the opacity, | 5577 // drawing child, it's drawn to a render surface which carries the opacity, |
| 5578 // so it's itself drawn without blending. | 5578 // so it's itself drawn without blending. |
| 5579 // Child layer with opaque content, drawn without blending (parent surface | 5579 // Child layer with opaque content, drawn without blending (parent surface |
| 5580 // carries the inherited opacity). | 5580 // carries the inherited opacity). |
| 5581 layer1->SetContentsOpaque(true); | 5581 layer1->SetContentsOpaque(true); |
| 5582 layer1->SetOpacity(0.5f); | 5582 layer1->SetOpacity(0.5f); |
| 5583 layer1->SetHasRenderSurface(true); | 5583 layer1->SetForceRenderSurface(true); |
| 5584 layer1->SetExpectation(false, true); | 5584 layer1->SetExpectation(false, true); |
| 5585 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 5585 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 5586 layer2->SetExpectation(false, false); | 5586 layer2->SetExpectation(false, false); |
| 5587 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 5587 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 5588 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 5588 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 5589 host_impl_->active_tree()->root_layer()); | 5589 host_impl_->active_tree()->root_layer()); |
| 5590 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5590 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 5591 host_impl_->DrawLayers(&frame); | 5591 host_impl_->DrawLayers(&frame); |
| 5592 EXPECT_TRUE(layer1->quads_appended()); | 5592 EXPECT_TRUE(layer1->quads_appended()); |
| 5593 EXPECT_TRUE(layer2->quads_appended()); | 5593 EXPECT_TRUE(layer2->quads_appended()); |
| 5594 host_impl_->DidDrawAllLayers(frame); | 5594 host_impl_->DidDrawAllLayers(frame); |
| 5595 layer1->SetHasRenderSurface(false); | 5595 layer1->SetForceRenderSurface(false); |
| 5596 | 5596 |
| 5597 // Draw again, but with child non-opaque, to make sure | 5597 // Draw again, but with child non-opaque, to make sure |
| 5598 // layer1 not culled. | 5598 // layer1 not culled. |
| 5599 layer1->SetContentsOpaque(true); | 5599 layer1->SetContentsOpaque(true); |
| 5600 layer1->SetOpacity(1.f); | 5600 layer1->SetOpacity(1.f); |
| 5601 layer1->SetExpectation(false, false); | 5601 layer1->SetExpectation(false, false); |
| 5602 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 5602 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 5603 layer2->SetContentsOpaque(true); | 5603 layer2->SetContentsOpaque(true); |
| 5604 layer2->SetOpacity(0.5f); | 5604 layer2->SetOpacity(0.5f); |
| 5605 layer2->SetExpectation(true, false); | 5605 layer2->SetExpectation(true, false); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5703 return FakeOutputSurface::CreateSoftware( | 5703 return FakeOutputSurface::CreateSoftware( |
| 5704 make_scoped_ptr(new SoftwareOutputDevice())); | 5704 make_scoped_ptr(new SoftwareOutputDevice())); |
| 5705 } | 5705 } |
| 5706 return FakeOutputSurface::Create3d(); | 5706 return FakeOutputSurface::Create3d(); |
| 5707 } | 5707 } |
| 5708 | 5708 |
| 5709 void SetupActiveTreeLayers() { | 5709 void SetupActiveTreeLayers() { |
| 5710 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 5710 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 5711 host_impl_->active_tree()->SetRootLayer( | 5711 host_impl_->active_tree()->SetRootLayer( |
| 5712 LayerImpl::Create(host_impl_->active_tree(), 1)); | 5712 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 5713 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); | 5713 host_impl_->active_tree()->root_layer()->SetForceRenderSurface(true); |
| 5714 host_impl_->active_tree()->root_layer()->AddChild( | 5714 host_impl_->active_tree()->root_layer()->AddChild( |
| 5715 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 5715 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 5716 2, | 5716 2, |
| 5717 host_impl_->resource_provider())); | 5717 host_impl_->resource_provider())); |
| 5718 child_ = static_cast<BlendStateCheckLayer*>( | 5718 child_ = static_cast<BlendStateCheckLayer*>( |
| 5719 host_impl_->active_tree()->root_layer()->children()[0].get()); | 5719 host_impl_->active_tree()->root_layer()->children()[0].get()); |
| 5720 child_->SetExpectation(false, false); | 5720 child_->SetExpectation(false, false); |
| 5721 child_->SetContentsOpaque(true); | 5721 child_->SetContentsOpaque(true); |
| 5722 } | 5722 } |
| 5723 | 5723 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5959 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 5959 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
| 5960 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 5960 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 5961 scoped_ptr<OutputSurface> output_surface( | 5961 scoped_ptr<OutputSurface> output_surface( |
| 5962 FakeOutputSurface::Create3d(provider)); | 5962 FakeOutputSurface::Create3d(provider)); |
| 5963 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 5963 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
| 5964 | 5964 |
| 5965 scoped_ptr<LayerImpl> root = | 5965 scoped_ptr<LayerImpl> root = |
| 5966 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 5966 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 5967 root->SetBounds(gfx::Size(10, 10)); | 5967 root->SetBounds(gfx::Size(10, 10)); |
| 5968 root->SetDrawsContent(true); | 5968 root->SetDrawsContent(true); |
| 5969 root->SetHasRenderSurface(true); | 5969 root->SetForceRenderSurface(true); |
| 5970 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 5970 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 5971 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 5971 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 5972 provider->TestContext3d()->clear_reshape_called(); | 5972 provider->TestContext3d()->clear_reshape_called(); |
| 5973 | 5973 |
| 5974 LayerTreeHostImpl::FrameData frame; | 5974 LayerTreeHostImpl::FrameData frame; |
| 5975 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 5975 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 5976 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | 5976 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); |
| 5977 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5977 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 5978 host_impl_->DrawLayers(&frame); | 5978 host_impl_->DrawLayers(&frame); |
| 5979 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 5979 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6025 settings, this, &task_runner_provider_, &stats_instrumentation_, | 6025 settings, this, &task_runner_provider_, &stats_instrumentation_, |
| 6026 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); | 6026 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); |
| 6027 layer_tree_host_impl->SetVisible(true); | 6027 layer_tree_host_impl->SetVisible(true); |
| 6028 layer_tree_host_impl->InitializeRenderer(output_surface.get()); | 6028 layer_tree_host_impl->InitializeRenderer(output_surface.get()); |
| 6029 layer_tree_host_impl->WillBeginImplFrame( | 6029 layer_tree_host_impl->WillBeginImplFrame( |
| 6030 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 6030 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
| 6031 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 6031 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 6032 | 6032 |
| 6033 scoped_ptr<LayerImpl> root = | 6033 scoped_ptr<LayerImpl> root = |
| 6034 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 6034 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 6035 root->SetHasRenderSurface(true); | 6035 root->SetForceRenderSurface(true); |
| 6036 scoped_ptr<LayerImpl> child = | 6036 scoped_ptr<LayerImpl> child = |
| 6037 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 6037 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 6038 child->SetPosition(gfx::PointF(12.f, 13.f)); | 6038 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 6039 child->SetBounds(gfx::Size(14, 15)); | 6039 child->SetBounds(gfx::Size(14, 15)); |
| 6040 child->SetDrawsContent(true); | 6040 child->SetDrawsContent(true); |
| 6041 root->SetBounds(gfx::Size(500, 500)); | 6041 root->SetBounds(gfx::Size(500, 500)); |
| 6042 root->SetDrawsContent(true); | 6042 root->SetDrawsContent(true); |
| 6043 root->AddChild(std::move(child)); | 6043 root->AddChild(std::move(child)); |
| 6044 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); | 6044 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); |
| 6045 | 6045 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6091 | 6091 |
| 6092 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 6092 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
| 6093 scoped_ptr<LayerImpl> root = | 6093 scoped_ptr<LayerImpl> root = |
| 6094 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6094 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 6095 scoped_ptr<LayerImpl> child = | 6095 scoped_ptr<LayerImpl> child = |
| 6096 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 6096 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 6097 child->SetBounds(gfx::Size(10, 10)); | 6097 child->SetBounds(gfx::Size(10, 10)); |
| 6098 child->SetDrawsContent(true); | 6098 child->SetDrawsContent(true); |
| 6099 root->SetBounds(gfx::Size(10, 10)); | 6099 root->SetBounds(gfx::Size(10, 10)); |
| 6100 root->SetDrawsContent(true); | 6100 root->SetDrawsContent(true); |
| 6101 root->SetHasRenderSurface(true); | 6101 root->SetForceRenderSurface(true); |
| 6102 root->AddChild(std::move(child)); | 6102 root->AddChild(std::move(child)); |
| 6103 | 6103 |
| 6104 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6104 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 6105 | 6105 |
| 6106 LayerTreeHostImpl::FrameData frame; | 6106 LayerTreeHostImpl::FrameData frame; |
| 6107 | 6107 |
| 6108 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6108 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 6109 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 6109 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
| 6110 EXPECT_EQ(1u, frame.render_passes.size()); | 6110 EXPECT_EQ(1u, frame.render_passes.size()); |
| 6111 host_impl_->DidDrawAllLayers(frame); | 6111 host_impl_->DidDrawAllLayers(frame); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6340 LayerImpl::Create(my_host_impl->active_tree(), 1); | 6340 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 6341 scoped_ptr<LayerImpl> child = | 6341 scoped_ptr<LayerImpl> child = |
| 6342 LayerImpl::Create(my_host_impl->active_tree(), 2); | 6342 LayerImpl::Create(my_host_impl->active_tree(), 2); |
| 6343 scoped_ptr<LayerImpl> grand_child = | 6343 scoped_ptr<LayerImpl> grand_child = |
| 6344 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 6344 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
| 6345 | 6345 |
| 6346 gfx::Rect root_rect(0, 0, 100, 100); | 6346 gfx::Rect root_rect(0, 0, 100, 100); |
| 6347 gfx::Rect child_rect(10, 10, 50, 50); | 6347 gfx::Rect child_rect(10, 10, 50, 50); |
| 6348 gfx::Rect grand_child_rect(5, 5, 150, 150); | 6348 gfx::Rect grand_child_rect(5, 5, 150, 150); |
| 6349 | 6349 |
| 6350 root->SetHasRenderSurface(true); | 6350 root->SetForceRenderSurface(true); |
| 6351 root->SetPosition(gfx::PointF(root_rect.origin())); | 6351 root->SetPosition(gfx::PointF(root_rect.origin())); |
| 6352 root->SetBounds(root_rect.size()); | 6352 root->SetBounds(root_rect.size()); |
| 6353 root->draw_properties().visible_layer_rect = root_rect; | 6353 root->draw_properties().visible_layer_rect = root_rect; |
| 6354 root->SetDrawsContent(false); | 6354 root->SetDrawsContent(false); |
| 6355 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | |
| 6356 | 6355 |
| 6357 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 6356 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
| 6358 child->SetOpacity(0.5f); | 6357 child->SetOpacity(0.5f); |
| 6359 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 6358 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
| 6360 child->draw_properties().visible_layer_rect = child_rect; | 6359 child->draw_properties().visible_layer_rect = child_rect; |
| 6361 child->SetDrawsContent(false); | 6360 child->SetDrawsContent(false); |
| 6362 child->SetHasRenderSurface(true); | 6361 child->SetForceRenderSurface(true); |
| 6363 | 6362 |
| 6364 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); | 6363 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); |
| 6365 grand_child->SetBounds(grand_child_rect.size()); | 6364 grand_child->SetBounds(grand_child_rect.size()); |
| 6366 grand_child->draw_properties().visible_layer_rect = grand_child_rect; | 6365 grand_child->draw_properties().visible_layer_rect = grand_child_rect; |
| 6367 grand_child->SetDrawsContent(true); | 6366 grand_child->SetDrawsContent(true); |
| 6368 | 6367 |
| 6369 child->AddChild(std::move(grand_child)); | 6368 child->AddChild(std::move(grand_child)); |
| 6370 root->AddChild(std::move(child)); | 6369 root->AddChild(std::move(child)); |
| 6371 | 6370 |
| 6372 my_host_impl->active_tree()->SetRootLayer(std::move(root)); | 6371 my_host_impl->active_tree()->SetRootLayer(std::move(root)); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6438 scoped_ptr<TestWebGraphicsContext3D> context = | 6437 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6439 TestWebGraphicsContext3D::Create(); | 6438 TestWebGraphicsContext3D::Create(); |
| 6440 TestWebGraphicsContext3D* context3d = context.get(); | 6439 TestWebGraphicsContext3D* context3d = context.get(); |
| 6441 scoped_ptr<OutputSurface> output_surface( | 6440 scoped_ptr<OutputSurface> output_surface( |
| 6442 FakeOutputSurface::Create3d(std::move(context))); | 6441 FakeOutputSurface::Create3d(std::move(context))); |
| 6443 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6442 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
| 6444 | 6443 |
| 6445 scoped_ptr<LayerImpl> root_layer = | 6444 scoped_ptr<LayerImpl> root_layer = |
| 6446 LayerImpl::Create(host_impl_->active_tree(), 1); | 6445 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6447 root_layer->SetBounds(gfx::Size(10, 10)); | 6446 root_layer->SetBounds(gfx::Size(10, 10)); |
| 6448 root_layer->SetHasRenderSurface(true); | 6447 root_layer->SetForceRenderSurface(true); |
| 6449 | 6448 |
| 6450 scoped_refptr<VideoFrame> softwareFrame = | 6449 scoped_refptr<VideoFrame> softwareFrame = |
| 6451 media::VideoFrame::CreateColorFrame( | 6450 media::VideoFrame::CreateColorFrame( |
| 6452 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 6451 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 6453 FakeVideoFrameProvider provider; | 6452 FakeVideoFrameProvider provider; |
| 6454 provider.set_frame(softwareFrame); | 6453 provider.set_frame(softwareFrame); |
| 6455 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 6454 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 6456 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 6455 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 6457 video_layer->SetBounds(gfx::Size(10, 10)); | 6456 video_layer->SetBounds(gfx::Size(10, 10)); |
| 6458 video_layer->SetDrawsContent(true); | 6457 video_layer->SetDrawsContent(true); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6571 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 6570 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
| 6572 } | 6571 } |
| 6573 }; | 6572 }; |
| 6574 | 6573 |
| 6575 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 6574 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 6576 scoped_ptr<SolidColorLayerImpl> root = | 6575 scoped_ptr<SolidColorLayerImpl> root = |
| 6577 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6576 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 6578 root->SetPosition(gfx::PointF()); | 6577 root->SetPosition(gfx::PointF()); |
| 6579 root->SetBounds(gfx::Size(10, 10)); | 6578 root->SetBounds(gfx::Size(10, 10)); |
| 6580 root->SetDrawsContent(true); | 6579 root->SetDrawsContent(true); |
| 6581 root->SetHasRenderSurface(true); | 6580 root->SetForceRenderSurface(true); |
| 6582 | 6581 |
| 6583 // Child layer is in the bottom right corner. | 6582 // Child layer is in the bottom right corner. |
| 6584 scoped_ptr<SolidColorLayerImpl> child = | 6583 scoped_ptr<SolidColorLayerImpl> child = |
| 6585 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 6584 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| 6586 child->SetPosition(gfx::PointF(9.f, 9.f)); | 6585 child->SetPosition(gfx::PointF(9.f, 9.f)); |
| 6587 child->SetBounds(gfx::Size(1, 1)); | 6586 child->SetBounds(gfx::Size(1, 1)); |
| 6588 child->SetDrawsContent(true); | 6587 child->SetDrawsContent(true); |
| 6589 root->AddChild(std::move(child)); | 6588 root->AddChild(std::move(child)); |
| 6590 | 6589 |
| 6591 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6590 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6628 host_impl_->SetViewportSize(device_viewport_size); | 6627 host_impl_->SetViewportSize(device_viewport_size); |
| 6629 | 6628 |
| 6630 host_impl_->CreatePendingTree(); | 6629 host_impl_->CreatePendingTree(); |
| 6631 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); | 6630 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 6632 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 6631 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
| 6633 16.f); | 6632 16.f); |
| 6634 | 6633 |
| 6635 scoped_ptr<LayerImpl> scoped_root = | 6634 scoped_ptr<LayerImpl> scoped_root = |
| 6636 LayerImpl::Create(host_impl_->pending_tree(), 1); | 6635 LayerImpl::Create(host_impl_->pending_tree(), 1); |
| 6637 LayerImpl* root = scoped_root.get(); | 6636 LayerImpl* root = scoped_root.get(); |
| 6638 root->SetHasRenderSurface(true); | 6637 root->SetForceRenderSurface(true); |
| 6639 | 6638 |
| 6640 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); | 6639 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); |
| 6641 | 6640 |
| 6642 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 6641 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
| 6643 LayerImpl::Create(host_impl_->pending_tree(), 2); | 6642 LayerImpl::Create(host_impl_->pending_tree(), 2); |
| 6644 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 6643 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
| 6645 root->AddChild(std::move(scoped_scrolling_layer)); | 6644 root->AddChild(std::move(scoped_scrolling_layer)); |
| 6646 | 6645 |
| 6647 gfx::Size content_layer_bounds(100000, 100); | 6646 gfx::Size content_layer_bounds(100000, 100); |
| 6648 scoped_refptr<FakeDisplayListRasterSource> raster_source( | 6647 scoped_refptr<FakeDisplayListRasterSource> raster_source( |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7006 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 7005 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 7007 } | 7006 } |
| 7008 | 7007 |
| 7009 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 7008 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
| 7010 // When flinging via touch, only the child should scroll (we should not | 7009 // When flinging via touch, only the child should scroll (we should not |
| 7011 // bubble). | 7010 // bubble). |
| 7012 gfx::Size surface_size(10, 10); | 7011 gfx::Size surface_size(10, 10); |
| 7013 gfx::Size content_size(20, 20); | 7012 gfx::Size content_size(20, 20); |
| 7014 scoped_ptr<LayerImpl> root_clip = | 7013 scoped_ptr<LayerImpl> root_clip = |
| 7015 LayerImpl::Create(host_impl_->active_tree(), 3); | 7014 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 7016 root_clip->SetHasRenderSurface(true); | 7015 root_clip->SetForceRenderSurface(true); |
| 7017 | 7016 |
| 7018 scoped_ptr<LayerImpl> root = | 7017 scoped_ptr<LayerImpl> root = |
| 7019 CreateScrollableLayer(1, content_size, root_clip.get()); | 7018 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 7020 root->SetIsContainerForFixedPositionLayers(true); | 7019 root->SetIsContainerForFixedPositionLayers(true); |
| 7021 scoped_ptr<LayerImpl> child = | 7020 scoped_ptr<LayerImpl> child = |
| 7022 CreateScrollableLayer(2, content_size, root_clip.get()); | 7021 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 7023 | 7022 |
| 7024 root->AddChild(std::move(child)); | 7023 root->AddChild(std::move(child)); |
| 7025 int root_id = root->id(); | 7024 int root_id = root->id(); |
| 7026 root_clip->AddChild(std::move(root)); | 7025 root_clip->AddChild(std::move(root)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7050 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7049 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 7051 ExpectNone(*scroll_info.get(), root_id); | 7050 ExpectNone(*scroll_info.get(), root_id); |
| 7052 } | 7051 } |
| 7053 } | 7052 } |
| 7054 | 7053 |
| 7055 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { | 7054 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
| 7056 // Scroll a child layer beyond its maximum scroll range and make sure the | 7055 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 7057 // the scroll doesn't bubble up to the parent layer. | 7056 // the scroll doesn't bubble up to the parent layer. |
| 7058 gfx::Size surface_size(10, 10); | 7057 gfx::Size surface_size(10, 10); |
| 7059 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 7058 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 7060 root->SetHasRenderSurface(true); | 7059 root->SetForceRenderSurface(true); |
| 7061 scoped_ptr<LayerImpl> root_scrolling = | 7060 scoped_ptr<LayerImpl> root_scrolling = |
| 7062 CreateScrollableLayer(2, surface_size, root.get()); | 7061 CreateScrollableLayer(2, surface_size, root.get()); |
| 7063 | 7062 |
| 7064 scoped_ptr<LayerImpl> grand_child = | 7063 scoped_ptr<LayerImpl> grand_child = |
| 7065 CreateScrollableLayer(4, surface_size, root.get()); | 7064 CreateScrollableLayer(4, surface_size, root.get()); |
| 7066 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 7065 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
| 7067 | 7066 |
| 7068 scoped_ptr<LayerImpl> child = | 7067 scoped_ptr<LayerImpl> child = |
| 7069 CreateScrollableLayer(3, surface_size, root.get()); | 7068 CreateScrollableLayer(3, surface_size, root.get()); |
| 7070 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); | 7069 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7121 host_impl_->ScrollEnd(); | 7120 host_impl_->ScrollEnd(); |
| 7122 } | 7121 } |
| 7123 } | 7122 } |
| 7124 | 7123 |
| 7125 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { | 7124 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { |
| 7126 // When flinging via wheel, we shouldn't bubble. | 7125 // When flinging via wheel, we shouldn't bubble. |
| 7127 gfx::Size surface_size(10, 10); | 7126 gfx::Size surface_size(10, 10); |
| 7128 gfx::Size content_size(20, 20); | 7127 gfx::Size content_size(20, 20); |
| 7129 scoped_ptr<LayerImpl> root_clip = | 7128 scoped_ptr<LayerImpl> root_clip = |
| 7130 LayerImpl::Create(host_impl_->active_tree(), 3); | 7129 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 7131 root_clip->SetHasRenderSurface(true); | 7130 root_clip->SetForceRenderSurface(true); |
| 7132 scoped_ptr<LayerImpl> root_scroll = | 7131 scoped_ptr<LayerImpl> root_scroll = |
| 7133 CreateScrollableLayer(1, content_size, root_clip.get()); | 7132 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 7134 int root_scroll_id = root_scroll->id(); | 7133 int root_scroll_id = root_scroll->id(); |
| 7135 scoped_ptr<LayerImpl> child = | 7134 scoped_ptr<LayerImpl> child = |
| 7136 CreateScrollableLayer(2, content_size, root_clip.get()); | 7135 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 7137 | 7136 |
| 7138 root_scroll->AddChild(std::move(child)); | 7137 root_scroll->AddChild(std::move(child)); |
| 7139 root_clip->AddChild(std::move(root_scroll)); | 7138 root_clip->AddChild(std::move(root_scroll)); |
| 7140 | 7139 |
| 7141 host_impl_->SetViewportSize(surface_size); | 7140 host_impl_->SetViewportSize(surface_size); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7353 } | 7352 } |
| 7354 | 7353 |
| 7355 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 7354 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 7356 // to CompositorFrameMetadata after SwapBuffers(); | 7355 // to CompositorFrameMetadata after SwapBuffers(); |
| 7357 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 7356 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 7358 scoped_ptr<SolidColorLayerImpl> root = | 7357 scoped_ptr<SolidColorLayerImpl> root = |
| 7359 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7358 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7360 root->SetPosition(gfx::PointF()); | 7359 root->SetPosition(gfx::PointF()); |
| 7361 root->SetBounds(gfx::Size(10, 10)); | 7360 root->SetBounds(gfx::Size(10, 10)); |
| 7362 root->SetDrawsContent(true); | 7361 root->SetDrawsContent(true); |
| 7363 root->SetHasRenderSurface(true); | 7362 root->SetForceRenderSurface(true); |
| 7364 | 7363 |
| 7365 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7364 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 7366 | 7365 |
| 7367 FakeOutputSurface* fake_output_surface = | 7366 FakeOutputSurface* fake_output_surface = |
| 7368 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7367 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 7369 | 7368 |
| 7370 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 7369 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
| 7371 fake_output_surface->last_sent_frame().metadata.latency_info; | 7370 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 7372 EXPECT_TRUE(metadata_latency_before.empty()); | 7371 EXPECT_TRUE(metadata_latency_before.empty()); |
| 7373 | 7372 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 7393 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 7392 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 7394 } | 7393 } |
| 7395 | 7394 |
| 7396 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 7395 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 7397 int root_layer_id = 1; | 7396 int root_layer_id = 1; |
| 7398 scoped_ptr<SolidColorLayerImpl> root = | 7397 scoped_ptr<SolidColorLayerImpl> root = |
| 7399 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 7398 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 7400 root->SetPosition(gfx::PointF()); | 7399 root->SetPosition(gfx::PointF()); |
| 7401 root->SetBounds(gfx::Size(10, 10)); | 7400 root->SetBounds(gfx::Size(10, 10)); |
| 7402 root->SetDrawsContent(true); | 7401 root->SetDrawsContent(true); |
| 7403 root->SetHasRenderSurface(true); | 7402 root->SetForceRenderSurface(true); |
| 7404 | 7403 |
| 7405 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7404 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 7406 | 7405 |
| 7407 // Ensure the default frame selection bounds are empty. | 7406 // Ensure the default frame selection bounds are empty. |
| 7408 FakeOutputSurface* fake_output_surface = | 7407 FakeOutputSurface* fake_output_surface = |
| 7409 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7408 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 7410 const ViewportSelection& selection_before = | 7409 const ViewportSelection& selection_before = |
| 7411 fake_output_surface->last_sent_frame().metadata.selection; | 7410 fake_output_surface->last_sent_frame().metadata.selection; |
| 7412 EXPECT_EQ(ViewportSelectionBound(), selection_before.start); | 7411 EXPECT_EQ(ViewportSelectionBound(), selection_before.start); |
| 7413 EXPECT_EQ(ViewportSelectionBound(), selection_before.end); | 7412 EXPECT_EQ(ViewportSelectionBound(), selection_before.end); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8028 contents->SetDrawsContent(true); | 8027 contents->SetDrawsContent(true); |
| 8029 contents->SetBounds(content_size); | 8028 contents->SetBounds(content_size); |
| 8030 contents->SetPosition(gfx::PointF()); | 8029 contents->SetPosition(gfx::PointF()); |
| 8031 | 8030 |
| 8032 outer_scroll->AddChild(std::move(contents)); | 8031 outer_scroll->AddChild(std::move(contents)); |
| 8033 outer_clip->AddChild(std::move(outer_scroll)); | 8032 outer_clip->AddChild(std::move(outer_scroll)); |
| 8034 inner_scroll->AddChild(std::move(outer_clip)); | 8033 inner_scroll->AddChild(std::move(outer_clip)); |
| 8035 page_scale->AddChild(std::move(inner_scroll)); | 8034 page_scale->AddChild(std::move(inner_scroll)); |
| 8036 inner_clip->AddChild(std::move(page_scale)); | 8035 inner_clip->AddChild(std::move(page_scale)); |
| 8037 | 8036 |
| 8038 inner_clip->SetHasRenderSurface(true); | 8037 inner_clip->SetForceRenderSurface(true); |
| 8039 layer_tree_impl->SetRootLayer(std::move(inner_clip)); | 8038 layer_tree_impl->SetRootLayer(std::move(inner_clip)); |
| 8040 layer_tree_impl->SetViewportLayersFromIds( | 8039 layer_tree_impl->SetViewportLayersFromIds( |
| 8041 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 8040 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
| 8042 kOuterViewportScrollLayerId); | 8041 kOuterViewportScrollLayerId); |
| 8043 | 8042 |
| 8044 host_impl_->active_tree()->DidBecomeActive(); | 8043 host_impl_->active_tree()->DidBecomeActive(); |
| 8045 } | 8044 } |
| 8046 }; | 8045 }; |
| 8047 | 8046 |
| 8048 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 8047 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8495 | 8494 |
| 8496 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { | 8495 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { |
| 8497 const gfx::Size layer_size(100, 100); | 8496 const gfx::Size layer_size(100, 100); |
| 8498 SetupScrollAndContentsLayers(layer_size); | 8497 SetupScrollAndContentsLayers(layer_size); |
| 8499 LayerImpl* content_layer = host_impl_->active_tree() | 8498 LayerImpl* content_layer = host_impl_->active_tree() |
| 8500 ->OuterViewportScrollLayer() | 8499 ->OuterViewportScrollLayer() |
| 8501 ->children()[0] | 8500 ->children()[0] |
| 8502 .get(); | 8501 .get(); |
| 8503 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 8502 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 8504 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 8503 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
| 8505 test_layer->SetHasRenderSurface(true); | 8504 test_layer->SetForceRenderSurface(true); |
| 8506 test_layer->SetDrawsContent(true); | 8505 test_layer->SetDrawsContent(true); |
| 8507 test_layer->SetBounds(layer_size); | 8506 test_layer->SetBounds(layer_size); |
| 8508 gfx::Transform perspective_transform; | 8507 gfx::Transform perspective_transform; |
| 8509 perspective_transform.ApplyPerspectiveDepth(2); | 8508 perspective_transform.ApplyPerspectiveDepth(2); |
| 8510 test_layer->SetTransform(perspective_transform); | 8509 test_layer->SetTransform(perspective_transform); |
| 8511 | 8510 |
| 8512 RebuildPropertyTrees(); | 8511 RebuildPropertyTrees(); |
| 8513 bool update_lcd_text = false; | 8512 bool update_lcd_text = false; |
| 8514 | 8513 |
| 8515 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 8514 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9152 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { | 9151 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { |
| 9153 // Checks that the sublayer scale of a transform node in the subtree of the | 9152 // Checks that the sublayer scale of a transform node in the subtree of the |
| 9154 // page scale layer is updated without a property tree rebuild. | 9153 // page scale layer is updated without a property tree rebuild. |
| 9155 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 9154 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 9156 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); | 9155 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); |
| 9157 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 9156 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
| 9158 page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 9157 page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 9159 | 9158 |
| 9160 LayerImpl* in_subtree_of_page_scale_layer = | 9159 LayerImpl* in_subtree_of_page_scale_layer = |
| 9161 host_impl_->active_tree()->LayerById(100); | 9160 host_impl_->active_tree()->LayerById(100); |
| 9162 in_subtree_of_page_scale_layer->SetHasRenderSurface(true); | 9161 in_subtree_of_page_scale_layer->SetForceRenderSurface(true); |
| 9163 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9162 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9164 DrawFrame(); | 9163 DrawFrame(); |
| 9165 TransformNode* node = | 9164 TransformNode* node = |
| 9166 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9165 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 9167 in_subtree_of_page_scale_layer->transform_tree_index()); | 9166 in_subtree_of_page_scale_layer->transform_tree_index()); |
| 9168 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 9167 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
| 9169 | 9168 |
| 9170 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 9169 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 9171 DrawFrame(); | 9170 DrawFrame(); |
| 9172 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); | 9171 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); |
| 9173 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9172 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 9174 in_subtree_of_page_scale_layer->transform_tree_index()); | 9173 in_subtree_of_page_scale_layer->transform_tree_index()); |
| 9175 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); | 9174 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9176 } | 9175 } |
| 9177 | 9176 |
| 9178 } // namespace | 9177 } // namespace |
| 9179 } // namespace cc | 9178 } // namespace cc |
| OLD | NEW |