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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
9 #include "cc/content_layer_client.h" | 9 #include "cc/content_layer_client.h" |
10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
11 #include "cc/layer_tree_host_impl.h" | 11 #include "cc/layer_tree_host_impl.h" |
12 #include "cc/layer_tree_impl.h" | 12 #include "cc/layer_tree_impl.h" |
13 #include "cc/output_surface.h" | 13 #include "cc/output_surface.h" |
14 #include "cc/single_thread_proxy.h" | 14 #include "cc/single_thread_proxy.h" |
| 15 #include "cc/test/fake_content_layer.h" |
15 #include "cc/test/fake_content_layer_client.h" | 16 #include "cc/test/fake_content_layer_client.h" |
16 #include "cc/test/fake_layer_tree_host_client.h" | 17 #include "cc/test/fake_layer_tree_host_client.h" |
17 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
18 #include "cc/test/fake_proxy.h" | 19 #include "cc/test/fake_proxy.h" |
| 20 #include "cc/test/fake_scrollbar_layer.h" |
19 #include "cc/test/geometry_test_utils.h" | 21 #include "cc/test/geometry_test_utils.h" |
20 #include "cc/test/layer_tree_test_common.h" | 22 #include "cc/test/layer_tree_test_common.h" |
21 #include "cc/resource_update_queue.h" | 23 #include "cc/resource_update_queue.h" |
22 #include "cc/test/occlusion_tracker_test_common.h" | 24 #include "cc/test/occlusion_tracker_test_common.h" |
23 #include "cc/timing_function.h" | 25 #include "cc/timing_function.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
26 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" |
27 #include "third_party/khronos/GLES2/gl2ext.h" | 29 #include "third_party/khronos/GLES2/gl2ext.h" |
28 #include "ui/gfx/point_conversions.h" | 30 #include "ui/gfx/point_conversions.h" |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 | 990 |
989 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, runMultiThread
) | 991 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, runMultiThread
) |
990 { | 992 { |
991 runTest(true); | 993 runTest(true); |
992 } | 994 } |
993 | 995 |
994 // Verify atomicity of commits and reuse of textures. | 996 // Verify atomicity of commits and reuse of textures. |
995 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { | 997 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { |
996 public: | 998 public: |
997 LayerTreeHostTestAtomicCommit() | 999 LayerTreeHostTestAtomicCommit() |
998 : m_layer(ContentLayerWithUpdateTracking::create(&m_client)) | |
999 { | 1000 { |
1000 // Make sure partial texture updates are turned off. | 1001 // Make sure partial texture updates are turned off. |
1001 m_settings.maxPartialTextureUpdates = 0; | 1002 m_settings.maxPartialTextureUpdates = 0; |
| 1003 // Linear fade animator prevents scrollbars from drawing immediately. |
| 1004 m_settings.useLinearFadeScrollbarAnimator = false; |
| 1005 } |
| 1006 |
| 1007 virtual void setupTree() OVERRIDE |
| 1008 { |
| 1009 m_layer = FakeContentLayer::Create(&m_client); |
| 1010 m_layer->setBounds(gfx::Size(10, 20)); |
| 1011 |
| 1012 m_scrollbar = FakeScrollbarLayer::Create(true, m_layer->id()); |
| 1013 m_scrollbar->setPosition(gfx::Point(0, 10)); |
| 1014 m_scrollbar->setBounds(gfx::Size(10, 10)); |
| 1015 |
| 1016 m_layer->addChild(m_scrollbar); |
| 1017 |
| 1018 m_layerTreeHost->setRootLayer(m_layer); |
| 1019 LayerTreeHostTest::setupTree(); |
1002 } | 1020 } |
1003 | 1021 |
1004 virtual void beginTest() OVERRIDE | 1022 virtual void beginTest() OVERRIDE |
1005 { | 1023 { |
1006 m_layerTreeHost->setRootLayer(m_layer); | |
1007 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | |
1008 | |
1009 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | |
1010 ResourceUpdateQueue queue; | |
1011 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
1012 postSetNeedsCommitToMainThread(); | 1024 postSetNeedsCommitToMainThread(); |
1013 } | 1025 } |
1014 | 1026 |
1015 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1027 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1016 { | 1028 { |
| 1029 ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); |
| 1030 |
1017 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); | 1031 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); |
1018 | 1032 |
1019 switch (impl->activeTree()->source_frame_number()) { | 1033 switch (impl->activeTree()->source_frame_number()) { |
1020 case 0: | 1034 case 0: |
1021 // Number of textures should be one. | 1035 // Number of textures should be one for each layer |
1022 ASSERT_EQ(1, context->NumTextures()); | 1036 ASSERT_EQ(2, context->NumTextures()); |
1023 // Number of textures used for commit should be one. | 1037 // Number of textures used for commit should be one for each layer. |
1024 EXPECT_EQ(1, context->NumUsedTextures()); | 1038 EXPECT_EQ(2, context->NumUsedTextures()); |
1025 // Verify that used texture is correct. | 1039 // Verify that used texture is correct. |
1026 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1040 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
| 1041 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
1027 | 1042 |
1028 context->ResetUsedTextures(); | 1043 context->ResetUsedTextures(); |
1029 postSetNeedsCommitToMainThread(); | 1044 postSetNeedsCommitToMainThread(); |
1030 break; | 1045 break; |
1031 case 1: | 1046 case 1: |
1032 // Number of textures should be two as the first texture | 1047 // Number of textures should be doubled as the first textures |
1033 // is used by impl thread and cannot by used for update. | 1048 // are used by impl thread and cannot by used for update. |
1034 ASSERT_EQ(2, context->NumTextures()); | 1049 ASSERT_EQ(4, context->NumTextures()); |
1035 // Number of textures used for commit should still be one. | 1050 // Number of textures used for commit should still be one for each l
ayer. |
1036 EXPECT_EQ(1, context->NumUsedTextures()); | 1051 EXPECT_EQ(2, context->NumUsedTextures()); |
1037 // First texture should not have been used. | 1052 // First textures should not have been used. |
1038 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); | 1053 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); |
1039 // New texture should have been used. | 1054 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
1040 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1055 // New textures should have been used. |
| 1056 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
| 1057 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
1041 | 1058 |
1042 context->ResetUsedTextures(); | 1059 context->ResetUsedTextures(); |
1043 postSetNeedsCommitToMainThread(); | 1060 postSetNeedsCommitToMainThread(); |
1044 break; | 1061 break; |
1045 case 2: | 1062 case 2: |
1046 endTest(); | 1063 endTest(); |
1047 break; | 1064 break; |
1048 default: | 1065 default: |
1049 NOTREACHED(); | 1066 NOTREACHED(); |
1050 break; | 1067 break; |
1051 } | 1068 } |
1052 } | 1069 } |
1053 | 1070 |
1054 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1071 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1055 { | 1072 { |
1056 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); | 1073 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); |
1057 | 1074 |
1058 // Number of textures used for draw should always be one. | 1075 // Number of textures used for draw should always be one for each layer. |
1059 EXPECT_EQ(1, context->NumUsedTextures()); | 1076 EXPECT_EQ(2, context->NumUsedTextures()); |
1060 context->ResetUsedTextures(); | 1077 context->ResetUsedTextures(); |
1061 } | 1078 } |
1062 | 1079 |
1063 virtual void layout() OVERRIDE | 1080 virtual void layout() OVERRIDE |
1064 { | 1081 { |
1065 m_layer->setNeedsDisplay(); | 1082 m_layer->setNeedsDisplay(); |
| 1083 m_scrollbar->setNeedsDisplay(); |
1066 } | 1084 } |
1067 | 1085 |
1068 virtual void afterTest() OVERRIDE | 1086 virtual void afterTest() OVERRIDE |
1069 { | 1087 { |
1070 } | 1088 } |
1071 | 1089 |
1072 private: | 1090 private: |
1073 FakeContentLayerClient m_client; | 1091 FakeContentLayerClient m_client; |
1074 scoped_refptr<ContentLayerWithUpdateTracking> m_layer; | 1092 scoped_refptr<FakeContentLayer> m_layer; |
| 1093 scoped_refptr<FakeScrollbarLayer> m_scrollbar; |
1075 }; | 1094 }; |
1076 | 1095 |
1077 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) | 1096 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) |
1078 { | 1097 { |
1079 runTest(true); | 1098 runTest(true); |
1080 } | 1099 } |
1081 | 1100 |
1082 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx:
:Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, c
onst gfx::Size& bounds, bool opaque) | 1101 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx:
:Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, c
onst gfx::Size& bounds, bool opaque) |
1083 { | 1102 { |
1084 layer->removeAllChildren(); | 1103 layer->removeAllChildren(); |
1085 if (parent) | 1104 if (parent) |
1086 parent->addChild(layer); | 1105 parent->addChild(layer); |
1087 layer->setTransform(transform); | 1106 layer->setTransform(transform); |
1088 layer->setAnchorPoint(anchor); | 1107 layer->setAnchorPoint(anchor); |
1089 layer->setPosition(position); | 1108 layer->setPosition(position); |
1090 layer->setBounds(bounds); | 1109 layer->setBounds(bounds); |
1091 layer->setContentsOpaque(opaque); | 1110 layer->setContentsOpaque(opaque); |
1092 } | 1111 } |
1093 | 1112 |
1094 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest
{ | 1113 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest
{ |
1095 public: | 1114 public: |
1096 LayerTreeHostTestAtomicCommitWithPartialUpdate() | 1115 LayerTreeHostTestAtomicCommitWithPartialUpdate() |
1097 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) | 1116 : m_numCommits(0) |
1098 , m_child(ContentLayerWithUpdateTracking::create(&m_client)) | |
1099 , m_numCommits(0) | |
1100 { | 1117 { |
1101 // Allow one partial texture update. | 1118 // Allow one partial texture update. |
1102 m_settings.maxPartialTextureUpdates = 1; | 1119 m_settings.maxPartialTextureUpdates = 1; |
| 1120 // Linear fade animator prevents scrollbars from drawing immediately. |
| 1121 m_settings.useLinearFadeScrollbarAnimator = false; |
| 1122 } |
| 1123 |
| 1124 virtual void setupTree() OVERRIDE |
| 1125 { |
| 1126 m_parent = FakeContentLayer::Create(&m_client); |
| 1127 m_parent->setBounds(gfx::Size(10, 20)); |
| 1128 |
| 1129 m_child = FakeContentLayer::Create(&m_client); |
| 1130 m_child->setPosition(gfx::Point(0, 10)); |
| 1131 m_child->setBounds(gfx::Size(3, 10)); |
| 1132 |
| 1133 m_scrollbarWithPaints = |
| 1134 FakeScrollbarLayer::Create(true, m_parent->id()); |
| 1135 m_scrollbarWithPaints->setPosition(gfx::Point(3, 10)); |
| 1136 m_scrollbarWithPaints->setBounds(gfx::Size(3, 10)); |
| 1137 |
| 1138 m_scrollbarWithoutPaints = |
| 1139 FakeScrollbarLayer::Create(false, m_parent->id()); |
| 1140 m_scrollbarWithoutPaints->setPosition(gfx::Point(6, 10)); |
| 1141 m_scrollbarWithoutPaints->setBounds(gfx::Size(3, 10)); |
| 1142 |
| 1143 m_parent->addChild(m_child); |
| 1144 m_parent->addChild(m_scrollbarWithPaints); |
| 1145 m_parent->addChild(m_scrollbarWithoutPaints); |
| 1146 |
| 1147 m_layerTreeHost->setRootLayer(m_parent); |
| 1148 LayerTreeHostTest::setupTree(); |
1103 } | 1149 } |
1104 | 1150 |
1105 virtual void beginTest() OVERRIDE | 1151 virtual void beginTest() OVERRIDE |
1106 { | 1152 { |
1107 m_layerTreeHost->setRootLayer(m_parent); | |
1108 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); | |
1109 | |
1110 gfx::Transform identityMatrix; | |
1111 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi
ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); | |
1112 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); | |
1113 | |
1114 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | |
1115 ResourceUpdateQueue queue; | |
1116 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
1117 postSetNeedsCommitToMainThread(); | 1153 postSetNeedsCommitToMainThread(); |
1118 } | 1154 } |
1119 | 1155 |
1120 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1156 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1121 { | 1157 { |
| 1158 ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); |
| 1159 |
1122 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); | 1160 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); |
1123 | 1161 |
1124 switch (impl->activeTree()->source_frame_number()) { | 1162 switch (impl->activeTree()->source_frame_number()) { |
1125 case 0: | 1163 case 0: |
1126 // Number of textures should be two. | 1164 // Number of textures should be one for each layer. |
1127 ASSERT_EQ(2, context->NumTextures()); | 1165 ASSERT_EQ(4, context->NumTextures()); |
1128 // Number of textures used for commit should be two. | 1166 // Number of textures used for commit should be one for each layer. |
1129 EXPECT_EQ(2, context->NumUsedTextures()); | 1167 EXPECT_EQ(4, context->NumUsedTextures()); |
1130 // Verify that used textures are correct. | 1168 // Verify that used textures are correct. |
1131 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1169 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
1132 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1170 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
1133 | |
1134 context->ResetUsedTextures(); | |
1135 postSetNeedsCommitToMainThread(); | |
1136 break; | |
1137 case 1: | |
1138 // Number of textures used for commit should still be two. | |
1139 EXPECT_EQ(2, context->NumUsedTextures()); | |
1140 // First two textures should not have been used. | |
1141 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); | |
1142 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); | |
1143 // New textures should have been used. | |
1144 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); | 1171 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
1145 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1172 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
1146 | 1173 |
1147 context->ResetUsedTextures(); | 1174 context->ResetUsedTextures(); |
1148 postSetNeedsCommitToMainThread(); | 1175 postSetNeedsCommitToMainThread(); |
1149 break; | 1176 break; |
1150 case 2: | 1177 case 1: |
1151 // Number of textures used for commit should still be two. | 1178 // Number of textures should be two for each content layer and one |
1152 EXPECT_EQ(2, context->NumUsedTextures()); | 1179 // for each scrollbar, since they always do a partial update. |
| 1180 ASSERT_EQ(6, context->NumTextures()); |
| 1181 // Number of textures used for commit should be one for each content |
| 1182 // layer, and one for the scrollbar layer that paints. |
| 1183 EXPECT_EQ(3, context->NumUsedTextures()); |
| 1184 |
| 1185 // First content textures should not have been used. |
| 1186 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); |
| 1187 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
| 1188 // The non-painting scrollbar's texture wasn't updated. |
| 1189 EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); |
| 1190 // The painting scrollbar's partial update texture was used. |
| 1191 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| 1192 // New textures should have been used. |
| 1193 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); |
| 1194 EXPECT_TRUE(context->UsedTexture(context->TextureAt(5))); |
1153 | 1195 |
1154 context->ResetUsedTextures(); | 1196 context->ResetUsedTextures(); |
1155 postSetNeedsCommitToMainThread(); | 1197 postSetNeedsCommitToMainThread(); |
| 1198 break; |
| 1199 case 2: |
| 1200 // Number of textures should be two for each content layer and one |
| 1201 // for each scrollbar, since they always do a partial update. |
| 1202 ASSERT_EQ(6, context->NumTextures()); |
| 1203 // Number of textures used for commit should be one for each content |
| 1204 // layer, and one for the scrollbar layer that paints. |
| 1205 EXPECT_EQ(3, context->NumUsedTextures()); |
| 1206 |
| 1207 // The non-painting scrollbar's texture wasn't updated. |
| 1208 EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); |
| 1209 // The painting scrollbar does a partial update. |
| 1210 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| 1211 // One content layer does a partial update also. |
| 1212 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); |
| 1213 EXPECT_FALSE(context->UsedTexture(context->TextureAt(5))); |
| 1214 |
| 1215 context->ResetUsedTextures(); |
| 1216 postSetNeedsCommitToMainThread(); |
1156 break; | 1217 break; |
1157 case 3: | 1218 case 3: |
1158 // No textures should be used for commit. | 1219 // No textures should be used for commit. |
1159 EXPECT_EQ(0, context->NumUsedTextures()); | 1220 EXPECT_EQ(0, context->NumUsedTextures()); |
1160 | 1221 |
1161 context->ResetUsedTextures(); | 1222 context->ResetUsedTextures(); |
1162 postSetNeedsCommitToMainThread(); | 1223 postSetNeedsCommitToMainThread(); |
1163 break; | 1224 break; |
1164 case 4: | 1225 case 4: |
1165 // Number of textures used for commit should be one. | 1226 // Number of textures used for commit should be two. One for the |
1166 EXPECT_EQ(1, context->NumUsedTextures()); | 1227 // content layer, and one for the painting scrollbar. The |
| 1228 // non-painting scrollbar doesn't update its texture. |
| 1229 EXPECT_EQ(2, context->NumUsedTextures()); |
1167 | 1230 |
1168 context->ResetUsedTextures(); | 1231 context->ResetUsedTextures(); |
1169 postSetNeedsCommitToMainThread(); | 1232 postSetNeedsCommitToMainThread(); |
1170 break; | 1233 break; |
1171 case 5: | 1234 case 5: |
1172 endTest(); | 1235 endTest(); |
1173 break; | 1236 break; |
1174 default: | 1237 default: |
1175 NOTREACHED(); | 1238 NOTREACHED(); |
1176 break; | 1239 break; |
1177 } | 1240 } |
1178 } | 1241 } |
1179 | 1242 |
1180 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1243 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1181 { | 1244 { |
1182 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); | 1245 FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D
*>(impl->outputSurface()->Context3D()); |
1183 | 1246 |
1184 // Number of textures used for drawing should two except for frame 4 | 1247 // Number of textures used for drawing should one per layer except for |
1185 // where the viewport only contains one layer. | 1248 // frame 3 where the viewport only contains one layer. |
1186 if (impl->activeTree()->source_frame_number() == 3) | 1249 if (impl->activeTree()->source_frame_number() == 3) |
1187 EXPECT_EQ(1, context->NumUsedTextures()); | 1250 EXPECT_EQ(1, context->NumUsedTextures()); |
1188 else | 1251 else |
1189 EXPECT_EQ(2, context->NumUsedTextures()); | 1252 EXPECT_EQ(4, context->NumUsedTextures()); |
1190 | 1253 |
1191 context->ResetUsedTextures(); | 1254 context->ResetUsedTextures(); |
1192 } | 1255 } |
1193 | 1256 |
1194 virtual void layout() OVERRIDE | 1257 virtual void layout() OVERRIDE |
1195 { | 1258 { |
1196 switch (m_numCommits++) { | 1259 switch (m_numCommits++) { |
1197 case 0: | 1260 case 0: |
1198 case 1: | 1261 case 1: |
1199 m_parent->setNeedsDisplay(); | 1262 m_parent->setNeedsDisplay(); |
1200 m_child->setNeedsDisplay(); | 1263 m_child->setNeedsDisplay(); |
| 1264 m_scrollbarWithPaints->setNeedsDisplay(); |
| 1265 m_scrollbarWithoutPaints->setNeedsDisplay(); |
1201 break; | 1266 break; |
1202 case 2: | 1267 case 2: |
1203 // Damage part of layers. | 1268 // Damage part of layers. |
1204 m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1269 m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
1205 m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1270 m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
| 1271 m_scrollbarWithPaints->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
| 1272 m_scrollbarWithoutPaints->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)
); |
1206 break; | 1273 break; |
1207 case 3: | 1274 case 3: |
1208 m_child->setNeedsDisplay(); | 1275 m_child->setNeedsDisplay(); |
| 1276 m_scrollbarWithPaints->setNeedsDisplay(); |
| 1277 m_scrollbarWithoutPaints->setNeedsDisplay(); |
1209 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); | 1278 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); |
1210 break; | 1279 break; |
1211 case 4: | 1280 case 4: |
1212 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); | 1281 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); |
1213 break; | 1282 break; |
1214 case 5: | 1283 case 5: |
1215 break; | 1284 break; |
1216 default: | 1285 default: |
1217 NOTREACHED(); | 1286 NOTREACHED(); |
1218 break; | 1287 break; |
1219 } | 1288 } |
1220 } | 1289 } |
1221 | 1290 |
1222 virtual void afterTest() OVERRIDE | 1291 virtual void afterTest() OVERRIDE |
1223 { | 1292 { |
1224 } | 1293 } |
1225 | 1294 |
1226 private: | 1295 private: |
1227 FakeContentLayerClient m_client; | 1296 FakeContentLayerClient m_client; |
1228 scoped_refptr<ContentLayerWithUpdateTracking> m_parent; | 1297 scoped_refptr<FakeContentLayer> m_parent; |
1229 scoped_refptr<ContentLayerWithUpdateTracking> m_child; | 1298 scoped_refptr<FakeContentLayer> m_child; |
| 1299 scoped_refptr<FakeScrollbarLayer> m_scrollbarWithPaints; |
| 1300 scoped_refptr<FakeScrollbarLayer> m_scrollbarWithoutPaints; |
1230 int m_numCommits; | 1301 int m_numCommits; |
1231 }; | 1302 }; |
1232 | 1303 |
1233 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) | 1304 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) |
1234 { | 1305 { |
1235 runTest(true); | 1306 runTest(true); |
1236 } | 1307 } |
1237 | 1308 |
1238 // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true) | 1309 // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true) |
1239 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { | 1310 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 LayerTreeSettings settings; | 2245 LayerTreeSettings settings; |
2175 settings.maxPartialTextureUpdates = 4; | 2246 settings.maxPartialTextureUpdates = 4; |
2176 | 2247 |
2177 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 2248 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
2178 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 2249 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
2179 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 2250 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
2180 } | 2251 } |
2181 | 2252 |
2182 } // namespace | 2253 } // namespace |
2183 } // namespace cc | 2254 } // namespace cc |
OLD | NEW |