OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "gpu/command_buffer/tests/gl_manager.h" | 5 #include "gpu/command_buffer/tests/gl_manager.h" |
6 #include "base/at_exit.h" | 6 #include "base/at_exit.h" |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "gpu/command_buffer/client/gles2_lib.h" | 8 #include "gpu/command_buffer/client/gles2_lib.h" |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "gpu/command_buffer/client/transfer_buffer.h" | 10 #include "gpu/command_buffer/client/transfer_buffer.h" |
11 #include "gpu/command_buffer/common/constants.h" | 11 #include "gpu/command_buffer/common/constants.h" |
| 12 #include "gpu/command_buffer/service/command_buffer_service.h" |
12 #include "gpu/command_buffer/service/context_group.h" | 13 #include "gpu/command_buffer/service/context_group.h" |
13 #include "gpu/command_buffer/service/gpu_scheduler.h" | 14 #include "gpu/command_buffer/service/gpu_scheduler.h" |
14 #include "gpu/command_buffer/service/command_buffer_service.h" | 15 #include "gpu/command_buffer/service/mailbox_manager.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gfx/gl/gl_context.h" | 17 #include "ui/gfx/gl/gl_context.h" |
17 #include "ui/gfx/gl/gl_share_group.h" | 18 #include "ui/gfx/gl/gl_share_group.h" |
18 #include "ui/gfx/gl/gl_surface.h" | 19 #include "ui/gfx/gl/gl_surface.h" |
19 | 20 |
20 namespace gpu { | 21 namespace gpu { |
21 | 22 |
22 GLManager::GLManager() { | 23 GLManager::GLManager(gles2::MailboxManager* mailbox_manager, |
| 24 gfx::GLShareGroup* share_group) |
| 25 : mailbox_manager_(mailbox_manager), |
| 26 share_group_(share_group) { |
23 } | 27 } |
24 | 28 |
25 GLManager::~GLManager() { | 29 GLManager::~GLManager() { |
26 } | 30 } |
27 | 31 |
28 void GLManager::Initialize(const gfx::Size& size) { | 32 void GLManager::Initialize(const gfx::Size& size) { |
29 const int32 kCommandBufferSize = 1024 * 1024; | 33 const int32 kCommandBufferSize = 1024 * 1024; |
30 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; | 34 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; |
31 const size_t kMinTransferBufferSize = 1 * 256 * 1024; | 35 const size_t kMinTransferBufferSize = 1 * 256 * 1024; |
32 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; | 36 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
(...skipping 14 matching lines...) Expand all Loading... |
47 attribs.push_back(EGL_GREEN_SIZE); | 51 attribs.push_back(EGL_GREEN_SIZE); |
48 attribs.push_back(8); | 52 attribs.push_back(8); |
49 attribs.push_back(EGL_BLUE_SIZE); | 53 attribs.push_back(EGL_BLUE_SIZE); |
50 attribs.push_back(8); | 54 attribs.push_back(8); |
51 attribs.push_back(EGL_ALPHA_SIZE); | 55 attribs.push_back(EGL_ALPHA_SIZE); |
52 attribs.push_back(8); | 56 attribs.push_back(8); |
53 attribs.push_back(EGL_DEPTH_SIZE); | 57 attribs.push_back(EGL_DEPTH_SIZE); |
54 attribs.push_back(16); | 58 attribs.push_back(16); |
55 attribs.push_back(EGL_NONE); | 59 attribs.push_back(EGL_NONE); |
56 | 60 |
57 share_group_ = new gfx::GLShareGroup; | |
58 command_buffer_.reset(new CommandBufferService); | 61 command_buffer_.reset(new CommandBufferService); |
59 ASSERT_TRUE(command_buffer_->Initialize()) | 62 ASSERT_TRUE(command_buffer_->Initialize()) |
60 << "could not create command buffer service"; | 63 << "could not create command buffer service"; |
61 | 64 |
62 decoder_.reset(::gpu::gles2::GLES2Decoder::Create( | 65 decoder_.reset(::gpu::gles2::GLES2Decoder::Create( |
63 new gles2::ContextGroup(false))); | 66 new gles2::ContextGroup(mailbox_manager_.get(), false))); |
64 | 67 |
65 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), | 68 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), |
66 decoder_.get(), | 69 decoder_.get(), |
67 decoder_.get())); | 70 decoder_.get())); |
68 | 71 |
69 decoder_->set_engine(gpu_scheduler_.get()); | 72 decoder_->set_engine(gpu_scheduler_.get()); |
70 | 73 |
71 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size); | 74 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size); |
72 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; | 75 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; |
73 | 76 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); | 139 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); |
137 ASSERT_EQ(::gpu::error::kNoError, state.error); | 140 ASSERT_EQ(::gpu::error::kNoError, state.error); |
138 } | 141 } |
139 | 142 |
140 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { | 143 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { |
141 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); | 144 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); |
142 } | 145 } |
143 | 146 |
144 } // namespace gpu | 147 } // namespace gpu |
145 | 148 |
OLD | NEW |