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 "config.h" | 5 #include "config.h" |
6 #include "cc/gl_renderer.h" | 6 #include "cc/gl_renderer.h" |
7 | 7 |
8 #include "cc/draw_quad.h" | 8 #include "cc/draw_quad.h" |
9 #include "cc/prioritized_texture_manager.h" | 9 #include "cc/prioritized_texture_manager.h" |
10 #include "cc/resource_provider.h" | 10 #include "cc/resource_provider.h" |
11 #include "cc/settings.h" | 11 #include "cc/settings.h" |
12 #include "cc/single_thread_proxy.h" | 12 #include "cc/single_thread_proxy.h" |
13 #include "cc/test/fake_web_compositor_output_surface.h" | 13 #include "cc/test/fake_web_compositor_output_surface.h" |
14 #include "cc/test/fake_web_graphics_context_3d.h" | 14 #include "cc/test/fake_web_graphics_context_3d.h" |
15 #include "cc/test/test_common.h" | 15 #include "cc/test/test_common.h" |
16 #include "cc/test/web_compositor_initializer.h" | |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
20 #include <public/WebTransformationMatrix.h> | 19 #include <public/WebTransformationMatrix.h> |
21 | 20 |
22 using namespace cc; | 21 using namespace cc; |
23 using namespace WebKit; | 22 using namespace WebKit; |
24 using namespace WebKitTests; | 23 using namespace WebKitTests; |
25 | 24 |
26 class FrameCountingMemoryAllocationSettingContext : public FakeWebGraphicsContex
t3D { | 25 class FrameCountingMemoryAllocationSettingContext : public FakeWebGraphicsContex
t3D { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Changing visibility to public. | 103 // Changing visibility to public. |
105 using GLRenderer::initialize; | 104 using GLRenderer::initialize; |
106 using GLRenderer::isFramebufferDiscarded; | 105 using GLRenderer::isFramebufferDiscarded; |
107 }; | 106 }; |
108 | 107 |
109 class GLRendererTest : public testing::Test { | 108 class GLRendererTest : public testing::Test { |
110 protected: | 109 protected: |
111 GLRendererTest() | 110 GLRendererTest() |
112 : m_suggestHaveBackbufferYes(1, true) | 111 : m_suggestHaveBackbufferYes(1, true) |
113 , m_suggestHaveBackbufferNo(1, false) | 112 , m_suggestHaveBackbufferNo(1, false) |
114 , m_compositorInitializer(0) | |
115 , m_context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::We
bGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext()))) | 113 , m_context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::We
bGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext()))) |
116 , m_resourceProvider(ResourceProvider::create(m_context.get())) | 114 , m_resourceProvider(ResourceProvider::create(m_context.get())) |
117 , m_renderer(&m_mockClient, m_resourceProvider.get()) | 115 , m_renderer(&m_mockClient, m_resourceProvider.get()) |
118 { | 116 { |
119 } | 117 } |
120 | 118 |
121 virtual void SetUp() | 119 virtual void SetUp() |
122 { | 120 { |
123 m_renderer.initialize(); | 121 m_renderer.initialize(); |
124 } | 122 } |
125 | 123 |
126 void swapBuffers() | 124 void swapBuffers() |
127 { | 125 { |
128 m_renderer.swapBuffers(); | 126 m_renderer.swapBuffers(); |
129 } | 127 } |
130 | 128 |
131 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); } | 129 FrameCountingMemoryAllocationSettingContext* context() { return static_cast<
FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); } |
132 | 130 |
133 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; | 131 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; |
134 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; | 132 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; |
135 | 133 |
136 WebCompositorInitializer m_compositorInitializer; | |
137 scoped_ptr<GraphicsContext> m_context; | 134 scoped_ptr<GraphicsContext> m_context; |
138 FakeRendererClient m_mockClient; | 135 FakeRendererClient m_mockClient; |
139 scoped_ptr<ResourceProvider> m_resourceProvider; | 136 scoped_ptr<ResourceProvider> m_resourceProvider; |
140 FakeRendererGL m_renderer; | 137 FakeRendererGL m_renderer; |
141 ScopedSettings m_scopedSettings; | 138 ScopedSettings m_scopedSettings; |
142 }; | 139 }; |
143 | 140 |
144 // Test GLRenderer discardFramebuffer functionality: | 141 // Test GLRenderer discardFramebuffer functionality: |
145 // Suggest recreating framebuffer when one already exists. | 142 // Suggest recreating framebuffer when one already exists. |
146 // Expected: it does nothing. | 143 // Expected: it does nothing. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 FakeRendererGL renderer(&mockClient, resourceProvider.get()); | 416 FakeRendererGL renderer(&mockClient, resourceProvider.get()); |
420 | 417 |
421 mockClient.rootRenderPass()->setHasTransparentBackground(true); | 418 mockClient.rootRenderPass()->setHasTransparentBackground(true); |
422 | 419 |
423 EXPECT_TRUE(renderer.initialize()); | 420 EXPECT_TRUE(renderer.initialize()); |
424 | 421 |
425 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 422 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
426 | 423 |
427 EXPECT_EQ(1, context->clearCount()); | 424 EXPECT_EQ(1, context->clearCount()); |
428 } | 425 } |
OLD | NEW |