OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gles2_conform_support/egl/display.h" | 5 #include "gpu/gles2_conform_support/egl/display.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 #include "gpu/command_buffer/client/gles2_lib.h" | 8 #include "gpu/command_buffer/client/gles2_lib.h" |
9 #include "gpu/command_buffer/service/command_buffer_service.h" | 9 #include "gpu/command_buffer/service/command_buffer_service.h" |
10 #include "gpu/command_buffer/service/context_group.h" | |
11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
12 #include "gpu/command_buffer/service/gpu_scheduler.h" | 11 #include "gpu/command_buffer/service/gpu_scheduler.h" |
13 #include "gpu/GLES2/gles2_command_buffer.h" | 12 #include "gpu/GLES2/gles2_command_buffer.h" |
14 #include "gpu/gles2_conform_support/egl/config.h" | 13 #include "gpu/gles2_conform_support/egl/config.h" |
15 #include "gpu/gles2_conform_support/egl/surface.h" | 14 #include "gpu/gles2_conform_support/egl/surface.h" |
16 | 15 |
17 namespace { | 16 namespace { |
18 const int32 kCommandBufferSize = 1024 * 1024; | 17 const int32 kCommandBufferSize = 1024 * 1024; |
19 const int32 kTransferBufferSize = 512 * 1024; | 18 const int32 kTransferBufferSize = 512 * 1024; |
20 } | 19 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 EGLSurface Display::CreateWindowSurface(EGLConfig config, | 101 EGLSurface Display::CreateWindowSurface(EGLConfig config, |
103 EGLNativeWindowType win, | 102 EGLNativeWindowType win, |
104 const EGLint* attrib_list) { | 103 const EGLint* attrib_list) { |
105 if (surface_ != NULL) { | 104 if (surface_ != NULL) { |
106 // We do not support more than one window surface. | 105 // We do not support more than one window surface. |
107 return EGL_NO_SURFACE; | 106 return EGL_NO_SURFACE; |
108 } | 107 } |
109 | 108 |
110 using gpu::GpuScheduler; | 109 using gpu::GpuScheduler; |
111 std::vector<int32> attribs; | 110 std::vector<int32> attribs; |
112 gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup(true)); | |
113 scoped_ptr<GpuScheduler> gpu_scheduler( | 111 scoped_ptr<GpuScheduler> gpu_scheduler( |
114 GpuScheduler::Create(command_buffer_.get(), | 112 GpuScheduler::Create(command_buffer_.get(), |
115 NULL, | 113 NULL, |
116 NULL)); | 114 NULL)); |
117 if (!gpu_scheduler->Initialize( | 115 if (!gpu_scheduler->Initialize( |
118 win, gfx::Size(), false, gpu::gles2::DisallowedExtensions(), NULL, | 116 win, gfx::Size(), false, gpu::gles2::DisallowedExtensions(), NULL, |
119 attribs, NULL)) | 117 attribs, NULL)) |
120 return EGL_NO_SURFACE; | 118 return EGL_NO_SURFACE; |
121 | 119 |
122 command_buffer_->SetPutOffsetChangeCallback( | 120 command_buffer_->SetPutOffsetChangeCallback( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 DCHECK(transfer_buffer_id_ != -1); | 152 DCHECK(transfer_buffer_id_ != -1); |
155 gpu::Buffer buffer = command_buffer_->GetTransferBuffer(transfer_buffer_id_); | 153 gpu::Buffer buffer = command_buffer_->GetTransferBuffer(transfer_buffer_id_); |
156 DCHECK(buffer.ptr != NULL); | 154 DCHECK(buffer.ptr != NULL); |
157 bool share_resources = share_ctx != NULL; | 155 bool share_resources = share_ctx != NULL; |
158 using gpu::gles2::GLES2Implementation; | 156 using gpu::gles2::GLES2Implementation; |
159 context_.reset(new GLES2Implementation( | 157 context_.reset(new GLES2Implementation( |
160 gles2_cmd_helper_.get(), | 158 gles2_cmd_helper_.get(), |
161 buffer.size, | 159 buffer.size, |
162 buffer.ptr, | 160 buffer.ptr, |
163 transfer_buffer_id_, | 161 transfer_buffer_id_, |
164 share_resources, | 162 share_resources)); |
165 true)); | |
166 | 163 |
167 context_->CommandBufferEnableCHROMIUM( | 164 context_->CommandBufferEnableCHROMIUM( |
168 PEPPER3D_ALLOW_BUFFERS_ON_MULTIPLE_TARGETS); | 165 PEPPER3D_ALLOW_BUFFERS_ON_MULTIPLE_TARGETS); |
169 context_->CommandBufferEnableCHROMIUM( | 166 context_->CommandBufferEnableCHROMIUM( |
170 PEPPER3D_SUPPORT_FIXED_ATTRIBS); | 167 PEPPER3D_SUPPORT_FIXED_ATTRIBS); |
171 | 168 |
172 return context_.get(); | 169 return context_.get(); |
173 } | 170 } |
174 | 171 |
175 void Display::DestroyContext(EGLContext ctx) { | 172 void Display::DestroyContext(EGLContext ctx) { |
176 DCHECK(IsValidContext(ctx)); | 173 DCHECK(IsValidContext(ctx)); |
177 context_.reset(); | 174 context_.reset(); |
178 } | 175 } |
179 | 176 |
180 bool Display::MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx) { | 177 bool Display::MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx) { |
181 if (ctx == EGL_NO_CONTEXT) { | 178 if (ctx == EGL_NO_CONTEXT) { |
182 gles2::SetGLContext(NULL); | 179 gles2::SetGLContext(NULL); |
183 } else { | 180 } else { |
184 DCHECK(IsValidSurface(draw)); | 181 DCHECK(IsValidSurface(draw)); |
185 DCHECK(IsValidSurface(read)); | 182 DCHECK(IsValidSurface(read)); |
186 DCHECK(IsValidContext(ctx)); | 183 DCHECK(IsValidContext(ctx)); |
187 gles2::SetGLContext(context_.get()); | 184 gles2::SetGLContext(context_.get()); |
188 } | 185 } |
189 return true; | 186 return true; |
190 } | 187 } |
191 | 188 |
192 } // namespace egl | 189 } // namespace egl |
OLD | NEW |