| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 using blink::WGC3Dsizei; | 35 using blink::WGC3Dsizei; |
| 36 using blink::WGC3Dsizeiptr; | 36 using blink::WGC3Dsizeiptr; |
| 37 using blink::WGC3Dint64; | 37 using blink::WGC3Dint64; |
| 38 using blink::WGC3Duint64; | 38 using blink::WGC3Duint64; |
| 39 using blink::WGC3Duint; | 39 using blink::WGC3Duint; |
| 40 using blink::WebGLId; | 40 using blink::WebGLId; |
| 41 using blink::WGC3Dsync; | 41 using blink::WGC3Dsync; |
| 42 | 42 |
| 43 namespace gpu_blink { | 43 namespace gpu_blink { |
| 44 | 44 |
| 45 namespace { | |
| 46 | |
| 47 uint32_t GenFlushID() { | |
| 48 static base::subtle::Atomic32 flush_id = 0; | |
| 49 | |
| 50 base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( | |
| 51 &flush_id, 1); | |
| 52 return static_cast<uint32_t>(my_id); | |
| 53 } | |
| 54 | |
| 55 } // namespace anonymous | |
| 56 | |
| 57 class WebGraphicsContext3DErrorMessageCallback | 45 class WebGraphicsContext3DErrorMessageCallback |
| 58 : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback { | 46 : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback { |
| 59 public: | 47 public: |
| 60 WebGraphicsContext3DErrorMessageCallback( | 48 WebGraphicsContext3DErrorMessageCallback( |
| 61 WebGraphicsContext3DImpl* context) | 49 WebGraphicsContext3DImpl* context) |
| 62 : graphics_context_(context) { | 50 : graphics_context_(context) { |
| 63 } | 51 } |
| 64 | 52 |
| 65 void OnErrorMessage(const char* msg, int id) override; | 53 void OnErrorMessage(const char* msg, int id) override; |
| 66 | 54 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 t6 a6, t7 a7, t8 a8, t9 a9, t10 a10,\ | 179 t6 a6, t7 a7, t8 a8, t9 a9, t10 a10,\ |
| 192 t11 a11, t12 a12) { \ | 180 t11 a11, t12 a12) { \ |
| 193 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); \ | 181 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); \ |
| 194 } | 182 } |
| 195 | 183 |
| 196 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl() | 184 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl() |
| 197 : initialized_(false), | 185 : initialized_(false), |
| 198 initialize_failed_(false), | 186 initialize_failed_(false), |
| 199 context_lost_callback_(0), | 187 context_lost_callback_(0), |
| 200 error_message_callback_(0), | 188 error_message_callback_(0), |
| 201 gl_(NULL), | 189 gl_(NULL) {} |
| 202 flush_id_(0) { | |
| 203 } | |
| 204 | 190 |
| 205 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() { | 191 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() { |
| 206 | 192 |
| 207 } | 193 } |
| 208 | 194 |
| 209 void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error) { | 195 void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error) { |
| 210 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == | 196 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == |
| 211 synthetic_errors_.end()) { | 197 synthetic_errors_.end()) { |
| 212 synthetic_errors_.push_back(error); | 198 synthetic_errors_.push_back(error); |
| 213 } | 199 } |
| 214 } | 200 } |
| 215 | 201 |
| 216 uint32_t WebGraphicsContext3DImpl::lastFlushID() { | 202 DELEGATE_TO_GL_R(lastFlushID, GetLastFlushIdCHROMIUM, WebGLId) |
| 217 return flush_id_; | |
| 218 } | |
| 219 | 203 |
| 220 DELEGATE_TO_GL_R(insertFenceSyncCHROMIUM, InsertFenceSyncCHROMIUM, WGC3Duint64) | 204 DELEGATE_TO_GL_R(insertFenceSyncCHROMIUM, InsertFenceSyncCHROMIUM, WGC3Duint64) |
| 221 | 205 |
| 222 bool WebGraphicsContext3DImpl::genSyncTokenCHROMIUM(WGC3Duint64 fenceSync, | 206 bool WebGraphicsContext3DImpl::genSyncTokenCHROMIUM(WGC3Duint64 fenceSync, |
| 223 WGC3Dbyte* syncToken) { | 207 WGC3Dbyte* syncToken) { |
| 224 gl_->GenSyncTokenCHROMIUM(fenceSync, syncToken); | 208 gl_->GenSyncTokenCHROMIUM(fenceSync, syncToken); |
| 225 return true; | 209 return true; |
| 226 } | 210 } |
| 227 | 211 |
| 228 DELEGATE_TO_GL_1(waitSyncTokenCHROMIUM, WaitSyncTokenCHROMIUM, const WGC3Dbyte*) | 212 DELEGATE_TO_GL_1(waitSyncTokenCHROMIUM, WaitSyncTokenCHROMIUM, const WGC3Dbyte*) |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 gl_->DrawElements( | 331 gl_->DrawElements( |
| 348 mode, count, type, | 332 mode, count, type, |
| 349 reinterpret_cast<void*>(static_cast<intptr_t>(offset))); | 333 reinterpret_cast<void*>(static_cast<intptr_t>(offset))); |
| 350 } | 334 } |
| 351 | 335 |
| 352 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) | 336 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) |
| 353 | 337 |
| 354 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, | 338 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, |
| 355 WGC3Duint) | 339 WGC3Duint) |
| 356 | 340 |
| 357 void WebGraphicsContext3DImpl::finish() { | 341 DELEGATE_TO_GL(finish, Finish) |
| 358 flush_id_ = GenFlushID(); | 342 DELEGATE_TO_GL(flush, Flush) |
| 359 gl_->Finish(); | |
| 360 } | |
| 361 | |
| 362 void WebGraphicsContext3DImpl::flush() { | |
| 363 flush_id_ = GenFlushID(); | |
| 364 gl_->Flush(); | |
| 365 } | |
| 366 | 343 |
| 367 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer, | 344 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer, |
| 368 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId) | 345 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId) |
| 369 | 346 |
| 370 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D, | 347 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D, |
| 371 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint) | 348 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint) |
| 372 | 349 |
| 373 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum) | 350 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum) |
| 374 | 351 |
| 375 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum) | 352 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum) |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; | 1191 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; |
| 1215 break; | 1192 break; |
| 1216 default: | 1193 default: |
| 1217 NOTREACHED(); | 1194 NOTREACHED(); |
| 1218 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; | 1195 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; |
| 1219 break; | 1196 break; |
| 1220 } | 1197 } |
| 1221 } | 1198 } |
| 1222 | 1199 |
| 1223 } // namespace gpu_blink | 1200 } // namespace gpu_blink |
| OLD | NEW |