OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
| 7 #include "cc/compositor_frame_metadata.h" |
7 #include "cc/draw_quad.h" | 8 #include "cc/draw_quad.h" |
8 #include "cc/prioritized_resource_manager.h" | 9 #include "cc/prioritized_resource_manager.h" |
9 #include "cc/resource_provider.h" | 10 #include "cc/resource_provider.h" |
10 #include "cc/test/fake_impl_proxy.h" | 11 #include "cc/test/fake_impl_proxy.h" |
11 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
12 #include "cc/test/fake_output_surface.h" | 13 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/fake_web_graphics_context_3d.h" | 14 #include "cc/test/fake_web_graphics_context_3d.h" |
14 #include "cc/test/render_pass_test_common.h" | 15 #include "cc/test/render_pass_test_common.h" |
15 #include "cc/test/render_pass_test_utils.h" | 16 #include "cc/test/render_pass_test_utils.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // RendererClient methods. | 79 // RendererClient methods. |
79 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } | 80 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } |
80 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } | 81 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } |
81 virtual void didLoseOutputSurface() OVERRIDE { } | 82 virtual void didLoseOutputSurface() OVERRIDE { } |
82 virtual void onSwapBuffersComplete() OVERRIDE { } | 83 virtual void onSwapBuffersComplete() OVERRIDE { } |
83 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } | 84 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } |
84 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } | 85 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } |
85 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } | 86 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } |
86 virtual bool hasImplThread() const OVERRIDE { return false; } | 87 virtual bool hasImplThread() const OVERRIDE { return false; } |
87 virtual bool shouldClearRootRenderPass() const OVERRIDE { return true; } | 88 virtual bool shouldClearRootRenderPass() const OVERRIDE { return true; } |
| 89 virtual CompositorFrameMetadata makeCompositorFrameMetadata() const |
| 90 OVERRIDE { return CompositorFrameMetadata(); } |
88 | 91 |
89 // Methods added for test. | 92 // Methods added for test. |
90 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou
nt; } | 93 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou
nt; } |
91 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } | 94 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } |
92 | 95 |
93 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } | 96 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } |
94 RenderPassList& renderPassesInDrawOrder() { return m_renderPassesInDrawOrder
; } | 97 RenderPassList& renderPassesInDrawOrder() { return m_renderPassesInDrawOrder
; } |
95 RenderPassIdHashMap& renderPasses() { return m_renderPasses; } | 98 RenderPassIdHashMap& renderPasses() { return m_renderPasses; } |
96 | 99 |
97 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } | 100 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } |
98 | 101 |
99 private: | 102 private: |
100 FakeImplProxy m_proxy; | 103 FakeImplProxy m_proxy; |
101 FakeLayerTreeHostImpl m_hostImpl; | 104 FakeLayerTreeHostImpl m_hostImpl; |
102 int m_setFullRootLayerDamageCount; | 105 int m_setFullRootLayerDamageCount; |
103 bool* m_lastCallWasSetVisibility; | 106 bool* m_lastCallWasSetVisibility; |
104 scoped_ptr<LayerImpl> m_rootLayer; | 107 scoped_ptr<LayerImpl> m_rootLayer; |
105 RenderPassList m_renderPassesInDrawOrder; | 108 RenderPassList m_renderPassesInDrawOrder; |
106 RenderPassIdHashMap m_renderPasses; | 109 RenderPassIdHashMap m_renderPasses; |
107 size_t m_memoryAllocationLimitBytes; | 110 size_t m_memoryAllocationLimitBytes; |
108 }; | 111 }; |
109 | 112 |
110 class FakeRendererGL : public GLRenderer { | 113 class FakeRendererGL : public GLRenderer { |
111 public: | 114 public: |
112 FakeRendererGL(RendererClient* client, ResourceProvider* resourceProvider) :
GLRenderer(client, resourceProvider) { } | 115 FakeRendererGL(RendererClient* client, OutputSurface* outputSurface, Resourc
eProvider* resourceProvider) : GLRenderer(client, outputSurface, resourceProvide
r) { } |
113 | 116 |
114 // GLRenderer methods. | 117 // GLRenderer methods. |
115 | 118 |
116 // Changing visibility to public. | 119 // Changing visibility to public. |
117 using GLRenderer::initialize; | 120 using GLRenderer::initialize; |
118 using GLRenderer::isBackbufferDiscarded; | 121 using GLRenderer::isBackbufferDiscarded; |
119 using GLRenderer::drawQuad; | 122 using GLRenderer::drawQuad; |
120 using GLRenderer::beginDrawingFrame; | 123 using GLRenderer::beginDrawingFrame; |
121 using GLRenderer::finishDrawingQuadList; | 124 using GLRenderer::finishDrawingQuadList; |
122 }; | 125 }; |
123 | 126 |
124 class GLRendererTest : public testing::Test { | 127 class GLRendererTest : public testing::Test { |
125 protected: | 128 protected: |
126 GLRendererTest() | 129 GLRendererTest() |
127 : m_suggestHaveBackbufferYes(1, true) | 130 : m_suggestHaveBackbufferYes(1, true) |
128 , m_suggestHaveBackbufferNo(1, false) | 131 , m_suggestHaveBackbufferNo(1, false) |
129 , m_context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsCo
ntext3D>(new FrameCountingMemoryAllocationSettingContext()))) | 132 , m_outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FrameCountingMemoryAllocationSettingContext()))) |
130 , m_resourceProvider(ResourceProvider::create(m_context.get())) | 133 , m_resourceProvider(ResourceProvider::create(m_outputSurface.get())) |
131 , m_renderer(&m_mockClient, m_resourceProvider.get()) | 134 , m_renderer(&m_mockClient, m_outputSurface.get(), m_resourceProvider.ge
t()) |
132 { | 135 { |
133 } | 136 } |
134 | 137 |
135 virtual void SetUp() | 138 virtual void SetUp() |
136 { | 139 { |
137 m_renderer.initialize(); | 140 m_renderer.initialize(); |
138 } | 141 } |
139 | 142 |
140 void swapBuffers() | 143 void swapBuffers() |
141 { | 144 { |
142 m_renderer.swapBuffers(); | 145 m_renderer.swapBuffers(); |
143 } | 146 } |
144 | 147 |
145 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_context->Context3D()); } | 148 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_outputSurface->Context3D()); } |
146 | 149 |
147 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; | 150 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; |
148 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; | 151 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; |
149 | 152 |
150 scoped_ptr<OutputSurface> m_context; | 153 scoped_ptr<OutputSurface> m_outputSurface; |
151 FakeRendererClient m_mockClient; | 154 FakeRendererClient m_mockClient; |
152 scoped_ptr<ResourceProvider> m_resourceProvider; | 155 scoped_ptr<ResourceProvider> m_resourceProvider; |
153 FakeRendererGL m_renderer; | 156 FakeRendererGL m_renderer; |
154 }; | 157 }; |
155 | 158 |
156 // Test GLRenderer discardBackbuffer functionality: | 159 // Test GLRenderer discardBackbuffer functionality: |
157 // Suggest recreating framebuffer when one already exists. | 160 // Suggest recreating framebuffer when one already exists. |
158 // Expected: it does nothing. | 161 // Expected: it does nothing. |
159 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) | 162 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) |
160 { | 163 { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name)
{ ADD_FAILURE(); return 0; } | 304 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name)
{ ADD_FAILURE(); return 0; } |
302 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat*
value) { ADD_FAILURE(); } | 305 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat*
value) { ADD_FAILURE(); } |
303 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v
alue) { ADD_FAILURE(); } | 306 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v
alue) { ADD_FAILURE(); } |
304 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname
) { ADD_FAILURE(); return 0; } | 307 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname
) { ADD_FAILURE(); return 0; } |
305 }; | 308 }; |
306 | 309 |
307 // This test isn't using the same fixture as GLRendererTest, and you can't mix T
EST() and TEST_F() with the same name, hence LRC2. | 310 // This test isn't using the same fixture as GLRendererTest, and you can't mix T
EST() and TEST_F() with the same name, hence LRC2. |
308 TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) | 311 TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) |
309 { | 312 { |
310 FakeRendererClient mockClient; | 313 FakeRendererClient mockClient; |
311 scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<Web
Kit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); | 314 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); |
312 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 315 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
313 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 316 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
314 | 317 |
315 EXPECT_TRUE(renderer.initialize()); | 318 EXPECT_TRUE(renderer.initialize()); |
316 } | 319 } |
317 | 320 |
318 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D { | 321 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D { |
319 public: | 322 public: |
320 LoseContextOnFirstGetContext() | 323 LoseContextOnFirstGetContext() |
321 : m_contextLost(false) | 324 : m_contextLost(false) |
322 { | 325 { |
323 } | 326 } |
(...skipping 20 matching lines...) Expand all Loading... |
344 return m_contextLost ? 1 : 0; | 347 return m_contextLost ? 1 : 0; |
345 } | 348 } |
346 | 349 |
347 private: | 350 private: |
348 bool m_contextLost; | 351 bool m_contextLost; |
349 }; | 352 }; |
350 | 353 |
351 TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) | 354 TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) |
352 { | 355 { |
353 FakeRendererClient mockClient; | 356 FakeRendererClient mockClient; |
354 scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<Web
Kit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 357 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
355 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 358 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
356 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 359 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
357 | 360 |
358 renderer.initialize(); | 361 renderer.initialize(); |
359 } | 362 } |
360 | 363 |
361 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic
sContext3D { | 364 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic
sContext3D { |
362 public: | 365 public: |
363 ContextThatDoesNotSupportMemoryManagmentExtensions() { } | 366 ContextThatDoesNotSupportMemoryManagmentExtensions() { } |
364 | 367 |
365 // WebGraphicsContext3D methods. | 368 // WebGraphicsContext3D methods. |
366 | 369 |
367 // This method would normally do a glSwapBuffers under the hood. | 370 // This method would normally do a glSwapBuffers under the hood. |
368 virtual void prepareTexture() { } | 371 virtual void prepareTexture() { } |
369 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll
ocationChangedCallbackCHROMIUM* callback) { } | 372 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll
ocationChangedCallbackCHROMIUM* callback) { } |
370 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } | 373 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } |
371 }; | 374 }; |
372 | 375 |
373 TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShoul
dDefaultToNonZeroAllocation) | 376 TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShoul
dDefaultToNonZeroAllocation) |
374 { | 377 { |
375 FakeRendererClient mockClient; | 378 FakeRendererClient mockClient; |
376 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExt
ensions))); | 379 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExt
ensions))); |
377 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 380 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
378 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 381 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
379 | 382 |
380 renderer.initialize(); | 383 renderer.initialize(); |
381 | 384 |
382 EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul); | 385 EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul); |
383 } | 386 } |
384 | 387 |
385 class ClearCountingContext : public FakeWebGraphicsContext3D { | 388 class ClearCountingContext : public FakeWebGraphicsContext3D { |
386 public: | 389 public: |
387 ClearCountingContext() : m_clear(0) { } | 390 ClearCountingContext() : m_clear(0) { } |
388 | 391 |
389 virtual void clear(WGC3Dbitfield) | 392 virtual void clear(WGC3Dbitfield) |
390 { | 393 { |
391 m_clear++; | 394 m_clear++; |
392 } | 395 } |
393 | 396 |
394 int clearCount() const { return m_clear; } | 397 int clearCount() const { return m_clear; } |
395 | 398 |
396 private: | 399 private: |
397 int m_clear; | 400 int m_clear; |
398 }; | 401 }; |
399 | 402 |
400 TEST(GLRendererTest2, opaqueBackground) | 403 TEST(GLRendererTest2, opaqueBackground) |
401 { | 404 { |
402 FakeRendererClient mockClient; | 405 FakeRendererClient mockClient; |
403 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 406 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
404 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); | 407 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); |
405 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 408 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
406 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 409 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
407 | 410 |
408 mockClient.rootRenderPass()->has_transparent_background = false; | 411 mockClient.rootRenderPass()->has_transparent_background = false; |
409 | 412 |
410 EXPECT_TRUE(renderer.initialize()); | 413 EXPECT_TRUE(renderer.initialize()); |
411 | 414 |
412 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 415 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
413 | 416 |
414 // On DEBUG builds, render passes with opaque background clear to blue to | 417 // On DEBUG builds, render passes with opaque background clear to blue to |
415 // easily see regions that were not drawn on the screen. | 418 // easily see regions that were not drawn on the screen. |
416 #ifdef NDEBUG | 419 #ifdef NDEBUG |
417 EXPECT_EQ(0, context->clearCount()); | 420 EXPECT_EQ(0, context->clearCount()); |
418 #else | 421 #else |
419 EXPECT_EQ(1, context->clearCount()); | 422 EXPECT_EQ(1, context->clearCount()); |
420 #endif | 423 #endif |
421 } | 424 } |
422 | 425 |
423 TEST(GLRendererTest2, transparentBackground) | 426 TEST(GLRendererTest2, transparentBackground) |
424 { | 427 { |
425 FakeRendererClient mockClient; | 428 FakeRendererClient mockClient; |
426 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 429 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
427 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); | 430 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); |
428 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 431 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
429 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 432 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
430 | 433 |
431 mockClient.rootRenderPass()->has_transparent_background = true; | 434 mockClient.rootRenderPass()->has_transparent_background = true; |
432 | 435 |
433 EXPECT_TRUE(renderer.initialize()); | 436 EXPECT_TRUE(renderer.initialize()); |
434 | 437 |
435 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 438 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
436 | 439 |
437 EXPECT_EQ(1, context->clearCount()); | 440 EXPECT_EQ(1, context->clearCount()); |
438 } | 441 } |
439 | 442 |
(...skipping 30 matching lines...) Expand all Loading... |
470 private: | 473 private: |
471 bool* m_lastCallWasSetVisibility; | 474 bool* m_lastCallWasSetVisibility; |
472 }; | 475 }; |
473 | 476 |
474 TEST(GLRendererTest2, visibilityChangeIsLastCall) | 477 TEST(GLRendererTest2, visibilityChangeIsLastCall) |
475 { | 478 { |
476 FakeRendererClient mockClient; | 479 FakeRendererClient mockClient; |
477 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))
); | 480 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))
); |
478 VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityC
hangeIsLastCallTrackingContext*>(outputSurface->Context3D()); | 481 VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityC
hangeIsLastCallTrackingContext*>(outputSurface->Context3D()); |
479 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 482 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
480 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 483 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
481 | 484 |
482 EXPECT_TRUE(renderer.initialize()); | 485 EXPECT_TRUE(renderer.initialize()); |
483 | 486 |
484 bool lastCallWasSetVisiblity = false; | 487 bool lastCallWasSetVisiblity = false; |
485 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to t
he GPU | 488 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to t
he GPU |
486 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy | 489 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy |
487 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving | 490 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving |
488 // them both a pointer to a variable on the stack. | 491 // them both a pointer to a variable on the stack. |
489 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 492 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
490 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 493 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 private: | 525 private: |
523 WGC3Denum m_activeTexture; | 526 WGC3Denum m_activeTexture; |
524 }; | 527 }; |
525 | 528 |
526 TEST(GLRendererTest2, activeTextureState) | 529 TEST(GLRendererTest2, activeTextureState) |
527 { | 530 { |
528 FakeRendererClient fakeClient; | 531 FakeRendererClient fakeClient; |
529 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); | 532 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); |
530 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->Context3D()); | 533 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->Context3D()); |
531 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 534 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
532 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); | 535 FakeRendererGL renderer(&fakeClient, outputSurface.get(), resourceProvider.g
et()); |
533 | 536 |
534 // During initialization we are allowed to set any texture parameters. | 537 // During initialization we are allowed to set any texture parameters. |
535 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); | 538 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); |
536 EXPECT_TRUE(renderer.initialize()); | 539 EXPECT_TRUE(renderer.initialize()); |
537 | 540 |
538 cc::RenderPass::Id id(1, 1); | 541 cc::RenderPass::Id id(1, 1); |
539 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 542 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
540 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::
Transform()); | 543 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::
Transform()); |
541 pass->AppendOneOfEveryQuadType(resourceProvider.get()); | 544 pass->AppendOneOfEveryQuadType(resourceProvider.get()); |
542 | 545 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 public: | 593 public: |
591 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); | 594 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); |
592 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 595 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); |
593 }; | 596 }; |
594 | 597 |
595 TEST(GLRendererTest2, shouldClearRootRenderPass) | 598 TEST(GLRendererTest2, shouldClearRootRenderPass) |
596 { | 599 { |
597 NoClearRootRenderPassFakeClient mockClient; | 600 NoClearRootRenderPassFakeClient mockClient; |
598 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new NoClearRootRenderPassMockContext))); | 601 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new NoClearRootRenderPassMockContext))); |
599 NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRende
rPassMockContext*>(outputSurface->Context3D()); | 602 NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRende
rPassMockContext*>(outputSurface->Context3D()); |
600 | |
601 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 603 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
602 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 604 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
603 EXPECT_TRUE(renderer.initialize()); | 605 EXPECT_TRUE(renderer.initialize()); |
604 | 606 |
605 gfx::Rect viewportRect(mockClient.deviceViewportSize()); | 607 gfx::Rect viewportRect(mockClient.deviceViewportSize()); |
606 ScopedPtrVector<RenderPass> renderPasses; | 608 ScopedPtrVector<RenderPass> renderPasses; |
607 | 609 |
608 RenderPass::Id rootPassId(1, 0); | 610 RenderPass::Id rootPassId(1, 0); |
609 TestRenderPass* rootPass = addRenderPass(renderPasses, rootPassId, viewportR
ect, gfx::Transform()); | 611 TestRenderPass* rootPass = addRenderPass(renderPasses, rootPassId, viewportR
ect, gfx::Transform()); |
610 addQuad(rootPass, viewportRect, SK_ColorGREEN); | 612 addQuad(rootPass, viewportRect, SK_ColorGREEN); |
611 | 613 |
612 RenderPass::Id childPassId(2, 0); | 614 RenderPass::Id childPassId(2, 0); |
(...skipping 26 matching lines...) Expand all Loading... |
639 | 641 |
640 renderer.decideRenderPassAllocationsForFrame(mockClient.renderPassesInDrawOr
der()); | 642 renderer.decideRenderPassAllocationsForFrame(mockClient.renderPassesInDrawOr
der()); |
641 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 643 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
642 | 644 |
643 // In multiple render passes all but the root pass should clear the framebuf
fer. | 645 // In multiple render passes all but the root pass should clear the framebuf
fer. |
644 Mock::VerifyAndClearExpectations(&mockContext); | 646 Mock::VerifyAndClearExpectations(&mockContext); |
645 } | 647 } |
646 | 648 |
647 } // namespace | 649 } // namespace |
648 } // namespace cc | 650 } // namespace cc |
OLD | NEW |