| 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 "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 // RendererClient methods. | 77 // RendererClient methods. |
| 77 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } | 78 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } |
| 78 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } | 79 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } |
| 79 virtual void didLoseOutputSurface() OVERRIDE { } | 80 virtual void didLoseOutputSurface() OVERRIDE { } |
| 80 virtual void onSwapBuffersComplete() OVERRIDE { } | 81 virtual void onSwapBuffersComplete() OVERRIDE { } |
| 81 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } | 82 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } |
| 82 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } | 83 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } |
| 83 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } | 84 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } |
| 84 virtual bool hasImplThread() const OVERRIDE { return false; } | 85 virtual bool hasImplThread() const OVERRIDE { return false; } |
| 86 virtual CompositorFrameMetadata makeCompositorFrameMetadata() const |
| 87 OVERRIDE { return CompositorFrameMetadata(); } |
| 85 | 88 |
| 86 // Methods added for test. | 89 // Methods added for test. |
| 87 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou
nt; } | 90 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou
nt; } |
| 88 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } | 91 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } |
| 89 | 92 |
| 90 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } | 93 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } |
| 91 RenderPassList& renderPassesInDrawOrder() { return m_renderPassesInDrawOrder
; } | 94 RenderPassList& renderPassesInDrawOrder() { return m_renderPassesInDrawOrder
; } |
| 92 RenderPassIdHashMap& renderPasses() { return m_renderPasses; } | 95 RenderPassIdHashMap& renderPasses() { return m_renderPasses; } |
| 93 | 96 |
| 94 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } | 97 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } |
| 95 | 98 |
| 96 private: | 99 private: |
| 97 FakeImplProxy m_proxy; | 100 FakeImplProxy m_proxy; |
| 98 FakeLayerTreeHostImpl m_hostImpl; | 101 FakeLayerTreeHostImpl m_hostImpl; |
| 99 int m_setFullRootLayerDamageCount; | 102 int m_setFullRootLayerDamageCount; |
| 100 bool* m_lastCallWasSetVisibility; | 103 bool* m_lastCallWasSetVisibility; |
| 101 scoped_ptr<LayerImpl> m_rootLayer; | 104 scoped_ptr<LayerImpl> m_rootLayer; |
| 102 RenderPassList m_renderPassesInDrawOrder; | 105 RenderPassList m_renderPassesInDrawOrder; |
| 103 RenderPassIdHashMap m_renderPasses; | 106 RenderPassIdHashMap m_renderPasses; |
| 104 size_t m_memoryAllocationLimitBytes; | 107 size_t m_memoryAllocationLimitBytes; |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 class FakeRendererGL : public GLRenderer { | 110 class FakeRendererGL : public GLRenderer { |
| 108 public: | 111 public: |
| 109 FakeRendererGL(RendererClient* client, ResourceProvider* resourceProvider) :
GLRenderer(client, resourceProvider) { } | 112 FakeRendererGL(RendererClient* client, OutputSurface* outputSurface, Resourc
eProvider* resourceProvider) : GLRenderer(client, outputSurface, resourceProvide
r) { } |
| 110 | 113 |
| 111 // GLRenderer methods. | 114 // GLRenderer methods. |
| 112 | 115 |
| 113 // Changing visibility to public. | 116 // Changing visibility to public. |
| 114 using GLRenderer::initialize; | 117 using GLRenderer::initialize; |
| 115 using GLRenderer::isBackbufferDiscarded; | 118 using GLRenderer::isBackbufferDiscarded; |
| 116 using GLRenderer::drawQuad; | 119 using GLRenderer::drawQuad; |
| 117 using GLRenderer::beginDrawingFrame; | 120 using GLRenderer::beginDrawingFrame; |
| 118 using GLRenderer::finishDrawingQuadList; | 121 using GLRenderer::finishDrawingQuadList; |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 class GLRendererTest : public testing::Test { | 124 class GLRendererTest : public testing::Test { |
| 122 protected: | 125 protected: |
| 123 GLRendererTest() | 126 GLRendererTest() |
| 124 : m_suggestHaveBackbufferYes(1, true) | 127 : m_suggestHaveBackbufferYes(1, true) |
| 125 , m_suggestHaveBackbufferNo(1, false) | 128 , m_suggestHaveBackbufferNo(1, false) |
| 126 , m_context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsCo
ntext3D>(new FrameCountingMemoryAllocationSettingContext()))) | 129 , m_outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FrameCountingMemoryAllocationSettingContext()))) |
| 127 , m_resourceProvider(ResourceProvider::create(m_context.get())) | 130 , m_resourceProvider(ResourceProvider::create(m_outputSurface.get())) |
| 128 , m_renderer(&m_mockClient, m_resourceProvider.get()) | 131 , m_renderer(&m_mockClient, m_outputSurface.get(), m_resourceProvider.ge
t()) |
| 129 { | 132 { |
| 130 } | 133 } |
| 131 | 134 |
| 132 virtual void SetUp() | 135 virtual void SetUp() |
| 133 { | 136 { |
| 134 m_renderer.initialize(); | 137 m_renderer.initialize(); |
| 135 } | 138 } |
| 136 | 139 |
| 137 void swapBuffers() | 140 void swapBuffers() |
| 138 { | 141 { |
| 139 m_renderer.swapBuffers(); | 142 m_renderer.swapBuffers(); |
| 140 } | 143 } |
| 141 | 144 |
| 142 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_context->Context3D()); } | 145 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_outputSurface->Context3D()); } |
| 143 | 146 |
| 144 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; | 147 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; |
| 145 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; | 148 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; |
| 146 | 149 |
| 147 scoped_ptr<OutputSurface> m_context; | 150 scoped_ptr<OutputSurface> m_outputSurface; |
| 148 FakeRendererClient m_mockClient; | 151 FakeRendererClient m_mockClient; |
| 149 scoped_ptr<ResourceProvider> m_resourceProvider; | 152 scoped_ptr<ResourceProvider> m_resourceProvider; |
| 150 FakeRendererGL m_renderer; | 153 FakeRendererGL m_renderer; |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 // Test GLRenderer discardBackbuffer functionality: | 156 // Test GLRenderer discardBackbuffer functionality: |
| 154 // Suggest recreating framebuffer when one already exists. | 157 // Suggest recreating framebuffer when one already exists. |
| 155 // Expected: it does nothing. | 158 // Expected: it does nothing. |
| 156 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) | 159 TEST_F(GLRendererTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) |
| 157 { | 160 { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name)
{ ADD_FAILURE(); return 0; } | 301 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name)
{ ADD_FAILURE(); return 0; } |
| 299 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat*
value) { ADD_FAILURE(); } | 302 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat*
value) { ADD_FAILURE(); } |
| 300 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v
alue) { ADD_FAILURE(); } | 303 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v
alue) { ADD_FAILURE(); } |
| 301 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname
) { ADD_FAILURE(); return 0; } | 304 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname
) { ADD_FAILURE(); return 0; } |
| 302 }; | 305 }; |
| 303 | 306 |
| 304 // 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. | 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. |
| 305 TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) | 308 TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) |
| 306 { | 309 { |
| 307 FakeRendererClient mockClient; | 310 FakeRendererClient mockClient; |
| 308 scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<Web
Kit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); | 311 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); |
| 309 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 312 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 310 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 313 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 311 | 314 |
| 312 EXPECT_TRUE(renderer.initialize()); | 315 EXPECT_TRUE(renderer.initialize()); |
| 313 } | 316 } |
| 314 | 317 |
| 315 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D { | 318 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D { |
| 316 public: | 319 public: |
| 317 LoseContextOnFirstGetContext() | 320 LoseContextOnFirstGetContext() |
| 318 : m_contextLost(false) | 321 : m_contextLost(false) |
| 319 { | 322 { |
| 320 } | 323 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 341 return m_contextLost ? 1 : 0; | 344 return m_contextLost ? 1 : 0; |
| 342 } | 345 } |
| 343 | 346 |
| 344 private: | 347 private: |
| 345 bool m_contextLost; | 348 bool m_contextLost; |
| 346 }; | 349 }; |
| 347 | 350 |
| 348 TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) | 351 TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) |
| 349 { | 352 { |
| 350 FakeRendererClient mockClient; | 353 FakeRendererClient mockClient; |
| 351 scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<Web
Kit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 354 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
| 352 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 355 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 353 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 356 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 354 | 357 |
| 355 renderer.initialize(); | 358 renderer.initialize(); |
| 356 } | 359 } |
| 357 | 360 |
| 358 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic
sContext3D { | 361 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic
sContext3D { |
| 359 public: | 362 public: |
| 360 ContextThatDoesNotSupportMemoryManagmentExtensions() { } | 363 ContextThatDoesNotSupportMemoryManagmentExtensions() { } |
| 361 | 364 |
| 362 // WebGraphicsContext3D methods. | 365 // WebGraphicsContext3D methods. |
| 363 | 366 |
| 364 // This method would normally do a glSwapBuffers under the hood. | 367 // This method would normally do a glSwapBuffers under the hood. |
| 365 virtual void prepareTexture() { } | 368 virtual void prepareTexture() { } |
| 366 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll
ocationChangedCallbackCHROMIUM* callback) { } | 369 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll
ocationChangedCallbackCHROMIUM* callback) { } |
| 367 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } | 370 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } |
| 368 }; | 371 }; |
| 369 | 372 |
| 370 TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShoul
dDefaultToNonZeroAllocation) | 373 TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShoul
dDefaultToNonZeroAllocation) |
| 371 { | 374 { |
| 372 FakeRendererClient mockClient; | 375 FakeRendererClient mockClient; |
| 373 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExt
ensions))); | 376 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExt
ensions))); |
| 374 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 377 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 375 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 378 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 376 | 379 |
| 377 renderer.initialize(); | 380 renderer.initialize(); |
| 378 | 381 |
| 379 EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul); | 382 EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul); |
| 380 } | 383 } |
| 381 | 384 |
| 382 class ClearCountingContext : public FakeWebGraphicsContext3D { | 385 class ClearCountingContext : public FakeWebGraphicsContext3D { |
| 383 public: | 386 public: |
| 384 ClearCountingContext() : m_clear(0) { } | 387 ClearCountingContext() : m_clear(0) { } |
| 385 | 388 |
| 386 virtual void clear(WGC3Dbitfield) | 389 virtual void clear(WGC3Dbitfield) |
| 387 { | 390 { |
| 388 m_clear++; | 391 m_clear++; |
| 389 } | 392 } |
| 390 | 393 |
| 391 int clearCount() const { return m_clear; } | 394 int clearCount() const { return m_clear; } |
| 392 | 395 |
| 393 private: | 396 private: |
| 394 int m_clear; | 397 int m_clear; |
| 395 }; | 398 }; |
| 396 | 399 |
| 397 TEST(GLRendererTest2, opaqueBackground) | 400 TEST(GLRendererTest2, opaqueBackground) |
| 398 { | 401 { |
| 399 FakeRendererClient mockClient; | 402 FakeRendererClient mockClient; |
| 400 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 403 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
| 401 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); | 404 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); |
| 402 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 405 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 403 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 406 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 404 | 407 |
| 405 mockClient.rootRenderPass()->has_transparent_background = false; | 408 mockClient.rootRenderPass()->has_transparent_background = false; |
| 406 | 409 |
| 407 EXPECT_TRUE(renderer.initialize()); | 410 EXPECT_TRUE(renderer.initialize()); |
| 408 | 411 |
| 409 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 412 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
| 410 | 413 |
| 411 // On DEBUG builds, render passes with opaque background clear to blue to | 414 // On DEBUG builds, render passes with opaque background clear to blue to |
| 412 // easily see regions that were not drawn on the screen. | 415 // easily see regions that were not drawn on the screen. |
| 413 #ifdef NDEBUG | 416 #ifdef NDEBUG |
| 414 EXPECT_EQ(0, context->clearCount()); | 417 EXPECT_EQ(0, context->clearCount()); |
| 415 #else | 418 #else |
| 416 EXPECT_EQ(1, context->clearCount()); | 419 EXPECT_EQ(1, context->clearCount()); |
| 417 #endif | 420 #endif |
| 418 } | 421 } |
| 419 | 422 |
| 420 TEST(GLRendererTest2, transparentBackground) | 423 TEST(GLRendererTest2, transparentBackground) |
| 421 { | 424 { |
| 422 FakeRendererClient mockClient; | 425 FakeRendererClient mockClient; |
| 423 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 426 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
| 424 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); | 427 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->Context3D()); |
| 425 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 428 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 426 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 429 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 427 | 430 |
| 428 mockClient.rootRenderPass()->has_transparent_background = true; | 431 mockClient.rootRenderPass()->has_transparent_background = true; |
| 429 | 432 |
| 430 EXPECT_TRUE(renderer.initialize()); | 433 EXPECT_TRUE(renderer.initialize()); |
| 431 | 434 |
| 432 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 435 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
| 433 | 436 |
| 434 EXPECT_EQ(1, context->clearCount()); | 437 EXPECT_EQ(1, context->clearCount()); |
| 435 } | 438 } |
| 436 | 439 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 467 private: | 470 private: |
| 468 bool* m_lastCallWasSetVisibility; | 471 bool* m_lastCallWasSetVisibility; |
| 469 }; | 472 }; |
| 470 | 473 |
| 471 TEST(GLRendererTest2, visibilityChangeIsLastCall) | 474 TEST(GLRendererTest2, visibilityChangeIsLastCall) |
| 472 { | 475 { |
| 473 FakeRendererClient mockClient; | 476 FakeRendererClient mockClient; |
| 474 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))
); | 477 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))
); |
| 475 VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityC
hangeIsLastCallTrackingContext*>(outputSurface->Context3D()); | 478 VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityC
hangeIsLastCallTrackingContext*>(outputSurface->Context3D()); |
| 476 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 479 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 477 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 480 FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.g
et()); |
| 478 | 481 |
| 479 EXPECT_TRUE(renderer.initialize()); | 482 EXPECT_TRUE(renderer.initialize()); |
| 480 | 483 |
| 481 bool lastCallWasSetVisiblity = false; | 484 bool lastCallWasSetVisiblity = false; |
| 482 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to t
he GPU | 485 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to t
he GPU |
| 483 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy | 486 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy |
| 484 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving | 487 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving |
| 485 // them both a pointer to a variable on the stack. | 488 // them both a pointer to a variable on the stack. |
| 486 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 489 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
| 487 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 490 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 private: | 522 private: |
| 520 WGC3Denum m_activeTexture; | 523 WGC3Denum m_activeTexture; |
| 521 }; | 524 }; |
| 522 | 525 |
| 523 TEST(GLRendererTest2, activeTextureState) | 526 TEST(GLRendererTest2, activeTextureState) |
| 524 { | 527 { |
| 525 FakeRendererClient fakeClient; | 528 FakeRendererClient fakeClient; |
| 526 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); | 529 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); |
| 527 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->Context3D()); | 530 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->Context3D()); |
| 528 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 531 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 529 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); | 532 FakeRendererGL renderer(&fakeClient, outputSurface.get(), resourceProvider.g
et()); |
| 530 | 533 |
| 531 // During initialization we are allowed to set any texture parameters. | 534 // During initialization we are allowed to set any texture parameters. |
| 532 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); | 535 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); |
| 533 EXPECT_TRUE(renderer.initialize()); | 536 EXPECT_TRUE(renderer.initialize()); |
| 534 | 537 |
| 535 cc::RenderPass::Id id(1, 1); | 538 cc::RenderPass::Id id(1, 1); |
| 536 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 539 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
| 537 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::
Transform()); | 540 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::
Transform()); |
| 538 pass->AppendOneOfEveryQuadType(resourceProvider.get()); | 541 pass->AppendOneOfEveryQuadType(resourceProvider.get()); |
| 539 | 542 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 it != pass->quad_list.backToFrontEnd(); ++it) { | 576 it != pass->quad_list.backToFrontEnd(); ++it) { |
| 574 renderer.drawQuad(drawingFrame, *it); | 577 renderer.drawQuad(drawingFrame, *it); |
| 575 } | 578 } |
| 576 renderer.finishDrawingQuadList(); | 579 renderer.finishDrawingQuadList(); |
| 577 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 580 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
| 578 Mock::VerifyAndClearExpectations(context); | 581 Mock::VerifyAndClearExpectations(context); |
| 579 } | 582 } |
| 580 | 583 |
| 581 } // namespace | 584 } // namespace |
| 582 } // namespace cc | 585 } // namespace cc |
| OLD | NEW |