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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698