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_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "cc/delegated_renderer_layer_impl.h" | 12 #include "cc/delegated_renderer_layer_impl.h" |
13 #include "cc/gl_renderer.h" | 13 #include "cc/gl_renderer.h" |
14 #include "cc/heads_up_display_layer_impl.h" | 14 #include "cc/heads_up_display_layer_impl.h" |
15 #include "cc/io_surface_layer_impl.h" | 15 #include "cc/io_surface_layer_impl.h" |
16 #include "cc/layer_impl.h" | 16 #include "cc/layer_impl.h" |
17 #include "cc/layer_tiling_data.h" | 17 #include "cc/layer_tiling_data.h" |
| 18 #include "cc/layer_tree_impl.h" |
18 #include "cc/math_util.h" | 19 #include "cc/math_util.h" |
19 #include "cc/quad_sink.h" | 20 #include "cc/quad_sink.h" |
20 #include "cc/render_pass_draw_quad.h" | 21 #include "cc/render_pass_draw_quad.h" |
21 #include "cc/scrollbar_geometry_fixed_thumb.h" | 22 #include "cc/scrollbar_geometry_fixed_thumb.h" |
22 #include "cc/scrollbar_layer_impl.h" | 23 #include "cc/scrollbar_layer_impl.h" |
23 #include "cc/single_thread_proxy.h" | 24 #include "cc/single_thread_proxy.h" |
24 #include "cc/solid_color_draw_quad.h" | 25 #include "cc/solid_color_draw_quad.h" |
25 #include "cc/test/animation_test_common.h" | 26 #include "cc/test/animation_test_common.h" |
26 #include "cc/test/fake_output_surface.h" | 27 #include "cc/test/fake_output_surface.h" |
27 #include "cc/test/fake_proxy.h" | 28 #include "cc/test/fake_proxy.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 if (scrollInfo.scrolls[i].layerId != id) | 156 if (scrollInfo.scrolls[i].layerId != id) |
156 continue; | 157 continue; |
157 timesEncountered++; | 158 timesEncountered++; |
158 } | 159 } |
159 | 160 |
160 ASSERT_EQ(0, timesEncountered); | 161 ASSERT_EQ(0, timesEncountered); |
161 } | 162 } |
162 | 163 |
163 void setupScrollAndContentsLayers(const gfx::Size& contentSize) | 164 void setupScrollAndContentsLayers(const gfx::Size& contentSize) |
164 { | 165 { |
165 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 166 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
166 root->setScrollable(true); | 167 root->setScrollable(true); |
167 root->setScrollOffset(gfx::Vector2d(0, 0)); | 168 root->setScrollOffset(gfx::Vector2d(0, 0)); |
168 root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.
height())); | 169 root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.
height())); |
169 root->setBounds(contentSize); | 170 root->setBounds(contentSize); |
170 root->setContentBounds(contentSize); | 171 root->setContentBounds(contentSize); |
171 root->setPosition(gfx::PointF(0, 0)); | 172 root->setPosition(gfx::PointF(0, 0)); |
172 root->setAnchorPoint(gfx::PointF(0, 0)); | 173 root->setAnchorPoint(gfx::PointF(0, 0)); |
173 | 174 |
174 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl.get(), 2); | 175 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre
e(), 2); |
175 contents->setDrawsContent(true); | 176 contents->setDrawsContent(true); |
176 contents->setBounds(contentSize); | 177 contents->setBounds(contentSize); |
177 contents->setContentBounds(contentSize); | 178 contents->setContentBounds(contentSize); |
178 contents->setPosition(gfx::PointF(0, 0)); | 179 contents->setPosition(gfx::PointF(0, 0)); |
179 contents->setAnchorPoint(gfx::PointF(0, 0)); | 180 contents->setAnchorPoint(gfx::PointF(0, 0)); |
180 root->addChild(contents.Pass()); | 181 root->addChild(contents.Pass()); |
181 m_hostImpl->setRootLayer(root.Pass()); | 182 m_hostImpl->setRootLayer(root.Pass()); |
182 } | 183 } |
183 | 184 |
184 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) | 185 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) |
185 { | 186 { |
186 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl.get(), id); | 187 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree()
, id); |
187 layer->setScrollable(true); | 188 layer->setScrollable(true); |
188 layer->setDrawsContent(true); | 189 layer->setDrawsContent(true); |
189 layer->setBounds(size); | 190 layer->setBounds(size); |
190 layer->setContentBounds(size); | 191 layer->setContentBounds(size); |
191 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); | 192 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); |
192 return layer.Pass(); | 193 return layer.Pass(); |
193 } | 194 } |
194 | 195 |
195 void initializeRendererAndDrawFrame() | 196 void initializeRendererAndDrawFrame() |
196 { | 197 { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 { | 288 { |
288 ASSERT_FALSE(m_hostImpl->rootLayer()); | 289 ASSERT_FALSE(m_hostImpl->rootLayer()); |
289 | 290 |
290 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 291 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
291 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 292 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
292 } | 293 } |
293 | 294 |
294 TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 295 TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
295 { | 296 { |
296 { | 297 { |
297 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 298 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
298 root->addChild(LayerImpl::create(m_hostImpl.get(), 2)); | 299 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 2)); |
299 root->addChild(LayerImpl::create(m_hostImpl.get(), 3)); | 300 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 3)); |
300 root->children()[1]->addChild(LayerImpl::create(m_hostImpl.get(), 4)); | 301 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 4)); |
301 root->children()[1]->addChild(LayerImpl::create(m_hostImpl.get(), 5)); | 302 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 5)); |
302 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp
l.get(), 6)); | 303 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp
l->activeTree(), 6)); |
303 m_hostImpl->setRootLayer(root.Pass()); | 304 m_hostImpl->setRootLayer(root.Pass()); |
304 } | 305 } |
305 LayerImpl* root = m_hostImpl->rootLayer(); | 306 LayerImpl* root = m_hostImpl->rootLayer(); |
306 | 307 |
307 expectClearedScrollDeltasRecursive(root); | 308 expectClearedScrollDeltasRecursive(root); |
308 | 309 |
309 scoped_ptr<ScrollAndScaleSet> scrollInfo; | 310 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
310 | 311 |
311 scrollInfo = m_hostImpl->processScrollDeltas(); | 312 scrollInfo = m_hostImpl->processScrollDeltas(); |
312 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 313 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
313 expectClearedScrollDeltasRecursive(root); | 314 expectClearedScrollDeltasRecursive(root); |
314 | 315 |
315 scrollInfo = m_hostImpl->processScrollDeltas(); | 316 scrollInfo = m_hostImpl->processScrollDeltas(); |
316 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 317 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
317 expectClearedScrollDeltasRecursive(root); | 318 expectClearedScrollDeltasRecursive(root); |
318 } | 319 } |
319 | 320 |
320 TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) | 321 TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) |
321 { | 322 { |
322 gfx::Vector2d scrollOffset(20, 30); | 323 gfx::Vector2d scrollOffset(20, 30); |
323 gfx::Vector2d scrollDelta(11, -15); | 324 gfx::Vector2d scrollDelta(11, -15); |
324 { | 325 { |
325 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 326 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
326 root->setScrollOffset(scrollOffset); | 327 root->setScrollOffset(scrollOffset); |
327 root->setScrollable(true); | 328 root->setScrollable(true); |
328 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 329 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); |
329 root->scrollBy(scrollDelta); | 330 root->scrollBy(scrollDelta); |
330 m_hostImpl->setRootLayer(root.Pass()); | 331 m_hostImpl->setRootLayer(root.Pass()); |
331 } | 332 } |
332 LayerImpl* root = m_hostImpl->rootLayer(); | 333 LayerImpl* root = m_hostImpl->rootLayer(); |
333 | 334 |
334 scoped_ptr<ScrollAndScaleSet> scrollInfo; | 335 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
335 | 336 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // The final page scale and scroll deltas should match what we got | 873 // The final page scale and scroll deltas should match what we got |
873 // earlier. | 874 // earlier. |
874 m_hostImpl->animate(endTime, base::Time()); | 875 m_hostImpl->animate(endTime, base::Time()); |
875 scrollInfo = m_hostImpl->processScrollDeltas(); | 876 scrollInfo = m_hostImpl->processScrollDeltas(); |
876 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 877 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
877 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); | 878 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); |
878 } | 879 } |
879 | 880 |
880 class DidDrawCheckLayer : public TiledLayerImpl { | 881 class DidDrawCheckLayer : public TiledLayerImpl { |
881 public: | 882 public: |
882 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id) { r
eturn scoped_ptr<LayerImpl>(new DidDrawCheckLayer(hostImpl, id)); } | 883 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new DidDrawCheckLayer(treeImpl, id)); } |
883 | 884 |
884 virtual void didDraw(ResourceProvider*) OVERRIDE | 885 virtual void didDraw(ResourceProvider*) OVERRIDE |
885 { | 886 { |
886 m_didDrawCalled = true; | 887 m_didDrawCalled = true; |
887 } | 888 } |
888 | 889 |
889 virtual void willDraw(ResourceProvider*) OVERRIDE | 890 virtual void willDraw(ResourceProvider*) OVERRIDE |
890 { | 891 { |
891 m_willDrawCalled = true; | 892 m_willDrawCalled = true; |
892 } | 893 } |
893 | 894 |
894 bool didDrawCalled() const { return m_didDrawCalled; } | 895 bool didDrawCalled() const { return m_didDrawCalled; } |
895 bool willDrawCalled() const { return m_willDrawCalled; } | 896 bool willDrawCalled() const { return m_willDrawCalled; } |
896 | 897 |
897 void clearDidDrawCheck() | 898 void clearDidDrawCheck() |
898 { | 899 { |
899 m_didDrawCalled = false; | 900 m_didDrawCalled = false; |
900 m_willDrawCalled = false; | 901 m_willDrawCalled = false; |
901 } | 902 } |
902 | 903 |
903 protected: | 904 protected: |
904 DidDrawCheckLayer(LayerTreeHostImpl* hostImpl, int id) | 905 DidDrawCheckLayer(LayerTreeImpl* treeImpl, int id) |
905 : TiledLayerImpl(hostImpl, id) | 906 : TiledLayerImpl(treeImpl, id) |
906 , m_didDrawCalled(false) | 907 , m_didDrawCalled(false) |
907 , m_willDrawCalled(false) | 908 , m_willDrawCalled(false) |
908 { | 909 { |
909 setAnchorPoint(gfx::PointF(0, 0)); | 910 setAnchorPoint(gfx::PointF(0, 0)); |
910 setBounds(gfx::Size(10, 10)); | 911 setBounds(gfx::Size(10, 10)); |
911 setContentBounds(gfx::Size(10, 10)); | 912 setContentBounds(gfx::Size(10, 10)); |
912 setDrawsContent(true); | 913 setDrawsContent(true); |
913 setSkipsDraw(false); | 914 setSkipsDraw(false); |
914 drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 915 drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
915 | 916 |
916 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10
0, 100), LayerTilingData::HasBorderTexels); | 917 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10
0, 100), LayerTilingData::HasBorderTexels); |
917 tiler->setBounds(contentBounds()); | 918 tiler->setBounds(contentBounds()); |
918 setTilingData(*tiler.get()); | 919 setTilingData(*tiler.get()); |
919 } | 920 } |
920 | 921 |
921 private: | 922 private: |
922 bool m_didDrawCalled; | 923 bool m_didDrawCalled; |
923 bool m_willDrawCalled; | 924 bool m_willDrawCalled; |
924 }; | 925 }; |
925 | 926 |
926 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 927 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
927 { | 928 { |
928 // The root layer is always drawn, so run this test on a child layer that | 929 // The root layer is always drawn, so run this test on a child layer that |
929 // will be masked out by the root layer's bounds. | 930 // will be masked out by the root layer's bounds. |
930 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 931 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
931 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 932 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
932 root->setMasksToBounds(true); | 933 root->setMasksToBounds(true); |
933 | 934 |
934 root->addChild(DidDrawCheckLayer::create(m_hostImpl.get(), 2)); | 935 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); |
935 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); | 936 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); |
936 // Ensure visibleContentRect for layer is empty | 937 // Ensure visibleContentRect for layer is empty |
937 layer->setPosition(gfx::PointF(100, 100)); | 938 layer->setPosition(gfx::PointF(100, 100)); |
938 layer->setBounds(gfx::Size(10, 10)); | 939 layer->setBounds(gfx::Size(10, 10)); |
939 layer->setContentBounds(gfx::Size(10, 10)); | 940 layer->setContentBounds(gfx::Size(10, 10)); |
940 | 941 |
941 LayerTreeHostImpl::FrameData frame; | 942 LayerTreeHostImpl::FrameData frame; |
942 | 943 |
943 EXPECT_FALSE(layer->willDrawCalled()); | 944 EXPECT_FALSE(layer->willDrawCalled()); |
944 EXPECT_FALSE(layer->didDrawCalled()); | 945 EXPECT_FALSE(layer->didDrawCalled()); |
(...skipping 21 matching lines...) Expand all Loading... |
966 EXPECT_TRUE(layer->didDrawCalled()); | 967 EXPECT_TRUE(layer->didDrawCalled()); |
967 | 968 |
968 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); | 969 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); |
969 } | 970 } |
970 | 971 |
971 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 972 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
972 { | 973 { |
973 gfx::Size bigSize(1000, 1000); | 974 gfx::Size bigSize(1000, 1000); |
974 m_hostImpl->setViewportSize(bigSize, bigSize); | 975 m_hostImpl->setViewportSize(bigSize, bigSize); |
975 | 976 |
976 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 977 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
977 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 978 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
978 | 979 |
979 root->addChild(DidDrawCheckLayer::create(m_hostImpl.get(), 2)); | 980 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); |
980 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); | 981 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); |
981 | 982 |
982 root->addChild(DidDrawCheckLayer::create(m_hostImpl.get(), 3)); | 983 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); |
983 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); | 984 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); |
984 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. | 985 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. |
985 topLayer->setBounds(bigSize); | 986 topLayer->setBounds(bigSize); |
986 topLayer->setContentBounds(bigSize); | 987 topLayer->setContentBounds(bigSize); |
987 topLayer->setContentsOpaque(true); | 988 topLayer->setContentsOpaque(true); |
988 | 989 |
989 LayerTreeHostImpl::FrameData frame; | 990 LayerTreeHostImpl::FrameData frame; |
990 | 991 |
991 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 992 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
992 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 993 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
993 EXPECT_FALSE(topLayer->willDrawCalled()); | 994 EXPECT_FALSE(topLayer->willDrawCalled()); |
994 EXPECT_FALSE(topLayer->didDrawCalled()); | 995 EXPECT_FALSE(topLayer->didDrawCalled()); |
995 | 996 |
996 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 997 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
997 m_hostImpl->drawLayers(frame); | 998 m_hostImpl->drawLayers(frame); |
998 m_hostImpl->didDrawAllLayers(frame); | 999 m_hostImpl->didDrawAllLayers(frame); |
999 | 1000 |
1000 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 1001 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
1001 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 1002 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
1002 EXPECT_TRUE(topLayer->willDrawCalled()); | 1003 EXPECT_TRUE(topLayer->willDrawCalled()); |
1003 EXPECT_TRUE(topLayer->didDrawCalled()); | 1004 EXPECT_TRUE(topLayer->didDrawCalled()); |
1004 } | 1005 } |
1005 | 1006 |
1006 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) | 1007 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) |
1007 { | 1008 { |
1008 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 1009 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
1009 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1010 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
1010 | 1011 |
1011 root->addChild(DidDrawCheckLayer::create(m_hostImpl.get(), 2)); | 1012 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); |
1012 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); | 1013 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); |
1013 | 1014 |
1014 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl.get(), 3)); | 1015 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); |
1015 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); | 1016 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); |
1016 | 1017 |
1017 layer1->setOpacity(0.3f); | 1018 layer1->setOpacity(0.3f); |
1018 layer1->setPreserves3D(false); | 1019 layer1->setPreserves3D(false); |
1019 | 1020 |
1020 EXPECT_FALSE(root->didDrawCalled()); | 1021 EXPECT_FALSE(root->didDrawCalled()); |
1021 EXPECT_FALSE(layer1->didDrawCalled()); | 1022 EXPECT_FALSE(layer1->didDrawCalled()); |
1022 EXPECT_FALSE(layer2->didDrawCalled()); | 1023 EXPECT_FALSE(layer2->didDrawCalled()); |
1023 | 1024 |
1024 LayerTreeHostImpl::FrameData frame; | 1025 LayerTreeHostImpl::FrameData frame; |
1025 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1026 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1026 m_hostImpl->drawLayers(frame); | 1027 m_hostImpl->drawLayers(frame); |
1027 m_hostImpl->didDrawAllLayers(frame); | 1028 m_hostImpl->didDrawAllLayers(frame); |
1028 | 1029 |
1029 EXPECT_TRUE(root->didDrawCalled()); | 1030 EXPECT_TRUE(root->didDrawCalled()); |
1030 EXPECT_TRUE(layer1->didDrawCalled()); | 1031 EXPECT_TRUE(layer1->didDrawCalled()); |
1031 EXPECT_TRUE(layer2->didDrawCalled()); | 1032 EXPECT_TRUE(layer2->didDrawCalled()); |
1032 | 1033 |
1033 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); | 1034 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); |
1034 EXPECT_TRUE(!!layer1->renderSurface()); | 1035 EXPECT_TRUE(!!layer1->renderSurface()); |
1035 } | 1036 } |
1036 | 1037 |
1037 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { | 1038 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
1038 public: | 1039 public: |
1039 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id, boo
l tileMissing, bool skipsDraw, bool animating, ResourceProvider* resourceProvide
r) | 1040 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id, bool ti
leMissing, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) |
1040 { | 1041 { |
1041 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(hostImpl,
id, tileMissing, skipsDraw, animating, resourceProvider)); | 1042 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(treeImpl,
id, tileMissing, skipsDraw, animating, resourceProvider)); |
1042 } | 1043 } |
1043 | 1044 |
1044 private: | 1045 private: |
1045 MissingTextureAnimatingLayer(LayerTreeHostImpl* hostImpl, int id, bool tileM
issing, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) | 1046 MissingTextureAnimatingLayer(LayerTreeImpl* treeImpl, int id, bool tileMissi
ng, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) |
1046 : DidDrawCheckLayer(hostImpl, id) | 1047 : DidDrawCheckLayer(treeImpl, id) |
1047 { | 1048 { |
1048 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(gfx::Si
ze(10, 10), LayerTilingData::NoBorderTexels); | 1049 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(gfx::Si
ze(10, 10), LayerTilingData::NoBorderTexels); |
1049 tilingData->setBounds(bounds()); | 1050 tilingData->setBounds(bounds()); |
1050 setTilingData(*tilingData.get()); | 1051 setTilingData(*tilingData.get()); |
1051 setSkipsDraw(skipsDraw); | 1052 setSkipsDraw(skipsDraw); |
1052 if (!tileMissing) { | 1053 if (!tileMissing) { |
1053 ResourceProvider::ResourceId resource = resourceProvider->createReso
urce(Renderer::ContentPool, gfx::Size(), GL_RGBA, ResourceProvider::TextureUsage
Any); | 1054 ResourceProvider::ResourceId resource = resourceProvider->createReso
urce(Renderer::ContentPool, gfx::Size(), GL_RGBA, ResourceProvider::TextureUsage
Any); |
1054 pushTileProperties(0, 0, resource, gfx::Rect(), false); | 1055 pushTileProperties(0, 0, resource, gfx::Rect(), false); |
1055 } | 1056 } |
1056 if (animating) | 1057 if (animating) |
1057 addAnimatedTransformToLayer(*this, 10, 3, 0); | 1058 addAnimatedTransformToLayer(*this, 10, 3, 0); |
1058 } | 1059 } |
1059 }; | 1060 }; |
1060 | 1061 |
1061 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 1062 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
1062 { | 1063 { |
1063 // When the texture is not missing, we draw as usual. | 1064 // When the texture is not missing, we draw as usual. |
1064 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 1065 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
1065 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1066 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
1066 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl.get(), 2, fal
se, false, true, m_hostImpl->resourceProvider())); | 1067 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, false, false, true, m_hostImpl->resourceProvider())); |
1067 | 1068 |
1068 LayerTreeHostImpl::FrameData frame; | 1069 LayerTreeHostImpl::FrameData frame; |
1069 | 1070 |
1070 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1071 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1071 m_hostImpl->drawLayers(frame); | 1072 m_hostImpl->drawLayers(frame); |
1072 m_hostImpl->didDrawAllLayers(frame); | 1073 m_hostImpl->didDrawAllLayers(frame); |
1073 | 1074 |
1074 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. | 1075 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. |
1075 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 1076 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
1076 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1077 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1077 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl.get(), 2, tru
e, false, false, m_hostImpl->resourceProvider())); | 1078 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, true, false, false, m_hostImpl->resourceProvider())); |
1078 | 1079 |
1079 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1080 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1080 m_hostImpl->drawLayers(frame); | 1081 m_hostImpl->drawLayers(frame); |
1081 m_hostImpl->didDrawAllLayers(frame); | 1082 m_hostImpl->didDrawAllLayers(frame); |
1082 | 1083 |
1083 // When a texture is missing and we're animating, we don't want to draw anyt
hing. | 1084 // When a texture is missing and we're animating, we don't want to draw anyt
hing. |
1084 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 1085 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
1085 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1086 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1086 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl.get(), 2, tru
e, false, true, m_hostImpl->resourceProvider())); | 1087 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, true, false, true, m_hostImpl->resourceProvider())); |
1087 | 1088 |
1088 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); | 1089 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); |
1089 m_hostImpl->drawLayers(frame); | 1090 m_hostImpl->drawLayers(frame); |
1090 m_hostImpl->didDrawAllLayers(frame); | 1091 m_hostImpl->didDrawAllLayers(frame); |
1091 | 1092 |
1092 // When the layer skips draw and we're animating, we still draw the frame. | 1093 // When the layer skips draw and we're animating, we still draw the frame. |
1093 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl.get(), 1)); | 1094 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); |
1094 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1095 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1095 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl.get(), 2, fal
se, true, true, m_hostImpl->resourceProvider())); | 1096 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, false, true, true, m_hostImpl->resourceProvider())); |
1096 | 1097 |
1097 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1098 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1098 m_hostImpl->drawLayers(frame); | 1099 m_hostImpl->drawLayers(frame); |
1099 m_hostImpl->didDrawAllLayers(frame); | 1100 m_hostImpl->didDrawAllLayers(frame); |
1100 } | 1101 } |
1101 | 1102 |
1102 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) | 1103 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) |
1103 { | 1104 { |
1104 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 1105 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1105 root->setScrollable(false); | 1106 root->setScrollable(false); |
1106 m_hostImpl->setRootLayer(root.Pass()); | 1107 m_hostImpl->setRootLayer(root.Pass()); |
1107 initializeRendererAndDrawFrame(); | 1108 initializeRendererAndDrawFrame(); |
1108 | 1109 |
1109 // Scroll event is ignored because layer is not scrollable. | 1110 // Scroll event is ignored because layer is not scrollable. |
1110 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 1111 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
1111 EXPECT_FALSE(m_didRequestRedraw); | 1112 EXPECT_FALSE(m_didRequestRedraw); |
1112 EXPECT_FALSE(m_didRequestCommit); | 1113 EXPECT_FALSE(m_didRequestCommit); |
1113 } | 1114 } |
1114 | 1115 |
1115 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) | 1116 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) |
1116 { | 1117 { |
1117 // Test the configuration where a non-composited root layer is embedded in a | 1118 // Test the configuration where a non-composited root layer is embedded in a |
1118 // scrollable outer layer. | 1119 // scrollable outer layer. |
1119 gfx::Size surfaceSize(10, 10); | 1120 gfx::Size surfaceSize(10, 10); |
1120 | 1121 |
1121 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(m_hostImpl.get(), 1); | 1122 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(m_hostImpl->activeTre
e(), 1); |
1122 contentLayer->setUseLCDText(true); | 1123 contentLayer->setUseLCDText(true); |
1123 contentLayer->setDrawsContent(true); | 1124 contentLayer->setDrawsContent(true); |
1124 contentLayer->setPosition(gfx::PointF(0, 0)); | 1125 contentLayer->setPosition(gfx::PointF(0, 0)); |
1125 contentLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1126 contentLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1126 contentLayer->setBounds(surfaceSize); | 1127 contentLayer->setBounds(surfaceSize); |
1127 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); | 1128 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); |
1128 contentLayer->setContentsScale(2, 2); | 1129 contentLayer->setContentsScale(2, 2); |
1129 | 1130 |
1130 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl.get(), 2); | 1131 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl->activeTree
(), 2); |
1131 scrollLayer->setScrollable(true); | 1132 scrollLayer->setScrollable(true); |
1132 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); | 1133 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); |
1133 scrollLayer->setBounds(surfaceSize); | 1134 scrollLayer->setBounds(surfaceSize); |
1134 scrollLayer->setContentBounds(surfaceSize); | 1135 scrollLayer->setContentBounds(surfaceSize); |
1135 scrollLayer->setPosition(gfx::PointF(0, 0)); | 1136 scrollLayer->setPosition(gfx::PointF(0, 0)); |
1136 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1137 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1137 scrollLayer->addChild(contentLayer.Pass()); | 1138 scrollLayer->addChild(contentLayer.Pass()); |
1138 | 1139 |
1139 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1140 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1140 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1141 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1141 initializeRendererAndDrawFrame(); | 1142 initializeRendererAndDrawFrame(); |
1142 | 1143 |
1143 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1144 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1144 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1145 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1145 m_hostImpl->scrollEnd(); | 1146 m_hostImpl->scrollEnd(); |
1146 EXPECT_TRUE(m_didRequestRedraw); | 1147 EXPECT_TRUE(m_didRequestRedraw); |
1147 EXPECT_TRUE(m_didRequestCommit); | 1148 EXPECT_TRUE(m_didRequestCommit); |
1148 } | 1149 } |
1149 | 1150 |
1150 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1151 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1151 { | 1152 { |
1152 gfx::Size surfaceSize(10, 10); | 1153 gfx::Size surfaceSize(10, 10); |
1153 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 1154 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1154 root->setBounds(surfaceSize); | 1155 root->setBounds(surfaceSize); |
1155 root->setContentBounds(surfaceSize); | 1156 root->setContentBounds(surfaceSize); |
1156 root->addChild(createScrollableLayer(2, surfaceSize)); | 1157 root->addChild(createScrollableLayer(2, surfaceSize)); |
1157 m_hostImpl->setRootLayer(root.Pass()); | 1158 m_hostImpl->setRootLayer(root.Pass()); |
1158 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1159 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1159 initializeRendererAndDrawFrame(); | 1160 initializeRendererAndDrawFrame(); |
1160 | 1161 |
1161 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1162 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1162 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1163 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1163 m_hostImpl->scrollEnd(); | 1164 m_hostImpl->scrollEnd(); |
1164 EXPECT_TRUE(m_didRequestRedraw); | 1165 EXPECT_TRUE(m_didRequestRedraw); |
1165 EXPECT_TRUE(m_didRequestCommit); | 1166 EXPECT_TRUE(m_didRequestCommit); |
1166 } | 1167 } |
1167 | 1168 |
1168 TEST_P(LayerTreeHostImplTest, scrollMissesChild) | 1169 TEST_P(LayerTreeHostImplTest, scrollMissesChild) |
1169 { | 1170 { |
1170 gfx::Size surfaceSize(10, 10); | 1171 gfx::Size surfaceSize(10, 10); |
1171 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 1172 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1172 root->addChild(createScrollableLayer(2, surfaceSize)); | 1173 root->addChild(createScrollableLayer(2, surfaceSize)); |
1173 m_hostImpl->setRootLayer(root.Pass()); | 1174 m_hostImpl->setRootLayer(root.Pass()); |
1174 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1175 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1175 initializeRendererAndDrawFrame(); | 1176 initializeRendererAndDrawFrame(); |
1176 | 1177 |
1177 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1178 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
1178 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); | 1179 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); |
1179 EXPECT_FALSE(m_didRequestRedraw); | 1180 EXPECT_FALSE(m_didRequestRedraw); |
1180 EXPECT_FALSE(m_didRequestCommit); | 1181 EXPECT_FALSE(m_didRequestCommit); |
1181 } | 1182 } |
1182 | 1183 |
1183 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) | 1184 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) |
1184 { | 1185 { |
1185 gfx::Size surfaceSize(10, 10); | 1186 gfx::Size surfaceSize(10, 10); |
1186 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 1187 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1187 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1188 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1188 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1189 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1189 | 1190 |
1190 gfx::Transform matrix; | 1191 gfx::Transform matrix; |
1191 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); | 1192 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); |
1192 child->setTransform(matrix); | 1193 child->setTransform(matrix); |
1193 child->setDoubleSided(false); | 1194 child->setDoubleSided(false); |
1194 | 1195 |
1195 root->addChild(child.Pass()); | 1196 root->addChild(child.Pass()); |
1196 m_hostImpl->setRootLayer(root.Pass()); | 1197 m_hostImpl->setRootLayer(root.Pass()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale); | 1351 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale); |
1351 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale); | 1352 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale); |
1352 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale); | 1353 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale); |
1353 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale
); | 1354 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale
); |
1354 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale
); | 1355 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale
); |
1355 } | 1356 } |
1356 | 1357 |
1357 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1358 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
1358 { | 1359 { |
1359 gfx::Size surfaceSize(10, 10); | 1360 gfx::Size surfaceSize(10, 10); |
1360 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 1361 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1361 root->setBounds(surfaceSize); | 1362 root->setBounds(surfaceSize); |
1362 root->setContentBounds(surfaceSize); | 1363 root->setContentBounds(surfaceSize); |
1363 // Also mark the root scrollable so it becomes the root scroll layer. | 1364 // Also mark the root scrollable so it becomes the root scroll layer. |
1364 root->setScrollable(true); | 1365 root->setScrollable(true); |
1365 int scrollLayerId = 2; | 1366 int scrollLayerId = 2; |
1366 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1367 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1367 m_hostImpl->setRootLayer(root.Pass()); | 1368 m_hostImpl->setRootLayer(root.Pass()); |
1368 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1369 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1369 initializeRendererAndDrawFrame(); | 1370 initializeRendererAndDrawFrame(); |
1370 | 1371 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 } | 1627 } |
1627 | 1628 |
1628 bool blend() const { return m_blend; } | 1629 bool blend() const { return m_blend; } |
1629 | 1630 |
1630 private: | 1631 private: |
1631 bool m_blend; | 1632 bool m_blend; |
1632 }; | 1633 }; |
1633 | 1634 |
1634 class BlendStateCheckLayer : public LayerImpl { | 1635 class BlendStateCheckLayer : public LayerImpl { |
1635 public: | 1636 public: |
1636 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id, Res
ourceProvider* resourceProvider) { return scoped_ptr<LayerImpl>(new BlendStateCh
eckLayer(hostImpl, id, resourceProvider)); } | 1637 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id, Resourc
eProvider* resourceProvider) { return scoped_ptr<LayerImpl>(new BlendStateCheckL
ayer(treeImpl, id, resourceProvider)); } |
1637 | 1638 |
1638 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 1639 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE |
1639 { | 1640 { |
1640 m_quadsAppended = true; | 1641 m_quadsAppended = true; |
1641 | 1642 |
1642 gfx::Rect opaqueRect; | 1643 gfx::Rect opaqueRect; |
1643 if (contentsOpaque()) | 1644 if (contentsOpaque()) |
1644 opaqueRect = m_quadRect; | 1645 opaqueRect = m_quadRect; |
1645 else | 1646 else |
1646 opaqueRect = m_opaqueContentRect; | 1647 opaqueRect = m_opaqueContentRect; |
(...skipping 14 matching lines...) Expand all Loading... |
1661 m_quadsAppended = false; | 1662 m_quadsAppended = false; |
1662 } | 1663 } |
1663 | 1664 |
1664 bool quadsAppended() const { return m_quadsAppended; } | 1665 bool quadsAppended() const { return m_quadsAppended; } |
1665 | 1666 |
1666 void setQuadRect(const gfx::Rect& rect) { m_quadRect = rect; } | 1667 void setQuadRect(const gfx::Rect& rect) { m_quadRect = rect; } |
1667 void setQuadVisibleRect(const gfx::Rect& rect) { m_quadVisibleRect = rect; } | 1668 void setQuadVisibleRect(const gfx::Rect& rect) { m_quadVisibleRect = rect; } |
1668 void setOpaqueContentRect(const gfx::Rect& rect) { m_opaqueContentRect = rec
t; } | 1669 void setOpaqueContentRect(const gfx::Rect& rect) { m_opaqueContentRect = rec
t; } |
1669 | 1670 |
1670 private: | 1671 private: |
1671 BlendStateCheckLayer(LayerTreeHostImpl* hostImpl, int id, ResourceProvider*
resourceProvider) | 1672 BlendStateCheckLayer(LayerTreeImpl* treeImpl, int id, ResourceProvider* reso
urceProvider) |
1672 : LayerImpl(hostImpl, id) | 1673 : LayerImpl(treeImpl, id) |
1673 , m_blend(false) | 1674 , m_blend(false) |
1674 , m_hasRenderSurface(false) | 1675 , m_hasRenderSurface(false) |
1675 , m_quadsAppended(false) | 1676 , m_quadsAppended(false) |
1676 , m_quadRect(5, 5, 5, 5) | 1677 , m_quadRect(5, 5, 5, 5) |
1677 , m_quadVisibleRect(5, 5, 5, 5) | 1678 , m_quadVisibleRect(5, 5, 5, 5) |
1678 , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, g
fx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny)) | 1679 , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, g
fx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny)) |
1679 { | 1680 { |
1680 setAnchorPoint(gfx::PointF(0, 0)); | 1681 setAnchorPoint(gfx::PointF(0, 0)); |
1681 setBounds(gfx::Size(10, 10)); | 1682 setBounds(gfx::Size(10, 10)); |
1682 setContentBounds(gfx::Size(10, 10)); | 1683 setContentBounds(gfx::Size(10, 10)); |
1683 setDrawsContent(true); | 1684 setDrawsContent(true); |
1684 } | 1685 } |
1685 | 1686 |
1686 bool m_blend; | 1687 bool m_blend; |
1687 bool m_hasRenderSurface; | 1688 bool m_hasRenderSurface; |
1688 bool m_quadsAppended; | 1689 bool m_quadsAppended; |
1689 gfx::Rect m_quadRect; | 1690 gfx::Rect m_quadRect; |
1690 gfx::Rect m_opaqueContentRect; | 1691 gfx::Rect m_opaqueContentRect; |
1691 gfx::Rect m_quadVisibleRect; | 1692 gfx::Rect m_quadVisibleRect; |
1692 ResourceProvider::ResourceId m_resourceId; | 1693 ResourceProvider::ResourceId m_resourceId; |
1693 }; | 1694 }; |
1694 | 1695 |
1695 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1696 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1696 { | 1697 { |
1697 { | 1698 { |
1698 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.get(), 1); | 1699 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
1699 root->setAnchorPoint(gfx::PointF(0, 0)); | 1700 root->setAnchorPoint(gfx::PointF(0, 0)); |
1700 root->setBounds(gfx::Size(10, 10)); | 1701 root->setBounds(gfx::Size(10, 10)); |
1701 root->setContentBounds(root->bounds()); | 1702 root->setContentBounds(root->bounds()); |
1702 root->setDrawsContent(false); | 1703 root->setDrawsContent(false); |
1703 m_hostImpl->setRootLayer(root.Pass()); | 1704 m_hostImpl->setRootLayer(root.Pass()); |
1704 } | 1705 } |
1705 LayerImpl* root = m_hostImpl->rootLayer(); | 1706 LayerImpl* root = m_hostImpl->rootLayer(); |
1706 | 1707 |
1707 root->addChild(BlendStateCheckLayer::create(m_hostImpl.get(), 2, m_hostImpl-
>resourceProvider())); | 1708 root->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 2, m_h
ostImpl->resourceProvider())); |
1708 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); | 1709 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); |
1709 layer1->setPosition(gfx::PointF(2, 2)); | 1710 layer1->setPosition(gfx::PointF(2, 2)); |
1710 | 1711 |
1711 LayerTreeHostImpl::FrameData frame; | 1712 LayerTreeHostImpl::FrameData frame; |
1712 | 1713 |
1713 // Opaque layer, drawn without blending. | 1714 // Opaque layer, drawn without blending. |
1714 layer1->setContentsOpaque(true); | 1715 layer1->setContentsOpaque(true); |
1715 layer1->setExpectation(false, false); | 1716 layer1->setExpectation(false, false); |
1716 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1717 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1717 m_hostImpl->drawLayers(frame); | 1718 m_hostImpl->drawLayers(frame); |
(...skipping 19 matching lines...) Expand all Loading... |
1737 | 1738 |
1738 // Layer with translucent opacity and painting, drawn with blending. | 1739 // Layer with translucent opacity and painting, drawn with blending. |
1739 layer1->setContentsOpaque(true); | 1740 layer1->setContentsOpaque(true); |
1740 layer1->setOpacity(0.5); | 1741 layer1->setOpacity(0.5); |
1741 layer1->setExpectation(true, false); | 1742 layer1->setExpectation(true, false); |
1742 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1743 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1743 m_hostImpl->drawLayers(frame); | 1744 m_hostImpl->drawLayers(frame); |
1744 EXPECT_TRUE(layer1->quadsAppended()); | 1745 EXPECT_TRUE(layer1->quadsAppended()); |
1745 m_hostImpl->didDrawAllLayers(frame); | 1746 m_hostImpl->didDrawAllLayers(frame); |
1746 | 1747 |
1747 layer1->addChild(BlendStateCheckLayer::create(m_hostImpl.get(), 3, m_hostImp
l->resourceProvider())); | 1748 layer1->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 3, m
_hostImpl->resourceProvider())); |
1748 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); | 1749 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); |
1749 layer2->setPosition(gfx::PointF(4, 4)); | 1750 layer2->setPosition(gfx::PointF(4, 4)); |
1750 | 1751 |
1751 // 2 opaque layers, drawn without blending. | 1752 // 2 opaque layers, drawn without blending. |
1752 layer1->setContentsOpaque(true); | 1753 layer1->setContentsOpaque(true); |
1753 layer1->setOpacity(1); | 1754 layer1->setOpacity(1); |
1754 layer1->setExpectation(false, false); | 1755 layer1->setExpectation(false, false); |
1755 layer2->setContentsOpaque(true); | 1756 layer2->setContentsOpaque(true); |
1756 layer2->setOpacity(1); | 1757 layer2->setOpacity(1); |
1757 layer2->setExpectation(false, false); | 1758 layer2->setExpectation(false, false); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 } | 1886 } |
1886 | 1887 |
1887 TEST_P(LayerTreeHostImplTest, viewportCovered) | 1888 TEST_P(LayerTreeHostImplTest, viewportCovered) |
1888 { | 1889 { |
1889 m_hostImpl->initializeRenderer(createOutputSurface()); | 1890 m_hostImpl->initializeRenderer(createOutputSurface()); |
1890 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1891 m_hostImpl->setBackgroundColor(SK_ColorGRAY); |
1891 | 1892 |
1892 gfx::Size viewportSize(1000, 1000); | 1893 gfx::Size viewportSize(1000, 1000); |
1893 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1894 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
1894 | 1895 |
1895 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl.get(), 1)); | 1896 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 1)); |
1896 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl.ge
t(), 2, m_hostImpl->resourceProvider())); | 1897 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl->a
ctiveTree(), 2, m_hostImpl->resourceProvider())); |
1897 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); | 1898 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); |
1898 child->setExpectation(false, false); | 1899 child->setExpectation(false, false); |
1899 child->setContentsOpaque(true); | 1900 child->setContentsOpaque(true); |
1900 | 1901 |
1901 // No gutter rects | 1902 // No gutter rects |
1902 { | 1903 { |
1903 gfx::Rect layerRect(0, 0, 1000, 1000); | 1904 gfx::Rect layerRect(0, 0, 1000, 1000); |
1904 child->setPosition(layerRect.origin()); | 1905 child->setPosition(layerRect.origin()); |
1905 child->setBounds(layerRect.size()); | 1906 child->setBounds(layerRect.size()); |
1906 child->setContentBounds(layerRect.size()); | 1907 child->setContentBounds(layerRect.size()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 } | 1981 } |
1981 | 1982 |
1982 bool reshapeCalled() const { return m_reshapeCalled; } | 1983 bool reshapeCalled() const { return m_reshapeCalled; } |
1983 | 1984 |
1984 private: | 1985 private: |
1985 bool m_reshapeCalled; | 1986 bool m_reshapeCalled; |
1986 }; | 1987 }; |
1987 | 1988 |
1988 class FakeDrawableLayerImpl: public LayerImpl { | 1989 class FakeDrawableLayerImpl: public LayerImpl { |
1989 public: | 1990 public: |
1990 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id) { r
eturn scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(hostImpl, id)); } | 1991 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(treeImpl, id)); } |
1991 protected: | 1992 protected: |
1992 FakeDrawableLayerImpl(LayerTreeHostImpl* hostImpl, int id) : LayerImpl(hostI
mpl, id) { } | 1993 FakeDrawableLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl,
id) { } |
1993 }; | 1994 }; |
1994 | 1995 |
1995 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1996 // Only reshape when we know we are going to draw. Otherwise, the reshape |
1996 // can leave the window at the wrong size if we never draw and the proper | 1997 // can leave the window at the wrong size if we never draw and the proper |
1997 // viewport size is never set. | 1998 // viewport size is never set. |
1998 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1999 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
1999 { | 2000 { |
2000 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); | 2001 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); |
2001 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->Context3D()); | 2002 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->Context3D()); |
2002 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2003 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
2003 | 2004 |
2004 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(),
1); | 2005 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); |
2005 root->setAnchorPoint(gfx::PointF(0, 0)); | 2006 root->setAnchorPoint(gfx::PointF(0, 0)); |
2006 root->setBounds(gfx::Size(10, 10)); | 2007 root->setBounds(gfx::Size(10, 10)); |
2007 root->setDrawsContent(true); | 2008 root->setDrawsContent(true); |
2008 m_hostImpl->setRootLayer(root.Pass()); | 2009 m_hostImpl->setRootLayer(root.Pass()); |
2009 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 2010 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
2010 | 2011 |
2011 LayerTreeHostImpl::FrameData frame; | 2012 LayerTreeHostImpl::FrameData frame; |
2012 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2013 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2013 m_hostImpl->drawLayers(frame); | 2014 m_hostImpl->drawLayers(frame); |
2014 EXPECT_TRUE(reshapeTracker->reshapeCalled()); | 2015 EXPECT_TRUE(reshapeTracker->reshapeCalled()); |
(...skipping 29 matching lines...) Expand all Loading... |
2044 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->Context3D()); | 2045 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->Context3D()); |
2045 | 2046 |
2046 // This test creates its own LayerTreeHostImpl, so | 2047 // This test creates its own LayerTreeHostImpl, so |
2047 // that we can force partial swap enabled. | 2048 // that we can force partial swap enabled. |
2048 LayerTreeSettings settings; | 2049 LayerTreeSettings settings; |
2049 settings.partialSwapEnabled = true; | 2050 settings.partialSwapEnabled = true; |
2050 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); | 2051 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
2051 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2052 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
2052 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 2053 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
2053 | 2054 |
2054 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(layerTreeHostImpl
.get(), 1); | 2055 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(layerTreeHostImpl
->activeTree(), 1); |
2055 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(layerTreeHostImp
l.get(), 2); | 2056 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(layerTreeHostImp
l->activeTree(), 2); |
2056 child->setPosition(gfx::PointF(12, 13)); | 2057 child->setPosition(gfx::PointF(12, 13)); |
2057 child->setAnchorPoint(gfx::PointF(0, 0)); | 2058 child->setAnchorPoint(gfx::PointF(0, 0)); |
2058 child->setBounds(gfx::Size(14, 15)); | 2059 child->setBounds(gfx::Size(14, 15)); |
2059 child->setContentBounds(gfx::Size(14, 15)); | 2060 child->setContentBounds(gfx::Size(14, 15)); |
2060 child->setDrawsContent(true); | 2061 child->setDrawsContent(true); |
2061 root->setAnchorPoint(gfx::PointF(0, 0)); | 2062 root->setAnchorPoint(gfx::PointF(0, 0)); |
2062 root->setBounds(gfx::Size(500, 500)); | 2063 root->setBounds(gfx::Size(500, 500)); |
2063 root->setContentBounds(gfx::Size(500, 500)); | 2064 root->setContentBounds(gfx::Size(500, 500)); |
2064 root->setDrawsContent(true); | 2065 root->setDrawsContent(true); |
2065 root->addChild(child.Pass()); | 2066 root->addChild(child.Pass()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 actualSwapRect = partialSwapTracker->partialSwapRect(); | 2108 actualSwapRect = partialSwapTracker->partialSwapRect(); |
2108 expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(10, 10)); | 2109 expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(10, 10)); |
2109 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 2110 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
2110 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 2111 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
2111 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 2112 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
2112 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 2113 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
2113 } | 2114 } |
2114 | 2115 |
2115 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 2116 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
2116 { | 2117 { |
2117 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(),
1); | 2118 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); |
2118 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(m_hostImpl.get()
, 2); | 2119 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(m_hostImpl->acti
veTree(), 2); |
2119 child->setAnchorPoint(gfx::PointF(0, 0)); | 2120 child->setAnchorPoint(gfx::PointF(0, 0)); |
2120 child->setBounds(gfx::Size(10, 10)); | 2121 child->setBounds(gfx::Size(10, 10)); |
2121 child->setContentBounds(gfx::Size(10, 10)); | 2122 child->setContentBounds(gfx::Size(10, 10)); |
2122 child->setDrawsContent(true); | 2123 child->setDrawsContent(true); |
2123 root->setAnchorPoint(gfx::PointF(0, 0)); | 2124 root->setAnchorPoint(gfx::PointF(0, 0)); |
2124 root->setBounds(gfx::Size(10, 10)); | 2125 root->setBounds(gfx::Size(10, 10)); |
2125 root->setContentBounds(gfx::Size(10, 10)); | 2126 root->setContentBounds(gfx::Size(10, 10)); |
2126 root->setDrawsContent(true); | 2127 root->setDrawsContent(true); |
2127 root->setOpacity(0.7f); | 2128 root->setOpacity(0.7f); |
2128 root->addChild(child.Pass()); | 2129 root->addChild(child.Pass()); |
2129 | 2130 |
2130 m_hostImpl->setRootLayer(root.Pass()); | 2131 m_hostImpl->setRootLayer(root.Pass()); |
2131 | 2132 |
2132 LayerTreeHostImpl::FrameData frame; | 2133 LayerTreeHostImpl::FrameData frame; |
2133 | 2134 |
2134 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2135 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2135 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2136 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
2136 EXPECT_EQ(1u, frame.renderPasses.size()); | 2137 EXPECT_EQ(1u, frame.renderPasses.size()); |
2137 m_hostImpl->didDrawAllLayers(frame); | 2138 m_hostImpl->didDrawAllLayers(frame); |
2138 } | 2139 } |
2139 | 2140 |
2140 } // namespace | 2141 } // namespace |
2141 | 2142 |
2142 class FakeLayerWithQuads : public LayerImpl { | 2143 class FakeLayerWithQuads : public LayerImpl { |
2143 public: | 2144 public: |
2144 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id) { r
eturn scoped_ptr<LayerImpl>(new FakeLayerWithQuads(hostImpl, id)); } | 2145 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeLayerWithQuads(treeImpl, id)); } |
2145 | 2146 |
2146 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 2147 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE |
2147 { | 2148 { |
2148 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); | 2149 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); |
2149 | 2150 |
2150 SkColor gray = SkColorSetRGB(100, 100, 100); | 2151 SkColor gray = SkColorSetRGB(100, 100, 100); |
2151 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds()); | 2152 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds()); |
2152 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::Create(); | 2153 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::Create(); |
2153 myQuad->SetNew(sharedQuadState, quadRect, gray); | 2154 myQuad->SetNew(sharedQuadState, quadRect, gray); |
2154 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); | 2155 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); |
2155 } | 2156 } |
2156 | 2157 |
2157 private: | 2158 private: |
2158 FakeLayerWithQuads(LayerTreeHostImpl* hostImpl, int id) | 2159 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id) |
2159 : LayerImpl(hostImpl, id) | 2160 : LayerImpl(treeImpl, id) |
2160 { | 2161 { |
2161 } | 2162 } |
2162 }; | 2163 }; |
2163 | 2164 |
2164 namespace { | 2165 namespace { |
2165 | 2166 |
2166 class MockContext : public FakeWebGraphicsContext3D { | 2167 class MockContext : public FakeWebGraphicsContext3D { |
2167 public: | 2168 public: |
2168 MOCK_METHOD1(useProgram, void(WebGLId program)); | 2169 MOCK_METHOD1(useProgram, void(WebGLId program)); |
2169 MOCK_METHOD5(uniform4f, void(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y,
WGC3Dfloat z, WGC3Dfloat w)); | 2170 MOCK_METHOD5(uniform4f, void(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y,
WGC3Dfloat z, WGC3Dfloat w)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 }; | 2255 }; |
2255 | 2256 |
2256 TEST_P(LayerTreeHostImplTest, noPartialSwap) | 2257 TEST_P(LayerTreeHostImplTest, noPartialSwap) |
2257 { | 2258 { |
2258 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2259 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
2259 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); | 2260 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); |
2260 MockContextHarness harness(mockContext); | 2261 MockContextHarness harness(mockContext); |
2261 | 2262 |
2262 // Run test case | 2263 // Run test case |
2263 createLayerTreeHost(false, outputSurface.Pass()); | 2264 createLayerTreeHost(false, outputSurface.Pass()); |
2264 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl.get(), 1)); | 2265 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); |
2265 | 2266 |
2266 // without partial swap, and no clipping, no scissor is set. | 2267 // without partial swap, and no clipping, no scissor is set. |
2267 harness.mustDrawSolidQuad(); | 2268 harness.mustDrawSolidQuad(); |
2268 harness.mustSetNoScissor(); | 2269 harness.mustSetNoScissor(); |
2269 { | 2270 { |
2270 LayerTreeHostImpl::FrameData frame; | 2271 LayerTreeHostImpl::FrameData frame; |
2271 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2272 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2272 m_hostImpl->drawLayers(frame); | 2273 m_hostImpl->drawLayers(frame); |
2273 m_hostImpl->didDrawAllLayers(frame); | 2274 m_hostImpl->didDrawAllLayers(frame); |
2274 } | 2275 } |
(...skipping 12 matching lines...) Expand all Loading... |
2287 Mock::VerifyAndClearExpectations(&mockContext); | 2288 Mock::VerifyAndClearExpectations(&mockContext); |
2288 } | 2289 } |
2289 | 2290 |
2290 TEST_P(LayerTreeHostImplTest, partialSwap) | 2291 TEST_P(LayerTreeHostImplTest, partialSwap) |
2291 { | 2292 { |
2292 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2293 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
2293 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); | 2294 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); |
2294 MockContextHarness harness(mockContext); | 2295 MockContextHarness harness(mockContext); |
2295 | 2296 |
2296 createLayerTreeHost(true, outputSurface.Pass()); | 2297 createLayerTreeHost(true, outputSurface.Pass()); |
2297 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl.get(), 1)); | 2298 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); |
2298 | 2299 |
2299 // The first frame is not a partially-swapped one. | 2300 // The first frame is not a partially-swapped one. |
2300 harness.mustSetScissor(0, 0, 10, 10); | 2301 harness.mustSetScissor(0, 0, 10, 10); |
2301 harness.mustDrawSolidQuad(); | 2302 harness.mustDrawSolidQuad(); |
2302 { | 2303 { |
2303 LayerTreeHostImpl::FrameData frame; | 2304 LayerTreeHostImpl::FrameData frame; |
2304 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2305 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2305 m_hostImpl->drawLayers(frame); | 2306 m_hostImpl->drawLayers(frame); |
2306 m_hostImpl->didDrawAllLayers(frame); | 2307 m_hostImpl->didDrawAllLayers(frame); |
2307 } | 2308 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 | | | 3 | | 2366 | | | 3 | |
2366 | | +-------------------+ | 2367 | | +-------------------+ |
2367 | | | | | 2368 | | | | |
2368 | +-----------+ | | 2369 | +-----------+ | |
2369 | | | 2370 | | |
2370 | | | 2371 | | |
2371 +--------------------+ | 2372 +--------------------+ |
2372 | 2373 |
2373 Layers 1, 2 have render surfaces | 2374 Layers 1, 2 have render surfaces |
2374 */ | 2375 */ |
2375 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 2376 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
2376 scoped_ptr<LayerImpl> child = LayerImpl::create(myHostImpl.get(), 2); | 2377 scoped_ptr<LayerImpl> child = LayerImpl::create(myHostImpl->activeTree(), 2)
; |
2377 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(myHostImpl.get
(), 3); | 2378 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(myHostImpl->ac
tiveTree(), 3); |
2378 | 2379 |
2379 gfx::Rect rootRect(0, 0, 100, 100); | 2380 gfx::Rect rootRect(0, 0, 100, 100); |
2380 gfx::Rect childRect(10, 10, 50, 50); | 2381 gfx::Rect childRect(10, 10, 50, 50); |
2381 gfx::Rect grandChildRect(5, 5, 150, 150); | 2382 gfx::Rect grandChildRect(5, 5, 150, 150); |
2382 | 2383 |
2383 root->createRenderSurface(); | 2384 root->createRenderSurface(); |
2384 root->setAnchorPoint(gfx::PointF(0, 0)); | 2385 root->setAnchorPoint(gfx::PointF(0, 0)); |
2385 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 2386 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
2386 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 2387 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
2387 root->setContentBounds(root->bounds()); | 2388 root->setContentBounds(root->bounds()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); | 2449 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); |
2449 | 2450 |
2450 myHostImpl->drawLayers(frame); | 2451 myHostImpl->drawLayers(frame); |
2451 myHostImpl->didDrawAllLayers(frame); | 2452 myHostImpl->didDrawAllLayers(frame); |
2452 } | 2453 } |
2453 } | 2454 } |
2454 | 2455 |
2455 // Make sure that output surface lost notifications are propagated through the t
ree. | 2456 // Make sure that output surface lost notifications are propagated through the t
ree. |
2456 class OutputSurfaceLostNotificationCheckLayer : public LayerImpl { | 2457 class OutputSurfaceLostNotificationCheckLayer : public LayerImpl { |
2457 public: | 2458 public: |
2458 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id) { r
eturn scoped_ptr<LayerImpl>(new OutputSurfaceLostNotificationCheckLayer(hostImpl
, id)); } | 2459 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new OutputSurfaceLostNotificationCheckLayer(treeImpl, id
)); } |
2459 | 2460 |
2460 virtual void didLoseOutputSurface() OVERRIDE | 2461 virtual void didLoseOutputSurface() OVERRIDE |
2461 { | 2462 { |
2462 m_didLoseOutputSurfaceCalled = true; | 2463 m_didLoseOutputSurfaceCalled = true; |
2463 } | 2464 } |
2464 | 2465 |
2465 bool didLoseOutputSurfaceCalled() const { return m_didLoseOutputSurfaceCalle
d; } | 2466 bool didLoseOutputSurfaceCalled() const { return m_didLoseOutputSurfaceCalle
d; } |
2466 | 2467 |
2467 private: | 2468 private: |
2468 OutputSurfaceLostNotificationCheckLayer(LayerTreeHostImpl* hostImpl, int id) | 2469 OutputSurfaceLostNotificationCheckLayer(LayerTreeImpl* treeImpl, int id) |
2469 : LayerImpl(hostImpl, id) | 2470 : LayerImpl(treeImpl, id) |
2470 , m_didLoseOutputSurfaceCalled(false) | 2471 , m_didLoseOutputSurfaceCalled(false) |
2471 { | 2472 { |
2472 } | 2473 } |
2473 | 2474 |
2474 bool m_didLoseOutputSurfaceCalled; | 2475 bool m_didLoseOutputSurfaceCalled; |
2475 }; | 2476 }; |
2476 | 2477 |
2477 TEST_P(LayerTreeHostImplTest, outputSurfaceLostAndRestoredNotificationSentToAllL
ayers) | 2478 TEST_P(LayerTreeHostImplTest, outputSurfaceLostAndRestoredNotificationSentToAllL
ayers) |
2478 { | 2479 { |
2479 m_hostImpl->setRootLayer(OutputSurfaceLostNotificationCheckLayer::create(m_h
ostImpl.get(), 1)); | 2480 m_hostImpl->setRootLayer(OutputSurfaceLostNotificationCheckLayer::create(m_h
ostImpl->activeTree(), 1)); |
2480 OutputSurfaceLostNotificationCheckLayer* root = static_cast<OutputSurfaceLos
tNotificationCheckLayer*>(m_hostImpl->rootLayer()); | 2481 OutputSurfaceLostNotificationCheckLayer* root = static_cast<OutputSurfaceLos
tNotificationCheckLayer*>(m_hostImpl->rootLayer()); |
2481 | 2482 |
2482 root->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl.ge
t(), 1)); | 2483 root->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl->a
ctiveTree(), 1)); |
2483 OutputSurfaceLostNotificationCheckLayer* layer1 = static_cast<OutputSurfaceL
ostNotificationCheckLayer*>(root->children()[0]); | 2484 OutputSurfaceLostNotificationCheckLayer* layer1 = static_cast<OutputSurfaceL
ostNotificationCheckLayer*>(root->children()[0]); |
2484 | 2485 |
2485 layer1->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl.
get(), 2)); | 2486 layer1->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl-
>activeTree(), 2)); |
2486 OutputSurfaceLostNotificationCheckLayer* layer2 = static_cast<OutputSurfaceL
ostNotificationCheckLayer*>(layer1->children()[0]); | 2487 OutputSurfaceLostNotificationCheckLayer* layer2 = static_cast<OutputSurfaceL
ostNotificationCheckLayer*>(layer1->children()[0]); |
2487 | 2488 |
2488 EXPECT_FALSE(root->didLoseOutputSurfaceCalled()); | 2489 EXPECT_FALSE(root->didLoseOutputSurfaceCalled()); |
2489 EXPECT_FALSE(layer1->didLoseOutputSurfaceCalled()); | 2490 EXPECT_FALSE(layer1->didLoseOutputSurfaceCalled()); |
2490 EXPECT_FALSE(layer2->didLoseOutputSurfaceCalled()); | 2491 EXPECT_FALSE(layer2->didLoseOutputSurfaceCalled()); |
2491 | 2492 |
2492 m_hostImpl->initializeRenderer(createOutputSurface()); | 2493 m_hostImpl->initializeRenderer(createOutputSurface()); |
2493 | 2494 |
2494 EXPECT_TRUE(root->didLoseOutputSurfaceCalled()); | 2495 EXPECT_TRUE(root->didLoseOutputSurfaceCalled()); |
2495 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled()); | 2496 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled()); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT
rack, WebRect& thumb, WebRect& endTrack) OVERRIDE | 2736 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT
rack, WebRect& thumb, WebRect& endTrack) OVERRIDE |
2736 { | 2737 { |
2737 thumb = WebRect(0, 5, 5, 2); | 2738 thumb = WebRect(0, 5, 5, 2); |
2738 startTrack = WebRect(0, 5, 0, 5); | 2739 startTrack = WebRect(0, 5, 0, 5); |
2739 endTrack = WebRect(0, 0, 0, 5); | 2740 endTrack = WebRect(0, 0, 0, 5); |
2740 } | 2741 } |
2741 }; | 2742 }; |
2742 | 2743 |
2743 class FakeScrollbarLayerImpl : public ScrollbarLayerImpl { | 2744 class FakeScrollbarLayerImpl : public ScrollbarLayerImpl { |
2744 public: | 2745 public: |
2745 static scoped_ptr<FakeScrollbarLayerImpl> create(LayerTreeHostImpl* hostImpl
, int id) | 2746 static scoped_ptr<FakeScrollbarLayerImpl> create(LayerTreeImpl* treeImpl, in
t id) |
2746 { | 2747 { |
2747 return make_scoped_ptr(new FakeScrollbarLayerImpl(hostImpl, id)); | 2748 return make_scoped_ptr(new FakeScrollbarLayerImpl(treeImpl, id)); |
2748 } | 2749 } |
2749 | 2750 |
2750 void createResources(ResourceProvider* provider) | 2751 void createResources(ResourceProvider* provider) |
2751 { | 2752 { |
2752 DCHECK(provider); | 2753 DCHECK(provider); |
2753 int pool = 0; | 2754 int pool = 0; |
2754 gfx::Size size(10, 10); | 2755 gfx::Size size(10, 10); |
2755 GLenum format = GL_RGBA; | 2756 GLenum format = GL_RGBA; |
2756 ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsage
Any; | 2757 ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsage
Any; |
2757 setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollba
rThemeGeometryNonEmpty::create())); | 2758 setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollba
rThemeGeometryNonEmpty::create())); |
2758 | 2759 |
2759 setBackTrackResourceId(provider->createResource(pool, size, format, hint
)); | 2760 setBackTrackResourceId(provider->createResource(pool, size, format, hint
)); |
2760 setForeTrackResourceId(provider->createResource(pool, size, format, hint
)); | 2761 setForeTrackResourceId(provider->createResource(pool, size, format, hint
)); |
2761 setThumbResourceId(provider->createResource(pool, size, format, hint)); | 2762 setThumbResourceId(provider->createResource(pool, size, format, hint)); |
2762 } | 2763 } |
2763 | 2764 |
2764 protected: | 2765 protected: |
2765 FakeScrollbarLayerImpl(LayerTreeHostImpl* hostImpl, int id) | 2766 FakeScrollbarLayerImpl(LayerTreeImpl* treeImpl, int id) |
2766 : ScrollbarLayerImpl(hostImpl, id) | 2767 : ScrollbarLayerImpl(treeImpl, id) |
2767 { | 2768 { |
2768 } | 2769 } |
2769 }; | 2770 }; |
2770 | 2771 |
2771 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
er* provider) | 2772 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
er* provider) |
2772 { | 2773 { |
2773 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S
ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); | 2774 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S
ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); |
2774 | 2775 |
2775 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 2776 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
2776 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1,
1), gfx::Transform()); | 2777 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1,
1), gfx::Transform()); |
2777 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); | 2778 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); |
2778 sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0,
1, 1), gfx::Rect(0, 0, 1, 1), false, 1); | 2779 sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0,
1, 1), gfx::Rect(0, 0, 1, 1), false, 1); |
2779 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 2780 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
2780 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)
, resourceId, false, gfx::RectF(0, 0, 1, 1), false); | 2781 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)
, resourceId, false, gfx::RectF(0, 0, 1, 1), false); |
2781 | 2782 |
2782 pass->AppendSharedQuadState(sharedState.Pass()); | 2783 pass->AppendSharedQuadState(sharedState.Pass()); |
2783 pass->AppendQuad(quad.PassAs<DrawQuad>()); | 2784 pass->AppendQuad(quad.PassAs<DrawQuad>()); |
2784 | 2785 |
2785 return pass.PassAs<RenderPass>(); | 2786 return pass.PassAs<RenderPass>(); |
2786 } | 2787 } |
2787 | 2788 |
2788 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) | 2789 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) |
2789 { | 2790 { |
2790 int layerId = 1; | 2791 int layerId = 1; |
2791 | 2792 |
2792 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl.get(), layerId+
+)); | 2793 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(),
layerId++)); |
2793 rootLayer->setBounds(gfx::Size(10, 10)); | 2794 rootLayer->setBounds(gfx::Size(10, 10)); |
2794 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2795 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2795 | 2796 |
2796 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(m_hostImpl.get
(), layerId++); | 2797 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(m_hostImpl->ac
tiveTree(), layerId++); |
2797 tileLayer->setBounds(gfx::Size(10, 10)); | 2798 tileLayer->setBounds(gfx::Size(10, 10)); |
2798 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2799 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2799 tileLayer->setContentBounds(gfx::Size(10, 10)); | 2800 tileLayer->setContentBounds(gfx::Size(10, 10)); |
2800 tileLayer->setDrawsContent(true); | 2801 tileLayer->setDrawsContent(true); |
2801 tileLayer->setSkipsDraw(false); | 2802 tileLayer->setSkipsDraw(false); |
2802 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); | 2803 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); |
2803 tilingData->setBounds(gfx::Size(10, 10)); | 2804 tilingData->setBounds(gfx::Size(10, 10)); |
2804 tileLayer->setTilingData(*tilingData); | 2805 tileLayer->setTilingData(*tilingData); |
2805 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); | 2806 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
2806 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); | 2807 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); |
2807 | 2808 |
2808 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(m_hostI
mpl.get(), layerId++); | 2809 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(m_hostI
mpl->activeTree(), layerId++); |
2809 textureLayer->setBounds(gfx::Size(10, 10)); | 2810 textureLayer->setBounds(gfx::Size(10, 10)); |
2810 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2811 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2811 textureLayer->setContentBounds(gfx::Size(10, 10)); | 2812 textureLayer->setContentBounds(gfx::Size(10, 10)); |
2812 textureLayer->setDrawsContent(true); | 2813 textureLayer->setDrawsContent(true); |
2813 textureLayer->setTextureId(StrictWebGraphicsContext3D::kExternalTextureId); | 2814 textureLayer->setTextureId(StrictWebGraphicsContext3D::kExternalTextureId); |
2814 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 2815 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
2815 | 2816 |
2816 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(m_hostImpl.get
(), layerId++); | 2817 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(m_hostImpl->ac
tiveTree(), layerId++); |
2817 maskLayer->setBounds(gfx::Size(10, 10)); | 2818 maskLayer->setBounds(gfx::Size(10, 10)); |
2818 maskLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2819 maskLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2819 maskLayer->setContentBounds(gfx::Size(10, 10)); | 2820 maskLayer->setContentBounds(gfx::Size(10, 10)); |
2820 maskLayer->setDrawsContent(true); | 2821 maskLayer->setDrawsContent(true); |
2821 maskLayer->setSkipsDraw(false); | 2822 maskLayer->setSkipsDraw(false); |
2822 maskLayer->setTilingData(*tilingData); | 2823 maskLayer->setTilingData(*tilingData); |
2823 maskLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); | 2824 maskLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
2824 | 2825 |
2825 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create
(m_hostImpl.get(), layerId++); | 2826 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create
(m_hostImpl->activeTree(), layerId++); |
2826 textureLayerWithMask->setBounds(gfx::Size(10, 10)); | 2827 textureLayerWithMask->setBounds(gfx::Size(10, 10)); |
2827 textureLayerWithMask->setAnchorPoint(gfx::PointF(0, 0)); | 2828 textureLayerWithMask->setAnchorPoint(gfx::PointF(0, 0)); |
2828 textureLayerWithMask->setContentBounds(gfx::Size(10, 10)); | 2829 textureLayerWithMask->setContentBounds(gfx::Size(10, 10)); |
2829 textureLayerWithMask->setDrawsContent(true); | 2830 textureLayerWithMask->setDrawsContent(true); |
2830 textureLayerWithMask->setTextureId(StrictWebGraphicsContext3D::kExternalText
ureId); | 2831 textureLayerWithMask->setTextureId(StrictWebGraphicsContext3D::kExternalText
ureId); |
2831 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); | 2832 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); |
2832 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); | 2833 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); |
2833 | 2834 |
2834 FakeVideoFrame videoFrame(VideoFrame::CreateColorFrame(gfx::Size(4, 4), | 2835 FakeVideoFrame videoFrame(VideoFrame::CreateColorFrame(gfx::Size(4, 4), |
2835 0x80, 0x80, 0x80, | 2836 0x80, 0x80, 0x80, |
2836 base::TimeDelta())); | 2837 base::TimeDelta())); |
2837 VideoLayerImpl::FrameUnwrapper unwrapper = | 2838 VideoLayerImpl::FrameUnwrapper unwrapper = |
2838 base::Bind(FakeVideoFrame::toVideoFrame); | 2839 base::Bind(FakeVideoFrame::toVideoFrame); |
2839 FakeVideoFrameProvider provider; | 2840 FakeVideoFrameProvider provider; |
2840 provider.setFrame(&videoFrame); | 2841 provider.setFrame(&videoFrame); |
2841 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(m_hostImpl.ge
t(), layerId++, &provider, unwrapper); | 2842 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(m_hostImpl->a
ctiveTree(), layerId++, &provider, unwrapper); |
2842 videoLayer->setBounds(gfx::Size(10, 10)); | 2843 videoLayer->setBounds(gfx::Size(10, 10)); |
2843 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2844 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2844 videoLayer->setContentBounds(gfx::Size(10, 10)); | 2845 videoLayer->setContentBounds(gfx::Size(10, 10)); |
2845 videoLayer->setDrawsContent(true); | 2846 videoLayer->setDrawsContent(true); |
2846 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2847 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2847 | 2848 |
2848 FakeVideoFrameProvider providerScaled; | 2849 FakeVideoFrameProvider providerScaled; |
2849 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(m_hostI
mpl.get(), layerId++, &providerScaled, unwrapper); | 2850 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(m_hostI
mpl->activeTree(), layerId++, &providerScaled, unwrapper); |
2850 videoLayerScaled->setBounds(gfx::Size(10, 10)); | 2851 videoLayerScaled->setBounds(gfx::Size(10, 10)); |
2851 videoLayerScaled->setAnchorPoint(gfx::PointF(0, 0)); | 2852 videoLayerScaled->setAnchorPoint(gfx::PointF(0, 0)); |
2852 videoLayerScaled->setContentBounds(gfx::Size(10, 10)); | 2853 videoLayerScaled->setContentBounds(gfx::Size(10, 10)); |
2853 videoLayerScaled->setDrawsContent(true); | 2854 videoLayerScaled->setDrawsContent(true); |
2854 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); | 2855 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); |
2855 | 2856 |
2856 FakeVideoFrameProvider hwProvider; | 2857 FakeVideoFrameProvider hwProvider; |
2857 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(m_hostImpl.
get(), layerId++, &hwProvider, unwrapper); | 2858 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(m_hostImpl-
>activeTree(), layerId++, &hwProvider, unwrapper); |
2858 hwVideoLayer->setBounds(gfx::Size(10, 10)); | 2859 hwVideoLayer->setBounds(gfx::Size(10, 10)); |
2859 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2860 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2860 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); | 2861 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); |
2861 hwVideoLayer->setDrawsContent(true); | 2862 hwVideoLayer->setDrawsContent(true); |
2862 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); | 2863 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); |
2863 | 2864 |
2864 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl.get(), layerId++); | 2865 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl->activeTree(), layerId++); |
2865 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 2866 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
2866 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2867 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2867 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 2868 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
2868 ioSurfaceLayer->setDrawsContent(true); | 2869 ioSurfaceLayer->setDrawsContent(true); |
2869 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 2870 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
2870 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 2871 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
2871 | 2872 |
2872 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea
te(m_hostImpl.get(), layerId++); | 2873 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea
te(m_hostImpl->activeTree(), layerId++); |
2873 hudLayer->setBounds(gfx::Size(10, 10)); | 2874 hudLayer->setBounds(gfx::Size(10, 10)); |
2874 hudLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2875 hudLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2875 hudLayer->setContentBounds(gfx::Size(10, 10)); | 2876 hudLayer->setContentBounds(gfx::Size(10, 10)); |
2876 hudLayer->setDrawsContent(true); | 2877 hudLayer->setDrawsContent(true); |
2877 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); | 2878 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); |
2878 | 2879 |
2879 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr
eate(m_hostImpl.get(), layerId++)); | 2880 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr
eate(m_hostImpl->activeTree(), layerId++)); |
2880 scrollbarLayer->setBounds(gfx::Size(10, 10)); | 2881 scrollbarLayer->setBounds(gfx::Size(10, 10)); |
2881 scrollbarLayer->setContentBounds(gfx::Size(10, 10)); | 2882 scrollbarLayer->setContentBounds(gfx::Size(10, 10)); |
2882 scrollbarLayer->setDrawsContent(true); | 2883 scrollbarLayer->setDrawsContent(true); |
2883 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); | 2884 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); |
2884 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); | 2885 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); |
2885 | 2886 |
2886 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende
rerLayerImpl::create(m_hostImpl.get(), layerId++)); | 2887 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende
rerLayerImpl::create(m_hostImpl->activeTree(), layerId++)); |
2887 delegatedRendererLayer->setBounds(gfx::Size(10, 10)); | 2888 delegatedRendererLayer->setBounds(gfx::Size(10, 10)); |
2888 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); | 2889 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); |
2889 delegatedRendererLayer->setDrawsContent(true); | 2890 delegatedRendererLayer->setDrawsContent(true); |
2890 ScopedPtrVector<RenderPass> passList; | 2891 ScopedPtrVector<RenderPass> passList; |
2891 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); | 2892 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); |
2892 delegatedRendererLayer->setRenderPasses(passList); | 2893 delegatedRendererLayer->setRenderPasses(passList); |
2893 EXPECT_TRUE(passList.isEmpty()); | 2894 EXPECT_TRUE(passList.isEmpty()); |
2894 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2895 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
2895 | 2896 |
2896 // Use a context that supports IOSurfaces | 2897 // Use a context that supports IOSurfaces |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 | 2992 |
2992 unsigned numTextures() const { return m_numTextures; } | 2993 unsigned numTextures() const { return m_numTextures; } |
2993 | 2994 |
2994 private: | 2995 private: |
2995 base::hash_map<WebGLId, bool> m_textures; | 2996 base::hash_map<WebGLId, bool> m_textures; |
2996 unsigned m_numTextures; | 2997 unsigned m_numTextures; |
2997 }; | 2998 }; |
2998 | 2999 |
2999 TEST_P(LayerTreeHostImplTest, layersFreeTextures) | 3000 TEST_P(LayerTreeHostImplTest, layersFreeTextures) |
3000 { | 3001 { |
3001 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl.get(), 1)); | 3002 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(),
1)); |
3002 rootLayer->setBounds(gfx::Size(10, 10)); | 3003 rootLayer->setBounds(gfx::Size(10, 10)); |
3003 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3004 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3004 | 3005 |
3005 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(m_hostImpl.get
(), 2); | 3006 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(m_hostImpl->ac
tiveTree(), 2); |
3006 tileLayer->setBounds(gfx::Size(10, 10)); | 3007 tileLayer->setBounds(gfx::Size(10, 10)); |
3007 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3008 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3008 tileLayer->setContentBounds(gfx::Size(10, 10)); | 3009 tileLayer->setContentBounds(gfx::Size(10, 10)); |
3009 tileLayer->setDrawsContent(true); | 3010 tileLayer->setDrawsContent(true); |
3010 tileLayer->setSkipsDraw(false); | 3011 tileLayer->setSkipsDraw(false); |
3011 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); | 3012 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); |
3012 tilingData->setBounds(gfx::Size(10, 10)); | 3013 tilingData->setBounds(gfx::Size(10, 10)); |
3013 tileLayer->setTilingData(*tilingData); | 3014 tileLayer->setTilingData(*tilingData); |
3014 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); | 3015 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
3015 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); | 3016 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); |
3016 | 3017 |
3017 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(m_hostI
mpl.get(), 3); | 3018 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(m_hostI
mpl->activeTree(), 3); |
3018 textureLayer->setBounds(gfx::Size(10, 10)); | 3019 textureLayer->setBounds(gfx::Size(10, 10)); |
3019 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3020 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3020 textureLayer->setContentBounds(gfx::Size(10, 10)); | 3021 textureLayer->setContentBounds(gfx::Size(10, 10)); |
3021 textureLayer->setDrawsContent(true); | 3022 textureLayer->setDrawsContent(true); |
3022 textureLayer->setTextureId(1); | 3023 textureLayer->setTextureId(1); |
3023 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 3024 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
3024 | 3025 |
3025 VideoLayerImpl::FrameUnwrapper unwrapper = | 3026 VideoLayerImpl::FrameUnwrapper unwrapper = |
3026 base::Bind(FakeVideoFrame::toVideoFrame); | 3027 base::Bind(FakeVideoFrame::toVideoFrame); |
3027 FakeVideoFrameProvider provider; | 3028 FakeVideoFrameProvider provider; |
3028 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(m_hostImpl.ge
t(), 4, &provider, unwrapper); | 3029 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(m_hostImpl->a
ctiveTree(), 4, &provider, unwrapper); |
3029 videoLayer->setBounds(gfx::Size(10, 10)); | 3030 videoLayer->setBounds(gfx::Size(10, 10)); |
3030 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3031 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3031 videoLayer->setContentBounds(gfx::Size(10, 10)); | 3032 videoLayer->setContentBounds(gfx::Size(10, 10)); |
3032 videoLayer->setDrawsContent(true); | 3033 videoLayer->setDrawsContent(true); |
3033 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 3034 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
3034 | 3035 |
3035 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl.get(), 5); | 3036 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl->activeTree(), 5); |
3036 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 3037 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
3037 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3038 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3038 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 3039 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
3039 ioSurfaceLayer->setDrawsContent(true); | 3040 ioSurfaceLayer->setDrawsContent(true); |
3040 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 3041 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
3041 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 3042 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
3042 | 3043 |
3043 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon
text3D (which the LayerTreeHostImpl takes ownership of). | 3044 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon
text3D (which the LayerTreeHostImpl takes ownership of). |
3044 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); | 3045 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); |
3045 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra
ckingWebGraphicsContext3D*>(outputSurface->Context3D()); | 3046 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra
ckingWebGraphicsContext3D*>(outputSurface->Context3D()); |
3046 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 3047 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
3047 | 3048 |
3048 m_hostImpl->setRootLayer(rootLayer.Pass()); | 3049 m_hostImpl->setRootLayer(rootLayer.Pass()); |
3049 | 3050 |
3050 LayerTreeHostImpl::FrameData frame; | 3051 LayerTreeHostImpl::FrameData frame; |
3051 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 3052 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
3052 m_hostImpl->drawLayers(frame); | 3053 m_hostImpl->drawLayers(frame); |
3053 m_hostImpl->didDrawAllLayers(frame); | 3054 m_hostImpl->didDrawAllLayers(frame); |
3054 m_hostImpl->swapBuffers(); | 3055 m_hostImpl->swapBuffers(); |
3055 | 3056 |
3056 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u); | 3057 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u); |
3057 | 3058 |
3058 // Kill the layer tree. | 3059 // Kill the layer tree. |
3059 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl.get(), 100)); | 3060 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 100)); |
3060 // There should be no textures left in use after. | 3061 // There should be no textures left in use after. |
3061 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures()); | 3062 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures()); |
3062 } | 3063 } |
3063 | 3064 |
3064 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 3065 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
3065 public: | 3066 public: |
3066 MOCK_METHOD1(useProgram, void(WebGLId program)); | 3067 MOCK_METHOD1(useProgram, void(WebGLId program)); |
3067 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 3068 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); |
3068 }; | 3069 }; |
3069 | 3070 |
3070 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) | 3071 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) |
3071 { | 3072 { |
3072 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); | 3073 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); |
3073 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); | 3074 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); |
3074 | 3075 |
3075 // Run test case | 3076 // Run test case |
3076 createLayerTreeHost(false, outputSurface.Pass()); | 3077 createLayerTreeHost(false, outputSurface.Pass()); |
3077 setupRootLayerImpl(LayerImpl::create(m_hostImpl.get(), 1)); | 3078 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); |
3078 m_hostImpl->setBackgroundColor(SK_ColorWHITE); | 3079 m_hostImpl->setBackgroundColor(SK_ColorWHITE); |
3079 | 3080 |
3080 // Verify one quad is drawn when transparent background set is not set. | 3081 // Verify one quad is drawn when transparent background set is not set. |
3081 m_hostImpl->setHasTransparentBackground(false); | 3082 m_hostImpl->setHasTransparentBackground(false); |
3082 EXPECT_CALL(*mockContext, useProgram(_)) | 3083 EXPECT_CALL(*mockContext, useProgram(_)) |
3083 .Times(1); | 3084 .Times(1); |
3084 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) | 3085 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) |
3085 .Times(1); | 3086 .Times(1); |
3086 LayerTreeHostImpl::FrameData frame; | 3087 LayerTreeHostImpl::FrameData frame; |
3087 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 3088 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
3088 m_hostImpl->drawLayers(frame); | 3089 m_hostImpl->drawLayers(frame); |
3089 m_hostImpl->didDrawAllLayers(frame); | 3090 m_hostImpl->didDrawAllLayers(frame); |
3090 Mock::VerifyAndClearExpectations(&mockContext); | 3091 Mock::VerifyAndClearExpectations(&mockContext); |
3091 | 3092 |
3092 // Verify no quads are drawn when transparent background is set. | 3093 // Verify no quads are drawn when transparent background is set. |
3093 m_hostImpl->setHasTransparentBackground(true); | 3094 m_hostImpl->setHasTransparentBackground(true); |
3094 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 3095 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
3095 m_hostImpl->drawLayers(frame); | 3096 m_hostImpl->drawLayers(frame); |
3096 m_hostImpl->didDrawAllLayers(frame); | 3097 m_hostImpl->didDrawAllLayers(frame); |
3097 Mock::VerifyAndClearExpectations(&mockContext); | 3098 Mock::VerifyAndClearExpectations(&mockContext); |
3098 } | 3099 } |
3099 | 3100 |
3100 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) | 3101 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) |
3101 { | 3102 { |
3102 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeHo
stImpl(), id); | 3103 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeIm
pl(), id); |
3103 LayerImpl* layerPtr = layer.get(); | 3104 LayerImpl* layerPtr = layer.get(); |
3104 layerPtr->setAnchorPoint(gfx::PointF(0, 0)); | 3105 layerPtr->setAnchorPoint(gfx::PointF(0, 0)); |
3105 layerPtr->setPosition(gfx::PointF(layerRect.origin())); | 3106 layerPtr->setPosition(gfx::PointF(layerRect.origin())); |
3106 layerPtr->setBounds(layerRect.size()); | 3107 layerPtr->setBounds(layerRect.size()); |
3107 layerPtr->setContentBounds(layerRect.size()); | 3108 layerPtr->setContentBounds(layerRect.size()); |
3108 layerPtr->setDrawsContent(true); // only children draw content | 3109 layerPtr->setDrawsContent(true); // only children draw content |
3109 layerPtr->setContentsOpaque(true); | 3110 layerPtr->setContentsOpaque(true); |
3110 parent->addChild(layer.Pass()); | 3111 parent->addChild(layer.Pass()); |
3111 if (result) | 3112 if (result) |
3112 *result = layerPtr; | 3113 *result = layerPtr; |
3113 } | 3114 } |
3114 | 3115 |
3115 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) | 3116 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) |
3116 { | 3117 { |
3117 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3118 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3118 | 3119 |
3119 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 3120 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
3120 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 3121 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
3121 | 3122 |
3122 scoped_ptr<LayerImpl> root = LayerImpl::create(layerTreeHostImpl, 1); | 3123 scoped_ptr<LayerImpl> root = LayerImpl::create(layerTreeHostImpl->activeTree
(), 1); |
3123 rootPtr = root.get(); | 3124 rootPtr = root.get(); |
3124 | 3125 |
3125 root->setAnchorPoint(gfx::PointF(0, 0)); | 3126 root->setAnchorPoint(gfx::PointF(0, 0)); |
3126 root->setPosition(gfx::PointF(0, 0)); | 3127 root->setPosition(gfx::PointF(0, 0)); |
3127 root->setBounds(rootSize); | 3128 root->setBounds(rootSize); |
3128 root->setContentBounds(rootSize); | 3129 root->setContentBounds(rootSize); |
3129 root->setDrawsContent(true); | 3130 root->setDrawsContent(true); |
3130 layerTreeHostImpl->setRootLayer(root.Pass()); | 3131 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass()); |
3131 | 3132 |
3132 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); | 3133 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); |
3133 intermediateLayerPtr->setDrawsContent(false); // only children draw content | 3134 intermediateLayerPtr->setDrawsContent(false); // only children draw content |
3134 | 3135 |
3135 // Surface layer is the layer that changes its opacity | 3136 // Surface layer is the layer that changes its opacity |
3136 // It will contain other layers that draw content. | 3137 // It will contain other layers that draw content. |
3137 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); | 3138 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); |
3138 surfaceLayerPtr->setDrawsContent(false); // only children draw content | 3139 surfaceLayerPtr->setDrawsContent(false); // only children draw content |
3139 surfaceLayerPtr->setOpacity(0.5f); | 3140 surfaceLayerPtr->setOpacity(0.5f); |
3140 surfaceLayerPtr->setForceRenderSurface(true); // This will cause it to have
a surface | 3141 surfaceLayerPtr->setForceRenderSurface(true); // This will cause it to have
a surface |
(...skipping 17 matching lines...) Expand all Loading... |
3158 LayerImpl* rootPtr; | 3159 LayerImpl* rootPtr; |
3159 LayerImpl* surfaceLayerPtr; | 3160 LayerImpl* surfaceLayerPtr; |
3160 | 3161 |
3161 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3162 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3162 | 3163 |
3163 gfx::Size rootSize(100, 100); | 3164 gfx::Size rootSize(100, 100); |
3164 | 3165 |
3165 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3166 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3166 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3167 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3167 | 3168 |
3168 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3169 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3169 rootPtr = root.get(); | 3170 rootPtr = root.get(); |
3170 | 3171 |
3171 root->setAnchorPoint(gfx::PointF(0, 0)); | 3172 root->setAnchorPoint(gfx::PointF(0, 0)); |
3172 root->setPosition(gfx::PointF(0, 0)); | 3173 root->setPosition(gfx::PointF(0, 0)); |
3173 root->setBounds(rootSize); | 3174 root->setBounds(rootSize); |
3174 root->setContentBounds(rootSize); | 3175 root->setContentBounds(rootSize); |
3175 root->setDrawsContent(true); | 3176 root->setDrawsContent(true); |
3176 root->setMasksToBounds(true); | 3177 root->setMasksToBounds(true); |
3177 myHostImpl->setRootLayer(root.Pass()); | 3178 myHostImpl->setRootLayer(root.Pass()); |
3178 | 3179 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3269 LayerImpl* layerS1Ptr; | 3270 LayerImpl* layerS1Ptr; |
3270 LayerImpl* layerS2Ptr; | 3271 LayerImpl* layerS2Ptr; |
3271 | 3272 |
3272 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3273 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3273 | 3274 |
3274 gfx::Size rootSize(1000, 1000); | 3275 gfx::Size rootSize(1000, 1000); |
3275 | 3276 |
3276 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3277 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3277 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3278 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3278 | 3279 |
3279 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3280 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3280 rootPtr = root.get(); | 3281 rootPtr = root.get(); |
3281 | 3282 |
3282 root->setAnchorPoint(gfx::PointF(0, 0)); | 3283 root->setAnchorPoint(gfx::PointF(0, 0)); |
3283 root->setPosition(gfx::PointF(0, 0)); | 3284 root->setPosition(gfx::PointF(0, 0)); |
3284 root->setBounds(rootSize); | 3285 root->setBounds(rootSize); |
3285 root->setContentBounds(rootSize); | 3286 root->setContentBounds(rootSize); |
3286 root->setDrawsContent(true); | 3287 root->setDrawsContent(true); |
3287 root->setMasksToBounds(true); | 3288 root->setMasksToBounds(true); |
3288 myHostImpl->setRootLayer(root.Pass()); | 3289 myHostImpl->setRootLayer(root.Pass()); |
3289 | 3290 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3380 LayerImpl* layerS1Ptr; | 3381 LayerImpl* layerS1Ptr; |
3381 LayerImpl* layerS2Ptr; | 3382 LayerImpl* layerS2Ptr; |
3382 | 3383 |
3383 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3384 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3384 | 3385 |
3385 gfx::Size rootSize(1000, 1000); | 3386 gfx::Size rootSize(1000, 1000); |
3386 | 3387 |
3387 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3388 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3388 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3389 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3389 | 3390 |
3390 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3391 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3391 rootPtr = root.get(); | 3392 rootPtr = root.get(); |
3392 | 3393 |
3393 root->setAnchorPoint(gfx::PointF(0, 0)); | 3394 root->setAnchorPoint(gfx::PointF(0, 0)); |
3394 root->setPosition(gfx::PointF(0, 0)); | 3395 root->setPosition(gfx::PointF(0, 0)); |
3395 root->setBounds(rootSize); | 3396 root->setBounds(rootSize); |
3396 root->setContentBounds(rootSize); | 3397 root->setContentBounds(rootSize); |
3397 root->setDrawsContent(true); | 3398 root->setDrawsContent(true); |
3398 root->setMasksToBounds(true); | 3399 root->setMasksToBounds(true); |
3399 myHostImpl->setRootLayer(root.Pass()); | 3400 myHostImpl->setRootLayer(root.Pass()); |
3400 | 3401 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3492 LayerImpl* layerS1Ptr; | 3493 LayerImpl* layerS1Ptr; |
3493 LayerImpl* layerS2Ptr; | 3494 LayerImpl* layerS2Ptr; |
3494 | 3495 |
3495 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3496 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3496 | 3497 |
3497 gfx::Size rootSize(1000, 1000); | 3498 gfx::Size rootSize(1000, 1000); |
3498 | 3499 |
3499 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3500 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3500 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3501 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3501 | 3502 |
3502 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3503 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3503 rootPtr = root.get(); | 3504 rootPtr = root.get(); |
3504 | 3505 |
3505 root->setAnchorPoint(gfx::PointF(0, 0)); | 3506 root->setAnchorPoint(gfx::PointF(0, 0)); |
3506 root->setPosition(gfx::PointF(0, 0)); | 3507 root->setPosition(gfx::PointF(0, 0)); |
3507 root->setBounds(rootSize); | 3508 root->setBounds(rootSize); |
3508 root->setContentBounds(rootSize); | 3509 root->setContentBounds(rootSize); |
3509 root->setDrawsContent(true); | 3510 root->setDrawsContent(true); |
3510 root->setMasksToBounds(true); | 3511 root->setMasksToBounds(true); |
3511 myHostImpl->setRootLayer(root.Pass()); | 3512 myHostImpl->setRootLayer(root.Pass()); |
3512 | 3513 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3573 LayerImpl* rootPtr; | 3574 LayerImpl* rootPtr; |
3574 LayerImpl* layerS1Ptr; | 3575 LayerImpl* layerS1Ptr; |
3575 | 3576 |
3576 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3577 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3577 | 3578 |
3578 gfx::Size rootSize(1000, 1000); | 3579 gfx::Size rootSize(1000, 1000); |
3579 | 3580 |
3580 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3581 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3581 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3582 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3582 | 3583 |
3583 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3584 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3584 rootPtr = root.get(); | 3585 rootPtr = root.get(); |
3585 | 3586 |
3586 root->setAnchorPoint(gfx::PointF(0, 0)); | 3587 root->setAnchorPoint(gfx::PointF(0, 0)); |
3587 root->setPosition(gfx::PointF(0, 0)); | 3588 root->setPosition(gfx::PointF(0, 0)); |
3588 root->setBounds(rootSize); | 3589 root->setBounds(rootSize); |
3589 root->setContentBounds(rootSize); | 3590 root->setContentBounds(rootSize); |
3590 root->setDrawsContent(true); | 3591 root->setDrawsContent(true); |
3591 root->setMasksToBounds(true); | 3592 root->setMasksToBounds(true); |
3592 myHostImpl->setRootLayer(root.Pass()); | 3593 myHostImpl->setRootLayer(root.Pass()); |
3593 | 3594 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3657 LayerImpl* layerS1Ptr; | 3658 LayerImpl* layerS1Ptr; |
3658 LayerImpl* layerS2Ptr; | 3659 LayerImpl* layerS2Ptr; |
3659 | 3660 |
3660 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3661 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3661 | 3662 |
3662 gfx::Size rootSize(1000, 1000); | 3663 gfx::Size rootSize(1000, 1000); |
3663 | 3664 |
3664 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3665 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3665 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3666 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3666 | 3667 |
3667 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3668 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3668 rootPtr = root.get(); | 3669 rootPtr = root.get(); |
3669 | 3670 |
3670 root->setAnchorPoint(gfx::PointF(0, 0)); | 3671 root->setAnchorPoint(gfx::PointF(0, 0)); |
3671 root->setPosition(gfx::PointF(0, 0)); | 3672 root->setPosition(gfx::PointF(0, 0)); |
3672 root->setBounds(rootSize); | 3673 root->setBounds(rootSize); |
3673 root->setContentBounds(rootSize); | 3674 root->setContentBounds(rootSize); |
3674 root->setDrawsContent(true); | 3675 root->setDrawsContent(true); |
3675 root->setMasksToBounds(true); | 3676 root->setMasksToBounds(true); |
3676 myHostImpl->setRootLayer(root.Pass()); | 3677 myHostImpl->setRootLayer(root.Pass()); |
3677 | 3678 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3761 | | | 3 | | 3762 | | | 3 | |
3762 | | +-------------------+ | 3763 | | +-------------------+ |
3763 | | | | | 3764 | | | | |
3764 | +-----------+ | | 3765 | +-----------+ | |
3765 | | | 3766 | | |
3766 | | | 3767 | | |
3767 +--------------------+ | 3768 +--------------------+ |
3768 | 3769 |
3769 Layers 1, 2 have render surfaces | 3770 Layers 1, 2 have render surfaces |
3770 */ | 3771 */ |
3771 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); | 3772 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3772 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(myHostImpl.get(),
2); | 3773 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(myHostImpl->active
Tree(), 2); |
3773 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(myHostImpl.get(), 3); | 3774 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(myHostImpl->activeTree(
), 3); |
3774 | 3775 |
3775 gfx::Rect rootRect(0, 0, 100, 100); | 3776 gfx::Rect rootRect(0, 0, 100, 100); |
3776 gfx::Rect childRect(10, 10, 50, 50); | 3777 gfx::Rect childRect(10, 10, 50, 50); |
3777 gfx::Rect grandChildRect(5, 5, 150, 150); | 3778 gfx::Rect grandChildRect(5, 5, 150, 150); |
3778 | 3779 |
3779 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3780 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
3780 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3781 myHostImpl->initializeRenderer(outputSurface.Pass()); |
3781 | 3782 |
3782 root->setAnchorPoint(gfx::PointF(0, 0)); | 3783 root->setAnchorPoint(gfx::PointF(0, 0)); |
3783 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 3784 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4928 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4929 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4929 drawFrameAndTestDamage(noDamage); | 4930 drawFrameAndTestDamage(noDamage); |
4930 } | 4931 } |
4931 | 4932 |
4932 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4933 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4933 LayerTreeHostImplTest, | 4934 LayerTreeHostImplTest, |
4934 ::testing::Values(false, true)); | 4935 ::testing::Values(false, true)); |
4935 | 4936 |
4936 } // namespace | 4937 } // namespace |
4937 } // namespace cc | 4938 } // namespace cc |
OLD | NEW |