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/draw_quad.h" | 7 #include "cc/draw_quad.h" |
8 #include "cc/prioritized_resource_manager.h" | 8 #include "cc/prioritized_resource_manager.h" |
9 #include "cc/resource_provider.h" | 9 #include "cc/resource_provider.h" |
10 #include "cc/test/fake_web_compositor_output_surface.h" | 10 #include "cc/test/fake_web_compositor_output_surface.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class FakeRendererClient : public RendererClient { | 52 class FakeRendererClient : public RendererClient { |
53 public: | 53 public: |
54 FakeRendererClient() | 54 FakeRendererClient() |
55 : m_setFullRootLayerDamageCount(0) | 55 : m_setFullRootLayerDamageCount(0) |
56 , m_lastCallWasSetVisibility(0) | 56 , m_lastCallWasSetVisibility(0) |
57 , m_rootLayer(LayerImpl::create(1)) | 57 , m_rootLayer(LayerImpl::create(1)) |
58 , m_memoryAllocationLimitBytes(PrioritizedResourceManager::defaultMemory
AllocationLimit()) | 58 , m_memoryAllocationLimitBytes(PrioritizedResourceManager::defaultMemory
AllocationLimit()) |
59 { | 59 { |
60 m_rootLayer->createRenderSurface(); | 60 m_rootLayer->createRenderSurface(); |
61 RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId
(); | 61 RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId
(); |
62 scoped_ptr<RenderPass> rootRenderPass = RenderPass::create(renderPassId,
gfx::Rect(), WebTransformationMatrix()); | 62 scoped_ptr<RenderPass> rootRenderPass = RenderPass::Create(); |
| 63 rootRenderPass->SetNew(renderPassId, gfx::Rect(), gfx::Rect(), WebTransf
ormationMatrix()); |
63 m_renderPassesInDrawOrder.push_back(rootRenderPass.get()); | 64 m_renderPassesInDrawOrder.push_back(rootRenderPass.get()); |
64 m_renderPasses.set(renderPassId, rootRenderPass.Pass()); | 65 m_renderPasses.set(renderPassId, rootRenderPass.Pass()); |
65 } | 66 } |
66 | 67 |
67 // RendererClient methods. | 68 // RendererClient methods. |
68 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } | 69 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } |
69 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } | 70 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } |
70 virtual void didLoseContext() OVERRIDE { } | 71 virtual void didLoseContext() OVERRIDE { } |
71 virtual void onSwapBuffersComplete() OVERRIDE { } | 72 virtual void onSwapBuffersComplete() OVERRIDE { } |
72 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } | 73 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 }; | 384 }; |
384 | 385 |
385 TEST(GLRendererTest2, opaqueBackground) | 386 TEST(GLRendererTest2, opaqueBackground) |
386 { | 387 { |
387 FakeRendererClient mockClient; | 388 FakeRendererClient mockClient; |
388 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 389 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
389 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->context3D()); | 390 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->context3D()); |
390 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 391 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
391 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 392 FakeRendererGL renderer(&mockClient, resourceProvider.get()); |
392 | 393 |
393 mockClient.rootRenderPass()->setHasTransparentBackground(false); | 394 mockClient.rootRenderPass()->has_transparent_background = false; |
394 | 395 |
395 EXPECT_TRUE(renderer.initialize()); | 396 EXPECT_TRUE(renderer.initialize()); |
396 | 397 |
397 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 398 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
398 | 399 |
399 // On DEBUG builds, render passes with opaque background clear to blue to | 400 // On DEBUG builds, render passes with opaque background clear to blue to |
400 // easily see regions that were not drawn on the screen. | 401 // easily see regions that were not drawn on the screen. |
401 #ifdef NDEBUG | 402 #ifdef NDEBUG |
402 EXPECT_EQ(0, context->clearCount()); | 403 EXPECT_EQ(0, context->clearCount()); |
403 #else | 404 #else |
404 EXPECT_EQ(1, context->clearCount()); | 405 EXPECT_EQ(1, context->clearCount()); |
405 #endif | 406 #endif |
406 } | 407 } |
407 | 408 |
408 TEST(GLRendererTest2, transparentBackground) | 409 TEST(GLRendererTest2, transparentBackground) |
409 { | 410 { |
410 FakeRendererClient mockClient; | 411 FakeRendererClient mockClient; |
411 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); | 412 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); |
412 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->context3D()); | 413 ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSur
face->context3D()); |
413 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 414 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
414 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 415 FakeRendererGL renderer(&mockClient, resourceProvider.get()); |
415 | 416 |
416 mockClient.rootRenderPass()->setHasTransparentBackground(true); | 417 mockClient.rootRenderPass()->has_transparent_background = true; |
417 | 418 |
418 EXPECT_TRUE(renderer.initialize()); | 419 EXPECT_TRUE(renderer.initialize()); |
419 | 420 |
420 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 421 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
421 | 422 |
422 EXPECT_EQ(1, context->clearCount()); | 423 EXPECT_EQ(1, context->clearCount()); |
423 } | 424 } |
424 | 425 |
425 class VisibilityChangeIsLastCallTrackingContext : public FakeWebGraphicsContext3
D { | 426 class VisibilityChangeIsLastCallTrackingContext : public FakeWebGraphicsContext3
D { |
426 public: | 427 public: |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 { | 523 { |
523 FakeRendererClient fakeClient; | 524 FakeRendererClient fakeClient; |
524 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)))
; | 525 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)))
; |
525 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->context3D()); | 526 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->context3D()); |
526 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 527 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
527 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); | 528 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); |
528 | 529 |
529 EXPECT_TRUE(renderer.initialize()); | 530 EXPECT_TRUE(renderer.initialize()); |
530 | 531 |
531 cc::RenderPass::Id id(1, 1); | 532 cc::RenderPass::Id id(1, 1); |
532 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(id, gfx::Rect(0, 0,
100, 100), WebTransformationMatrix()); | 533 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
533 pass->appendOneOfEveryQuadType(resourceProvider.get()); | 534 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), WebTr
ansformationMatrix()); |
| 535 pass->AppendOneOfEveryQuadType(resourceProvider.get()); |
534 | 536 |
535 context->setInDraw(); | 537 context->setInDraw(); |
536 | 538 |
537 cc::DirectRenderer::DrawingFrame drawingFrame; | 539 cc::DirectRenderer::DrawingFrame drawingFrame; |
538 renderer.beginDrawingFrame(drawingFrame); | 540 renderer.beginDrawingFrame(drawingFrame); |
539 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 541 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
540 | 542 |
541 for (cc::QuadList::backToFrontIterator it = pass->quadList().backToFrontBegi
n(); | 543 for (cc::QuadList::backToFrontIterator it = pass->quad_list.backToFrontBegin
(); |
542 it != pass->quadList().backToFrontEnd(); ++it) { | 544 it != pass->quad_list.backToFrontEnd(); ++it) { |
543 renderer.drawQuad(drawingFrame, *it); | 545 renderer.drawQuad(drawingFrame, *it); |
544 } | 546 } |
545 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 547 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
546 } | 548 } |
547 | 549 |
548 } // namespace | 550 } // namespace |
549 } // namespace cc | 551 } // namespace cc |
OLD | NEW |