Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 11275120: Virtual GL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "gpu/command_buffer/client/gles2_implementation.h" 11 #include "gpu/command_buffer/client/gles2_implementation.h"
12 #include "gpu/command_buffer/client/gles2_lib.h" 12 #include "gpu/command_buffer/client/gles2_lib.h"
13 #include "gpu/command_buffer/client/transfer_buffer.h" 13 #include "gpu/command_buffer/client/transfer_buffer.h"
14 #include "gpu/command_buffer/common/constants.h" 14 #include "gpu/command_buffer/common/constants.h"
15 #include "gpu/command_buffer/service/command_buffer_service.h" 15 #include "gpu/command_buffer/service/command_buffer_service.h"
16 #include "gpu/command_buffer/service/context_group.h" 16 #include "gpu/command_buffer/service/context_group.h"
17 #include "gpu/command_buffer/service/gl_context_virtual.h"
17 #include "gpu/command_buffer/service/gpu_scheduler.h" 18 #include "gpu/command_buffer/service/gpu_scheduler.h"
18 #include "gpu/command_buffer/service/mailbox_manager.h" 19 #include "gpu/command_buffer/service/mailbox_manager.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gl/gl_context.h" 21 #include "ui/gl/gl_context.h"
21 #include "ui/gl/gl_share_group.h" 22 #include "ui/gl/gl_share_group.h"
22 #include "ui/gl/gl_surface.h" 23 #include "ui/gl/gl_surface.h"
23 24
24 namespace gpu { 25 namespace gpu {
25 26
26 GLManager::GLManager() { 27 GLManager::GLManager() {
27 } 28 }
28 29
29 GLManager::~GLManager() { 30 GLManager::~GLManager() {
30 } 31 }
31 32
32 void GLManager::Initialize(const gfx::Size& size) { 33 void GLManager::Initialize(const gfx::Size& size) {
33 Setup(size, NULL, NULL, NULL, NULL); 34 Setup(size, NULL, NULL, NULL, NULL, NULL);
34 } 35 }
35 36
36 void GLManager::InitializeShared( 37 void GLManager::InitializeShared(
37 const gfx::Size& size, GLManager* gl_manager) { 38 const gfx::Size& size, GLManager* gl_manager) {
38 DCHECK(gl_manager); 39 DCHECK(gl_manager);
39 Setup( 40 Setup(
40 size, 41 size,
41 gl_manager->mailbox_manager(), 42 gl_manager->mailbox_manager(),
42 gl_manager->share_group(), 43 gl_manager->share_group(),
43 gl_manager->decoder_->GetContextGroup(), 44 gl_manager->decoder_->GetContextGroup(),
44 gl_manager->gles2_implementation()->share_group()); 45 gl_manager->gles2_implementation()->share_group(),
46 NULL);
45 } 47 }
46 48
47 void GLManager::InitializeSharedMailbox( 49 void GLManager::InitializeSharedMailbox(
48 const gfx::Size& size, GLManager* gl_manager) { 50 const gfx::Size& size, GLManager* gl_manager) {
49 DCHECK(gl_manager); 51 DCHECK(gl_manager);
50 Setup( 52 Setup(
51 size, 53 size,
52 gl_manager->mailbox_manager(), 54 gl_manager->mailbox_manager(),
53 gl_manager->share_group(), 55 gl_manager->share_group(),
54 NULL, 56 NULL,
57 NULL,
55 NULL); 58 NULL);
56 } 59 }
57 60
61 void GLManager::InitializeVirtual(
62 const gfx::Size& size, GLManager* real_gl_manager) {
63 DCHECK(real_gl_manager);
64 Setup(
65 size,
66 NULL,
67 NULL,
68 NULL,
69 NULL,
70 real_gl_manager->context());
71 }
72
58 void GLManager::Setup( 73 void GLManager::Setup(
59 const gfx::Size& size, 74 const gfx::Size& size,
60 gles2::MailboxManager* mailbox_manager, 75 gles2::MailboxManager* mailbox_manager,
61 gfx::GLShareGroup* share_group, 76 gfx::GLShareGroup* share_group,
62 gles2::ContextGroup* context_group, 77 gles2::ContextGroup* context_group,
63 gles2::ShareGroup* client_share_group) { 78 gles2::ShareGroup* client_share_group,
79 gfx::GLContext* real_gl_context) {
64 const int32 kCommandBufferSize = 1024 * 1024; 80 const int32 kCommandBufferSize = 1024 * 1024;
65 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; 81 const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
66 const size_t kMinTransferBufferSize = 1 * 256 * 1024; 82 const size_t kMinTransferBufferSize = 1 * 256 * 1024;
67 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; 83 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
68 const bool kBindGeneratesResource = false; 84 const bool kBindGeneratesResource = false;
69 const bool kShareResources = true; 85 const bool kShareResources = true;
70 86
71 // From <EGL/egl.h>. 87 // From <EGL/egl.h>.
72 const int32 EGL_ALPHA_SIZE = 0x3021; 88 const int32 EGL_ALPHA_SIZE = 0x3021;
73 const int32 EGL_BLUE_SIZE = 0x3022; 89 const int32 EGL_BLUE_SIZE = 0x3022;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 128
113 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), 129 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(),
114 decoder_.get(), 130 decoder_.get(),
115 decoder_.get())); 131 decoder_.get()));
116 132
117 decoder_->set_engine(gpu_scheduler_.get()); 133 decoder_->set_engine(gpu_scheduler_.get());
118 134
119 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size); 135 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size);
120 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface"; 136 ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface";
121 137
122 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), 138 if (real_gl_context) {
123 surface_.get(), 139 context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual(
124 gpu_preference); 140 share_group_.get(), real_gl_context, decoder_.get()));
141 ASSERT_TRUE(context_->Initialize(
142 surface_.get(), gfx::PreferIntegratedGpu));
143 } else {
144 context_ = gfx::GLContext::CreateGLContext(share_group_.get(),
145 surface_.get(),
146 gpu_preference);
147 }
125 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; 148 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context";
126 149
127 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); 150 ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
128 151
129 ASSERT_TRUE(decoder_->Initialize( 152 ASSERT_TRUE(decoder_->Initialize(
130 surface_.get(), 153 surface_.get(),
131 context_.get(), 154 context_.get(),
132 true, 155 true,
133 size, 156 size,
134 ::gpu::gles2::DisallowedFeatures(), 157 ::gpu::gles2::DisallowedFeatures(),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); 212 ::gpu::CommandBuffer::State state = command_buffer_->GetState();
190 ASSERT_EQ(::gpu::error::kNoError, state.error); 213 ASSERT_EQ(::gpu::error::kNoError, state.error);
191 } 214 }
192 215
193 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { 216 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) {
194 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 217 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
195 } 218 }
196 219
197 } // namespace gpu 220 } // namespace gpu
198 221
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_virtual_contexts_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698