OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/compositor/buffer_queue.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 #include <stdint.h> | 8 #include <stdint.h> |
7 | |
8 #include <set> | 9 #include <set> |
| 10 #include <utility> |
9 | 11 |
10 #include "cc/test/test_context_provider.h" | 12 #include "cc/test/test_context_provider.h" |
11 #include "cc/test/test_web_graphics_context_3d.h" | 13 #include "cc/test/test_web_graphics_context_3d.h" |
12 #include "content/browser/compositor/buffer_queue.h" | |
13 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 14 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
14 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 15 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
15 #include "content/common/gpu/client/gl_helper.h" | 16 #include "content/common/gpu/client/gl_helper.h" |
16 #include "gpu/GLES2/gl2extchromium.h" | 17 #include "gpu/GLES2/gl2extchromium.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/khronos/GLES2/gl2ext.h" | 20 #include "third_party/khronos/GLES2/gl2ext.h" |
20 | 21 |
21 using ::testing::_; | 22 using ::testing::_; |
22 using ::testing::Expectation; | 23 using ::testing::Expectation; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 class BufferQueueTest : public ::testing::Test { | 89 class BufferQueueTest : public ::testing::Test { |
89 public: | 90 public: |
90 BufferQueueTest() : doublebuffering_(true), first_frame_(true) {} | 91 BufferQueueTest() : doublebuffering_(true), first_frame_(true) {} |
91 | 92 |
92 void SetUp() override { | 93 void SetUp() override { |
93 InitWithContext(cc::TestWebGraphicsContext3D::Create()); | 94 InitWithContext(cc::TestWebGraphicsContext3D::Create()); |
94 } | 95 } |
95 | 96 |
96 void InitWithContext(scoped_ptr<cc::TestWebGraphicsContext3D> context) { | 97 void InitWithContext(scoped_ptr<cc::TestWebGraphicsContext3D> context) { |
97 scoped_refptr<cc::TestContextProvider> context_provider = | 98 scoped_refptr<cc::TestContextProvider> context_provider = |
98 cc::TestContextProvider::Create(context.Pass()); | 99 cc::TestContextProvider::Create(std::move(context)); |
99 context_provider->BindToCurrentThread(); | 100 context_provider->BindToCurrentThread(); |
100 gpu_memory_buffer_manager_.reset(new StubBrowserGpuMemoryBufferManager); | 101 gpu_memory_buffer_manager_.reset(new StubBrowserGpuMemoryBufferManager); |
101 mock_output_surface_ = | 102 mock_output_surface_ = |
102 new MockBufferQueue(context_provider, gpu_memory_buffer_manager_.get(), | 103 new MockBufferQueue(context_provider, gpu_memory_buffer_manager_.get(), |
103 GL_TEXTURE_2D, GL_RGBA); | 104 GL_TEXTURE_2D, GL_RGBA); |
104 output_surface_.reset(mock_output_surface_); | 105 output_surface_.reset(mock_output_surface_); |
105 output_surface_->Initialize(); | 106 output_surface_->Initialize(); |
106 } | 107 } |
107 | 108 |
108 unsigned current_surface() { | 109 unsigned current_surface() { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager) { | 230 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager) { |
230 *context = new MockedContext(); | 231 *context = new MockedContext(); |
231 scoped_refptr<cc::TestContextProvider> context_provider = | 232 scoped_refptr<cc::TestContextProvider> context_provider = |
232 cc::TestContextProvider::Create( | 233 cc::TestContextProvider::Create( |
233 scoped_ptr<cc::TestWebGraphicsContext3D>(*context)); | 234 scoped_ptr<cc::TestWebGraphicsContext3D>(*context)); |
234 context_provider->BindToCurrentThread(); | 235 context_provider->BindToCurrentThread(); |
235 scoped_ptr<BufferQueue> buffer_queue( | 236 scoped_ptr<BufferQueue> buffer_queue( |
236 new BufferQueue(context_provider, target, GL_RGBA, nullptr, | 237 new BufferQueue(context_provider, target, GL_RGBA, nullptr, |
237 gpu_memory_buffer_manager, 1)); | 238 gpu_memory_buffer_manager, 1)); |
238 buffer_queue->Initialize(); | 239 buffer_queue->Initialize(); |
239 return buffer_queue.Pass(); | 240 return buffer_queue; |
240 } | 241 } |
241 | 242 |
242 TEST(BufferQueueStandaloneTest, FboInitialization) { | 243 TEST(BufferQueueStandaloneTest, FboInitialization) { |
243 MockedContext* context; | 244 MockedContext* context; |
244 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager( | 245 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager( |
245 new StubBrowserGpuMemoryBufferManager); | 246 new StubBrowserGpuMemoryBufferManager); |
246 scoped_ptr<BufferQueue> output_surface = CreateOutputSurfaceWithMock( | 247 scoped_ptr<BufferQueue> output_surface = CreateOutputSurfaceWithMock( |
247 GL_TEXTURE_2D, &context, gpu_memory_buffer_manager.get()); | 248 GL_TEXTURE_2D, &context, gpu_memory_buffer_manager.get()); |
248 | 249 |
249 EXPECT_CALL(*context, bindFramebuffer(GL_FRAMEBUFFER, Ne(0U))); | 250 EXPECT_CALL(*context, bindFramebuffer(GL_FRAMEBUFFER, Ne(0U))); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 testing::Mock::VerifyAndClearExpectations(mock_output_surface_); | 614 testing::Mock::VerifyAndClearExpectations(mock_output_surface_); |
614 EXPECT_CALL(*mock_output_surface_, | 615 EXPECT_CALL(*mock_output_surface_, |
615 CopyBufferDamage(target_texture, source_texture, small_damage, _)) | 616 CopyBufferDamage(target_texture, source_texture, small_damage, _)) |
616 .Times(1); | 617 .Times(1); |
617 output_surface_->SwapBuffers(small_damage); | 618 output_surface_->SwapBuffers(small_damage); |
618 testing::Mock::VerifyAndClearExpectations(mock_output_surface_); | 619 testing::Mock::VerifyAndClearExpectations(mock_output_surface_); |
619 } | 620 } |
620 | 621 |
621 } // namespace | 622 } // namespace |
622 } // namespace content | 623 } // namespace content |
OLD | NEW |