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/blink/webgraphicscontext3d_impl.h" | 5 #include "gpu/blink/webgraphicscontext3d_impl.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "gpu/GLES2/gl2extchromium.h" | 10 #include "gpu/GLES2/gl2extchromium.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/common/gles2_cmd_utils.h" | 13 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
14 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 14 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
15 | 15 |
16 #include "third_party/khronos/GLES2/gl2.h" | 16 #include "third_party/khronos/GLES2/gl2.h" |
17 #ifndef GL_GLEXT_PROTOTYPES | 17 #ifndef GL_GLEXT_PROTOTYPES |
18 #define GL_GLEXT_PROTOTYPES 1 | 18 #define GL_GLEXT_PROTOTYPES 1 |
19 #endif | 19 #endif |
20 #include "third_party/khronos/GLES2/gl2ext.h" | 20 #include "third_party/khronos/GLES2/gl2ext.h" |
21 | 21 |
| 22 using blink::WGC3Dbitfield; |
| 23 using blink::WGC3Dboolean; |
| 24 using blink::WGC3Dbyte; |
| 25 using blink::WGC3Dchar; |
| 26 using blink::WGC3Dclampf; |
| 27 using blink::WGC3Denum; |
| 28 using blink::WGC3Dfloat; |
| 29 using blink::WGC3Dint; |
| 30 using blink::WGC3Dintptr; |
| 31 using blink::WGC3Dsizei; |
| 32 using blink::WGC3Dsizeiptr; |
| 33 using blink::WGC3Duint64; |
| 34 using blink::WGC3Duint; |
| 35 using blink::WebGLId; |
| 36 |
22 namespace gpu_blink { | 37 namespace gpu_blink { |
23 | 38 |
24 namespace { | 39 namespace { |
25 | 40 |
26 uint32_t GenFlushID() { | 41 uint32_t GenFlushID() { |
27 static base::subtle::Atomic32 flush_id = 0; | 42 static base::subtle::Atomic32 flush_id = 0; |
28 | 43 |
29 base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( | 44 base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( |
30 &flush_id, 1); | 45 &flush_id, 1); |
31 return static_cast<uint32_t>(my_id); | 46 return static_cast<uint32_t>(my_id); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 WebGLId program, WGC3Duint index, ActiveInfo& info) { | 369 WebGLId program, WGC3Duint index, ActiveInfo& info) { |
355 if (!program) { | 370 if (!program) { |
356 synthesizeGLError(GL_INVALID_VALUE); | 371 synthesizeGLError(GL_INVALID_VALUE); |
357 return false; | 372 return false; |
358 } | 373 } |
359 GLint max_name_length = -1; | 374 GLint max_name_length = -1; |
360 gl_->GetProgramiv( | 375 gl_->GetProgramiv( |
361 program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); | 376 program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); |
362 if (max_name_length < 0) | 377 if (max_name_length < 0) |
363 return false; | 378 return false; |
364 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); | 379 if (max_name_length == 0) { |
365 if (!name) { | 380 // No active attributes exist. |
366 synthesizeGLError(GL_OUT_OF_MEMORY); | 381 synthesizeGLError(GL_INVALID_VALUE); |
367 return false; | 382 return false; |
368 } | 383 } |
| 384 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); |
369 GLsizei length = 0; | 385 GLsizei length = 0; |
370 GLint size = -1; | 386 GLint size = -1; |
371 GLenum type = 0; | 387 GLenum type = 0; |
372 gl_->GetActiveAttrib( | 388 gl_->GetActiveAttrib( |
373 program, index, max_name_length, &length, &size, &type, name.get()); | 389 program, index, max_name_length, &length, &size, &type, name.get()); |
374 if (size < 0) { | 390 if (size < 0) { |
375 return false; | 391 return false; |
376 } | 392 } |
377 info.name = blink::WebString::fromUTF8(name.get(), length); | 393 info.name = blink::WebString::fromUTF8(name.get(), length); |
378 info.type = type; | 394 info.type = type; |
379 info.size = size; | 395 info.size = size; |
380 return true; | 396 return true; |
381 } | 397 } |
382 | 398 |
383 bool WebGraphicsContext3DImpl::getActiveUniform( | 399 bool WebGraphicsContext3DImpl::getActiveUniform( |
384 WebGLId program, WGC3Duint index, ActiveInfo& info) { | 400 WebGLId program, WGC3Duint index, ActiveInfo& info) { |
385 GLint max_name_length = -1; | 401 GLint max_name_length = -1; |
386 gl_->GetProgramiv( | 402 gl_->GetProgramiv( |
387 program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length); | 403 program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length); |
388 if (max_name_length < 0) | 404 if (max_name_length < 0) |
389 return false; | 405 return false; |
390 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); | 406 if (max_name_length == 0) { |
391 if (!name) { | 407 // No active uniforms exist. |
392 synthesizeGLError(GL_OUT_OF_MEMORY); | 408 synthesizeGLError(GL_INVALID_VALUE); |
393 return false; | 409 return false; |
394 } | 410 } |
| 411 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); |
395 GLsizei length = 0; | 412 GLsizei length = 0; |
396 GLint size = -1; | 413 GLint size = -1; |
397 GLenum type = 0; | 414 GLenum type = 0; |
398 gl_->GetActiveUniform( | 415 gl_->GetActiveUniform( |
399 program, index, max_name_length, &length, &size, &type, name.get()); | 416 program, index, max_name_length, &length, &size, &type, name.get()); |
400 if (size < 0) { | 417 if (size < 0) { |
401 return false; | 418 return false; |
402 } | 419 } |
403 info.name = blink::WebString::fromUTF8(name.get(), length); | 420 info.name = blink::WebString::fromUTF8(name.get(), length); |
404 info.type = type; | 421 info.type = type; |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 output_attribs->samples = attributes.antialias ? 4 : 0; | 1229 output_attribs->samples = attributes.antialias ? 4 : 0; |
1213 output_attribs->sample_buffers = attributes.antialias ? 1 : 0; | 1230 output_attribs->sample_buffers = attributes.antialias ? 1 : 0; |
1214 output_attribs->fail_if_major_perf_caveat = | 1231 output_attribs->fail_if_major_perf_caveat = |
1215 attributes.failIfMajorPerformanceCaveat; | 1232 attributes.failIfMajorPerformanceCaveat; |
1216 output_attribs->bind_generates_resource = false; | 1233 output_attribs->bind_generates_resource = false; |
1217 output_attribs->es3_context_required = | 1234 output_attribs->es3_context_required = |
1218 (attributes.webGL && attributes.webGLVersion == 2); | 1235 (attributes.webGL && attributes.webGLVersion == 2); |
1219 } | 1236 } |
1220 | 1237 |
1221 } // namespace gpu_blink | 1238 } // namespace gpu_blink |
OLD | NEW |