| 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" |
| 11 #include "cc/test/fake_web_graphics_context_3d.h" | 11 #include "cc/test/fake_web_graphics_context_3d.h" |
| 12 #include "cc/test/render_pass_test_common.h" | 12 #include "cc/test/render_pass_test_common.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/khronos/GLES2/gl2.h" | 15 #include "third_party/khronos/GLES2/gl2.h" |
| 16 #include <public/WebTransformationMatrix.h> | 16 #include "ui/gfx/transform.h" |
| 17 | 17 |
| 18 using namespace WebKit; | 18 using namespace WebKit; |
| 19 using namespace WebKitTests; | 19 using namespace WebKitTests; |
| 20 | 20 |
| 21 using gfx::Transform; |
| 22 |
| 21 namespace cc { | 23 namespace cc { |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 class FrameCountingMemoryAllocationSettingContext : public FakeWebGraphicsContex
t3D { | 26 class FrameCountingMemoryAllocationSettingContext : public FakeWebGraphicsContex
t3D { |
| 25 public: | 27 public: |
| 26 FrameCountingMemoryAllocationSettingContext() : m_frame(0) { } | 28 FrameCountingMemoryAllocationSettingContext() : m_frame(0) { } |
| 27 | 29 |
| 28 // WebGraphicsContext3D methods. | 30 // WebGraphicsContext3D methods. |
| 29 | 31 |
| 30 // This method would normally do a glSwapBuffers under the hood. | 32 // This method would normally do a glSwapBuffers under the hood. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 public: | 55 public: |
| 54 FakeRendererClient() | 56 FakeRendererClient() |
| 55 : m_setFullRootLayerDamageCount(0) | 57 : m_setFullRootLayerDamageCount(0) |
| 56 , m_lastCallWasSetVisibility(0) | 58 , m_lastCallWasSetVisibility(0) |
| 57 , m_rootLayer(LayerImpl::create(1)) | 59 , m_rootLayer(LayerImpl::create(1)) |
| 58 , m_memoryAllocationLimitBytes(PrioritizedResourceManager::defaultMemory
AllocationLimit()) | 60 , m_memoryAllocationLimitBytes(PrioritizedResourceManager::defaultMemory
AllocationLimit()) |
| 59 { | 61 { |
| 60 m_rootLayer->createRenderSurface(); | 62 m_rootLayer->createRenderSurface(); |
| 61 RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId
(); | 63 RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId
(); |
| 62 scoped_ptr<RenderPass> rootRenderPass = RenderPass::Create(); | 64 scoped_ptr<RenderPass> rootRenderPass = RenderPass::Create(); |
| 63 rootRenderPass->SetNew(renderPassId, gfx::Rect(), gfx::Rect(), WebTransf
ormationMatrix()); | 65 rootRenderPass->SetNew(renderPassId, gfx::Rect(), gfx::Rect(), Transform
()); |
| 64 m_renderPassesInDrawOrder.push_back(rootRenderPass.get()); | 66 m_renderPassesInDrawOrder.push_back(rootRenderPass.get()); |
| 65 m_renderPasses.set(renderPassId, rootRenderPass.Pass()); | 67 m_renderPasses.set(renderPassId, rootRenderPass.Pass()); |
| 66 } | 68 } |
| 67 | 69 |
| 68 // RendererClient methods. | 70 // RendererClient methods. |
| 69 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } | 71 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } |
| 70 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } | 72 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } |
| 71 virtual void didLoseContext() OVERRIDE { } | 73 virtual void didLoseContext() OVERRIDE { } |
| 72 virtual void onSwapBuffersComplete() OVERRIDE { } | 74 virtual void onSwapBuffersComplete() OVERRIDE { } |
| 73 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } | 75 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 FakeRendererClient fakeClient; | 526 FakeRendererClient fakeClient; |
| 525 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)))
; | 527 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)))
; |
| 526 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->context3D()); | 528 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->context3D()); |
| 527 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 529 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 528 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); | 530 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); |
| 529 | 531 |
| 530 EXPECT_TRUE(renderer.initialize()); | 532 EXPECT_TRUE(renderer.initialize()); |
| 531 | 533 |
| 532 cc::RenderPass::Id id(1, 1); | 534 cc::RenderPass::Id id(1, 1); |
| 533 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 535 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
| 534 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), WebTr
ansformationMatrix()); | 536 pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), Trans
form()); |
| 535 pass->AppendOneOfEveryQuadType(resourceProvider.get()); | 537 pass->AppendOneOfEveryQuadType(resourceProvider.get()); |
| 536 | 538 |
| 537 context->setInDraw(); | 539 context->setInDraw(); |
| 538 | 540 |
| 539 cc::DirectRenderer::DrawingFrame drawingFrame; | 541 cc::DirectRenderer::DrawingFrame drawingFrame; |
| 540 renderer.beginDrawingFrame(drawingFrame); | 542 renderer.beginDrawingFrame(drawingFrame); |
| 541 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 543 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
| 542 | 544 |
| 543 for (cc::QuadList::backToFrontIterator it = pass->quad_list.backToFrontBegin
(); | 545 for (cc::QuadList::backToFrontIterator it = pass->quad_list.backToFrontBegin
(); |
| 544 it != pass->quad_list.backToFrontEnd(); ++it) { | 546 it != pass->quad_list.backToFrontEnd(); ++it) { |
| 545 renderer.drawQuad(drawingFrame, *it); | 547 renderer.drawQuad(drawingFrame, *it); |
| 546 } | 548 } |
| 547 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 549 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
| 548 } | 550 } |
| 549 | 551 |
| 550 } // namespace | 552 } // namespace |
| 551 } // namespace cc | 553 } // namespace cc |
| OLD | NEW |