OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
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 21 matching lines...) Expand all Loading... |
32 #include "cc/test/test_common.h" | 32 #include "cc/test/test_common.h" |
33 #include "cc/texture_draw_quad.h" | 33 #include "cc/texture_draw_quad.h" |
34 #include "cc/texture_layer_impl.h" | 34 #include "cc/texture_layer_impl.h" |
35 #include "cc/tile_draw_quad.h" | 35 #include "cc/tile_draw_quad.h" |
36 #include "cc/tiled_layer_impl.h" | 36 #include "cc/tiled_layer_impl.h" |
37 #include "cc/video_layer_impl.h" | 37 #include "cc/video_layer_impl.h" |
38 #include "media/base/media.h" | 38 #include "media/base/media.h" |
39 #include "media/base/video_frame.h" | 39 #include "media/base/video_frame.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "ui/gfx/size_conversions.h" |
42 #include <public/WebVideoFrame.h> | 43 #include <public/WebVideoFrame.h> |
43 #include <public/WebVideoFrameProvider.h> | 44 #include <public/WebVideoFrameProvider.h> |
44 | 45 |
45 using namespace cc; | 46 using namespace cc; |
46 using namespace LayerTestCommon; | 47 using namespace LayerTestCommon; |
47 using namespace WebKit; | 48 using namespace WebKit; |
48 using namespace WebKitTests; | 49 using namespace WebKitTests; |
49 | 50 |
50 using media::VideoFrame; | 51 using media::VideoFrame; |
51 using ::testing::Mock; | 52 using ::testing::Mock; |
(...skipping 15 matching lines...) Expand all Loading... |
67 , m_didRequestRedraw(false) | 68 , m_didRequestRedraw(false) |
68 , m_reduceMemoryResult(true) | 69 , m_reduceMemoryResult(true) |
69 { | 70 { |
70 media::InitializeMediaLibraryForTesting(); | 71 media::InitializeMediaLibraryForTesting(); |
71 } | 72 } |
72 | 73 |
73 virtual void SetUp() | 74 virtual void SetUp() |
74 { | 75 { |
75 Settings::setPageScalePinchZoomEnabled(GetParam()); | 76 Settings::setPageScalePinchZoomEnabled(GetParam()); |
76 LayerTreeSettings settings; | 77 LayerTreeSettings settings; |
77 settings.minimumOcclusionTrackingSize = IntSize(); | 78 settings.minimumOcclusionTrackingSize = gfx::Size(); |
78 | 79 |
79 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 80 m_hostImpl = LayerTreeHostImpl::create(settings, this); |
80 m_hostImpl->initializeRenderer(createContext()); | 81 m_hostImpl->initializeRenderer(createContext()); |
81 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 82 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
82 } | 83 } |
83 | 84 |
84 virtual void TearDown() | 85 virtual void TearDown() |
85 { | 86 { |
86 } | 87 } |
87 | 88 |
88 virtual void didLoseContextOnImplThread() OVERRIDE { } | 89 virtual void didLoseContextOnImplThread() OVERRIDE { } |
89 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 90 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
90 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 91 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
91 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 92 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
92 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 93 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
93 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 94 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
94 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 95 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
95 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } | 96 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } |
96 virtual void sendManagedMemoryStats() OVERRIDE { } | 97 virtual void sendManagedMemoryStats() OVERRIDE { } |
97 | 98 |
98 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } | 99 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } |
99 | 100 |
100 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) | 101 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) |
101 { | 102 { |
102 Settings::setPartialSwapEnabled(partialSwap); | 103 Settings::setPartialSwapEnabled(partialSwap); |
103 | 104 |
104 LayerTreeSettings settings; | 105 LayerTreeSettings settings; |
105 settings.minimumOcclusionTrackingSize = IntSize(); | 106 settings.minimumOcclusionTrackingSize = gfx::Size(); |
106 | 107 |
107 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this); | 108 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this); |
108 | 109 |
109 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 110 myHostImpl->initializeRenderer(graphicsContext.Pass()); |
110 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 111 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
111 | 112 |
112 root->setAnchorPoint(FloatPoint(0, 0)); | 113 root->setAnchorPoint(gfx::PointF(0, 0)); |
113 root->setPosition(FloatPoint(0, 0)); | 114 root->setPosition(gfx::PointF(0, 0)); |
114 root->setBounds(IntSize(10, 10)); | 115 root->setBounds(gfx::Size(10, 10)); |
115 root->setContentBounds(IntSize(10, 10)); | 116 root->setContentBounds(gfx::Size(10, 10)); |
116 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); | 117 root->setVisibleContentRect(gfx::Rect(0, 0, 10, 10)); |
117 root->setDrawsContent(true); | 118 root->setDrawsContent(true); |
118 myHostImpl->setRootLayer(root.Pass()); | 119 myHostImpl->setRootLayer(root.Pass()); |
119 return myHostImpl.Pass(); | 120 return myHostImpl.Pass(); |
120 } | 121 } |
121 | 122 |
122 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) | 123 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) |
123 { | 124 { |
124 ASSERT_EQ(layer->scrollDelta(), IntSize()); | 125 ASSERT_EQ(layer->scrollDelta(), IntSize()); |
125 for (size_t i = 0; i < layer->children().size(); ++i) | 126 for (size_t i = 0; i < layer->children().size(); ++i) |
126 expectClearedScrollDeltasRecursive(layer->children()[i]); | 127 expectClearedScrollDeltasRecursive(layer->children()[i]); |
127 } | 128 } |
128 | 129 |
129 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons
t IntSize& scrollDelta) | 130 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons
t IntSize& scrollDelta) |
130 { | 131 { |
131 int timesEncountered = 0; | 132 int timesEncountered = 0; |
132 | 133 |
133 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { | 134 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { |
134 if (scrollInfo.scrolls[i].layerId != id) | 135 if (scrollInfo.scrolls[i].layerId != id) |
135 continue; | 136 continue; |
136 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid
th()); | 137 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid
th()); |
137 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he
ight()); | 138 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he
ight()); |
138 timesEncountered++; | 139 timesEncountered++; |
139 } | 140 } |
140 | 141 |
141 ASSERT_EQ(timesEncountered, 1); | 142 ASSERT_EQ(timesEncountered, 1); |
142 } | 143 } |
143 | 144 |
144 void setupScrollAndContentsLayers(const IntSize& contentSize) | 145 void setupScrollAndContentsLayers(const gfx::Size& contentSize) |
145 { | 146 { |
146 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 147 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
147 root->setScrollable(true); | 148 root->setScrollable(true); |
148 root->setScrollPosition(IntPoint(0, 0)); | 149 root->setScrollPosition(IntPoint(0, 0)); |
149 root->setMaxScrollPosition(contentSize); | 150 root->setMaxScrollPosition(cc::IntSize(contentSize)); |
150 root->setBounds(contentSize); | 151 root->setBounds(contentSize); |
151 root->setContentBounds(contentSize); | 152 root->setContentBounds(contentSize); |
152 root->setPosition(FloatPoint(0, 0)); | 153 root->setPosition(gfx::PointF(0, 0)); |
153 root->setAnchorPoint(FloatPoint(0, 0)); | 154 root->setAnchorPoint(gfx::PointF(0, 0)); |
154 | 155 |
155 scoped_ptr<LayerImpl> contents = LayerImpl::create(2); | 156 scoped_ptr<LayerImpl> contents = LayerImpl::create(2); |
156 contents->setDrawsContent(true); | 157 contents->setDrawsContent(true); |
157 contents->setBounds(contentSize); | 158 contents->setBounds(contentSize); |
158 contents->setContentBounds(contentSize); | 159 contents->setContentBounds(contentSize); |
159 contents->setPosition(FloatPoint(0, 0)); | 160 contents->setPosition(gfx::PointF(0, 0)); |
160 contents->setAnchorPoint(FloatPoint(0, 0)); | 161 contents->setAnchorPoint(gfx::PointF(0, 0)); |
161 root->addChild(contents.Pass()); | 162 root->addChild(contents.Pass()); |
162 m_hostImpl->setRootLayer(root.Pass()); | 163 m_hostImpl->setRootLayer(root.Pass()); |
163 } | 164 } |
164 | 165 |
165 static scoped_ptr<LayerImpl> createScrollableLayer(int id, const IntSize& si
ze) | 166 static scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size&
size) |
166 { | 167 { |
167 scoped_ptr<LayerImpl> layer = LayerImpl::create(id); | 168 scoped_ptr<LayerImpl> layer = LayerImpl::create(id); |
168 layer->setScrollable(true); | 169 layer->setScrollable(true); |
169 layer->setDrawsContent(true); | 170 layer->setDrawsContent(true); |
170 layer->setBounds(size); | 171 layer->setBounds(size); |
171 layer->setContentBounds(size); | 172 layer->setContentBounds(size); |
172 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2)
); | 173 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2)
); |
173 return layer.Pass(); | 174 return layer.Pass(); |
174 } | 175 } |
175 | 176 |
(...skipping 29 matching lines...) Expand all Loading... |
205 }; | 206 }; |
206 | 207 |
207 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged) | 208 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged) |
208 { | 209 { |
209 // Note: It is not possible to disable the renderer once it has been set, | 210 // Note: It is not possible to disable the renderer once it has been set, |
210 // so we do not need to test that disabling the renderer notifies us | 211 // so we do not need to test that disabling the renderer notifies us |
211 // that canDraw changed. | 212 // that canDraw changed. |
212 EXPECT_FALSE(m_hostImpl->canDraw()); | 213 EXPECT_FALSE(m_hostImpl->canDraw()); |
213 m_onCanDrawStateChangedCalled = false; | 214 m_onCanDrawStateChangedCalled = false; |
214 | 215 |
215 setupScrollAndContentsLayers(IntSize(100, 100)); | 216 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
216 EXPECT_TRUE(m_hostImpl->canDraw()); | 217 EXPECT_TRUE(m_hostImpl->canDraw()); |
217 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 218 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
218 m_onCanDrawStateChangedCalled = false; | 219 m_onCanDrawStateChangedCalled = false; |
219 | 220 |
220 // Toggle the root layer to make sure it toggles canDraw | 221 // Toggle the root layer to make sure it toggles canDraw |
221 m_hostImpl->setRootLayer(scoped_ptr<LayerImpl>()); | 222 m_hostImpl->setRootLayer(scoped_ptr<LayerImpl>()); |
222 EXPECT_FALSE(m_hostImpl->canDraw()); | 223 EXPECT_FALSE(m_hostImpl->canDraw()); |
223 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 224 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
224 m_onCanDrawStateChangedCalled = false; | 225 m_onCanDrawStateChangedCalled = false; |
225 | 226 |
226 setupScrollAndContentsLayers(IntSize(100, 100)); | 227 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
227 EXPECT_TRUE(m_hostImpl->canDraw()); | 228 EXPECT_TRUE(m_hostImpl->canDraw()); |
228 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 229 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
229 m_onCanDrawStateChangedCalled = false; | 230 m_onCanDrawStateChangedCalled = false; |
230 | 231 |
231 // Toggle the device viewport size to make sure it toggles canDraw. | 232 // Toggle the device viewport size to make sure it toggles canDraw. |
232 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(0, 0)); | 233 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(0, 0)); |
233 EXPECT_FALSE(m_hostImpl->canDraw()); | 234 EXPECT_FALSE(m_hostImpl->canDraw()); |
234 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 235 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
235 m_onCanDrawStateChangedCalled = false; | 236 m_onCanDrawStateChangedCalled = false; |
236 | 237 |
237 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 238 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
238 EXPECT_TRUE(m_hostImpl->canDraw()); | 239 EXPECT_TRUE(m_hostImpl->canDraw()); |
239 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 240 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
240 m_onCanDrawStateChangedCalled = false; | 241 m_onCanDrawStateChangedCalled = false; |
241 | 242 |
242 // Toggle contents textures purged without causing any evictions, | 243 // Toggle contents textures purged without causing any evictions, |
243 // and make sure that it does not change canDraw. | 244 // and make sure that it does not change canDraw. |
244 setReduceMemoryResult(false); | 245 setReduceMemoryResult(false); |
245 m_hostImpl->setManagedMemoryPolicy(ManagedMemoryPolicy( | 246 m_hostImpl->setManagedMemoryPolicy(ManagedMemoryPolicy( |
246 m_hostImpl->memoryAllocationLimitBytes() - 1)); | 247 m_hostImpl->memoryAllocationLimitBytes() - 1)); |
247 EXPECT_TRUE(m_hostImpl->canDraw()); | 248 EXPECT_TRUE(m_hostImpl->canDraw()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 325 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); |
325 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); | 326 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); |
326 | 327 |
327 root->scrollBy(IntSize()); | 328 root->scrollBy(IntSize()); |
328 scrollInfo = m_hostImpl->processScrollDeltas(); | 329 scrollInfo = m_hostImpl->processScrollDeltas(); |
329 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 330 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); |
330 } | 331 } |
331 | 332 |
332 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) | 333 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) |
333 { | 334 { |
334 setupScrollAndContentsLayers(IntSize(100, 100)); | 335 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
335 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 336 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
336 initializeRendererAndDrawFrame(); | 337 initializeRendererAndDrawFrame(); |
337 | 338 |
338 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 339 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
339 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 340 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
340 m_hostImpl->scrollEnd(); | 341 m_hostImpl->scrollEnd(); |
341 EXPECT_TRUE(m_didRequestRedraw); | 342 EXPECT_TRUE(m_didRequestRedraw); |
342 EXPECT_TRUE(m_didRequestCommit); | 343 EXPECT_TRUE(m_didRequestCommit); |
343 } | 344 } |
344 | 345 |
345 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) | 346 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) |
346 { | 347 { |
347 // We should not crash when trying to scroll an empty layer tree. | 348 // We should not crash when trying to scroll an empty layer tree. |
348 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 349 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); |
349 } | 350 } |
350 | 351 |
351 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) | 352 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) |
352 { | 353 { |
353 LayerTreeSettings settings; | 354 LayerTreeSettings settings; |
354 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 355 m_hostImpl = LayerTreeHostImpl::create(settings, this); |
355 | 356 |
356 // Initialization will fail here. | 357 // Initialization will fail here. |
357 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 358 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); |
358 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 359 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
359 | 360 |
360 setupScrollAndContentsLayers(IntSize(100, 100)); | 361 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
361 | 362 |
362 // We should not crash when trying to scroll after the renderer initializati
on fails. | 363 // We should not crash when trying to scroll after the renderer initializati
on fails. |
363 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 364 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); |
364 } | 365 } |
365 | 366 |
366 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) | 367 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) |
367 { | 368 { |
368 const int scrollLayerId = 1; | 369 const int scrollLayerId = 1; |
369 | 370 |
370 setupScrollAndContentsLayers(IntSize(100, 100)); | 371 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
371 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 372 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
372 initializeRendererAndDrawFrame(); | 373 initializeRendererAndDrawFrame(); |
373 | 374 |
374 // We should not crash if the tree is replaced while we are scrolling. | 375 // We should not crash if the tree is replaced while we are scrolling. |
375 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 376 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
376 m_hostImpl->detachLayerTree(); | 377 m_hostImpl->detachLayerTree(); |
377 | 378 |
378 setupScrollAndContentsLayers(IntSize(100, 100)); | 379 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
379 | 380 |
380 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. | 381 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. |
381 IntSize scrollDelta(0, 10); | 382 IntSize scrollDelta(0, 10); |
382 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 383 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
383 m_hostImpl->scrollEnd(); | 384 m_hostImpl->scrollEnd(); |
384 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 385 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
385 expectContains(*scrollInfo, scrollLayerId, scrollDelta); | 386 expectContains(*scrollInfo, scrollLayerId, scrollDelta); |
386 } | 387 } |
387 | 388 |
388 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) | 389 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) |
389 { | 390 { |
390 setupScrollAndContentsLayers(IntSize(100, 100)); | 391 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
391 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 392 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
392 initializeRendererAndDrawFrame(); | 393 initializeRendererAndDrawFrame(); |
393 | 394 |
394 // We should be able to scroll even if the root layer loses its render surfa
ce after the most | 395 // We should be able to scroll even if the root layer loses its render surfa
ce after the most |
395 // recent render. | 396 // recent render. |
396 m_hostImpl->rootLayer()->clearRenderSurface(); | 397 m_hostImpl->rootLayer()->clearRenderSurface(); |
397 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 398 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
398 } | 399 } |
399 | 400 |
400 TEST_P(LayerTreeHostImplTest, wheelEventHandlers) | 401 TEST_P(LayerTreeHostImplTest, wheelEventHandlers) |
401 { | 402 { |
402 setupScrollAndContentsLayers(IntSize(100, 100)); | 403 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
403 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 404 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
404 initializeRendererAndDrawFrame(); | 405 initializeRendererAndDrawFrame(); |
405 LayerImpl* root = m_hostImpl->rootLayer(); | 406 LayerImpl* root = m_hostImpl->rootLayer(); |
406 | 407 |
407 root->setHaveWheelEventHandlers(true); | 408 root->setHaveWheelEventHandlers(true); |
408 | 409 |
409 // With registered event handlers, wheel scrolls have to go to the main thre
ad. | 410 // With registered event handlers, wheel scrolls have to go to the main thre
ad. |
410 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); | 411 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); |
411 | 412 |
412 // But gesture scrolls can still be handled. | 413 // But gesture scrolls can still be handled. |
413 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); | 414 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); |
414 } | 415 } |
415 | 416 |
416 TEST_P(LayerTreeHostImplTest, shouldScrollOnMainThread) | 417 TEST_P(LayerTreeHostImplTest, shouldScrollOnMainThread) |
417 { | 418 { |
418 setupScrollAndContentsLayers(IntSize(100, 100)); | 419 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
419 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 420 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
420 initializeRendererAndDrawFrame(); | 421 initializeRendererAndDrawFrame(); |
421 LayerImpl* root = m_hostImpl->rootLayer(); | 422 LayerImpl* root = m_hostImpl->rootLayer(); |
422 | 423 |
423 root->setShouldScrollOnMainThread(true); | 424 root->setShouldScrollOnMainThread(true); |
424 | 425 |
425 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); | 426 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); |
426 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollOnMainThread); | 427 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollOnMainThread); |
427 } | 428 } |
428 | 429 |
429 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic) | 430 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic) |
430 { | 431 { |
431 setupScrollAndContentsLayers(IntSize(200, 200)); | 432 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
432 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 433 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
433 initializeRendererAndDrawFrame(); | 434 initializeRendererAndDrawFrame(); |
434 LayerImpl* root = m_hostImpl->rootLayer(); | 435 LayerImpl* root = m_hostImpl->rootLayer(); |
435 | 436 |
436 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); | 437 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); |
437 | 438 |
438 // All scroll types inside the non-fast scrollable region should fail. | 439 // All scroll types inside the non-fast scrollable region should fail. |
439 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 440 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
440 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollOnMainThread); | 441 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollOnMainThread); |
441 | 442 |
442 // All scroll types outside this region should succeed. | 443 // All scroll types outside this region should succeed. |
443 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 444 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
444 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 445 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
445 m_hostImpl->scrollEnd(); | 446 m_hostImpl->scrollEnd(); |
446 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 447 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
447 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 448 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
448 m_hostImpl->scrollEnd(); | 449 m_hostImpl->scrollEnd(); |
449 } | 450 } |
450 | 451 |
451 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) | 452 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) |
452 { | 453 { |
453 setupScrollAndContentsLayers(IntSize(200, 200)); | 454 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
454 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 455 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
455 LayerImpl* root = m_hostImpl->rootLayer(); | 456 LayerImpl* root = m_hostImpl->rootLayer(); |
456 | 457 |
457 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); | 458 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); |
458 root->setPosition(FloatPoint(-25, 0)); | 459 root->setPosition(gfx::PointF(-25, 0)); |
459 initializeRendererAndDrawFrame(); | 460 initializeRendererAndDrawFrame(); |
460 | 461 |
461 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. | 462 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. |
462 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 463 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
463 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1)); | 464 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1)); |
464 m_hostImpl->scrollEnd(); | 465 m_hostImpl->scrollEnd(); |
465 | 466 |
466 // This point is still inside the non-fast region. | 467 // This point is still inside the non-fast region. |
467 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 468 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
468 } | 469 } |
469 | 470 |
470 TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) | 471 TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) |
471 { | 472 { |
472 setupScrollAndContentsLayers(IntSize(100, 100)); | 473 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
473 | 474 |
474 float deviceScaleFactor = 2; | 475 float deviceScaleFactor = 2; |
475 IntSize layoutViewport(25, 25); | 476 gfx::Size layoutViewport(25, 25); |
476 IntSize deviceViewport(layoutViewport); | 477 gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScale
Factor))); |
477 deviceViewport.scale(deviceScaleFactor); | |
478 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); | 478 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); |
479 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 479 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
480 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); | 480 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); |
481 | 481 |
482 deviceScaleFactor = 1; | 482 deviceScaleFactor = 1; |
483 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); | 483 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); |
484 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 484 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
485 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); | 485 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); |
486 } | 486 } |
487 | 487 |
488 TEST_P(LayerTreeHostImplTest, implPinchZoom) | 488 TEST_P(LayerTreeHostImplTest, implPinchZoom) |
489 { | 489 { |
490 // This test is specific to the page-scale based pinch zoom. | 490 // This test is specific to the page-scale based pinch zoom. |
491 if (!Settings::pageScalePinchZoomEnabled()) | 491 if (!Settings::pageScalePinchZoomEnabled()) |
492 return; | 492 return; |
493 | 493 |
494 setupScrollAndContentsLayers(IntSize(100, 100)); | 494 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
495 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 495 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
496 initializeRendererAndDrawFrame(); | 496 initializeRendererAndDrawFrame(); |
497 | 497 |
498 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 498 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
499 DCHECK(scrollLayer); | 499 DCHECK(scrollLayer); |
500 | 500 |
501 const float minPageScale = 1, maxPageScale = 4; | 501 const float minPageScale = 1, maxPageScale = 4; |
502 const WebTransformationMatrix identityScaleTransform; | 502 const WebTransformationMatrix identityScaleTransform; |
503 | 503 |
504 // The impl-based pinch zoome should not adjust the max scroll position. | 504 // The impl-based pinch zoome should not adjust the max scroll position. |
505 { | 505 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 537 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
538 m_hostImpl->scrollEnd(); | 538 m_hostImpl->scrollEnd(); |
539 | 539 |
540 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 540 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
541 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 541 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 TEST_P(LayerTreeHostImplTest, pinchGesture) | 545 TEST_P(LayerTreeHostImplTest, pinchGesture) |
546 { | 546 { |
547 setupScrollAndContentsLayers(IntSize(100, 100)); | 547 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
548 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 548 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
549 initializeRendererAndDrawFrame(); | 549 initializeRendererAndDrawFrame(); |
550 | 550 |
551 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 551 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
552 DCHECK(scrollLayer); | 552 DCHECK(scrollLayer); |
553 | 553 |
554 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 554 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; |
555 const float maxPageScale = 4; | 555 const float maxPageScale = 4; |
556 const WebTransformationMatrix identityScaleTransform; | 556 const WebTransformationMatrix identityScaleTransform; |
557 | 557 |
558 // Basic pinch zoom in gesture | 558 // Basic pinch zoom in gesture |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 m_hostImpl->pinchGestureEnd(); | 624 m_hostImpl->pinchGestureEnd(); |
625 | 625 |
626 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 626 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
627 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 627 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
628 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); | 628 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); |
629 } | 629 } |
630 } | 630 } |
631 | 631 |
632 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) | 632 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) |
633 { | 633 { |
634 setupScrollAndContentsLayers(IntSize(100, 100)); | 634 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
635 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 635 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
636 initializeRendererAndDrawFrame(); | 636 initializeRendererAndDrawFrame(); |
637 | 637 |
638 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 638 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
639 DCHECK(scrollLayer); | 639 DCHECK(scrollLayer); |
640 | 640 |
641 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 641 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; |
642 const float maxPageScale = 4; | 642 const float maxPageScale = 4; |
643 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 643 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
644 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 644 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
645 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 645 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
(...skipping 30 matching lines...) Expand all Loading... |
676 | 676 |
677 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 677 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
678 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 678 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
679 // Pushed to (0,0) via clamping against contents layer size. | 679 // Pushed to (0,0) via clamping against contents layer size. |
680 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 680 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); |
681 } | 681 } |
682 } | 682 } |
683 | 683 |
684 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming) | 684 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming) |
685 { | 685 { |
686 setupScrollAndContentsLayers(IntSize(100, 100)); | 686 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
687 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 687 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
688 initializeRendererAndDrawFrame(); | 688 initializeRendererAndDrawFrame(); |
689 | 689 |
690 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 690 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
691 DCHECK(scrollLayer); | 691 DCHECK(scrollLayer); |
692 | 692 |
693 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 693 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; |
694 const float maxPageScale = 4; | 694 const float maxPageScale = 4; |
695 | 695 |
696 // Pinch zoom in. | 696 // Pinch zoom in. |
697 { | 697 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 745 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
746 } else { | 746 } else { |
747 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); | 747 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); |
748 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); | 748 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); |
749 } | 749 } |
750 } | 750 } |
751 } | 751 } |
752 | 752 |
753 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
Scale) | 753 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
Scale) |
754 { | 754 { |
755 setupScrollAndContentsLayers(IntSize(100, 100)); | 755 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
756 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 756 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
757 initializeRendererAndDrawFrame(); | 757 initializeRendererAndDrawFrame(); |
758 | 758 |
759 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 759 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
760 DCHECK(scrollLayer); | 760 DCHECK(scrollLayer); |
761 | 761 |
762 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 762 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; |
763 const float maxPageScale = 4; | 763 const float maxPageScale = 4; |
764 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 764 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
765 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 765 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
766 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 766 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 m_didDrawCalled = false; | 819 m_didDrawCalled = false; |
820 m_willDrawCalled = false; | 820 m_willDrawCalled = false; |
821 } | 821 } |
822 | 822 |
823 protected: | 823 protected: |
824 explicit DidDrawCheckLayer(int id) | 824 explicit DidDrawCheckLayer(int id) |
825 : TiledLayerImpl(id) | 825 : TiledLayerImpl(id) |
826 , m_didDrawCalled(false) | 826 , m_didDrawCalled(false) |
827 , m_willDrawCalled(false) | 827 , m_willDrawCalled(false) |
828 { | 828 { |
829 setAnchorPoint(FloatPoint(0, 0)); | 829 setAnchorPoint(gfx::PointF(0, 0)); |
830 setBounds(IntSize(10, 10)); | 830 setBounds(gfx::Size(10, 10)); |
831 setContentBounds(IntSize(10, 10)); | 831 setContentBounds(gfx::Size(10, 10)); |
832 setDrawsContent(true); | 832 setDrawsContent(true); |
833 setSkipsDraw(false); | 833 setSkipsDraw(false); |
834 setVisibleContentRect(IntRect(0, 0, 10, 10)); | 834 setVisibleContentRect(gfx::Rect(0, 0, 10, 10)); |
835 | 835 |
836 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(IntSize(100,
100), LayerTilingData::HasBorderTexels); | 836 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10
0, 100), LayerTilingData::HasBorderTexels); |
837 tiler->setBounds(contentBounds()); | 837 tiler->setBounds(contentBounds()); |
838 setTilingData(*tiler.get()); | 838 setTilingData(*tiler.get()); |
839 } | 839 } |
840 | 840 |
841 private: | 841 private: |
842 bool m_didDrawCalled; | 842 bool m_didDrawCalled; |
843 bool m_willDrawCalled; | 843 bool m_willDrawCalled; |
844 }; | 844 }; |
845 | 845 |
846 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 846 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
847 { | 847 { |
848 // The root layer is always drawn, so run this test on a child layer that | 848 // The root layer is always drawn, so run this test on a child layer that |
849 // will be masked out by the root layer's bounds. | 849 // will be masked out by the root layer's bounds. |
850 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 850 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
851 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 851 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
852 root->setMasksToBounds(true); | 852 root->setMasksToBounds(true); |
853 | 853 |
854 root->addChild(DidDrawCheckLayer::create(2)); | 854 root->addChild(DidDrawCheckLayer::create(2)); |
855 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); | 855 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); |
856 // Ensure visibleContentRect for layer is empty | 856 // Ensure visibleContentRect for layer is empty |
857 layer->setPosition(FloatPoint(100, 100)); | 857 layer->setPosition(gfx::PointF(100, 100)); |
858 layer->setBounds(IntSize(10, 10)); | 858 layer->setBounds(gfx::Size(10, 10)); |
859 layer->setContentBounds(IntSize(10, 10)); | 859 layer->setContentBounds(gfx::Size(10, 10)); |
860 | 860 |
861 LayerTreeHostImpl::FrameData frame; | 861 LayerTreeHostImpl::FrameData frame; |
862 | 862 |
863 EXPECT_FALSE(layer->willDrawCalled()); | 863 EXPECT_FALSE(layer->willDrawCalled()); |
864 EXPECT_FALSE(layer->didDrawCalled()); | 864 EXPECT_FALSE(layer->didDrawCalled()); |
865 | 865 |
866 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 866 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
867 m_hostImpl->drawLayers(frame); | 867 m_hostImpl->drawLayers(frame); |
868 m_hostImpl->didDrawAllLayers(frame); | 868 m_hostImpl->didDrawAllLayers(frame); |
869 | 869 |
870 EXPECT_FALSE(layer->willDrawCalled()); | 870 EXPECT_FALSE(layer->willDrawCalled()); |
871 EXPECT_FALSE(layer->didDrawCalled()); | 871 EXPECT_FALSE(layer->didDrawCalled()); |
872 | 872 |
873 EXPECT_TRUE(layer->visibleContentRect().isEmpty()); | 873 EXPECT_TRUE(layer->visibleContentRect().IsEmpty()); |
874 | 874 |
875 // Ensure visibleContentRect for layer layer is not empty | 875 // Ensure visibleContentRect for layer layer is not empty |
876 layer->setPosition(FloatPoint(0, 0)); | 876 layer->setPosition(gfx::PointF(0, 0)); |
877 | 877 |
878 EXPECT_FALSE(layer->willDrawCalled()); | 878 EXPECT_FALSE(layer->willDrawCalled()); |
879 EXPECT_FALSE(layer->didDrawCalled()); | 879 EXPECT_FALSE(layer->didDrawCalled()); |
880 | 880 |
881 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 881 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
882 m_hostImpl->drawLayers(frame); | 882 m_hostImpl->drawLayers(frame); |
883 m_hostImpl->didDrawAllLayers(frame); | 883 m_hostImpl->didDrawAllLayers(frame); |
884 | 884 |
885 EXPECT_TRUE(layer->willDrawCalled()); | 885 EXPECT_TRUE(layer->willDrawCalled()); |
886 EXPECT_TRUE(layer->didDrawCalled()); | 886 EXPECT_TRUE(layer->didDrawCalled()); |
887 | 887 |
888 EXPECT_FALSE(layer->visibleContentRect().isEmpty()); | 888 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); |
889 } | 889 } |
890 | 890 |
891 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 891 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
892 { | 892 { |
893 IntSize bigSize(1000, 1000); | 893 gfx::Size bigSize(1000, 1000); |
894 m_hostImpl->setViewportSize(bigSize, bigSize); | 894 m_hostImpl->setViewportSize(bigSize, bigSize); |
895 | 895 |
896 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 896 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
897 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 897 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
898 | 898 |
899 root->addChild(DidDrawCheckLayer::create(2)); | 899 root->addChild(DidDrawCheckLayer::create(2)); |
900 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); | 900 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); |
901 | 901 |
902 root->addChild(DidDrawCheckLayer::create(3)); | 902 root->addChild(DidDrawCheckLayer::create(3)); |
903 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); | 903 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 public: | 958 public: |
959 static scoped_ptr<LayerImpl> create(int id, bool tileMissing, bool skipsDraw
, bool animating, ResourceProvider* resourceProvider) | 959 static scoped_ptr<LayerImpl> create(int id, bool tileMissing, bool skipsDraw
, bool animating, ResourceProvider* resourceProvider) |
960 { | 960 { |
961 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(id, tileMi
ssing, skipsDraw, animating, resourceProvider)); | 961 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(id, tileMi
ssing, skipsDraw, animating, resourceProvider)); |
962 } | 962 } |
963 | 963 |
964 private: | 964 private: |
965 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr
aw, bool animating, ResourceProvider* resourceProvider) | 965 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr
aw, bool animating, ResourceProvider* resourceProvider) |
966 : DidDrawCheckLayer(id) | 966 : DidDrawCheckLayer(id) |
967 { | 967 { |
968 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(IntSize
(10, 10), LayerTilingData::NoBorderTexels); | 968 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(gfx::Si
ze(10, 10), LayerTilingData::NoBorderTexels); |
969 tilingData->setBounds(bounds()); | 969 tilingData->setBounds(bounds()); |
970 setTilingData(*tilingData.get()); | 970 setTilingData(*tilingData.get()); |
971 setSkipsDraw(skipsDraw); | 971 setSkipsDraw(skipsDraw); |
972 if (!tileMissing) { | 972 if (!tileMissing) { |
973 ResourceProvider::ResourceId resource = resourceProvider->createReso
urce(Renderer::ContentPool, IntSize(), GL_RGBA, ResourceProvider::TextureUsageAn
y); | 973 ResourceProvider::ResourceId resource = resourceProvider->createReso
urce(Renderer::ContentPool, gfx::Size(), GL_RGBA, ResourceProvider::TextureUsage
Any); |
974 pushTileProperties(0, 0, resource, IntRect(), false); | 974 pushTileProperties(0, 0, resource, gfx::Rect(), false); |
975 } | 975 } |
976 if (animating) | 976 if (animating) |
977 addAnimatedTransformToLayer(*this, 10, 3, 0); | 977 addAnimatedTransformToLayer(*this, 10, 3, 0); |
978 } | 978 } |
979 }; | 979 }; |
980 | 980 |
981 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 981 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
982 { | 982 { |
983 // When the texture is not missing, we draw as usual. | 983 // When the texture is not missing, we draw as usual. |
984 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 984 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 // Scroll event is ignored because layer is not scrollable. | 1029 // Scroll event is ignored because layer is not scrollable. |
1030 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 1030 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); |
1031 EXPECT_FALSE(m_didRequestRedraw); | 1031 EXPECT_FALSE(m_didRequestRedraw); |
1032 EXPECT_FALSE(m_didRequestCommit); | 1032 EXPECT_FALSE(m_didRequestCommit); |
1033 } | 1033 } |
1034 | 1034 |
1035 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) | 1035 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) |
1036 { | 1036 { |
1037 // Test the configuration where a non-composited root layer is embedded in a | 1037 // Test the configuration where a non-composited root layer is embedded in a |
1038 // scrollable outer layer. | 1038 // scrollable outer layer. |
1039 IntSize surfaceSize(10, 10); | 1039 gfx::Size surfaceSize(10, 10); |
1040 | 1040 |
1041 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(1); | 1041 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(1); |
1042 contentLayer->setUseLCDText(true); | 1042 contentLayer->setUseLCDText(true); |
1043 contentLayer->setDrawsContent(true); | 1043 contentLayer->setDrawsContent(true); |
1044 contentLayer->setPosition(FloatPoint(0, 0)); | 1044 contentLayer->setPosition(gfx::PointF(0, 0)); |
1045 contentLayer->setAnchorPoint(FloatPoint(0, 0)); | 1045 contentLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1046 contentLayer->setBounds(surfaceSize); | 1046 contentLayer->setBounds(surfaceSize); |
1047 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize.
height() * 2)); | 1047 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); |
1048 contentLayer->setContentsScale(2, 2); | 1048 contentLayer->setContentsScale(2, 2); |
1049 | 1049 |
1050 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2); | 1050 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2); |
1051 scrollLayer->setScrollable(true); | 1051 scrollLayer->setScrollable(true); |
1052 scrollLayer->setMaxScrollPosition(surfaceSize); | 1052 scrollLayer->setMaxScrollPosition(cc::IntSize(surfaceSize)); |
1053 scrollLayer->setBounds(surfaceSize); | 1053 scrollLayer->setBounds(surfaceSize); |
1054 scrollLayer->setContentBounds(surfaceSize); | 1054 scrollLayer->setContentBounds(surfaceSize); |
1055 scrollLayer->setPosition(FloatPoint(0, 0)); | 1055 scrollLayer->setPosition(gfx::PointF(0, 0)); |
1056 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); | 1056 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1057 scrollLayer->addChild(contentLayer.Pass()); | 1057 scrollLayer->addChild(contentLayer.Pass()); |
1058 | 1058 |
1059 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1059 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1060 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1060 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1061 initializeRendererAndDrawFrame(); | 1061 initializeRendererAndDrawFrame(); |
1062 | 1062 |
1063 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1063 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
1064 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1064 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
1065 m_hostImpl->scrollEnd(); | 1065 m_hostImpl->scrollEnd(); |
1066 EXPECT_TRUE(m_didRequestRedraw); | 1066 EXPECT_TRUE(m_didRequestRedraw); |
1067 EXPECT_TRUE(m_didRequestCommit); | 1067 EXPECT_TRUE(m_didRequestCommit); |
1068 } | 1068 } |
1069 | 1069 |
1070 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1070 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1071 { | 1071 { |
1072 IntSize surfaceSize(10, 10); | 1072 gfx::Size surfaceSize(10, 10); |
1073 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1073 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1074 root->setBounds(surfaceSize); | 1074 root->setBounds(surfaceSize); |
1075 root->setContentBounds(surfaceSize); | 1075 root->setContentBounds(surfaceSize); |
1076 root->addChild(createScrollableLayer(2, surfaceSize)); | 1076 root->addChild(createScrollableLayer(2, surfaceSize)); |
1077 m_hostImpl->setRootLayer(root.Pass()); | 1077 m_hostImpl->setRootLayer(root.Pass()); |
1078 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1078 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1079 initializeRendererAndDrawFrame(); | 1079 initializeRendererAndDrawFrame(); |
1080 | 1080 |
1081 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1081 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
1082 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1082 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
1083 m_hostImpl->scrollEnd(); | 1083 m_hostImpl->scrollEnd(); |
1084 EXPECT_TRUE(m_didRequestRedraw); | 1084 EXPECT_TRUE(m_didRequestRedraw); |
1085 EXPECT_TRUE(m_didRequestCommit); | 1085 EXPECT_TRUE(m_didRequestCommit); |
1086 } | 1086 } |
1087 | 1087 |
1088 TEST_P(LayerTreeHostImplTest, scrollMissesChild) | 1088 TEST_P(LayerTreeHostImplTest, scrollMissesChild) |
1089 { | 1089 { |
1090 IntSize surfaceSize(10, 10); | 1090 gfx::Size surfaceSize(10, 10); |
1091 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1091 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1092 root->addChild(createScrollableLayer(2, surfaceSize)); | 1092 root->addChild(createScrollableLayer(2, surfaceSize)); |
1093 m_hostImpl->setRootLayer(root.Pass()); | 1093 m_hostImpl->setRootLayer(root.Pass()); |
1094 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1094 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1095 initializeRendererAndDrawFrame(); | 1095 initializeRendererAndDrawFrame(); |
1096 | 1096 |
1097 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1097 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
1098 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), InputHandlerClient::Wheel
), InputHandlerClient::ScrollIgnored); | 1098 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), InputHandlerClient::Wheel
), InputHandlerClient::ScrollIgnored); |
1099 EXPECT_FALSE(m_didRequestRedraw); | 1099 EXPECT_FALSE(m_didRequestRedraw); |
1100 EXPECT_FALSE(m_didRequestCommit); | 1100 EXPECT_FALSE(m_didRequestCommit); |
1101 } | 1101 } |
1102 | 1102 |
1103 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) | 1103 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) |
1104 { | 1104 { |
1105 IntSize surfaceSize(10, 10); | 1105 gfx::Size surfaceSize(10, 10); |
1106 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1106 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1107 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1107 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1108 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1108 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1109 | 1109 |
1110 WebTransformationMatrix matrix; | 1110 WebTransformationMatrix matrix; |
1111 matrix.rotate3d(180, 0, 0); | 1111 matrix.rotate3d(180, 0, 0); |
1112 child->setTransform(matrix); | 1112 child->setTransform(matrix); |
1113 child->setDoubleSided(false); | 1113 child->setDoubleSided(false); |
1114 | 1114 |
1115 root->addChild(child.Pass()); | 1115 root->addChild(child.Pass()); |
1116 m_hostImpl->setRootLayer(root.Pass()); | 1116 m_hostImpl->setRootLayer(root.Pass()); |
1117 initializeRendererAndDrawFrame(); | 1117 initializeRendererAndDrawFrame(); |
1118 | 1118 |
1119 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1119 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
1120 // nothing scrollable behind it. | 1120 // nothing scrollable behind it. |
1121 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 1121 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); |
1122 EXPECT_FALSE(m_didRequestRedraw); | 1122 EXPECT_FALSE(m_didRequestRedraw); |
1123 EXPECT_FALSE(m_didRequestCommit); | 1123 EXPECT_FALSE(m_didRequestCommit); |
1124 } | 1124 } |
1125 | 1125 |
1126 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) | 1126 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) |
1127 { | 1127 { |
1128 IntSize surfaceSize(10, 10); | 1128 gfx::Size surfaceSize(10, 10); |
1129 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1129 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
1130 contentLayer->setShouldScrollOnMainThread(true); | 1130 contentLayer->setShouldScrollOnMainThread(true); |
1131 contentLayer->setScrollable(false); | 1131 contentLayer->setScrollable(false); |
1132 | 1132 |
1133 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1133 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1134 scrollLayer->addChild(contentLayer.Pass()); | 1134 scrollLayer->addChild(contentLayer.Pass()); |
1135 | 1135 |
1136 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1136 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1137 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1137 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1138 initializeRendererAndDrawFrame(); | 1138 initializeRendererAndDrawFrame(); |
1139 | 1139 |
1140 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1140 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
1141 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); | 1141 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); |
1142 } | 1142 } |
1143 | 1143 |
1144 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1144 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1145 { | 1145 { |
1146 IntSize surfaceSize(10, 10); | 1146 gfx::Size surfaceSize(10, 10); |
1147 float pageScale = 2; | 1147 float pageScale = 2; |
1148 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1148 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1149 m_hostImpl->setRootLayer(root.Pass()); | 1149 m_hostImpl->setRootLayer(root.Pass()); |
1150 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1150 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1151 initializeRendererAndDrawFrame(); | 1151 initializeRendererAndDrawFrame(); |
1152 | 1152 |
1153 IntSize scrollDelta(0, 10); | 1153 IntSize scrollDelta(0, 10); |
1154 IntSize expectedScrollDelta(scrollDelta); | 1154 IntSize expectedScrollDelta(scrollDelta); |
1155 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1155 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1156 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1156 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
(...skipping 12 matching lines...) Expand all Loading... |
1169 | 1169 |
1170 // The scroll range should also have been updated. | 1170 // The scroll range should also have been updated. |
1171 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1171 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1172 | 1172 |
1173 // The page scale delta remains constant because the impl thread did not sca
le. | 1173 // The page scale delta remains constant because the impl thread did not sca
le. |
1174 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix(
)); | 1174 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix(
)); |
1175 } | 1175 } |
1176 | 1176 |
1177 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1177 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1178 { | 1178 { |
1179 IntSize surfaceSize(10, 10); | 1179 gfx::Size surfaceSize(10, 10); |
1180 float pageScale = 2; | 1180 float pageScale = 2; |
1181 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1181 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1182 m_hostImpl->setRootLayer(root.Pass()); | 1182 m_hostImpl->setRootLayer(root.Pass()); |
1183 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1183 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1184 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1184 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1185 initializeRendererAndDrawFrame(); | 1185 initializeRendererAndDrawFrame(); |
1186 | 1186 |
1187 IntSize scrollDelta(0, 10); | 1187 IntSize scrollDelta(0, 10); |
1188 IntSize expectedScrollDelta(scrollDelta); | 1188 IntSize expectedScrollDelta(scrollDelta); |
1189 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1189 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
(...skipping 15 matching lines...) Expand all Loading... |
1205 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1205 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1206 | 1206 |
1207 // The page scale delta should match the new scale on the impl side. | 1207 // The page scale delta should match the new scale on the impl side. |
1208 WebTransformationMatrix expectedScale; | 1208 WebTransformationMatrix expectedScale; |
1209 expectedScale.scale(pageScale); | 1209 expectedScale.scale(pageScale); |
1210 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); | 1210 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); |
1211 } | 1211 } |
1212 | 1212 |
1213 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) | 1213 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) |
1214 { | 1214 { |
1215 IntSize surfaceSize(10, 10); | 1215 gfx::Size surfaceSize(10, 10); |
1216 float defaultPageScale = 1; | 1216 float defaultPageScale = 1; |
1217 WebTransformationMatrix defaultPageScaleMatrix; | 1217 WebTransformationMatrix defaultPageScaleMatrix; |
1218 | 1218 |
1219 float newPageScale = 2; | 1219 float newPageScale = 2; |
1220 WebTransformationMatrix newPageScaleMatrix; | 1220 WebTransformationMatrix newPageScaleMatrix; |
1221 newPageScaleMatrix.scale(newPageScale); | 1221 newPageScaleMatrix.scale(newPageScale); |
1222 | 1222 |
1223 // Create a normal scrollable root layer and another scrollable child layer. | 1223 // Create a normal scrollable root layer and another scrollable child layer. |
1224 setupScrollAndContentsLayers(surfaceSize); | 1224 setupScrollAndContentsLayers(surfaceSize); |
1225 LayerImpl* root = m_hostImpl->rootLayer(); | 1225 LayerImpl* root = m_hostImpl->rootLayer(); |
(...skipping 24 matching lines...) Expand all Loading... |
1250 EXPECT_EQ(root->drawTransform().m11(), newPageScale); | 1250 EXPECT_EQ(root->drawTransform().m11(), newPageScale); |
1251 EXPECT_EQ(root->drawTransform().m22(), newPageScale); | 1251 EXPECT_EQ(root->drawTransform().m22(), newPageScale); |
1252 EXPECT_EQ(child->drawTransform().m11(), newPageScale); | 1252 EXPECT_EQ(child->drawTransform().m11(), newPageScale); |
1253 EXPECT_EQ(child->drawTransform().m22(), newPageScale); | 1253 EXPECT_EQ(child->drawTransform().m22(), newPageScale); |
1254 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); | 1254 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); |
1255 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); | 1255 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); |
1256 } | 1256 } |
1257 | 1257 |
1258 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1258 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
1259 { | 1259 { |
1260 IntSize surfaceSize(10, 10); | 1260 gfx::Size surfaceSize(10, 10); |
1261 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1261 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1262 root->setBounds(surfaceSize); | 1262 root->setBounds(surfaceSize); |
1263 root->setContentBounds(surfaceSize); | 1263 root->setContentBounds(surfaceSize); |
1264 // Also mark the root scrollable so it becomes the root scroll layer. | 1264 // Also mark the root scrollable so it becomes the root scroll layer. |
1265 root->setScrollable(true); | 1265 root->setScrollable(true); |
1266 int scrollLayerId = 2; | 1266 int scrollLayerId = 2; |
1267 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1267 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1268 m_hostImpl->setRootLayer(root.Pass()); | 1268 m_hostImpl->setRootLayer(root.Pass()); |
1269 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1269 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1270 initializeRendererAndDrawFrame(); | 1270 initializeRendererAndDrawFrame(); |
(...skipping 25 matching lines...) Expand all Loading... |
1296 // The page scale delta remains constant because the impl thread did not sca
le. | 1296 // The page scale delta remains constant because the impl thread did not sca
le. |
1297 WebTransformationMatrix identityTransform; | 1297 WebTransformationMatrix identityTransform; |
1298 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); | 1298 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); |
1299 } | 1299 } |
1300 | 1300 |
1301 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) | 1301 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) |
1302 { | 1302 { |
1303 // Scroll a child layer beyond its maximum scroll range and make sure the | 1303 // Scroll a child layer beyond its maximum scroll range and make sure the |
1304 // parent layer is scrolled on the axis on which the child was unable to | 1304 // parent layer is scrolled on the axis on which the child was unable to |
1305 // scroll. | 1305 // scroll. |
1306 IntSize surfaceSize(10, 10); | 1306 gfx::Size surfaceSize(10, 10); |
1307 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1307 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1308 | 1308 |
1309 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1309 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
1310 grandChild->setScrollPosition(IntPoint(0, 5)); | 1310 grandChild->setScrollPosition(IntPoint(0, 5)); |
1311 | 1311 |
1312 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1312 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1313 child->setScrollPosition(IntPoint(3, 0)); | 1313 child->setScrollPosition(IntPoint(3, 0)); |
1314 child->addChild(grandChild.Pass()); | 1314 child->addChild(grandChild.Pass()); |
1315 | 1315 |
1316 root->addChild(child.Pass()); | 1316 root->addChild(child.Pass()); |
(...skipping 15 matching lines...) Expand all Loading... |
1332 | 1332 |
1333 // The child should have only scrolled on the other axis. | 1333 // The child should have only scrolled on the other axis. |
1334 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); | 1334 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); |
1335 } | 1335 } |
1336 } | 1336 } |
1337 | 1337 |
1338 TEST_P(LayerTreeHostImplTest, scrollEventBubbling) | 1338 TEST_P(LayerTreeHostImplTest, scrollEventBubbling) |
1339 { | 1339 { |
1340 // When we try to scroll a non-scrollable child layer, the scroll delta | 1340 // When we try to scroll a non-scrollable child layer, the scroll delta |
1341 // should be applied to one of its ancestors if possible. | 1341 // should be applied to one of its ancestors if possible. |
1342 IntSize surfaceSize(10, 10); | 1342 gfx::Size surfaceSize(10, 10); |
1343 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1343 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1344 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1344 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1345 | 1345 |
1346 child->setScrollable(false); | 1346 child->setScrollable(false); |
1347 root->addChild(child.Pass()); | 1347 root->addChild(child.Pass()); |
1348 | 1348 |
1349 m_hostImpl->setRootLayer(root.Pass()); | 1349 m_hostImpl->setRootLayer(root.Pass()); |
1350 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1350 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1351 initializeRendererAndDrawFrame(); | 1351 initializeRendererAndDrawFrame(); |
1352 { | 1352 { |
1353 IntSize scrollDelta(0, 4); | 1353 IntSize scrollDelta(0, 4); |
1354 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 1354 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
1355 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1355 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1356 m_hostImpl->scrollEnd(); | 1356 m_hostImpl->scrollEnd(); |
1357 | 1357 |
1358 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1358 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1359 | 1359 |
1360 // Only the root should have scrolled. | 1360 // Only the root should have scrolled. |
1361 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 1361 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
1362 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 1362 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
1363 } | 1363 } |
1364 } | 1364 } |
1365 | 1365 |
1366 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) | 1366 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) |
1367 { | 1367 { |
1368 IntSize surfaceSize(10, 10); | 1368 gfx::Size surfaceSize(10, 10); |
1369 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); | 1369 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); |
1370 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1370 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1371 | 1371 |
1372 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. | 1372 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. |
1373 initializeRendererAndDrawFrame(); | 1373 initializeRendererAndDrawFrame(); |
1374 m_hostImpl->detachLayerTree(); | 1374 m_hostImpl->detachLayerTree(); |
1375 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); | 1375 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); |
1376 | 1376 |
1377 // Scrolling should still work even though we did not draw yet. | 1377 // Scrolling should still work even though we did not draw yet. |
1378 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1378 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
1379 } | 1379 } |
1380 | 1380 |
1381 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) | 1381 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) |
1382 { | 1382 { |
1383 setupScrollAndContentsLayers(IntSize(100, 100)); | 1383 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
1384 | 1384 |
1385 // Rotate the root layer 90 degrees counter-clockwise about its center. | 1385 // Rotate the root layer 90 degrees counter-clockwise about its center. |
1386 WebTransformationMatrix rotateTransform; | 1386 WebTransformationMatrix rotateTransform; |
1387 rotateTransform.rotate(-90); | 1387 rotateTransform.rotate(-90); |
1388 m_hostImpl->rootLayer()->setTransform(rotateTransform); | 1388 m_hostImpl->rootLayer()->setTransform(rotateTransform); |
1389 | 1389 |
1390 IntSize surfaceSize(50, 50); | 1390 gfx::Size surfaceSize(50, 50); |
1391 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1391 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1392 initializeRendererAndDrawFrame(); | 1392 initializeRendererAndDrawFrame(); |
1393 | 1393 |
1394 // Scroll to the right in screen coordinates with a gesture. | 1394 // Scroll to the right in screen coordinates with a gesture. |
1395 IntSize gestureScrollDelta(10, 0); | 1395 IntSize gestureScrollDelta(10, 0); |
1396 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); | 1396 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); |
1397 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1397 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); |
1398 m_hostImpl->scrollEnd(); | 1398 m_hostImpl->scrollEnd(); |
1399 | 1399 |
1400 // The layer should have scrolled down in its local coordinates. | 1400 // The layer should have scrolled down in its local coordinates. |
1401 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1401 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1402 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0,
gestureScrollDelta.width())); | 1402 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0,
gestureScrollDelta.width())); |
1403 | 1403 |
1404 // Reset and scroll down with the wheel. | 1404 // Reset and scroll down with the wheel. |
1405 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); | 1405 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); |
1406 IntSize wheelScrollDelta(0, 10); | 1406 IntSize wheelScrollDelta(0, 10); |
1407 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1407 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); |
1408 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); | 1408 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); |
1409 m_hostImpl->scrollEnd(); | 1409 m_hostImpl->scrollEnd(); |
1410 | 1410 |
1411 // The layer should have scrolled down in its local coordinates. | 1411 // The layer should have scrolled down in its local coordinates. |
1412 scrollInfo = m_hostImpl->processScrollDeltas(); | 1412 scrollInfo = m_hostImpl->processScrollDeltas(); |
1413 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1413 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1414 } | 1414 } |
1415 | 1415 |
1416 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1416 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
1417 { | 1417 { |
1418 setupScrollAndContentsLayers(IntSize(100, 100)); | 1418 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
1419 int childLayerId = 3; | 1419 int childLayerId = 3; |
1420 float childLayerAngle = -20; | 1420 float childLayerAngle = -20; |
1421 | 1421 |
1422 // Create a child layer that is rotated to a non-axis-aligned angle. | 1422 // Create a child layer that is rotated to a non-axis-aligned angle. |
1423 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl
->rootLayer()->contentBounds()); | 1423 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl
->rootLayer()->contentBounds()); |
1424 WebTransformationMatrix rotateTransform; | 1424 WebTransformationMatrix rotateTransform; |
1425 rotateTransform.translate(-50, -50); | 1425 rotateTransform.translate(-50, -50); |
1426 rotateTransform.rotate(childLayerAngle); | 1426 rotateTransform.rotate(childLayerAngle); |
1427 rotateTransform.translate(50, 50); | 1427 rotateTransform.translate(50, 50); |
1428 child->setTransform(rotateTransform); | 1428 child->setTransform(rotateTransform); |
1429 | 1429 |
1430 // Only allow vertical scrolling. | 1430 // Only allow vertical scrolling. |
1431 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); | 1431 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); |
1432 m_hostImpl->rootLayer()->addChild(child.Pass()); | 1432 m_hostImpl->rootLayer()->addChild(child.Pass()); |
1433 | 1433 |
1434 IntSize surfaceSize(50, 50); | 1434 gfx::Size surfaceSize(50, 50); |
1435 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1435 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1436 initializeRendererAndDrawFrame(); | 1436 initializeRendererAndDrawFrame(); |
1437 | 1437 |
1438 { | 1438 { |
1439 // Scroll down in screen coordinates with a gesture. | 1439 // Scroll down in screen coordinates with a gesture. |
1440 IntSize gestureScrollDelta(0, 10); | 1440 IntSize gestureScrollDelta(0, 10); |
1441 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 1441 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
1442 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1442 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); |
1443 m_hostImpl->scrollEnd(); | 1443 m_hostImpl->scrollEnd(); |
1444 | 1444 |
(...skipping 24 matching lines...) Expand all Loading... |
1469 | 1469 |
1470 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1470 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
1471 // orthogonal to the child layer's vertical scroll axis. | 1471 // orthogonal to the child layer's vertical scroll axis. |
1472 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de
g2rad(childLayerAngle)), 2), 0); | 1472 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de
g2rad(childLayerAngle)), 2), 0); |
1473 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); | 1473 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); |
1474 } | 1474 } |
1475 } | 1475 } |
1476 | 1476 |
1477 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) | 1477 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) |
1478 { | 1478 { |
1479 setupScrollAndContentsLayers(IntSize(100, 100)); | 1479 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
1480 | 1480 |
1481 // Scale the layer to twice its normal size. | 1481 // Scale the layer to twice its normal size. |
1482 int scale = 2; | 1482 int scale = 2; |
1483 WebTransformationMatrix scaleTransform; | 1483 WebTransformationMatrix scaleTransform; |
1484 scaleTransform.scale(scale); | 1484 scaleTransform.scale(scale); |
1485 m_hostImpl->rootLayer()->setTransform(scaleTransform); | 1485 m_hostImpl->rootLayer()->setTransform(scaleTransform); |
1486 | 1486 |
1487 IntSize surfaceSize(50, 50); | 1487 gfx::Size surfaceSize(50, 50); |
1488 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1488 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1489 initializeRendererAndDrawFrame(); | 1489 initializeRendererAndDrawFrame(); |
1490 | 1490 |
1491 // Scroll down in screen coordinates with a gesture. | 1491 // Scroll down in screen coordinates with a gesture. |
1492 IntSize scrollDelta(0, 10); | 1492 IntSize scrollDelta(0, 10); |
1493 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); | 1493 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); |
1494 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1494 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1495 m_hostImpl->scrollEnd(); | 1495 m_hostImpl->scrollEnd(); |
1496 | 1496 |
1497 // The layer should have scrolled down in its local coordinates, but half he
amount. | 1497 // The layer should have scrolled down in its local coordinates, but half he
amount. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 }; | 1533 }; |
1534 | 1534 |
1535 class BlendStateCheckLayer : public LayerImpl { | 1535 class BlendStateCheckLayer : public LayerImpl { |
1536 public: | 1536 public: |
1537 static scoped_ptr<LayerImpl> create(int id, ResourceProvider* resourceProvid
er) { return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(id, resourceProvider
)); } | 1537 static scoped_ptr<LayerImpl> create(int id, ResourceProvider* resourceProvid
er) { return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(id, resourceProvider
)); } |
1538 | 1538 |
1539 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 1539 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE |
1540 { | 1540 { |
1541 m_quadsAppended = true; | 1541 m_quadsAppended = true; |
1542 | 1542 |
1543 IntRect opaqueRect; | 1543 gfx::Rect opaqueRect; |
1544 if (contentsOpaque()) | 1544 if (contentsOpaque()) |
1545 opaqueRect = m_quadRect; | 1545 opaqueRect = m_quadRect; |
1546 else | 1546 else |
1547 opaqueRect = m_opaqueContentRect; | 1547 opaqueRect = m_opaqueContentRect; |
1548 | 1548 |
1549 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); | 1549 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); |
1550 scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::create(sha
redQuadState, m_quadRect, opaqueRect, m_resourceId, IntPoint(), IntSize(1, 1), 0
, false, false, false, false, false); | 1550 scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::create(sha
redQuadState, m_quadRect, opaqueRect, m_resourceId, gfx::Vector2d(), gfx::Size(1
, 1), 0, false, false, false, false, false); |
1551 testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect); | 1551 testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect); |
1552 EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending()); | 1552 EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending()); |
1553 EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); | 1553 EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); |
1554 quadSink.append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsData
); | 1554 quadSink.append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsData
); |
1555 } | 1555 } |
1556 | 1556 |
1557 void setExpectation(bool blend, bool hasRenderSurface) | 1557 void setExpectation(bool blend, bool hasRenderSurface) |
1558 { | 1558 { |
1559 m_blend = blend; | 1559 m_blend = blend; |
1560 m_hasRenderSurface = hasRenderSurface; | 1560 m_hasRenderSurface = hasRenderSurface; |
1561 m_quadsAppended = false; | 1561 m_quadsAppended = false; |
1562 } | 1562 } |
1563 | 1563 |
1564 bool quadsAppended() const { return m_quadsAppended; } | 1564 bool quadsAppended() const { return m_quadsAppended; } |
1565 | 1565 |
1566 void setQuadRect(const IntRect& rect) { m_quadRect = rect; } | 1566 void setQuadRect(const gfx::Rect& rect) { m_quadRect = rect; } |
1567 void setQuadVisibleRect(const IntRect& rect) { m_quadVisibleRect = rect; } | 1567 void setQuadVisibleRect(const gfx::Rect& rect) { m_quadVisibleRect = rect; } |
1568 void setOpaqueContentRect(const IntRect& rect) { m_opaqueContentRect = rect;
} | 1568 void setOpaqueContentRect(const gfx::Rect& rect) { m_opaqueContentRect = rec
t; } |
1569 | 1569 |
1570 private: | 1570 private: |
1571 explicit BlendStateCheckLayer(int id, ResourceProvider* resourceProvider) | 1571 explicit BlendStateCheckLayer(int id, ResourceProvider* resourceProvider) |
1572 : LayerImpl(id) | 1572 : LayerImpl(id) |
1573 , m_blend(false) | 1573 , m_blend(false) |
1574 , m_hasRenderSurface(false) | 1574 , m_hasRenderSurface(false) |
1575 , m_quadsAppended(false) | 1575 , m_quadsAppended(false) |
1576 , m_quadRect(5, 5, 5, 5) | 1576 , m_quadRect(5, 5, 5, 5) |
1577 , m_quadVisibleRect(5, 5, 5, 5) | 1577 , m_quadVisibleRect(5, 5, 5, 5) |
1578 , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, I
ntSize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny)) | 1578 , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, g
fx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny)) |
1579 { | 1579 { |
1580 setAnchorPoint(FloatPoint(0, 0)); | 1580 setAnchorPoint(gfx::PointF(0, 0)); |
1581 setBounds(IntSize(10, 10)); | 1581 setBounds(gfx::Size(10, 10)); |
1582 setContentBounds(IntSize(10, 10)); | 1582 setContentBounds(gfx::Size(10, 10)); |
1583 setDrawsContent(true); | 1583 setDrawsContent(true); |
1584 } | 1584 } |
1585 | 1585 |
1586 bool m_blend; | 1586 bool m_blend; |
1587 bool m_hasRenderSurface; | 1587 bool m_hasRenderSurface; |
1588 bool m_quadsAppended; | 1588 bool m_quadsAppended; |
1589 IntRect m_quadRect; | 1589 gfx::Rect m_quadRect; |
1590 IntRect m_opaqueContentRect; | 1590 gfx::Rect m_opaqueContentRect; |
1591 IntRect m_quadVisibleRect; | 1591 gfx::Rect m_quadVisibleRect; |
1592 ResourceProvider::ResourceId m_resourceId; | 1592 ResourceProvider::ResourceId m_resourceId; |
1593 }; | 1593 }; |
1594 | 1594 |
1595 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1595 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1596 { | 1596 { |
1597 { | 1597 { |
1598 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1598 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1599 root->setAnchorPoint(FloatPoint(0, 0)); | 1599 root->setAnchorPoint(gfx::PointF(0, 0)); |
1600 root->setBounds(IntSize(10, 10)); | 1600 root->setBounds(gfx::Size(10, 10)); |
1601 root->setContentBounds(root->bounds()); | 1601 root->setContentBounds(root->bounds()); |
1602 root->setDrawsContent(false); | 1602 root->setDrawsContent(false); |
1603 m_hostImpl->setRootLayer(root.Pass()); | 1603 m_hostImpl->setRootLayer(root.Pass()); |
1604 } | 1604 } |
1605 LayerImpl* root = m_hostImpl->rootLayer(); | 1605 LayerImpl* root = m_hostImpl->rootLayer(); |
1606 | 1606 |
1607 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider(
))); | 1607 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider(
))); |
1608 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); | 1608 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); |
1609 layer1->setPosition(FloatPoint(2, 2)); | 1609 layer1->setPosition(gfx::PointF(2, 2)); |
1610 | 1610 |
1611 LayerTreeHostImpl::FrameData frame; | 1611 LayerTreeHostImpl::FrameData frame; |
1612 | 1612 |
1613 // Opaque layer, drawn without blending. | 1613 // Opaque layer, drawn without blending. |
1614 layer1->setContentsOpaque(true); | 1614 layer1->setContentsOpaque(true); |
1615 layer1->setExpectation(false, false); | 1615 layer1->setExpectation(false, false); |
1616 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1616 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1617 m_hostImpl->drawLayers(frame); | 1617 m_hostImpl->drawLayers(frame); |
1618 EXPECT_TRUE(layer1->quadsAppended()); | 1618 EXPECT_TRUE(layer1->quadsAppended()); |
1619 m_hostImpl->didDrawAllLayers(frame); | 1619 m_hostImpl->didDrawAllLayers(frame); |
(...skipping 19 matching lines...) Expand all Loading... |
1639 layer1->setContentsOpaque(true); | 1639 layer1->setContentsOpaque(true); |
1640 layer1->setOpacity(0.5); | 1640 layer1->setOpacity(0.5); |
1641 layer1->setExpectation(true, false); | 1641 layer1->setExpectation(true, false); |
1642 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1642 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1643 m_hostImpl->drawLayers(frame); | 1643 m_hostImpl->drawLayers(frame); |
1644 EXPECT_TRUE(layer1->quadsAppended()); | 1644 EXPECT_TRUE(layer1->quadsAppended()); |
1645 m_hostImpl->didDrawAllLayers(frame); | 1645 m_hostImpl->didDrawAllLayers(frame); |
1646 | 1646 |
1647 layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvide
r())); | 1647 layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvide
r())); |
1648 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); | 1648 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); |
1649 layer2->setPosition(FloatPoint(4, 4)); | 1649 layer2->setPosition(gfx::PointF(4, 4)); |
1650 | 1650 |
1651 // 2 opaque layers, drawn without blending. | 1651 // 2 opaque layers, drawn without blending. |
1652 layer1->setContentsOpaque(true); | 1652 layer1->setContentsOpaque(true); |
1653 layer1->setOpacity(1); | 1653 layer1->setOpacity(1); |
1654 layer1->setExpectation(false, false); | 1654 layer1->setExpectation(false, false); |
1655 layer2->setContentsOpaque(true); | 1655 layer2->setContentsOpaque(true); |
1656 layer2->setOpacity(1); | 1656 layer2->setOpacity(1); |
1657 layer2->setExpectation(false, false); | 1657 layer2->setExpectation(false, false); |
1658 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1658 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1659 m_hostImpl->drawLayers(frame); | 1659 m_hostImpl->drawLayers(frame); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 layer2->setOpacity(1); | 1733 layer2->setOpacity(1); |
1734 layer2->setExpectation(false, false); | 1734 layer2->setExpectation(false, false); |
1735 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1735 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1736 m_hostImpl->drawLayers(frame); | 1736 m_hostImpl->drawLayers(frame); |
1737 EXPECT_TRUE(layer1->quadsAppended()); | 1737 EXPECT_TRUE(layer1->quadsAppended()); |
1738 EXPECT_TRUE(layer2->quadsAppended()); | 1738 EXPECT_TRUE(layer2->quadsAppended()); |
1739 m_hostImpl->didDrawAllLayers(frame); | 1739 m_hostImpl->didDrawAllLayers(frame); |
1740 | 1740 |
1741 // Layer with partially opaque contents, drawn with blending. | 1741 // Layer with partially opaque contents, drawn with blending. |
1742 layer1->setContentsOpaque(false); | 1742 layer1->setContentsOpaque(false); |
1743 layer1->setQuadRect(IntRect(5, 5, 5, 5)); | 1743 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
1744 layer1->setQuadVisibleRect(IntRect(5, 5, 5, 5)); | 1744 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
1745 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 1745 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
1746 layer1->setExpectation(true, false); | 1746 layer1->setExpectation(true, false); |
1747 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1747 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1748 m_hostImpl->drawLayers(frame); | 1748 m_hostImpl->drawLayers(frame); |
1749 EXPECT_TRUE(layer1->quadsAppended()); | 1749 EXPECT_TRUE(layer1->quadsAppended()); |
1750 m_hostImpl->didDrawAllLayers(frame); | 1750 m_hostImpl->didDrawAllLayers(frame); |
1751 | 1751 |
1752 // Layer with partially opaque contents partially culled, drawn with blendin
g. | 1752 // Layer with partially opaque contents partially culled, drawn with blendin
g. |
1753 layer1->setContentsOpaque(false); | 1753 layer1->setContentsOpaque(false); |
1754 layer1->setQuadRect(IntRect(5, 5, 5, 5)); | 1754 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
1755 layer1->setQuadVisibleRect(IntRect(5, 5, 5, 2)); | 1755 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
1756 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 1756 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
1757 layer1->setExpectation(true, false); | 1757 layer1->setExpectation(true, false); |
1758 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1758 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1759 m_hostImpl->drawLayers(frame); | 1759 m_hostImpl->drawLayers(frame); |
1760 EXPECT_TRUE(layer1->quadsAppended()); | 1760 EXPECT_TRUE(layer1->quadsAppended()); |
1761 m_hostImpl->didDrawAllLayers(frame); | 1761 m_hostImpl->didDrawAllLayers(frame); |
1762 | 1762 |
1763 // Layer with partially opaque contents culled, drawn with blending. | 1763 // Layer with partially opaque contents culled, drawn with blending. |
1764 layer1->setContentsOpaque(false); | 1764 layer1->setContentsOpaque(false); |
1765 layer1->setQuadRect(IntRect(5, 5, 5, 5)); | 1765 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
1766 layer1->setQuadVisibleRect(IntRect(7, 5, 3, 5)); | 1766 layer1->setQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
1767 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 1767 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
1768 layer1->setExpectation(true, false); | 1768 layer1->setExpectation(true, false); |
1769 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1769 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1770 m_hostImpl->drawLayers(frame); | 1770 m_hostImpl->drawLayers(frame); |
1771 EXPECT_TRUE(layer1->quadsAppended()); | 1771 EXPECT_TRUE(layer1->quadsAppended()); |
1772 m_hostImpl->didDrawAllLayers(frame); | 1772 m_hostImpl->didDrawAllLayers(frame); |
1773 | 1773 |
1774 // Layer with partially opaque contents and translucent contents culled, dra
wn without blending. | 1774 // Layer with partially opaque contents and translucent contents culled, dra
wn without blending. |
1775 layer1->setContentsOpaque(false); | 1775 layer1->setContentsOpaque(false); |
1776 layer1->setQuadRect(IntRect(5, 5, 5, 5)); | 1776 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
1777 layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5)); | 1777 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
1778 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 1778 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
1779 layer1->setExpectation(false, false); | 1779 layer1->setExpectation(false, false); |
1780 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1780 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1781 m_hostImpl->drawLayers(frame); | 1781 m_hostImpl->drawLayers(frame); |
1782 EXPECT_TRUE(layer1->quadsAppended()); | 1782 EXPECT_TRUE(layer1->quadsAppended()); |
1783 m_hostImpl->didDrawAllLayers(frame); | 1783 m_hostImpl->didDrawAllLayers(frame); |
1784 | 1784 |
1785 } | 1785 } |
1786 | 1786 |
1787 TEST_P(LayerTreeHostImplTest, viewportCovered) | 1787 TEST_P(LayerTreeHostImplTest, viewportCovered) |
1788 { | 1788 { |
1789 m_hostImpl->initializeRenderer(createContext()); | 1789 m_hostImpl->initializeRenderer(createContext()); |
1790 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1790 m_hostImpl->setBackgroundColor(SK_ColorGRAY); |
1791 | 1791 |
1792 IntSize viewportSize(1000, 1000); | 1792 gfx::Size viewportSize(1000, 1000); |
1793 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1793 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
1794 | 1794 |
1795 m_hostImpl->setRootLayer(LayerImpl::create(1)); | 1795 m_hostImpl->setRootLayer(LayerImpl::create(1)); |
1796 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(2, m_hostImpl
->resourceProvider())); | 1796 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(2, m_hostImpl
->resourceProvider())); |
1797 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); | 1797 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); |
1798 child->setExpectation(false, false); | 1798 child->setExpectation(false, false); |
1799 child->setContentsOpaque(true); | 1799 child->setContentsOpaque(true); |
1800 | 1800 |
1801 // No gutter rects | 1801 // No gutter rects |
1802 { | 1802 { |
1803 IntRect layerRect(0, 0, 1000, 1000); | 1803 gfx::Rect layerRect(0, 0, 1000, 1000); |
1804 child->setPosition(layerRect.location()); | 1804 child->setPosition(layerRect.origin()); |
1805 child->setBounds(layerRect.size()); | 1805 child->setBounds(layerRect.size()); |
1806 child->setContentBounds(layerRect.size()); | 1806 child->setContentBounds(layerRect.size()); |
1807 child->setQuadRect(IntRect(IntPoint(), layerRect.size())); | 1807 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1808 child->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); | 1808 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1809 | 1809 |
1810 LayerTreeHostImpl::FrameData frame; | 1810 LayerTreeHostImpl::FrameData frame; |
1811 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1811 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1812 ASSERT_EQ(1u, frame.renderPasses.size()); | 1812 ASSERT_EQ(1u, frame.renderPasses.size()); |
1813 | 1813 |
1814 size_t numGutterQuads = 0; | 1814 size_t numGutterQuads = 0; |
1815 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) | 1815 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) |
1816 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== DrawQuad::SolidColor) ? 1 : 0; | 1816 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== DrawQuad::SolidColor) ? 1 : 0; |
1817 EXPECT_EQ(0u, numGutterQuads); | 1817 EXPECT_EQ(0u, numGutterQuads); |
1818 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); | 1818 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); |
1819 | 1819 |
1820 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(I
ntPoint::zero(), viewportSize)); | 1820 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), gfx::Rect
(gfx::Point(), viewportSize)); |
1821 m_hostImpl->didDrawAllLayers(frame); | 1821 m_hostImpl->didDrawAllLayers(frame); |
1822 } | 1822 } |
1823 | 1823 |
1824 // Empty visible content area (fullscreen gutter rect) | 1824 // Empty visible content area (fullscreen gutter rect) |
1825 { | 1825 { |
1826 IntRect layerRect(0, 0, 0, 0); | 1826 gfx::Rect layerRect(0, 0, 0, 0); |
1827 child->setPosition(layerRect.location()); | 1827 child->setPosition(layerRect.origin()); |
1828 child->setBounds(layerRect.size()); | 1828 child->setBounds(layerRect.size()); |
1829 child->setContentBounds(layerRect.size()); | 1829 child->setContentBounds(layerRect.size()); |
1830 child->setQuadRect(IntRect(IntPoint(), layerRect.size())); | 1830 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1831 child->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); | 1831 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1832 | 1832 |
1833 LayerTreeHostImpl::FrameData frame; | 1833 LayerTreeHostImpl::FrameData frame; |
1834 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1834 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1835 ASSERT_EQ(1u, frame.renderPasses.size()); | 1835 ASSERT_EQ(1u, frame.renderPasses.size()); |
1836 m_hostImpl->didDrawAllLayers(frame); | 1836 m_hostImpl->didDrawAllLayers(frame); |
1837 | 1837 |
1838 size_t numGutterQuads = 0; | 1838 size_t numGutterQuads = 0; |
1839 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) | 1839 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) |
1840 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== DrawQuad::SolidColor) ? 1 : 0; | 1840 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== DrawQuad::SolidColor) ? 1 : 0; |
1841 EXPECT_EQ(1u, numGutterQuads); | 1841 EXPECT_EQ(1u, numGutterQuads); |
1842 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); | 1842 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); |
1843 | 1843 |
1844 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(I
ntPoint::zero(), viewportSize)); | 1844 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), gfx::Rect
(gfx::Point(), viewportSize)); |
1845 m_hostImpl->didDrawAllLayers(frame); | 1845 m_hostImpl->didDrawAllLayers(frame); |
1846 } | 1846 } |
1847 | 1847 |
1848 // Content area in middle of clip rect (four surrounding gutter rects) | 1848 // Content area in middle of clip rect (four surrounding gutter rects) |
1849 { | 1849 { |
1850 IntRect layerRect(500, 500, 200, 200); | 1850 gfx::Rect layerRect(500, 500, 200, 200); |
1851 child->setPosition(layerRect.location()); | 1851 child->setPosition(layerRect.origin()); |
1852 child->setBounds(layerRect.size()); | 1852 child->setBounds(layerRect.size()); |
1853 child->setContentBounds(layerRect.size()); | 1853 child->setContentBounds(layerRect.size()); |
1854 child->setQuadRect(IntRect(IntPoint(), layerRect.size())); | 1854 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1855 child->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); | 1855 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1856 | 1856 |
1857 LayerTreeHostImpl::FrameData frame; | 1857 LayerTreeHostImpl::FrameData frame; |
1858 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1858 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1859 ASSERT_EQ(1u, frame.renderPasses.size()); | 1859 ASSERT_EQ(1u, frame.renderPasses.size()); |
1860 | 1860 |
1861 size_t numGutterQuads = 0; | 1861 size_t numGutterQuads = 0; |
1862 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) | 1862 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) |
1863 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== DrawQuad::SolidColor) ? 1 : 0; | 1863 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== DrawQuad::SolidColor) ? 1 : 0; |
1864 EXPECT_EQ(4u, numGutterQuads); | 1864 EXPECT_EQ(4u, numGutterQuads); |
1865 EXPECT_EQ(5u, frame.renderPasses[0]->quadList().size()); | 1865 EXPECT_EQ(5u, frame.renderPasses[0]->quadList().size()); |
1866 | 1866 |
1867 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(I
ntPoint::zero(), viewportSize)); | 1867 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), gfx::Rect
(gfx::Point(), viewportSize)); |
1868 m_hostImpl->didDrawAllLayers(frame); | 1868 m_hostImpl->didDrawAllLayers(frame); |
1869 } | 1869 } |
1870 | 1870 |
1871 } | 1871 } |
1872 | 1872 |
1873 | 1873 |
1874 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { | 1874 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { |
1875 public: | 1875 public: |
1876 ReshapeTrackerContext() : m_reshapeCalled(false) { } | 1876 ReshapeTrackerContext() : m_reshapeCalled(false) { } |
1877 | 1877 |
(...skipping 18 matching lines...) Expand all Loading... |
1896 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1896 // Only reshape when we know we are going to draw. Otherwise, the reshape |
1897 // can leave the window at the wrong size if we never draw and the proper | 1897 // can leave the window at the wrong size if we never draw and the proper |
1898 // viewport size is never set. | 1898 // viewport size is never set. |
1899 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1899 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
1900 { | 1900 { |
1901 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).Pass
As<GraphicsContext>(); | 1901 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).Pass
As<GraphicsContext>(); |
1902 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3D()); | 1902 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3D()); |
1903 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 1903 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
1904 | 1904 |
1905 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 1905 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
1906 root->setAnchorPoint(FloatPoint(0, 0)); | 1906 root->setAnchorPoint(gfx::PointF(0, 0)); |
1907 root->setBounds(IntSize(10, 10)); | 1907 root->setBounds(gfx::Size(10, 10)); |
1908 root->setDrawsContent(true); | 1908 root->setDrawsContent(true); |
1909 m_hostImpl->setRootLayer(root.Pass()); | 1909 m_hostImpl->setRootLayer(root.Pass()); |
1910 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 1910 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
1911 | 1911 |
1912 LayerTreeHostImpl::FrameData frame; | 1912 LayerTreeHostImpl::FrameData frame; |
1913 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1913 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1914 m_hostImpl->drawLayers(frame); | 1914 m_hostImpl->drawLayers(frame); |
1915 EXPECT_TRUE(reshapeTracker->reshapeCalled()); | 1915 EXPECT_TRUE(reshapeTracker->reshapeCalled()); |
1916 m_hostImpl->didDrawAllLayers(frame); | 1916 m_hostImpl->didDrawAllLayers(frame); |
1917 } | 1917 } |
1918 | 1918 |
1919 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { | 1919 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { |
1920 public: | 1920 public: |
1921 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) | 1921 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) |
1922 { | 1922 { |
1923 m_partialSwapRect = IntRect(x, y, width, height); | 1923 m_partialSwapRect = gfx::Rect(x, y, width, height); |
1924 } | 1924 } |
1925 | 1925 |
1926 virtual WebString getString(WGC3Denum name) | 1926 virtual WebString getString(WGC3Denum name) |
1927 { | 1927 { |
1928 if (name == GL_EXTENSIONS) | 1928 if (name == GL_EXTENSIONS) |
1929 return WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibi
lity"); | 1929 return WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibi
lity"); |
1930 | 1930 |
1931 return WebString(); | 1931 return WebString(); |
1932 } | 1932 } |
1933 | 1933 |
1934 IntRect partialSwapRect() const { return m_partialSwapRect; } | 1934 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } |
1935 | 1935 |
1936 private: | 1936 private: |
1937 IntRect m_partialSwapRect; | 1937 gfx::Rect m_partialSwapRect; |
1938 }; | 1938 }; |
1939 | 1939 |
1940 // Make sure damage tracking propagates all the way to the graphics context, | 1940 // Make sure damage tracking propagates all the way to the graphics context, |
1941 // where it should request to swap only the subBuffer that is damaged. | 1941 // where it should request to swap only the subBuffer that is damaged. |
1942 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) | 1942 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) |
1943 { | 1943 { |
1944 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); | 1944 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); |
1945 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); | 1945 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); |
1946 | 1946 |
1947 // This test creates its own LayerTreeHostImpl, so | 1947 // This test creates its own LayerTreeHostImpl, so |
1948 // that we can force partial swap enabled. | 1948 // that we can force partial swap enabled. |
1949 LayerTreeSettings settings; | 1949 LayerTreeSettings settings; |
1950 Settings::setPartialSwapEnabled(true); | 1950 Settings::setPartialSwapEnabled(true); |
1951 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this); | 1951 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this); |
1952 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 1952 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
1953 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); | 1953 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
1954 | 1954 |
1955 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 1955 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
1956 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); | 1956 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); |
1957 child->setPosition(FloatPoint(12, 13)); | 1957 child->setPosition(gfx::PointF(12, 13)); |
1958 child->setAnchorPoint(FloatPoint(0, 0)); | 1958 child->setAnchorPoint(gfx::PointF(0, 0)); |
1959 child->setBounds(IntSize(14, 15)); | 1959 child->setBounds(gfx::Size(14, 15)); |
1960 child->setContentBounds(IntSize(14, 15)); | 1960 child->setContentBounds(gfx::Size(14, 15)); |
1961 child->setDrawsContent(true); | 1961 child->setDrawsContent(true); |
1962 root->setAnchorPoint(FloatPoint(0, 0)); | 1962 root->setAnchorPoint(gfx::PointF(0, 0)); |
1963 root->setBounds(IntSize(500, 500)); | 1963 root->setBounds(gfx::Size(500, 500)); |
1964 root->setContentBounds(IntSize(500, 500)); | 1964 root->setContentBounds(gfx::Size(500, 500)); |
1965 root->setDrawsContent(true); | 1965 root->setDrawsContent(true); |
1966 root->addChild(child.Pass()); | 1966 root->addChild(child.Pass()); |
1967 layerTreeHostImpl->setRootLayer(root.Pass()); | 1967 layerTreeHostImpl->setRootLayer(root.Pass()); |
1968 | 1968 |
1969 LayerTreeHostImpl::FrameData frame; | 1969 LayerTreeHostImpl::FrameData frame; |
1970 | 1970 |
1971 // First frame, the entire screen should get swapped. | 1971 // First frame, the entire screen should get swapped. |
1972 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 1972 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
1973 layerTreeHostImpl->drawLayers(frame); | 1973 layerTreeHostImpl->drawLayers(frame); |
1974 layerTreeHostImpl->didDrawAllLayers(frame); | 1974 layerTreeHostImpl->didDrawAllLayers(frame); |
1975 layerTreeHostImpl->swapBuffers(); | 1975 layerTreeHostImpl->swapBuffers(); |
1976 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); | 1976 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); |
1977 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); | 1977 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500)); |
1978 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 1978 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
1979 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 1979 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
1980 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 1980 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
1981 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 1981 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
1982 | 1982 |
1983 // Second frame, only the damaged area should get swapped. Damage should be
the union | 1983 // Second frame, only the damaged area should get swapped. Damage should be
the union |
1984 // of old and new child rects. | 1984 // of old and new child rects. |
1985 // expected damage rect: IntRect(IntPoint::zero(), IntSize(26, 28)); | 1985 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(26, 28)); |
1986 // expected swap rect: vertically flipped, with origin at bottom left corner
. | 1986 // expected swap rect: vertically flipped, with origin at bottom left corner
. |
1987 layerTreeHostImpl->rootLayer()->children()[0]->setPosition(FloatPoint(0, 0))
; | 1987 layerTreeHostImpl->rootLayer()->children()[0]->setPosition(gfx::PointF(0, 0)
); |
1988 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 1988 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
1989 layerTreeHostImpl->drawLayers(frame); | 1989 layerTreeHostImpl->drawLayers(frame); |
1990 m_hostImpl->didDrawAllLayers(frame); | 1990 m_hostImpl->didDrawAllLayers(frame); |
1991 layerTreeHostImpl->swapBuffers(); | 1991 layerTreeHostImpl->swapBuffers(); |
1992 actualSwapRect = partialSwapTracker->partialSwapRect(); | 1992 actualSwapRect = partialSwapTracker->partialSwapRect(); |
1993 expectedSwapRect = IntRect(IntPoint(0, 500-28), IntSize(26, 28)); | 1993 expectedSwapRect = gfx::Rect(gfx::Point(0, 500-28), gfx::Size(26, 28)); |
1994 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 1994 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
1995 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 1995 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
1996 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 1996 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
1997 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 1997 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
1998 | 1998 |
1999 // Make sure that partial swap is constrained to the viewport dimensions | 1999 // Make sure that partial swap is constrained to the viewport dimensions |
2000 // expected damage rect: IntRect(IntPoint::zero(), IntSize(500, 500)); | 2000 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(500, 500)); |
2001 // expected swap rect: flipped damage rect, but also clamped to viewport | 2001 // expected swap rect: flipped damage rect, but also clamped to viewport |
2002 layerTreeHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 2002 layerTreeHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
2003 layerTreeHostImpl->rootLayer()->setOpacity(0.7f); // this will damage everyt
hing | 2003 layerTreeHostImpl->rootLayer()->setOpacity(0.7f); // this will damage everyt
hing |
2004 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 2004 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
2005 layerTreeHostImpl->drawLayers(frame); | 2005 layerTreeHostImpl->drawLayers(frame); |
2006 m_hostImpl->didDrawAllLayers(frame); | 2006 m_hostImpl->didDrawAllLayers(frame); |
2007 layerTreeHostImpl->swapBuffers(); | 2007 layerTreeHostImpl->swapBuffers(); |
2008 actualSwapRect = partialSwapTracker->partialSwapRect(); | 2008 actualSwapRect = partialSwapTracker->partialSwapRect(); |
2009 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); | 2009 expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(10, 10)); |
2010 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 2010 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
2011 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 2011 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
2012 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 2012 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
2013 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 2013 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
2014 } | 2014 } |
2015 | 2015 |
2016 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 2016 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
2017 { | 2017 { |
2018 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 2018 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
2019 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); | 2019 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); |
2020 child->setAnchorPoint(FloatPoint(0, 0)); | 2020 child->setAnchorPoint(gfx::PointF(0, 0)); |
2021 child->setBounds(IntSize(10, 10)); | 2021 child->setBounds(gfx::Size(10, 10)); |
2022 child->setContentBounds(IntSize(10, 10)); | 2022 child->setContentBounds(gfx::Size(10, 10)); |
2023 child->setDrawsContent(true); | 2023 child->setDrawsContent(true); |
2024 root->setAnchorPoint(FloatPoint(0, 0)); | 2024 root->setAnchorPoint(gfx::PointF(0, 0)); |
2025 root->setBounds(IntSize(10, 10)); | 2025 root->setBounds(gfx::Size(10, 10)); |
2026 root->setContentBounds(IntSize(10, 10)); | 2026 root->setContentBounds(gfx::Size(10, 10)); |
2027 root->setDrawsContent(true); | 2027 root->setDrawsContent(true); |
2028 root->setOpacity(0.7f); | 2028 root->setOpacity(0.7f); |
2029 root->addChild(child.Pass()); | 2029 root->addChild(child.Pass()); |
2030 | 2030 |
2031 m_hostImpl->setRootLayer(root.Pass()); | 2031 m_hostImpl->setRootLayer(root.Pass()); |
2032 | 2032 |
2033 LayerTreeHostImpl::FrameData frame; | 2033 LayerTreeHostImpl::FrameData frame; |
2034 | 2034 |
2035 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2035 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2036 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2036 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
2037 EXPECT_EQ(1u, frame.renderPasses.size()); | 2037 EXPECT_EQ(1u, frame.renderPasses.size()); |
2038 m_hostImpl->didDrawAllLayers(frame); | 2038 m_hostImpl->didDrawAllLayers(frame); |
2039 } | 2039 } |
2040 | 2040 |
2041 } // namespace | 2041 } // namespace |
2042 | 2042 |
2043 class FakeLayerWithQuads : public LayerImpl { | 2043 class FakeLayerWithQuads : public LayerImpl { |
2044 public: | 2044 public: |
2045 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew FakeLayerWithQuads(id)); } | 2045 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew FakeLayerWithQuads(id)); } |
2046 | 2046 |
2047 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 2047 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE |
2048 { | 2048 { |
2049 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); | 2049 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); |
2050 | 2050 |
2051 SkColor gray = SkColorSetRGB(100, 100, 100); | 2051 SkColor gray = SkColorSetRGB(100, 100, 100); |
2052 IntRect quadRect(IntPoint(0, 0), contentBounds()); | 2052 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds()); |
2053 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::create(share
dQuadState, quadRect, gray); | 2053 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::create(share
dQuadState, quadRect, gray); |
2054 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); | 2054 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); |
2055 } | 2055 } |
2056 | 2056 |
2057 private: | 2057 private: |
2058 FakeLayerWithQuads(int id) | 2058 FakeLayerWithQuads(int id) |
2059 : LayerImpl(id) | 2059 : LayerImpl(id) |
2060 { | 2060 { |
2061 } | 2061 } |
2062 }; | 2062 }; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 harness.mustDrawSolidQuad(); | 2185 harness.mustDrawSolidQuad(); |
2186 { | 2186 { |
2187 LayerTreeHostImpl::FrameData frame; | 2187 LayerTreeHostImpl::FrameData frame; |
2188 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2188 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2189 myHostImpl->drawLayers(frame); | 2189 myHostImpl->drawLayers(frame); |
2190 myHostImpl->didDrawAllLayers(frame); | 2190 myHostImpl->didDrawAllLayers(frame); |
2191 } | 2191 } |
2192 Mock::VerifyAndClearExpectations(&mockContext); | 2192 Mock::VerifyAndClearExpectations(&mockContext); |
2193 | 2193 |
2194 // Damage a portion of the frame. | 2194 // Damage a portion of the frame. |
2195 myHostImpl->rootLayer()->setUpdateRect(IntRect(0, 0, 2, 3)); | 2195 myHostImpl->rootLayer()->setUpdateRect(gfx::Rect(0, 0, 2, 3)); |
2196 | 2196 |
2197 // The second frame will be partially-swapped (the y coordinates are flipped
). | 2197 // The second frame will be partially-swapped (the y coordinates are flipped
). |
2198 harness.mustSetScissor(0, 7, 2, 3); | 2198 harness.mustSetScissor(0, 7, 2, 3); |
2199 harness.mustDrawSolidQuad(); | 2199 harness.mustDrawSolidQuad(); |
2200 { | 2200 { |
2201 LayerTreeHostImpl::FrameData frame; | 2201 LayerTreeHostImpl::FrameData frame; |
2202 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2202 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2203 myHostImpl->drawLayers(frame); | 2203 myHostImpl->drawLayers(frame); |
2204 myHostImpl->didDrawAllLayers(frame); | 2204 myHostImpl->didDrawAllLayers(frame); |
2205 } | 2205 } |
(...skipping 24 matching lines...) Expand all Loading... |
2230 | 2230 |
2231 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client) | 2231 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client) |
2232 { | 2232 { |
2233 Settings::setPartialSwapEnabled(partialSwap); | 2233 Settings::setPartialSwapEnabled(partialSwap); |
2234 | 2234 |
2235 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 2235 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
2236 | 2236 |
2237 LayerTreeSettings settings; | 2237 LayerTreeSettings settings; |
2238 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client); | 2238 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client); |
2239 myHostImpl->initializeRenderer(context.Pass()); | 2239 myHostImpl->initializeRenderer(context.Pass()); |
2240 myHostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 2240 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
2241 | 2241 |
2242 /* | 2242 /* |
2243 Layers are created as follows: | 2243 Layers are created as follows: |
2244 | 2244 |
2245 +--------------------+ | 2245 +--------------------+ |
2246 | 1 | | 2246 | 1 | |
2247 | +-----------+ | | 2247 | +-----------+ | |
2248 | | 2 | | | 2248 | | 2 | | |
2249 | | +-------------------+ | 2249 | | +-------------------+ |
2250 | | | 3 | | 2250 | | | 3 | |
2251 | | +-------------------+ | 2251 | | +-------------------+ |
2252 | | | | | 2252 | | | | |
2253 | +-----------+ | | 2253 | +-----------+ | |
2254 | | | 2254 | | |
2255 | | | 2255 | | |
2256 +--------------------+ | 2256 +--------------------+ |
2257 | 2257 |
2258 Layers 1, 2 have render surfaces | 2258 Layers 1, 2 have render surfaces |
2259 */ | 2259 */ |
2260 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 2260 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
2261 scoped_ptr<LayerImpl> child = LayerImpl::create(2); | 2261 scoped_ptr<LayerImpl> child = LayerImpl::create(2); |
2262 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(3); | 2262 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(3); |
2263 | 2263 |
2264 IntRect rootRect(0, 0, 100, 100); | 2264 gfx::Rect rootRect(0, 0, 100, 100); |
2265 IntRect childRect(10, 10, 50, 50); | 2265 gfx::Rect childRect(10, 10, 50, 50); |
2266 IntRect grandChildRect(5, 5, 150, 150); | 2266 gfx::Rect grandChildRect(5, 5, 150, 150); |
2267 | 2267 |
2268 root->createRenderSurface(); | 2268 root->createRenderSurface(); |
2269 root->setAnchorPoint(FloatPoint(0, 0)); | 2269 root->setAnchorPoint(gfx::PointF(0, 0)); |
2270 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); | 2270 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
2271 root->setBounds(IntSize(rootRect.width(), rootRect.height())); | 2271 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
2272 root->setContentBounds(root->bounds()); | 2272 root->setContentBounds(root->bounds()); |
2273 root->setVisibleContentRect(rootRect); | 2273 root->setVisibleContentRect(rootRect); |
2274 root->setDrawsContent(false); | 2274 root->setDrawsContent(false); |
2275 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w
idth(), rootRect.height()))); | 2275 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(root
Rect.width(), rootRect.height()))); |
2276 | 2276 |
2277 child->setAnchorPoint(FloatPoint(0, 0)); | 2277 child->setAnchorPoint(gfx::PointF(0, 0)); |
2278 child->setPosition(FloatPoint(childRect.x(), childRect.y())); | 2278 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); |
2279 child->setOpacity(0.5f); | 2279 child->setOpacity(0.5f); |
2280 child->setBounds(IntSize(childRect.width(), childRect.height())); | 2280 child->setBounds(gfx::Size(childRect.width(), childRect.height())); |
2281 child->setContentBounds(child->bounds()); | 2281 child->setContentBounds(child->bounds()); |
2282 child->setVisibleContentRect(childRect); | 2282 child->setVisibleContentRect(childRect); |
2283 child->setDrawsContent(false); | 2283 child->setDrawsContent(false); |
2284 | 2284 |
2285 grandChild->setAnchorPoint(FloatPoint(0, 0)); | 2285 grandChild->setAnchorPoint(gfx::PointF(0, 0)); |
2286 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); | 2286 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
2287 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height(
))); | 2287 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
2288 grandChild->setContentBounds(grandChild->bounds()); | 2288 grandChild->setContentBounds(grandChild->bounds()); |
2289 grandChild->setVisibleContentRect(grandChildRect); | 2289 grandChild->setVisibleContentRect(grandChildRect); |
2290 grandChild->setDrawsContent(true); | 2290 grandChild->setDrawsContent(true); |
2291 | 2291 |
2292 child->addChild(grandChild.Pass()); | 2292 child->addChild(grandChild.Pass()); |
2293 root->addChild(child.Pass()); | 2293 root->addChild(child.Pass()); |
2294 | 2294 |
2295 myHostImpl->setRootLayer(root.Pass()); | 2295 myHostImpl->setRootLayer(root.Pass()); |
2296 return myHostImpl.Pass(); | 2296 return myHostImpl.Pass(); |
2297 } | 2297 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 public: | 2624 public: |
2625 static scoped_ptr<FakeScrollbarLayerImpl> create(int id) | 2625 static scoped_ptr<FakeScrollbarLayerImpl> create(int id) |
2626 { | 2626 { |
2627 return make_scoped_ptr(new FakeScrollbarLayerImpl(id)); | 2627 return make_scoped_ptr(new FakeScrollbarLayerImpl(id)); |
2628 } | 2628 } |
2629 | 2629 |
2630 void createResources(ResourceProvider* provider) | 2630 void createResources(ResourceProvider* provider) |
2631 { | 2631 { |
2632 DCHECK(provider); | 2632 DCHECK(provider); |
2633 int pool = 0; | 2633 int pool = 0; |
2634 IntSize size(10, 10); | 2634 gfx::Size size(10, 10); |
2635 GLenum format = GL_RGBA; | 2635 GLenum format = GL_RGBA; |
2636 ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsage
Any; | 2636 ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsage
Any; |
2637 setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollba
rThemeGeometryNonEmpty::create())); | 2637 setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollba
rThemeGeometryNonEmpty::create())); |
2638 | 2638 |
2639 setBackTrackResourceId(provider->createResource(pool, size, format, hint
)); | 2639 setBackTrackResourceId(provider->createResource(pool, size, format, hint
)); |
2640 setForeTrackResourceId(provider->createResource(pool, size, format, hint
)); | 2640 setForeTrackResourceId(provider->createResource(pool, size, format, hint
)); |
2641 setThumbResourceId(provider->createResource(pool, size, format, hint)); | 2641 setThumbResourceId(provider->createResource(pool, size, format, hint)); |
2642 } | 2642 } |
2643 | 2643 |
2644 protected: | 2644 protected: |
2645 explicit FakeScrollbarLayerImpl(int id) | 2645 explicit FakeScrollbarLayerImpl(int id) |
2646 : ScrollbarLayerImpl(id) | 2646 : ScrollbarLayerImpl(id) |
2647 { | 2647 { |
2648 } | 2648 } |
2649 }; | 2649 }; |
2650 | 2650 |
2651 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
er* provider) | 2651 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
er* provider) |
2652 { | 2652 { |
2653 ResourceProvider::ResourceId resourceId = provider->createResource(0, IntSiz
e(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); | 2653 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S
ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); |
2654 | 2654 |
2655 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(RenderPass::Id(1, 1
), IntRect(0, 0, 1, 1), WebTransformationMatrix()); | 2655 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(RenderPass::Id(1, 1
), gfx::Rect(0, 0, 1, 1), WebTransformationMatrix()); |
2656 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::create(WebTransfo
rmationMatrix(), IntRect(0, 0, 1, 1), IntRect(0, 0, 1, 1), 1, false); | 2656 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::create(WebTransfo
rmationMatrix(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 1, false); |
2657 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedState.get()
, IntRect(0, 0, 1, 1), resourceId, false, FloatRect(0, 0, 1, 1), false); | 2657 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedState.get()
, gfx::Rect(0, 0, 1, 1), resourceId, false, gfx::RectF(0, 0, 1, 1), false); |
2658 | 2658 |
2659 pass->appendSharedQuadState(sharedState.Pass()); | 2659 pass->appendSharedQuadState(sharedState.Pass()); |
2660 pass->appendQuad(quad.PassAs<DrawQuad>()); | 2660 pass->appendQuad(quad.PassAs<DrawQuad>()); |
2661 | 2661 |
2662 return pass.PassAs<RenderPass>(); | 2662 return pass.PassAs<RenderPass>(); |
2663 } | 2663 } |
2664 | 2664 |
2665 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2665 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
2666 { | 2666 { |
2667 int layerId = 1; | 2667 int layerId = 1; |
2668 | 2668 |
2669 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); | 2669 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); |
2670 rootLayer->setBounds(IntSize(10, 10)); | 2670 rootLayer->setBounds(gfx::Size(10, 10)); |
2671 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2671 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2672 | 2672 |
2673 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); | 2673 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); |
2674 tileLayer->setBounds(IntSize(10, 10)); | 2674 tileLayer->setBounds(gfx::Size(10, 10)); |
2675 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2675 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2676 tileLayer->setContentBounds(IntSize(10, 10)); | 2676 tileLayer->setContentBounds(gfx::Size(10, 10)); |
2677 tileLayer->setDrawsContent(true); | 2677 tileLayer->setDrawsContent(true); |
2678 tileLayer->setSkipsDraw(false); | 2678 tileLayer->setSkipsDraw(false); |
2679 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(IntSize(10, 1
0), LayerTilingData::NoBorderTexels)); | 2679 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); |
2680 tilingData->setBounds(IntSize(10, 10)); | 2680 tilingData->setBounds(gfx::Size(10, 10)); |
2681 tileLayer->setTilingData(*tilingData); | 2681 tileLayer->setTilingData(*tilingData); |
2682 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10), false); | 2682 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
2683 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); | 2683 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); |
2684 | 2684 |
2685 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(layerId
++); | 2685 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(layerId
++); |
2686 textureLayer->setBounds(IntSize(10, 10)); | 2686 textureLayer->setBounds(gfx::Size(10, 10)); |
2687 textureLayer->setAnchorPoint(FloatPoint(0, 0)); | 2687 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2688 textureLayer->setContentBounds(IntSize(10, 10)); | 2688 textureLayer->setContentBounds(gfx::Size(10, 10)); |
2689 textureLayer->setDrawsContent(true); | 2689 textureLayer->setDrawsContent(true); |
2690 textureLayer->setTextureId(1); | 2690 textureLayer->setTextureId(1); |
2691 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 2691 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
2692 | 2692 |
2693 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(layerId++); | 2693 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(layerId++); |
2694 maskLayer->setBounds(IntSize(10, 10)); | 2694 maskLayer->setBounds(gfx::Size(10, 10)); |
2695 maskLayer->setAnchorPoint(FloatPoint(0, 0)); | 2695 maskLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2696 maskLayer->setContentBounds(IntSize(10, 10)); | 2696 maskLayer->setContentBounds(gfx::Size(10, 10)); |
2697 maskLayer->setDrawsContent(true); | 2697 maskLayer->setDrawsContent(true); |
2698 maskLayer->setSkipsDraw(false); | 2698 maskLayer->setSkipsDraw(false); |
2699 maskLayer->setTilingData(*tilingData); | 2699 maskLayer->setTilingData(*tilingData); |
2700 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10), false); | 2700 maskLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
2701 | 2701 |
2702 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create
(layerId++); | 2702 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create
(layerId++); |
2703 textureLayerWithMask->setBounds(IntSize(10, 10)); | 2703 textureLayerWithMask->setBounds(gfx::Size(10, 10)); |
2704 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); | 2704 textureLayerWithMask->setAnchorPoint(gfx::PointF(0, 0)); |
2705 textureLayerWithMask->setContentBounds(IntSize(10, 10)); | 2705 textureLayerWithMask->setContentBounds(gfx::Size(10, 10)); |
2706 textureLayerWithMask->setDrawsContent(true); | 2706 textureLayerWithMask->setDrawsContent(true); |
2707 textureLayerWithMask->setTextureId(1); | 2707 textureLayerWithMask->setTextureId(1); |
2708 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); | 2708 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); |
2709 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); | 2709 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); |
2710 | 2710 |
2711 FakeVideoFrame videoFrame(VideoFrame::CreateColorFrame(gfx::Size(4, 4), | 2711 FakeVideoFrame videoFrame(VideoFrame::CreateColorFrame(gfx::Size(4, 4), |
2712 0x80, 0x80, 0x80, | 2712 0x80, 0x80, 0x80, |
2713 base::TimeDelta())); | 2713 base::TimeDelta())); |
2714 VideoLayerImpl::FrameUnwrapper unwrapper = | 2714 VideoLayerImpl::FrameUnwrapper unwrapper = |
2715 base::Bind(FakeVideoFrame::toVideoFrame); | 2715 base::Bind(FakeVideoFrame::toVideoFrame); |
2716 FakeVideoFrameProvider provider; | 2716 FakeVideoFrameProvider provider; |
2717 provider.setFrame(&videoFrame); | 2717 provider.setFrame(&videoFrame); |
2718 scoped_ptr<VideoLayerImpl> videoLayer = | 2718 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider, unwrapper); |
2719 VideoLayerImpl::create(layerId++, &provider, unwrapper); | 2719 videoLayer->setBounds(gfx::Size(10, 10)); |
2720 videoLayer->setBounds(IntSize(10, 10)); | 2720 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2721 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2721 videoLayer->setContentBounds(gfx::Size(10, 10)); |
2722 videoLayer->setContentBounds(IntSize(10, 10)); | |
2723 videoLayer->setDrawsContent(true); | 2722 videoLayer->setDrawsContent(true); |
2724 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2723 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2725 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2724 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2726 | 2725 |
2727 FakeVideoFrameProvider hwProvider; | 2726 FakeVideoFrameProvider hwProvider; |
2728 scoped_ptr<VideoLayerImpl> hwVideoLayer = | 2727 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++,
&hwProvider, unwrapper); |
2729 VideoLayerImpl::create(layerId++, &hwProvider, unwrapper); | 2728 hwVideoLayer->setBounds(gfx::Size(10, 10)); |
2730 hwVideoLayer->setBounds(IntSize(10, 10)); | 2729 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2731 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2730 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); |
2732 hwVideoLayer->setContentBounds(IntSize(10, 10)); | |
2733 hwVideoLayer->setDrawsContent(true); | 2731 hwVideoLayer->setDrawsContent(true); |
2734 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2732 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2735 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); | 2733 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); |
2736 | 2734 |
2737 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l
ayerId++); | 2735 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l
ayerId++); |
2738 ioSurfaceLayer->setBounds(IntSize(10, 10)); | 2736 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
2739 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); | 2737 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2740 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); | 2738 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
2741 ioSurfaceLayer->setDrawsContent(true); | 2739 ioSurfaceLayer->setDrawsContent(true); |
2742 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); | 2740 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
2743 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2741 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2744 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 2742 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
2745 | 2743 |
2746 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea
te(layerId++); | 2744 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea
te(layerId++); |
2747 hudLayer->setBounds(IntSize(10, 10)); | 2745 hudLayer->setBounds(gfx::Size(10, 10)); |
2748 hudLayer->setAnchorPoint(FloatPoint(0, 0)); | 2746 hudLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2749 hudLayer->setContentBounds(IntSize(10, 10)); | 2747 hudLayer->setContentBounds(gfx::Size(10, 10)); |
2750 hudLayer->setDrawsContent(true); | 2748 hudLayer->setDrawsContent(true); |
2751 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2749 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2752 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); | 2750 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); |
2753 | 2751 |
2754 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr
eate(layerId++)); | 2752 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr
eate(layerId++)); |
2755 scrollbarLayer->setBounds(IntSize(10, 10)); | 2753 scrollbarLayer->setBounds(gfx::Size(10, 10)); |
2756 scrollbarLayer->setContentBounds(IntSize(10, 10)); | 2754 scrollbarLayer->setContentBounds(gfx::Size(10, 10)); |
2757 scrollbarLayer->setDrawsContent(true); | 2755 scrollbarLayer->setDrawsContent(true); |
2758 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2756 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2759 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); | 2757 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); |
2760 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); | 2758 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); |
2761 | 2759 |
2762 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende
rerLayerImpl::create(layerId++)); | 2760 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende
rerLayerImpl::create(layerId++)); |
2763 delegatedRendererLayer->setBounds(IntSize(10, 10)); | 2761 delegatedRendererLayer->setBounds(gfx::Size(10, 10)); |
2764 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); | 2762 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); |
2765 delegatedRendererLayer->setDrawsContent(true); | 2763 delegatedRendererLayer->setDrawsContent(true); |
2766 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2764 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2767 ScopedPtrVector<RenderPass> passList; | 2765 ScopedPtrVector<RenderPass> passList; |
2768 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); | 2766 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); |
2769 delegatedRendererLayer->setRenderPasses(passList); | 2767 delegatedRendererLayer->setRenderPasses(passList); |
2770 EXPECT_TRUE(passList.isEmpty()); | 2768 EXPECT_TRUE(passList.isEmpty()); |
2771 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2769 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
2772 | 2770 |
2773 // Use a context that supports IOSurfaces | 2771 // Use a context that supports IOSurfaces |
2774 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); | 2772 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 unsigned numTextures() const { return m_numTextures; } | 2858 unsigned numTextures() const { return m_numTextures; } |
2861 | 2859 |
2862 private: | 2860 private: |
2863 base::hash_map<WebGLId, bool> m_textures; | 2861 base::hash_map<WebGLId, bool> m_textures; |
2864 unsigned m_numTextures; | 2862 unsigned m_numTextures; |
2865 }; | 2863 }; |
2866 | 2864 |
2867 TEST_P(LayerTreeHostImplTest, layersFreeTextures) | 2865 TEST_P(LayerTreeHostImplTest, layersFreeTextures) |
2868 { | 2866 { |
2869 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(1)); | 2867 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(1)); |
2870 rootLayer->setBounds(IntSize(10, 10)); | 2868 rootLayer->setBounds(gfx::Size(10, 10)); |
2871 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2869 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2872 | 2870 |
2873 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(2); | 2871 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(2); |
2874 tileLayer->setBounds(IntSize(10, 10)); | 2872 tileLayer->setBounds(gfx::Size(10, 10)); |
2875 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2873 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2876 tileLayer->setContentBounds(IntSize(10, 10)); | 2874 tileLayer->setContentBounds(gfx::Size(10, 10)); |
2877 tileLayer->setDrawsContent(true); | 2875 tileLayer->setDrawsContent(true); |
2878 tileLayer->setSkipsDraw(false); | 2876 tileLayer->setSkipsDraw(false); |
2879 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(IntSize(10, 1
0), LayerTilingData::NoBorderTexels)); | 2877 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); |
2880 tilingData->setBounds(IntSize(10, 10)); | 2878 tilingData->setBounds(gfx::Size(10, 10)); |
2881 tileLayer->setTilingData(*tilingData); | 2879 tileLayer->setTilingData(*tilingData); |
2882 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10), false); | 2880 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
2883 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); | 2881 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); |
2884 | 2882 |
2885 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(3); | 2883 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(3); |
2886 textureLayer->setBounds(IntSize(10, 10)); | 2884 textureLayer->setBounds(gfx::Size(10, 10)); |
2887 textureLayer->setAnchorPoint(FloatPoint(0, 0)); | 2885 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2888 textureLayer->setContentBounds(IntSize(10, 10)); | 2886 textureLayer->setContentBounds(gfx::Size(10, 10)); |
2889 textureLayer->setDrawsContent(true); | 2887 textureLayer->setDrawsContent(true); |
2890 textureLayer->setTextureId(1); | 2888 textureLayer->setTextureId(1); |
2891 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 2889 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
2892 | 2890 |
2893 VideoLayerImpl::FrameUnwrapper unwrapper = | 2891 VideoLayerImpl::FrameUnwrapper unwrapper = |
2894 base::Bind(FakeVideoFrame::toVideoFrame); | 2892 base::Bind(FakeVideoFrame::toVideoFrame); |
2895 FakeVideoFrameProvider provider; | 2893 FakeVideoFrameProvider provider; |
2896 scoped_ptr<VideoLayerImpl> videoLayer = | 2894 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider,
unwrapper); |
2897 VideoLayerImpl::create(4, &provider, unwrapper); | 2895 videoLayer->setBounds(gfx::Size(10, 10)); |
2898 videoLayer->setBounds(IntSize(10, 10)); | 2896 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2899 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2897 videoLayer->setContentBounds(gfx::Size(10, 10)); |
2900 videoLayer->setContentBounds(IntSize(10, 10)); | |
2901 videoLayer->setDrawsContent(true); | 2898 videoLayer->setDrawsContent(true); |
2902 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2899 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2903 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2900 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2904 | 2901 |
2905 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5
); | 2902 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5
); |
2906 ioSurfaceLayer->setBounds(IntSize(10, 10)); | 2903 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
2907 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); | 2904 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2908 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); | 2905 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
2909 ioSurfaceLayer->setDrawsContent(true); | 2906 ioSurfaceLayer->setDrawsContent(true); |
2910 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); | 2907 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
2911 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2908 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2912 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 2909 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
2913 | 2910 |
2914 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the LayerTreeHostImpl takes ownership of). | 2911 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the LayerTreeHostImpl takes ownership of). |
2915 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))
); | 2912 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))
); |
2916 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(outputSurface->context3D()); | 2913 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(outputSurface->context3D()); |
2917 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2914 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
2918 | 2915 |
2919 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2916 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2920 | 2917 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2960 Mock::VerifyAndClearExpectations(&mockContext); | 2957 Mock::VerifyAndClearExpectations(&mockContext); |
2961 | 2958 |
2962 // Verify no quads are drawn when transparent background is set. | 2959 // Verify no quads are drawn when transparent background is set. |
2963 myHostImpl->setHasTransparentBackground(true); | 2960 myHostImpl->setHasTransparentBackground(true); |
2964 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2961 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2965 myHostImpl->drawLayers(frame); | 2962 myHostImpl->drawLayers(frame); |
2966 myHostImpl->didDrawAllLayers(frame); | 2963 myHostImpl->didDrawAllLayers(frame); |
2967 Mock::VerifyAndClearExpectations(&mockContext); | 2964 Mock::VerifyAndClearExpectations(&mockContext); |
2968 } | 2965 } |
2969 | 2966 |
2970 static void addDrawingLayerTo(LayerImpl* parent, int id, const IntRect& layerRec
t, LayerImpl** result) | 2967 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) |
2971 { | 2968 { |
2972 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(id); | 2969 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(id); |
2973 LayerImpl* layerPtr = layer.get(); | 2970 LayerImpl* layerPtr = layer.get(); |
2974 layerPtr->setAnchorPoint(FloatPoint(0, 0)); | 2971 layerPtr->setAnchorPoint(gfx::PointF(0, 0)); |
2975 layerPtr->setPosition(FloatPoint(layerRect.location())); | 2972 layerPtr->setPosition(gfx::PointF(layerRect.origin())); |
2976 layerPtr->setBounds(layerRect.size()); | 2973 layerPtr->setBounds(layerRect.size()); |
2977 layerPtr->setContentBounds(layerRect.size()); | 2974 layerPtr->setContentBounds(layerRect.size()); |
2978 layerPtr->setDrawsContent(true); // only children draw content | 2975 layerPtr->setDrawsContent(true); // only children draw content |
2979 layerPtr->setContentsOpaque(true); | 2976 layerPtr->setContentsOpaque(true); |
2980 parent->addChild(layer.Pass()); | 2977 parent->addChild(layer.Pass()); |
2981 if (result) | 2978 if (result) |
2982 *result = layerPtr; | 2979 *result = layerPtr; |
2983 } | 2980 } |
2984 | 2981 |
2985 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const IntSize& rootSize) | 2982 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) |
2986 { | 2983 { |
2987 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 2984 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
2988 | 2985 |
2989 layerTreeHostImpl->initializeRenderer(context.Pass()); | 2986 layerTreeHostImpl->initializeRenderer(context.Pass()); |
2990 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 2987 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
2991 | 2988 |
2992 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 2989 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
2993 rootPtr = root.get(); | 2990 rootPtr = root.get(); |
2994 | 2991 |
2995 root->setAnchorPoint(FloatPoint(0, 0)); | 2992 root->setAnchorPoint(gfx::PointF(0, 0)); |
2996 root->setPosition(FloatPoint(0, 0)); | 2993 root->setPosition(gfx::PointF(0, 0)); |
2997 root->setBounds(rootSize); | 2994 root->setBounds(rootSize); |
2998 root->setContentBounds(rootSize); | 2995 root->setContentBounds(rootSize); |
2999 root->setDrawsContent(true); | 2996 root->setDrawsContent(true); |
3000 layerTreeHostImpl->setRootLayer(root.Pass()); | 2997 layerTreeHostImpl->setRootLayer(root.Pass()); |
3001 | 2998 |
3002 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei
ght()), &intermediateLayerPtr); | 2999 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); |
3003 intermediateLayerPtr->setDrawsContent(false); // only children draw content | 3000 intermediateLayerPtr->setDrawsContent(false); // only children draw content |
3004 | 3001 |
3005 // Surface layer is the layer that changes its opacity | 3002 // Surface layer is the layer that changes its opacity |
3006 // It will contain other layers that draw content. | 3003 // It will contain other layers that draw content. |
3007 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(),
rootSize.height()), &surfaceLayerPtr); | 3004 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); |
3008 surfaceLayerPtr->setDrawsContent(false); // only children draw content | 3005 surfaceLayerPtr->setDrawsContent(false); // only children draw content |
3009 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface | 3006 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface |
3010 | 3007 |
3011 // Child of the surface layer will produce some quads | 3008 // Child of the surface layer will produce some quads |
3012 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, r
ootSize.height() - 25), &childPtr); | 3009 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25,
rootSize.height() - 25), &childPtr); |
3013 } | 3010 } |
3014 | 3011 |
3015 class GLRendererWithReleaseTextures : public GLRenderer { | 3012 class GLRendererWithReleaseTextures : public GLRenderer { |
3016 public: | 3013 public: |
3017 using GLRenderer::releaseRenderPassTextures; | 3014 using GLRenderer::releaseRenderPassTextures; |
3018 }; | 3015 }; |
3019 | 3016 |
3020 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) | 3017 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) |
3021 { | 3018 { |
3022 Settings::setPartialSwapEnabled(true); | 3019 Settings::setPartialSwapEnabled(true); |
3023 | 3020 |
3024 LayerTreeSettings settings; | 3021 LayerTreeSettings settings; |
3025 settings.minimumOcclusionTrackingSize = IntSize(); | 3022 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3026 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3023 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3027 | 3024 |
3028 LayerImpl* rootPtr; | 3025 LayerImpl* rootPtr; |
3029 LayerImpl* surfaceLayerPtr; | 3026 LayerImpl* surfaceLayerPtr; |
3030 | 3027 |
3031 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3028 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3032 | 3029 |
3033 IntSize rootSize(100, 100); | 3030 gfx::Size rootSize(100, 100); |
3034 | 3031 |
3035 myHostImpl->initializeRenderer(context.Pass()); | 3032 myHostImpl->initializeRenderer(context.Pass()); |
3036 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3033 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3037 | 3034 |
3038 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3035 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3039 rootPtr = root.get(); | 3036 rootPtr = root.get(); |
3040 | 3037 |
3041 root->setAnchorPoint(FloatPoint(0, 0)); | 3038 root->setAnchorPoint(gfx::PointF(0, 0)); |
3042 root->setPosition(FloatPoint(0, 0)); | 3039 root->setPosition(gfx::PointF(0, 0)); |
3043 root->setBounds(rootSize); | 3040 root->setBounds(rootSize); |
3044 root->setContentBounds(rootSize); | 3041 root->setContentBounds(rootSize); |
3045 root->setDrawsContent(true); | 3042 root->setDrawsContent(true); |
3046 root->setMasksToBounds(true); | 3043 root->setMasksToBounds(true); |
3047 myHostImpl->setRootLayer(root.Pass()); | 3044 myHostImpl->setRootLayer(root.Pass()); |
3048 | 3045 |
3049 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh
t()), &surfaceLayerPtr); | 3046 addDrawingLayerTo(rootPtr, 3, gfx::Rect(0, 0, rootSize.width(), rootSize.hei
ght()), &surfaceLayerPtr); |
3050 surfaceLayerPtr->setDrawsContent(false); | 3047 surfaceLayerPtr->setDrawsContent(false); |
3051 | 3048 |
3052 // Surface layer is the layer that changes its opacity | 3049 // Surface layer is the layer that changes its opacity |
3053 // It will contain other layers that draw content. | 3050 // It will contain other layers that draw content. |
3054 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface | 3051 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface |
3055 | 3052 |
3056 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); | 3053 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0); |
3057 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); | 3054 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0); |
3058 | 3055 |
3059 // Rotation will put part of the child ouside the bounds of the root layer. | 3056 // Rotation will put part of the child ouside the bounds of the root layer. |
3060 // Nevertheless, the child layers should be drawn. | 3057 // Nevertheless, the child layers should be drawn. |
3061 WebTransformationMatrix transform = surfaceLayerPtr->transform(); | 3058 WebTransformationMatrix transform = surfaceLayerPtr->transform(); |
3062 transform.translate(50, 50); | 3059 transform.translate(50, 50); |
3063 transform.rotate(35); | 3060 transform.rotate(35); |
3064 transform.translate(-50, -50); | 3061 transform.translate(-50, -50); |
3065 surfaceLayerPtr->setTransform(transform); | 3062 surfaceLayerPtr->setTransform(transform); |
3066 | 3063 |
3067 { | 3064 { |
3068 LayerTreeHostImpl::FrameData frame; | 3065 LayerTreeHostImpl::FrameData frame; |
3069 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3066 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3070 | 3067 |
3071 // Must receive two render passes, each with one quad | 3068 // Must receive two render passes, each with one quad |
3072 ASSERT_EQ(2U, frame.renderPasses.size()); | 3069 ASSERT_EQ(2U, frame.renderPasses.size()); |
3073 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3070 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
3074 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 3071 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
3075 | 3072 |
3076 // Verify that the child layers are being clipped. | 3073 // Verify that the child layers are being clipped. |
3077 gfx::Rect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->quadVi
sibleRect(); | 3074 gfx::Rect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->quadVi
sibleRect(); |
3078 EXPECT_LT(quadVisibleRect.width(), 100); | 3075 EXPECT_LT(quadVisibleRect.width(), 100); |
3079 | 3076 |
3080 quadVisibleRect = frame.renderPasses[0]->quadList()[1]->quadVisibleRect(
); | 3077 quadVisibleRect = frame.renderPasses[0]->quadList()[1]->quadVisibleRect(
); |
3081 EXPECT_LT(quadVisibleRect.width(), 100); | 3078 EXPECT_LT(quadVisibleRect.width(), 100); |
3082 | 3079 |
3083 // Verify that the render surface texture is *not* clipped. | 3080 // Verify that the render surface texture is *not* clipped. |
3084 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), frame.renderPasses[0]->outputRec
t()); | 3081 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), frame.renderPasses[0]->outputR
ect()); |
3085 | 3082 |
3086 EXPECT_EQ(DrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->ma
terial()); | 3083 EXPECT_EQ(DrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->ma
terial()); |
3087 RenderPassDrawQuad* quad = static_cast<RenderPassDrawQuad*>(frame.render
Passes[1]->quadList()[0]); | 3084 RenderPassDrawQuad* quad = static_cast<RenderPassDrawQuad*>(frame.render
Passes[1]->quadList()[0]); |
3088 EXPECT_FALSE(quad->contentsChangedSinceLastFrame().IsEmpty()); | 3085 EXPECT_FALSE(quad->contentsChangedSinceLastFrame().IsEmpty()); |
3089 | 3086 |
3090 myHostImpl->drawLayers(frame); | 3087 myHostImpl->drawLayers(frame); |
3091 myHostImpl->didDrawAllLayers(frame); | 3088 myHostImpl->didDrawAllLayers(frame); |
3092 } | 3089 } |
3093 | 3090 |
3094 transform = surfaceLayerPtr->transform(); | 3091 transform = surfaceLayerPtr->transform(); |
(...skipping 17 matching lines...) Expand all Loading... |
3112 myHostImpl->drawLayers(frame); | 3109 myHostImpl->drawLayers(frame); |
3113 myHostImpl->didDrawAllLayers(frame); | 3110 myHostImpl->didDrawAllLayers(frame); |
3114 } | 3111 } |
3115 } | 3112 } |
3116 | 3113 |
3117 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) | 3114 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) |
3118 { | 3115 { |
3119 Settings::setPartialSwapEnabled(false); | 3116 Settings::setPartialSwapEnabled(false); |
3120 | 3117 |
3121 LayerTreeSettings settings; | 3118 LayerTreeSettings settings; |
3122 settings.minimumOcclusionTrackingSize = IntSize(); | 3119 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3123 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3120 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3124 | 3121 |
3125 // Layers are structure as follows: | 3122 // Layers are structure as follows: |
3126 // | 3123 // |
3127 // R +-- S1 +- L10 (owning) | 3124 // R +-- S1 +- L10 (owning) |
3128 // | +- L11 | 3125 // | +- L11 |
3129 // | +- L12 | 3126 // | +- L12 |
3130 // | | 3127 // | |
3131 // +-- S2 +- L20 (owning) | 3128 // +-- S2 +- L20 (owning) |
3132 // +- L21 | 3129 // +- L21 |
3133 // | 3130 // |
3134 // Occlusion: | 3131 // Occlusion: |
3135 // L12 occludes L11 (internal) | 3132 // L12 occludes L11 (internal) |
3136 // L20 occludes L10 (external) | 3133 // L20 occludes L10 (external) |
3137 // L21 occludes L20 (internal) | 3134 // L21 occludes L20 (internal) |
3138 | 3135 |
3139 LayerImpl* rootPtr; | 3136 LayerImpl* rootPtr; |
3140 LayerImpl* layerS1Ptr; | 3137 LayerImpl* layerS1Ptr; |
3141 LayerImpl* layerS2Ptr; | 3138 LayerImpl* layerS2Ptr; |
3142 | 3139 |
3143 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3140 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3144 | 3141 |
3145 IntSize rootSize(1000, 1000); | 3142 gfx::Size rootSize(1000, 1000); |
3146 | 3143 |
3147 myHostImpl->initializeRenderer(context.Pass()); | 3144 myHostImpl->initializeRenderer(context.Pass()); |
3148 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3145 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3149 | 3146 |
3150 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3147 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3151 rootPtr = root.get(); | 3148 rootPtr = root.get(); |
3152 | 3149 |
3153 root->setAnchorPoint(FloatPoint(0, 0)); | 3150 root->setAnchorPoint(gfx::PointF(0, 0)); |
3154 root->setPosition(FloatPoint(0, 0)); | 3151 root->setPosition(gfx::PointF(0, 0)); |
3155 root->setBounds(rootSize); | 3152 root->setBounds(rootSize); |
3156 root->setContentBounds(rootSize); | 3153 root->setContentBounds(rootSize); |
3157 root->setDrawsContent(true); | 3154 root->setDrawsContent(true); |
3158 root->setMasksToBounds(true); | 3155 root->setMasksToBounds(true); |
3159 myHostImpl->setRootLayer(root.Pass()); | 3156 myHostImpl->setRootLayer(root.Pass()); |
3160 | 3157 |
3161 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); | 3158 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
3162 layerS1Ptr->setForceRenderSurface(true); | 3159 layerS1Ptr->setForceRenderSurface(true); |
3163 | 3160 |
3164 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 | 3161 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
3165 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 | 3162 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
3166 | 3163 |
3167 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); | 3164 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
3168 layerS2Ptr->setForceRenderSurface(true); | 3165 layerS2Ptr->setForceRenderSurface(true); |
3169 | 3166 |
3170 addDrawingLayerTo(layerS2Ptr, 6, IntRect(20, 20, 5, 5), 0); // L21 | 3167 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 |
3171 | 3168 |
3172 // Initial draw - must receive all quads | 3169 // Initial draw - must receive all quads |
3173 { | 3170 { |
3174 LayerTreeHostImpl::FrameData frame; | 3171 LayerTreeHostImpl::FrameData frame; |
3175 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3172 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3176 | 3173 |
3177 // Must receive 3 render passes. | 3174 // Must receive 3 render passes. |
3178 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded
); for S2, there is 2 quads. | 3175 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded
); for S2, there is 2 quads. |
3179 ASSERT_EQ(3U, frame.renderPasses.size()); | 3176 ASSERT_EQ(3U, frame.renderPasses.size()); |
3180 | 3177 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3228 myHostImpl->didDrawAllLayers(frame); | 3225 myHostImpl->didDrawAllLayers(frame); |
3229 } | 3226 } |
3230 | 3227 |
3231 } | 3228 } |
3232 | 3229 |
3233 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) | 3230 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) |
3234 { | 3231 { |
3235 Settings::setPartialSwapEnabled(false); | 3232 Settings::setPartialSwapEnabled(false); |
3236 | 3233 |
3237 LayerTreeSettings settings; | 3234 LayerTreeSettings settings; |
3238 settings.minimumOcclusionTrackingSize = IntSize(); | 3235 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3239 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3236 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3240 | 3237 |
3241 // Layers are structure as follows: | 3238 // Layers are structure as follows: |
3242 // | 3239 // |
3243 // R +-- S1 +- L10 (owning, non drawing) | 3240 // R +-- S1 +- L10 (owning, non drawing) |
3244 // | +- L11 (corner, unoccluded) | 3241 // | +- L11 (corner, unoccluded) |
3245 // | +- L12 (corner, unoccluded) | 3242 // | +- L12 (corner, unoccluded) |
3246 // | +- L13 (corner, unoccluded) | 3243 // | +- L13 (corner, unoccluded) |
3247 // | +- L14 (corner, entirely occluded) | 3244 // | +- L14 (corner, entirely occluded) |
3248 // | | 3245 // | |
3249 // +-- S2 +- L20 (owning, drawing) | 3246 // +-- S2 +- L20 (owning, drawing) |
3250 // | 3247 // |
3251 | 3248 |
3252 LayerImpl* rootPtr; | 3249 LayerImpl* rootPtr; |
3253 LayerImpl* layerS1Ptr; | 3250 LayerImpl* layerS1Ptr; |
3254 LayerImpl* layerS2Ptr; | 3251 LayerImpl* layerS2Ptr; |
3255 | 3252 |
3256 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3253 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3257 | 3254 |
3258 IntSize rootSize(1000, 1000); | 3255 gfx::Size rootSize(1000, 1000); |
3259 | 3256 |
3260 myHostImpl->initializeRenderer(context.Pass()); | 3257 myHostImpl->initializeRenderer(context.Pass()); |
3261 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3258 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3262 | 3259 |
3263 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3260 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3264 rootPtr = root.get(); | 3261 rootPtr = root.get(); |
3265 | 3262 |
3266 root->setAnchorPoint(FloatPoint(0, 0)); | 3263 root->setAnchorPoint(gfx::PointF(0, 0)); |
3267 root->setPosition(FloatPoint(0, 0)); | 3264 root->setPosition(gfx::PointF(0, 0)); |
3268 root->setBounds(rootSize); | 3265 root->setBounds(rootSize); |
3269 root->setContentBounds(rootSize); | 3266 root->setContentBounds(rootSize); |
3270 root->setDrawsContent(true); | 3267 root->setDrawsContent(true); |
3271 root->setMasksToBounds(true); | 3268 root->setMasksToBounds(true); |
3272 myHostImpl->setRootLayer(root.Pass()); | 3269 myHostImpl->setRootLayer(root.Pass()); |
3273 | 3270 |
3274 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); | 3271 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); |
3275 layerS1Ptr->setForceRenderSurface(true); | 3272 layerS1Ptr->setForceRenderSurface(true); |
3276 layerS1Ptr->setDrawsContent(false); | 3273 layerS1Ptr->setDrawsContent(false); |
3277 | 3274 |
3278 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 | 3275 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
3279 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 | 3276 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 |
3280 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 | 3277 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 |
3281 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 | 3278 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 |
3282 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 | 3279 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14 |
3283 | 3280 |
3284 addDrawingLayerTo(rootPtr, 7, IntRect(450, 450, 450, 450), &layerS2Ptr); | 3281 addDrawingLayerTo(rootPtr, 7, gfx::Rect(450, 450, 450, 450), &layerS2Ptr); |
3285 layerS2Ptr->setForceRenderSurface(true); | 3282 layerS2Ptr->setForceRenderSurface(true); |
3286 | 3283 |
3287 // Initial draw - must receive all quads | 3284 // Initial draw - must receive all quads |
3288 { | 3285 { |
3289 LayerTreeHostImpl::FrameData frame; | 3286 LayerTreeHostImpl::FrameData frame; |
3290 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3287 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3291 | 3288 |
3292 // Must receive 3 render passes. | 3289 // Must receive 3 render passes. |
3293 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. | 3290 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. |
3294 ASSERT_EQ(3U, frame.renderPasses.size()); | 3291 ASSERT_EQ(3U, frame.renderPasses.size()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3344 myHostImpl->drawLayers(frame); | 3341 myHostImpl->drawLayers(frame); |
3345 myHostImpl->didDrawAllLayers(frame); | 3342 myHostImpl->didDrawAllLayers(frame); |
3346 } | 3343 } |
3347 } | 3344 } |
3348 | 3345 |
3349 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) | 3346 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) |
3350 { | 3347 { |
3351 Settings::setPartialSwapEnabled(false); | 3348 Settings::setPartialSwapEnabled(false); |
3352 | 3349 |
3353 LayerTreeSettings settings; | 3350 LayerTreeSettings settings; |
3354 settings.minimumOcclusionTrackingSize = IntSize(); | 3351 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3355 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3352 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3356 | 3353 |
3357 // Layers are structured as follows: | 3354 // Layers are structured as follows: |
3358 // | 3355 // |
3359 // R +-- S1 +- L10 (owning, drawing) | 3356 // R +-- S1 +- L10 (owning, drawing) |
3360 // | +- L11 (corner, occluded by L12) | 3357 // | +- L11 (corner, occluded by L12) |
3361 // | +- L12 (opposite corner) | 3358 // | +- L12 (opposite corner) |
3362 // | | 3359 // | |
3363 // +-- S2 +- L20 (owning, drawing) | 3360 // +-- S2 +- L20 (owning, drawing) |
3364 // | 3361 // |
3365 | 3362 |
3366 LayerImpl* rootPtr; | 3363 LayerImpl* rootPtr; |
3367 LayerImpl* layerS1Ptr; | 3364 LayerImpl* layerS1Ptr; |
3368 LayerImpl* layerS2Ptr; | 3365 LayerImpl* layerS2Ptr; |
3369 | 3366 |
3370 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3367 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3371 | 3368 |
3372 IntSize rootSize(1000, 1000); | 3369 gfx::Size rootSize(1000, 1000); |
3373 | 3370 |
3374 myHostImpl->initializeRenderer(context.Pass()); | 3371 myHostImpl->initializeRenderer(context.Pass()); |
3375 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3372 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3376 | 3373 |
3377 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3374 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3378 rootPtr = root.get(); | 3375 rootPtr = root.get(); |
3379 | 3376 |
3380 root->setAnchorPoint(FloatPoint(0, 0)); | 3377 root->setAnchorPoint(gfx::PointF(0, 0)); |
3381 root->setPosition(FloatPoint(0, 0)); | 3378 root->setPosition(gfx::PointF(0, 0)); |
3382 root->setBounds(rootSize); | 3379 root->setBounds(rootSize); |
3383 root->setContentBounds(rootSize); | 3380 root->setContentBounds(rootSize); |
3384 root->setDrawsContent(true); | 3381 root->setDrawsContent(true); |
3385 root->setMasksToBounds(true); | 3382 root->setMasksToBounds(true); |
3386 myHostImpl->setRootLayer(root.Pass()); | 3383 myHostImpl->setRootLayer(root.Pass()); |
3387 | 3384 |
3388 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); | 3385 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
3389 layerS1Ptr->setForceRenderSurface(true); | 3386 layerS1Ptr->setForceRenderSurface(true); |
3390 | 3387 |
3391 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 | 3388 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
3392 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 | 3389 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 |
3393 | 3390 |
3394 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); | 3391 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); |
3395 layerS2Ptr->setForceRenderSurface(true); | 3392 layerS2Ptr->setForceRenderSurface(true); |
3396 | 3393 |
3397 // Initial draw - must receive all quads | 3394 // Initial draw - must receive all quads |
3398 { | 3395 { |
3399 LayerTreeHostImpl::FrameData frame; | 3396 LayerTreeHostImpl::FrameData frame; |
3400 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3397 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3401 | 3398 |
3402 // Must receive 3 render passes. | 3399 // Must receive 3 render passes. |
3403 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. | 3400 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. |
3404 ASSERT_EQ(3U, frame.renderPasses.size()); | 3401 ASSERT_EQ(3U, frame.renderPasses.size()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3445 // Layers are structured as follows: | 3442 // Layers are structured as follows: |
3446 // | 3443 // |
3447 // R +-- S1 +- L10 (rotated, drawing) | 3444 // R +-- S1 +- L10 (rotated, drawing) |
3448 // +- L11 (occupies half surface) | 3445 // +- L11 (occupies half surface) |
3449 | 3446 |
3450 LayerImpl* rootPtr; | 3447 LayerImpl* rootPtr; |
3451 LayerImpl* layerS1Ptr; | 3448 LayerImpl* layerS1Ptr; |
3452 | 3449 |
3453 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3450 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3454 | 3451 |
3455 IntSize rootSize(1000, 1000); | 3452 gfx::Size rootSize(1000, 1000); |
3456 | 3453 |
3457 myHostImpl->initializeRenderer(context.Pass()); | 3454 myHostImpl->initializeRenderer(context.Pass()); |
3458 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3455 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3459 | 3456 |
3460 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3457 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3461 rootPtr = root.get(); | 3458 rootPtr = root.get(); |
3462 | 3459 |
3463 root->setAnchorPoint(FloatPoint(0, 0)); | 3460 root->setAnchorPoint(gfx::PointF(0, 0)); |
3464 root->setPosition(FloatPoint(0, 0)); | 3461 root->setPosition(gfx::PointF(0, 0)); |
3465 root->setBounds(rootSize); | 3462 root->setBounds(rootSize); |
3466 root->setContentBounds(rootSize); | 3463 root->setContentBounds(rootSize); |
3467 root->setDrawsContent(true); | 3464 root->setDrawsContent(true); |
3468 root->setMasksToBounds(true); | 3465 root->setMasksToBounds(true); |
3469 myHostImpl->setRootLayer(root.Pass()); | 3466 myHostImpl->setRootLayer(root.Pass()); |
3470 | 3467 |
3471 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); | 3468 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
3472 layerS1Ptr->setForceRenderSurface(true); | 3469 layerS1Ptr->setForceRenderSurface(true); |
3473 WebTransformationMatrix transform = layerS1Ptr->transform(); | 3470 WebTransformationMatrix transform = layerS1Ptr->transform(); |
3474 transform.translate(200, 200); | 3471 transform.translate(200, 200); |
3475 transform.rotate(45); | 3472 transform.rotate(45); |
3476 transform.translate(-200, -200); | 3473 transform.translate(-200, -200); |
3477 layerS1Ptr->setTransform(transform); | 3474 layerS1Ptr->setTransform(transform); |
3478 | 3475 |
3479 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 | 3476 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 |
3480 | 3477 |
3481 // Initial draw - must receive all quads | 3478 // Initial draw - must receive all quads |
3482 { | 3479 { |
3483 LayerTreeHostImpl::FrameData frame; | 3480 LayerTreeHostImpl::FrameData frame; |
3484 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3481 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3485 | 3482 |
3486 // Must receive 2 render passes. | 3483 // Must receive 2 render passes. |
3487 ASSERT_EQ(2U, frame.renderPasses.size()); | 3484 ASSERT_EQ(2U, frame.renderPasses.size()); |
3488 | 3485 |
3489 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3486 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
(...skipping 17 matching lines...) Expand all Loading... |
3507 myHostImpl->drawLayers(frame); | 3504 myHostImpl->drawLayers(frame); |
3508 myHostImpl->didDrawAllLayers(frame); | 3505 myHostImpl->didDrawAllLayers(frame); |
3509 } | 3506 } |
3510 } | 3507 } |
3511 | 3508 |
3512 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) | 3509 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) |
3513 { | 3510 { |
3514 Settings::setPartialSwapEnabled(true); | 3511 Settings::setPartialSwapEnabled(true); |
3515 | 3512 |
3516 LayerTreeSettings settings; | 3513 LayerTreeSettings settings; |
3517 settings.minimumOcclusionTrackingSize = IntSize(); | 3514 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3518 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3515 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3519 | 3516 |
3520 // Layers are structure as follows: | 3517 // Layers are structure as follows: |
3521 // | 3518 // |
3522 // R +-- S1 +- L10 (owning) | 3519 // R +-- S1 +- L10 (owning) |
3523 // | +- L11 | 3520 // | +- L11 |
3524 // | +- L12 | 3521 // | +- L12 |
3525 // | | 3522 // | |
3526 // +-- S2 +- L20 (owning) | 3523 // +-- S2 +- L20 (owning) |
3527 // +- L21 | 3524 // +- L21 |
3528 // | 3525 // |
3529 // Occlusion: | 3526 // Occlusion: |
3530 // L12 occludes L11 (internal) | 3527 // L12 occludes L11 (internal) |
3531 // L20 occludes L10 (external) | 3528 // L20 occludes L10 (external) |
3532 // L21 occludes L20 (internal) | 3529 // L21 occludes L20 (internal) |
3533 | 3530 |
3534 LayerImpl* rootPtr; | 3531 LayerImpl* rootPtr; |
3535 LayerImpl* layerS1Ptr; | 3532 LayerImpl* layerS1Ptr; |
3536 LayerImpl* layerS2Ptr; | 3533 LayerImpl* layerS2Ptr; |
3537 | 3534 |
3538 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3535 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3539 | 3536 |
3540 IntSize rootSize(1000, 1000); | 3537 gfx::Size rootSize(1000, 1000); |
3541 | 3538 |
3542 myHostImpl->initializeRenderer(context.Pass()); | 3539 myHostImpl->initializeRenderer(context.Pass()); |
3543 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3540 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3544 | 3541 |
3545 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3542 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3546 rootPtr = root.get(); | 3543 rootPtr = root.get(); |
3547 | 3544 |
3548 root->setAnchorPoint(FloatPoint(0, 0)); | 3545 root->setAnchorPoint(gfx::PointF(0, 0)); |
3549 root->setPosition(FloatPoint(0, 0)); | 3546 root->setPosition(gfx::PointF(0, 0)); |
3550 root->setBounds(rootSize); | 3547 root->setBounds(rootSize); |
3551 root->setContentBounds(rootSize); | 3548 root->setContentBounds(rootSize); |
3552 root->setDrawsContent(true); | 3549 root->setDrawsContent(true); |
3553 root->setMasksToBounds(true); | 3550 root->setMasksToBounds(true); |
3554 myHostImpl->setRootLayer(root.Pass()); | 3551 myHostImpl->setRootLayer(root.Pass()); |
3555 | 3552 |
3556 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); | 3553 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
3557 layerS1Ptr->setForceRenderSurface(true); | 3554 layerS1Ptr->setForceRenderSurface(true); |
3558 | 3555 |
3559 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 | 3556 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
3560 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 | 3557 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
3561 | 3558 |
3562 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); | 3559 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
3563 layerS2Ptr->setForceRenderSurface(true); | 3560 layerS2Ptr->setForceRenderSurface(true); |
3564 | 3561 |
3565 addDrawingLayerTo(layerS2Ptr, 6, IntRect(20, 20, 5, 5), 0); // L21 | 3562 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 |
3566 | 3563 |
3567 // Initial draw - must receive all quads | 3564 // Initial draw - must receive all quads |
3568 { | 3565 { |
3569 LayerTreeHostImpl::FrameData frame; | 3566 LayerTreeHostImpl::FrameData frame; |
3570 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3567 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3571 | 3568 |
3572 // Must receive 3 render passes. | 3569 // Must receive 3 render passes. |
3573 // For Root, there are 2 quads; for S1, there are 2 quads (one is occlud
ed); for S2, there is 2 quads. | 3570 // For Root, there are 2 quads; for S1, there are 2 quads (one is occlud
ed); for S2, there is 2 quads. |
3574 ASSERT_EQ(3U, frame.renderPasses.size()); | 3571 ASSERT_EQ(3U, frame.renderPasses.size()); |
3575 | 3572 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3620 myHostImpl->drawLayers(frame); | 3617 myHostImpl->drawLayers(frame); |
3621 myHostImpl->didDrawAllLayers(frame); | 3618 myHostImpl->didDrawAllLayers(frame); |
3622 } | 3619 } |
3623 } | 3620 } |
3624 | 3621 |
3625 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) | 3622 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) |
3626 { | 3623 { |
3627 Settings::setPartialSwapEnabled(false); | 3624 Settings::setPartialSwapEnabled(false); |
3628 | 3625 |
3629 LayerTreeSettings settings; | 3626 LayerTreeSettings settings; |
3630 settings.minimumOcclusionTrackingSize = IntSize(); | 3627 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3631 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3628 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3632 | 3629 |
3633 /* | 3630 /* |
3634 Layers are created as follows: | 3631 Layers are created as follows: |
3635 | 3632 |
3636 +--------------------+ | 3633 +--------------------+ |
3637 | 1 | | 3634 | 1 | |
3638 | +-----------+ | | 3635 | +-----------+ | |
3639 | | 2 | | | 3636 | | 2 | | |
3640 | | +-------------------+ | 3637 | | +-------------------+ |
3641 | | | 3 | | 3638 | | | 3 | |
3642 | | +-------------------+ | 3639 | | +-------------------+ |
3643 | | | | | 3640 | | | | |
3644 | +-----------+ | | 3641 | +-----------+ | |
3645 | | | 3642 | | |
3646 | | | 3643 | | |
3647 +--------------------+ | 3644 +--------------------+ |
3648 | 3645 |
3649 Layers 1, 2 have render surfaces | 3646 Layers 1, 2 have render surfaces |
3650 */ | 3647 */ |
3651 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3648 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3652 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); | 3649 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); |
3653 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); | 3650 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); |
3654 | 3651 |
3655 IntRect rootRect(0, 0, 100, 100); | 3652 gfx::Rect rootRect(0, 0, 100, 100); |
3656 IntRect childRect(10, 10, 50, 50); | 3653 gfx::Rect childRect(10, 10, 50, 50); |
3657 IntRect grandChildRect(5, 5, 150, 150); | 3654 gfx::Rect grandChildRect(5, 5, 150, 150); |
3658 | 3655 |
3659 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3656 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3660 myHostImpl->initializeRenderer(context.Pass()); | 3657 myHostImpl->initializeRenderer(context.Pass()); |
3661 | 3658 |
3662 root->setAnchorPoint(FloatPoint(0, 0)); | 3659 root->setAnchorPoint(gfx::PointF(0, 0)); |
3663 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); | 3660 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
3664 root->setBounds(IntSize(rootRect.width(), rootRect.height())); | 3661 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
3665 root->setContentBounds(root->bounds()); | 3662 root->setContentBounds(root->bounds()); |
3666 root->setDrawsContent(true); | 3663 root->setDrawsContent(true); |
3667 root->setMasksToBounds(true); | 3664 root->setMasksToBounds(true); |
3668 | 3665 |
3669 child->setAnchorPoint(FloatPoint(0, 0)); | 3666 child->setAnchorPoint(gfx::PointF(0, 0)); |
3670 child->setPosition(FloatPoint(childRect.x(), childRect.y())); | 3667 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); |
3671 child->setOpacity(0.5); | 3668 child->setOpacity(0.5); |
3672 child->setBounds(IntSize(childRect.width(), childRect.height())); | 3669 child->setBounds(gfx::Size(childRect.width(), childRect.height())); |
3673 child->setContentBounds(child->bounds()); | 3670 child->setContentBounds(child->bounds()); |
3674 child->setDrawsContent(true); | 3671 child->setDrawsContent(true); |
3675 child->setSkipsDraw(false); | 3672 child->setSkipsDraw(false); |
3676 | 3673 |
3677 // child layer has 10x10 tiles. | 3674 // child layer has 10x10 tiles. |
3678 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(IntSize(10, 10),
LayerTilingData::HasBorderTexels); | 3675 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10, 10
), LayerTilingData::HasBorderTexels); |
3679 tiler->setBounds(child->contentBounds()); | 3676 tiler->setBounds(child->contentBounds()); |
3680 child->setTilingData(*tiler.get()); | 3677 child->setTilingData(*tiler.get()); |
3681 | 3678 |
3682 grandChild->setAnchorPoint(FloatPoint(0, 0)); | 3679 grandChild->setAnchorPoint(gfx::PointF(0, 0)); |
3683 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); | 3680 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
3684 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height(
))); | 3681 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
3685 grandChild->setContentBounds(grandChild->bounds()); | 3682 grandChild->setContentBounds(grandChild->bounds()); |
3686 grandChild->setDrawsContent(true); | 3683 grandChild->setDrawsContent(true); |
3687 | 3684 |
3688 TiledLayerImpl* childPtr = child.get(); | 3685 TiledLayerImpl* childPtr = child.get(); |
3689 RenderPass::Id childPassId(childPtr->id(), 0); | 3686 RenderPass::Id childPassId(childPtr->id(), 0); |
3690 | 3687 |
3691 child->addChild(grandChild.Pass()); | 3688 child->addChild(grandChild.Pass()); |
3692 root->addChild(child.PassAs<LayerImpl>()); | 3689 root->addChild(child.PassAs<LayerImpl>()); |
3693 myHostImpl->setRootLayer(root.Pass()); | 3690 myHostImpl->setRootLayer(root.Pass()); |
3694 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); | 3691 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); |
(...skipping 14 matching lines...) Expand all Loading... |
3709 LayerTreeHostImpl::FrameData frame; | 3706 LayerTreeHostImpl::FrameData frame; |
3710 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3707 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3711 myHostImpl->drawLayers(frame); | 3708 myHostImpl->drawLayers(frame); |
3712 myHostImpl->didDrawAllLayers(frame); | 3709 myHostImpl->didDrawAllLayers(frame); |
3713 } | 3710 } |
3714 | 3711 |
3715 // We should still have cached textures for surface 2 after drawing with no
damage. | 3712 // We should still have cached textures for surface 2 after drawing with no
damage. |
3716 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); | 3713 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); |
3717 | 3714 |
3718 // Damage a single tile of surface 2. | 3715 // Damage a single tile of surface 2. |
3719 childPtr->setUpdateRect(IntRect(10, 10, 10, 10)); | 3716 childPtr->setUpdateRect(gfx::Rect(10, 10, 10, 10)); |
3720 | 3717 |
3721 { | 3718 { |
3722 LayerTreeHostImpl::FrameData frame; | 3719 LayerTreeHostImpl::FrameData frame; |
3723 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3720 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3724 myHostImpl->drawLayers(frame); | 3721 myHostImpl->drawLayers(frame); |
3725 myHostImpl->didDrawAllLayers(frame); | 3722 myHostImpl->didDrawAllLayers(frame); |
3726 } | 3723 } |
3727 | 3724 |
3728 // We should have a cached texture for surface 2 again even though it was da
maged. | 3725 // We should have a cached texture for surface 2 again even though it was da
maged. |
3729 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); | 3726 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); |
3730 } | 3727 } |
3731 | 3728 |
3732 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) | 3729 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) |
3733 { | 3730 { |
3734 Settings::setPartialSwapEnabled(true); | 3731 Settings::setPartialSwapEnabled(true); |
3735 | 3732 |
3736 LayerTreeSettings settings; | 3733 LayerTreeSettings settings; |
3737 settings.minimumOcclusionTrackingSize = IntSize(); | 3734 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3738 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3735 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3739 | 3736 |
3740 LayerImpl* rootPtr; | 3737 LayerImpl* rootPtr; |
3741 LayerImpl* intermediateLayerPtr; | 3738 LayerImpl* intermediateLayerPtr; |
3742 LayerImpl* surfaceLayerPtr; | 3739 LayerImpl* surfaceLayerPtr; |
3743 LayerImpl* childPtr; | 3740 LayerImpl* childPtr; |
3744 | 3741 |
3745 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, IntSize(100, 100)); | 3742 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); |
3746 | 3743 |
3747 { | 3744 { |
3748 LayerTreeHostImpl::FrameData frame; | 3745 LayerTreeHostImpl::FrameData frame; |
3749 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3746 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3750 | 3747 |
3751 // Must receive two render passes, each with one quad | 3748 // Must receive two render passes, each with one quad |
3752 ASSERT_EQ(2U, frame.renderPasses.size()); | 3749 ASSERT_EQ(2U, frame.renderPasses.size()); |
3753 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 3750 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
3754 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 3751 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
3755 | 3752 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 myHostImpl->drawLayers(frame); | 3885 myHostImpl->drawLayers(frame); |
3889 myHostImpl->didDrawAllLayers(frame); | 3886 myHostImpl->didDrawAllLayers(frame); |
3890 } | 3887 } |
3891 } | 3888 } |
3892 | 3889 |
3893 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) | 3890 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) |
3894 { | 3891 { |
3895 Settings::setPartialSwapEnabled(false); | 3892 Settings::setPartialSwapEnabled(false); |
3896 | 3893 |
3897 LayerTreeSettings settings; | 3894 LayerTreeSettings settings; |
3898 settings.minimumOcclusionTrackingSize = IntSize(); | 3895 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3899 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3896 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); |
3900 | 3897 |
3901 LayerImpl* rootPtr; | 3898 LayerImpl* rootPtr; |
3902 LayerImpl* intermediateLayerPtr; | 3899 LayerImpl* intermediateLayerPtr; |
3903 LayerImpl* surfaceLayerPtr; | 3900 LayerImpl* surfaceLayerPtr; |
3904 LayerImpl* childPtr; | 3901 LayerImpl* childPtr; |
3905 | 3902 |
3906 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, IntSize(100, 100)); | 3903 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); |
3907 | 3904 |
3908 { | 3905 { |
3909 LayerTreeHostImpl::FrameData frame; | 3906 LayerTreeHostImpl::FrameData frame; |
3910 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3907 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3911 | 3908 |
3912 // Must receive two render passes, each with one quad | 3909 // Must receive two render passes, each with one quad |
3913 ASSERT_EQ(2U, frame.renderPasses.size()); | 3910 ASSERT_EQ(2U, frame.renderPasses.size()); |
3914 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 3911 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
3915 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 3912 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
3916 | 3913 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 | 4093 |
4097 return renderer.Pass(); | 4094 return renderer.Pass(); |
4098 } | 4095 } |
4099 | 4096 |
4100 void clearCachedTextures() { m_textures.clear(); } | 4097 void clearCachedTextures() { m_textures.clear(); } |
4101 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } | 4098 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } |
4102 | 4099 |
4103 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } | 4100 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } |
4104 | 4101 |
4105 // RendererClient implementation. | 4102 // RendererClient implementation. |
4106 virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_viewpo
rtSize; } | 4103 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } |
4107 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } | 4104 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } |
4108 virtual void didLoseContext() OVERRIDE { } | 4105 virtual void didLoseContext() OVERRIDE { } |
4109 virtual void onSwapBuffersComplete() OVERRIDE { } | 4106 virtual void onSwapBuffersComplete() OVERRIDE { } |
4110 virtual void setFullRootLayerDamage() OVERRIDE { } | 4107 virtual void setFullRootLayerDamage() OVERRIDE { } |
4111 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } | 4108 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } |
4112 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } | 4109 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } |
4113 | 4110 |
4114 protected: | 4111 protected: |
4115 TestRenderer(ResourceProvider* resourceProvider) : GLRenderer(this, resource
Provider) { } | 4112 TestRenderer(ResourceProvider* resourceProvider) : GLRenderer(this, resource
Provider) { } |
4116 | 4113 |
4117 private: | 4114 private: |
4118 LayerTreeSettings m_settings; | 4115 LayerTreeSettings m_settings; |
4119 IntSize m_viewportSize; | 4116 gfx::Size m_viewportSize; |
4120 base::hash_set<RenderPass::Id> m_textures; | 4117 base::hash_set<RenderPass::Id> m_textures; |
4121 }; | 4118 }; |
4122 | 4119 |
4123 static void configureRenderPassTestData(const char* testScript, RenderPassRemova
lTestData& testData, TestRenderer* renderer) | 4120 static void configureRenderPassTestData(const char* testScript, RenderPassRemova
lTestData& testData, TestRenderer* renderer) |
4124 { | 4121 { |
4125 renderer->clearCachedTextures(); | 4122 renderer->clearCachedTextures(); |
4126 | 4123 |
4127 // One shared state for all quads - we don't need the correct details | 4124 // One shared state for all quads - we don't need the correct details |
4128 testData.sharedQuadState = SharedQuadState::create(WebTransformationMatrix()
, IntRect(), IntRect(), 1.0, true); | 4125 testData.sharedQuadState = SharedQuadState::create(WebTransformationMatrix()
, gfx::Rect(), gfx::Rect(), 1.0, true); |
4129 | 4126 |
4130 const char* currentChar = testScript; | 4127 const char* currentChar = testScript; |
4131 | 4128 |
4132 // Pre-create root pass | 4129 // Pre-create root pass |
4133 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1
]); | 4130 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1
]); |
4134 testData.renderPassCache.add(rootRenderPassId, TestRenderPass::create(rootRe
nderPassId, IntRect(), WebTransformationMatrix())); | 4131 testData.renderPassCache.add(rootRenderPassId, TestRenderPass::create(rootRe
nderPassId, gfx::Rect(), WebTransformationMatrix())); |
4135 while (*currentChar) { | 4132 while (*currentChar) { |
4136 int layerId = *currentChar; | 4133 int layerId = *currentChar; |
4137 currentChar++; | 4134 currentChar++; |
4138 ASSERT_TRUE(currentChar); | 4135 ASSERT_TRUE(currentChar); |
4139 int index = *currentChar; | 4136 int index = *currentChar; |
4140 currentChar++; | 4137 currentChar++; |
4141 | 4138 |
4142 RenderPass::Id renderPassId = RenderPass::Id(layerId, index); | 4139 RenderPass::Id renderPassId = RenderPass::Id(layerId, index); |
4143 | 4140 |
4144 bool isReplica = false; | 4141 bool isReplica = false; |
4145 if (!testData.renderPassCache.contains(renderPassId)) | 4142 if (!testData.renderPassCache.contains(renderPassId)) |
4146 isReplica = true; | 4143 isReplica = true; |
4147 | 4144 |
4148 scoped_ptr<TestRenderPass> renderPass = testData.renderPassCache.take(re
nderPassId); | 4145 scoped_ptr<TestRenderPass> renderPass = testData.renderPassCache.take(re
nderPassId); |
4149 | 4146 |
4150 // Cycle through quad data and create all quads | 4147 // Cycle through quad data and create all quads |
4151 while (*currentChar && *currentChar != '\n') { | 4148 while (*currentChar && *currentChar != '\n') { |
4152 if (*currentChar == 's') { | 4149 if (*currentChar == 's') { |
4153 // Solid color draw quad | 4150 // Solid color draw quad |
4154 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::create
(testData.sharedQuadState.get(), IntRect(0, 0, 10, 10), SK_ColorWHITE); | 4151 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::create
(testData.sharedQuadState.get(), gfx::Rect(0, 0, 10, 10), SK_ColorWHITE); |
4155 | 4152 |
4156 renderPass->appendQuad(quad.PassAs<DrawQuad>()); | 4153 renderPass->appendQuad(quad.PassAs<DrawQuad>()); |
4157 currentChar++; | 4154 currentChar++; |
4158 } else if ((*currentChar >= 'A') && (*currentChar <= 'Z')) { | 4155 } else if ((*currentChar >= 'A') && (*currentChar <= 'Z')) { |
4159 // RenderPass draw quad | 4156 // RenderPass draw quad |
4160 int layerId = *currentChar; | 4157 int layerId = *currentChar; |
4161 currentChar++; | 4158 currentChar++; |
4162 ASSERT_TRUE(currentChar); | 4159 ASSERT_TRUE(currentChar); |
4163 int index = *currentChar; | 4160 int index = *currentChar; |
4164 currentChar++; | 4161 currentChar++; |
(...skipping 16 matching lines...) Expand all Loading... |
4181 currentChar++; | 4178 currentChar++; |
4182 } | 4179 } |
4183 if (*currentChar == ']') | 4180 if (*currentChar == ']') |
4184 currentChar++; | 4181 currentChar++; |
4185 } | 4182 } |
4186 | 4183 |
4187 if (testData.renderPassCache.find(newRenderPassId) == testData.r
enderPassCache.end()) { | 4184 if (testData.renderPassCache.find(newRenderPassId) == testData.r
enderPassCache.end()) { |
4188 if (hasTexture) | 4185 if (hasTexture) |
4189 renderer->setHaveCachedResourcesForRenderPassId(newRende
rPassId); | 4186 renderer->setHaveCachedResourcesForRenderPassId(newRende
rPassId); |
4190 | 4187 |
4191 testData.renderPassCache.add(newRenderPassId, TestRenderPass
::create(newRenderPassId, IntRect(), WebTransformationMatrix())); | 4188 testData.renderPassCache.add(newRenderPassId, TestRenderPass
::create(newRenderPassId, gfx::Rect(), WebTransformationMatrix())); |
4192 } | 4189 } |
4193 | 4190 |
4194 IntRect quadRect = IntRect(0, 0, 1, 1); | 4191 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1); |
4195 IntRect contentsChangedRect = contentsChanged ? quadRect : IntRe
ct(); | 4192 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx
::Rect(); |
4196 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::create
(testData.sharedQuadState.get(), quadRect, newRenderPassId, isReplica, 1, conten
tsChangedRect, 1, 1, 0, 0); | 4193 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::create
(testData.sharedQuadState.get(), quadRect, newRenderPassId, isReplica, 1, conten
tsChangedRect, 1, 1, 0, 0); |
4197 renderPass->appendQuad(quad.PassAs<DrawQuad>()); | 4194 renderPass->appendQuad(quad.PassAs<DrawQuad>()); |
4198 } | 4195 } |
4199 } | 4196 } |
4200 testData.renderPasses.insert(testData.renderPasses.begin(), renderPass.g
et()); | 4197 testData.renderPasses.insert(testData.renderPasses.begin(), renderPass.g
et()); |
4201 testData.renderPassesById.add(renderPassId, renderPass.PassAs<RenderPass
>()); | 4198 testData.renderPassesById.add(renderPassId, renderPass.PassAs<RenderPass
>()); |
4202 if (*currentChar) | 4199 if (*currentChar) |
4203 currentChar++; | 4200 currentChar++; |
4204 } | 4201 } |
4205 } | 4202 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4406 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4403 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4407 testCaseIndex++; | 4404 testCaseIndex++; |
4408 } | 4405 } |
4409 } | 4406 } |
4410 | 4407 |
4411 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4408 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4412 LayerTreeHostImplTest, | 4409 LayerTreeHostImplTest, |
4413 ::testing::Values(false, true)); | 4410 ::testing::Values(false, true)); |
4414 | 4411 |
4415 } // namespace | 4412 } // namespace |
OLD | NEW |