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/client/gl_in_process_context.h" | 5 #include "gpu/command_buffer/client/gl_in_process_context.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const int32 GREEN_SIZE = 0x3023; | 140 const int32 GREEN_SIZE = 0x3023; |
141 const int32 RED_SIZE = 0x3024; | 141 const int32 RED_SIZE = 0x3024; |
142 const int32 DEPTH_SIZE = 0x3025; | 142 const int32 DEPTH_SIZE = 0x3025; |
143 const int32 STENCIL_SIZE = 0x3026; | 143 const int32 STENCIL_SIZE = 0x3026; |
144 const int32 SAMPLES = 0x3031; | 144 const int32 SAMPLES = 0x3031; |
145 const int32 SAMPLE_BUFFERS = 0x3032; | 145 const int32 SAMPLE_BUFFERS = 0x3032; |
146 const int32 NONE = 0x3038; | 146 const int32 NONE = 0x3038; |
147 | 147 |
148 // Chromium-specific attributes | 148 // Chromium-specific attributes |
149 const int32 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002; | 149 const int32 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002; |
| 150 const int32 LOSE_CONTEXT_WHEN_OUT_OF_MEMORY = 0x10003; |
150 | 151 |
151 std::vector<int32> attrib_vector; | 152 std::vector<int32> attrib_vector; |
152 if (attribs.alpha_size >= 0) { | 153 if (attribs.alpha_size >= 0) { |
153 attrib_vector.push_back(ALPHA_SIZE); | 154 attrib_vector.push_back(ALPHA_SIZE); |
154 attrib_vector.push_back(attribs.alpha_size); | 155 attrib_vector.push_back(attribs.alpha_size); |
155 } | 156 } |
156 if (attribs.blue_size >= 0) { | 157 if (attribs.blue_size >= 0) { |
157 attrib_vector.push_back(BLUE_SIZE); | 158 attrib_vector.push_back(BLUE_SIZE); |
158 attrib_vector.push_back(attribs.blue_size); | 159 attrib_vector.push_back(attribs.blue_size); |
159 } | 160 } |
(...skipping 18 matching lines...) Expand all Loading... |
178 attrib_vector.push_back(attribs.samples); | 179 attrib_vector.push_back(attribs.samples); |
179 } | 180 } |
180 if (attribs.sample_buffers >= 0) { | 181 if (attribs.sample_buffers >= 0) { |
181 attrib_vector.push_back(SAMPLE_BUFFERS); | 182 attrib_vector.push_back(SAMPLE_BUFFERS); |
182 attrib_vector.push_back(attribs.sample_buffers); | 183 attrib_vector.push_back(attribs.sample_buffers); |
183 } | 184 } |
184 if (attribs.fail_if_major_perf_caveat > 0) { | 185 if (attribs.fail_if_major_perf_caveat > 0) { |
185 attrib_vector.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); | 186 attrib_vector.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); |
186 attrib_vector.push_back(attribs.fail_if_major_perf_caveat); | 187 attrib_vector.push_back(attribs.fail_if_major_perf_caveat); |
187 } | 188 } |
| 189 if (attribs.lose_context_when_out_of_memory > 0) { |
| 190 attrib_vector.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY); |
| 191 attrib_vector.push_back(attribs.lose_context_when_out_of_memory); |
| 192 } |
188 attrib_vector.push_back(NONE); | 193 attrib_vector.push_back(NONE); |
189 | 194 |
190 base::Closure wrapped_callback = | 195 base::Closure wrapped_callback = |
191 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); | 196 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); |
192 command_buffer_.reset(new InProcessCommandBuffer(service)); | 197 command_buffer_.reset(new InProcessCommandBuffer(service)); |
193 | 198 |
194 scoped_ptr<base::AutoLock> scoped_shared_context_lock; | 199 scoped_ptr<base::AutoLock> scoped_shared_context_lock; |
195 scoped_refptr<gles2::ShareGroup> share_group; | 200 scoped_refptr<gles2::ShareGroup> share_group; |
196 InProcessCommandBuffer* share_command_buffer = NULL; | 201 InProcessCommandBuffer* share_command_buffer = NULL; |
197 if (use_global_share_group) { | 202 if (use_global_share_group) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); | 248 transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); |
244 | 249 |
245 bool bind_generates_resources = false; | 250 bool bind_generates_resources = false; |
246 | 251 |
247 // Create the object exposing the OpenGL API. | 252 // Create the object exposing the OpenGL API. |
248 gles2_implementation_.reset(new gles2::GLES2Implementation( | 253 gles2_implementation_.reset(new gles2::GLES2Implementation( |
249 gles2_helper_.get(), | 254 gles2_helper_.get(), |
250 share_group, | 255 share_group, |
251 transfer_buffer_.get(), | 256 transfer_buffer_.get(), |
252 bind_generates_resources, | 257 bind_generates_resources, |
| 258 attribs.lose_context_when_out_of_memory > 0, |
253 command_buffer_.get())); | 259 command_buffer_.get())); |
254 | 260 |
255 if (use_global_share_group) { | 261 if (use_global_share_group) { |
256 g_all_shared_contexts.Get().insert(this); | 262 g_all_shared_contexts.Get().insert(this); |
257 scoped_shared_context_lock.reset(); | 263 scoped_shared_context_lock.reset(); |
258 } | 264 } |
259 | 265 |
260 if (!gles2_implementation_->Initialize( | 266 if (!gles2_implementation_->Initialize( |
261 kStartTransferBufferSize, | 267 kStartTransferBufferSize, |
262 kMinTransferBufferSize, | 268 kMinTransferBufferSize, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } // anonymous namespace | 301 } // anonymous namespace |
296 | 302 |
297 GLInProcessContextAttribs::GLInProcessContextAttribs() | 303 GLInProcessContextAttribs::GLInProcessContextAttribs() |
298 : alpha_size(-1), | 304 : alpha_size(-1), |
299 blue_size(-1), | 305 blue_size(-1), |
300 green_size(-1), | 306 green_size(-1), |
301 red_size(-1), | 307 red_size(-1), |
302 depth_size(-1), | 308 depth_size(-1), |
303 stencil_size(-1), | 309 stencil_size(-1), |
304 samples(-1), | 310 samples(-1), |
305 sample_buffers(-1) {} | 311 sample_buffers(-1), |
| 312 fail_if_major_perf_caveat(-1), |
| 313 lose_context_when_out_of_memory(-1) {} |
306 | 314 |
307 // static | 315 // static |
308 GLInProcessContext* GLInProcessContext::CreateContext( | 316 GLInProcessContext* GLInProcessContext::CreateContext( |
309 bool is_offscreen, | 317 bool is_offscreen, |
310 gfx::AcceleratedWidget window, | 318 gfx::AcceleratedWidget window, |
311 const gfx::Size& size, | 319 const gfx::Size& size, |
312 bool share_resources, | 320 bool share_resources, |
313 const GLInProcessContextAttribs& attribs, | 321 const GLInProcessContextAttribs& attribs, |
314 gfx::GpuPreference gpu_preference) { | 322 gfx::GpuPreference gpu_preference) { |
315 scoped_ptr<GLInProcessContextImpl> context( | 323 scoped_ptr<GLInProcessContextImpl> context( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 surface->GetSize(), | 355 surface->GetSize(), |
348 attribs, | 356 attribs, |
349 gpu_preference, | 357 gpu_preference, |
350 service)) | 358 service)) |
351 return NULL; | 359 return NULL; |
352 | 360 |
353 return context.release(); | 361 return context.release(); |
354 } | 362 } |
355 | 363 |
356 } // namespace gpu | 364 } // namespace gpu |
OLD | NEW |