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

Side by Side Diff: content/renderer/webgraphicscontext3d_command_buffer_impl.cc

Issue 7056020: Make WebGraphics3DCommandBufferImpl use GLES2Implemenation directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months 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) 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "content/renderer/webgraphicscontext3d_command_buffer_impl.h" 7 #include "content/renderer/webgraphicscontext3d_command_buffer_impl.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #ifndef GL_GLEXT_PROTOTYPES 10 #ifndef GL_GLEXT_PROTOTYPES
11 #define GL_GLEXT_PROTOTYPES 1 11 #define GL_GLEXT_PROTOTYPES 1
12 #endif 12 #endif
13 #include <GLES2/gl2ext.h> 13 #include <GLES2/gl2ext.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 16
17 #include "base/string_tokenizer.h" 17 #include "base/string_tokenizer.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/debug/trace_event.h" 19 #include "base/debug/trace_event.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
22 #include "content/common/content_switches.h" 22 #include "content/common/content_switches.h"
23 #include "content/renderer/gpu_channel_host.h" 23 #include "content/renderer/gpu_channel_host.h"
24 #include "content/renderer/render_thread.h" 24 #include "content/renderer/render_thread.h"
25 #include "content/renderer/render_view.h" 25 #include "content/renderer/render_view.h"
26 #include "gpu/command_buffer/client/gles2_implementation.h"
26 #include "gpu/command_buffer/common/constants.h" 27 #include "gpu/command_buffer/common/constants.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
29 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" 30 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h"
30 31
32 #if defined(USE_REAL_GL_API)
33 #define CALL_GL_IMPL(name) gl##name
34 inline void WebGraphicsContext3DCommandBufferImpl::localMakeContextCurrent() {
35 makeContextCurrent();
36 }
37 #else
38 #define CALL_GL_IMPL(name) (gles2_implementation_->name)
39 inline void WebGraphicsContext3DCommandBufferImpl::localMakeContextCurrent() {
40 }
41 #endif
42
31 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() 43 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
32 : context_(NULL), 44 : context_(NULL),
45 gles2_implementation_(NULL),
33 web_view_(NULL), 46 web_view_(NULL),
34 #if defined(OS_MACOSX) 47 #if defined(OS_MACOSX)
35 plugin_handle_(NULL), 48 plugin_handle_(NULL),
36 #endif // defined(OS_MACOSX) 49 #endif // defined(OS_MACOSX)
37 context_lost_callback_(0), 50 context_lost_callback_(0),
38 cached_width_(0), 51 cached_width_(0),
39 cached_height_(0), 52 cached_height_(0),
40 bound_fbo_(0) { 53 bound_fbo_(0) {
41 } 54 }
42 55
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 parent_context, 150 parent_context,
138 gfx::Size(1, 1), 151 gfx::Size(1, 1),
139 kWebGraphicsContext3DPerferredGLExtensions, 152 kWebGraphicsContext3DPerferredGLExtensions,
140 attribs, 153 attribs,
141 active_url); 154 active_url);
142 web_view_ = NULL; 155 web_view_ = NULL;
143 } 156 }
144 if (!context_) 157 if (!context_)
145 return false; 158 return false;
146 159
160 gles2_implementation_ = context_->GetImplementation();
147 context_->SetContextLostCallback( 161 context_->SetContextLostCallback(
148 NewCallback(this, 162 NewCallback(this,
149 &WebGraphicsContext3DCommandBufferImpl::OnContextLost)); 163 &WebGraphicsContext3DCommandBufferImpl::OnContextLost));
150 164
151 // TODO(gman): Remove this. 165 // TODO(gman): Remove this.
152 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 166 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
153 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) { 167 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) {
154 context_->DisableShaderTranslation(); 168 context_->DisableShaderTranslation();
155 } 169 }
156 170
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 211
198 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { 212 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() {
199 // Copies the contents of the off-screen render target into the texture 213 // Copies the contents of the off-screen render target into the texture
200 // used by the compositor. 214 // used by the compositor.
201 context_->SwapBuffers(); 215 context_->SwapBuffers();
202 } 216 }
203 217
204 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { 218 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) {
205 cached_width_ = width; 219 cached_width_ = width;
206 cached_height_ = height; 220 cached_height_ = height;
207 makeContextCurrent(); 221 localMakeContextCurrent();
Ken Russell (switch to Gerrit) 2011/05/21 01:09:21 I thought the reason for this change was to make t
greggman 2011/05/21 01:22:49 You're right. I changed it to the simpler way.
208 222
209 if (web_view_) { 223 if (web_view_) {
210 #if defined(OS_MACOSX) 224 #if defined(OS_MACOSX)
211 context_->ResizeOnscreen(gfx::Size(width, height)); 225 context_->ResizeOnscreen(gfx::Size(width, height));
212 #else 226 #else
213 glResizeCHROMIUM(width, height); 227 CALL_GL_IMPL(ResizeCHROMIUM)(width, height);
214 #endif 228 #endif
215 } else { 229 } else {
216 context_->ResizeOffscreen(gfx::Size(width, height)); 230 context_->ResizeOffscreen(gfx::Size(width, height));
217 // Force a SwapBuffers to get the framebuffer to resize. 231 // Force a SwapBuffers to get the framebuffer to resize.
218 context_->SwapBuffers(); 232 context_->SwapBuffers();
219 } 233 }
220 234
221 #ifdef FLIP_FRAMEBUFFER_VERTICALLY 235 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
222 scanline_.reset(new uint8[width * 4]); 236 scanline_.reset(new uint8[width * 4]);
223 #endif // FLIP_FRAMEBUFFER_VERTICALLY 237 #endif // FLIP_FRAMEBUFFER_VERTICALLY
224 } 238 }
225 239
226 WebGLId WebGraphicsContext3DCommandBufferImpl::createCompositorTexture( 240 WebGLId WebGraphicsContext3DCommandBufferImpl::createCompositorTexture(
227 WGC3Dsizei width, WGC3Dsizei height) { 241 WGC3Dsizei width, WGC3Dsizei height) {
228 makeContextCurrent(); 242 localMakeContextCurrent();
229 return context_->CreateParentTexture(gfx::Size(width, height)); 243 return context_->CreateParentTexture(gfx::Size(width, height));
230 } 244 }
231 245
232 void WebGraphicsContext3DCommandBufferImpl::deleteCompositorTexture( 246 void WebGraphicsContext3DCommandBufferImpl::deleteCompositorTexture(
233 WebGLId parent_texture) { 247 WebGLId parent_texture) {
234 makeContextCurrent(); 248 localMakeContextCurrent();
235 context_->DeleteParentTexture(parent_texture); 249 context_->DeleteParentTexture(parent_texture);
236 } 250 }
237 251
238 #ifdef FLIP_FRAMEBUFFER_VERTICALLY 252 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
239 void WebGraphicsContext3DCommandBufferImpl::FlipVertically( 253 void WebGraphicsContext3DCommandBufferImpl::FlipVertically(
240 uint8* framebuffer, 254 uint8* framebuffer,
241 unsigned int width, 255 unsigned int width,
242 unsigned int height) { 256 unsigned int height) {
243 uint8* scanline = scanline_.get(); 257 uint8* scanline = scanline_.get();
244 if (!scanline) 258 if (!scanline)
(...skipping 14 matching lines...) Expand all
259 } 273 }
260 #endif 274 #endif
261 275
262 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer( 276 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer(
263 unsigned char* pixels, 277 unsigned char* pixels,
264 size_t buffer_size) { 278 size_t buffer_size) {
265 if (buffer_size != static_cast<size_t>(4 * width() * height())) { 279 if (buffer_size != static_cast<size_t>(4 * width() * height())) {
266 return false; 280 return false;
267 } 281 }
268 282
269 makeContextCurrent(); 283 localMakeContextCurrent();
270 284
271 // Earlier versions of this code used the GPU to flip the 285 // Earlier versions of this code used the GPU to flip the
272 // framebuffer vertically before reading it back for compositing 286 // framebuffer vertically before reading it back for compositing
273 // via software. This code was quite complicated, used a lot of 287 // via software. This code was quite complicated, used a lot of
274 // GPU memory, and didn't provide an obvious speedup. Since this 288 // GPU memory, and didn't provide an obvious speedup. Since this
275 // vertical flip is only a temporary solution anyway until Chrome 289 // vertical flip is only a temporary solution anyway until Chrome
276 // is fully GPU composited, it wasn't worth the complexity. 290 // is fully GPU composited, it wasn't worth the complexity.
277 291
278 bool mustRestoreFBO = (bound_fbo_ != 0); 292 bool mustRestoreFBO = (bound_fbo_ != 0);
279 if (mustRestoreFBO) { 293 if (mustRestoreFBO) {
280 glBindFramebuffer(GL_FRAMEBUFFER, 0); 294 CALL_GL_IMPL(BindFramebuffer)(GL_FRAMEBUFFER, 0);
281 } 295 }
282 glReadPixels(0, 0, cached_width_, cached_height_, 296 CALL_GL_IMPL(ReadPixels)(0, 0, cached_width_, cached_height_,
283 GL_RGBA, GL_UNSIGNED_BYTE, pixels); 297 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
284 298
285 // Swizzle red and blue channels 299 // Swizzle red and blue channels
286 // TODO(kbr): expose GL_BGRA as extension 300 // TODO(kbr): expose GL_BGRA as extension
287 for (size_t i = 0; i < buffer_size; i += 4) { 301 for (size_t i = 0; i < buffer_size; i += 4) {
288 std::swap(pixels[i], pixels[i + 2]); 302 std::swap(pixels[i], pixels[i + 2]);
289 } 303 }
290 304
291 if (mustRestoreFBO) { 305 if (mustRestoreFBO) {
292 glBindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); 306 CALL_GL_IMPL(BindFramebuffer)(GL_FRAMEBUFFER, bound_fbo_);
293 } 307 }
294 308
295 #ifdef FLIP_FRAMEBUFFER_VERTICALLY 309 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
296 if (pixels) { 310 if (pixels) {
297 FlipVertically(pixels, cached_width_, cached_height_); 311 FlipVertically(pixels, cached_width_, cached_height_);
298 } 312 }
299 #endif 313 #endif
300 314
301 return true; 315 return true;
302 } 316 }
303 317
304 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( 318 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError(
305 WGC3Denum error) { 319 WGC3Denum error) {
306 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == 320 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
307 synthetic_errors_.end()) { 321 synthetic_errors_.end()) {
308 synthetic_errors_.push_back(error); 322 synthetic_errors_.push_back(error);
309 } 323 }
310 } 324 }
311 325
312 void* WebGraphicsContext3DCommandBufferImpl::mapBufferSubDataCHROMIUM( 326 void* WebGraphicsContext3DCommandBufferImpl::mapBufferSubDataCHROMIUM(
313 WGC3Denum target, 327 WGC3Denum target,
314 WGC3Dintptr offset, 328 WGC3Dintptr offset,
315 WGC3Dsizeiptr size, 329 WGC3Dsizeiptr size,
316 WGC3Denum access) { 330 WGC3Denum access) {
317 makeContextCurrent(); 331 localMakeContextCurrent();
318 return glMapBufferSubDataCHROMIUM(target, offset, size, access); 332 return CALL_GL_IMPL(MapBufferSubDataCHROMIUM)(target, offset, size, access);
319 } 333 }
320 334
321 void WebGraphicsContext3DCommandBufferImpl::unmapBufferSubDataCHROMIUM( 335 void WebGraphicsContext3DCommandBufferImpl::unmapBufferSubDataCHROMIUM(
322 const void* mem) { 336 const void* mem) {
323 makeContextCurrent(); 337 localMakeContextCurrent();
324 return glUnmapBufferSubDataCHROMIUM(mem); 338 return CALL_GL_IMPL(UnmapBufferSubDataCHROMIUM)(mem);
325 } 339 }
326 340
327 void* WebGraphicsContext3DCommandBufferImpl::mapTexSubImage2DCHROMIUM( 341 void* WebGraphicsContext3DCommandBufferImpl::mapTexSubImage2DCHROMIUM(
328 WGC3Denum target, 342 WGC3Denum target,
329 WGC3Dint level, 343 WGC3Dint level,
330 WGC3Dint xoffset, 344 WGC3Dint xoffset,
331 WGC3Dint yoffset, 345 WGC3Dint yoffset,
332 WGC3Dsizei width, 346 WGC3Dsizei width,
333 WGC3Dsizei height, 347 WGC3Dsizei height,
334 WGC3Denum format, 348 WGC3Denum format,
335 WGC3Denum type, 349 WGC3Denum type,
336 WGC3Denum access) { 350 WGC3Denum access) {
337 return glMapTexSubImage2DCHROMIUM( 351 return CALL_GL_IMPL(MapTexSubImage2DCHROMIUM)(
338 target, level, xoffset, yoffset, width, height, format, type, access); 352 target, level, xoffset, yoffset, width, height, format, type, access);
339 } 353 }
340 354
341 void WebGraphicsContext3DCommandBufferImpl::unmapTexSubImage2DCHROMIUM( 355 void WebGraphicsContext3DCommandBufferImpl::unmapTexSubImage2DCHROMIUM(
342 const void* mem) { 356 const void* mem) {
343 makeContextCurrent(); 357 localMakeContextCurrent();
344 glUnmapTexSubImage2DCHROMIUM(mem); 358 CALL_GL_IMPL(UnmapTexSubImage2DCHROMIUM)(mem);
345 } 359 }
346 360
347 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( 361 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM(
348 WebGLId texture, WebGLId parentTexture) { 362 WebGLId texture, WebGLId parentTexture) {
349 copyTextureToCompositor(texture, parentTexture); 363 copyTextureToCompositor(texture, parentTexture);
350 } 364 }
351 365
352 void WebGraphicsContext3DCommandBufferImpl::getParentToChildLatchCHROMIUM( 366 void WebGraphicsContext3DCommandBufferImpl::getParentToChildLatchCHROMIUM(
353 WGC3Duint* latch_id) 367 WGC3Duint* latch_id)
354 { 368 {
(...skipping 10 matching lines...) Expand all
365 if (!context_->GetChildToParentLatch(latch_id)) { 379 if (!context_->GetChildToParentLatch(latch_id)) {
366 LOG(ERROR) << "getLatch must only be called on child context"; 380 LOG(ERROR) << "getLatch must only be called on child context";
367 synthesizeGLError(GL_INVALID_OPERATION); 381 synthesizeGLError(GL_INVALID_OPERATION);
368 *latch_id = gpu::kInvalidLatchId; 382 *latch_id = gpu::kInvalidLatchId;
369 } 383 }
370 } 384 }
371 385
372 void WebGraphicsContext3DCommandBufferImpl::waitLatchCHROMIUM( 386 void WebGraphicsContext3DCommandBufferImpl::waitLatchCHROMIUM(
373 WGC3Duint latch_id) 387 WGC3Duint latch_id)
374 { 388 {
375 makeContextCurrent(); 389 localMakeContextCurrent();
376 glWaitLatchCHROMIUM(latch_id); 390 CALL_GL_IMPL(WaitLatchCHROMIUM)(latch_id);
377 } 391 }
378 392
379 void WebGraphicsContext3DCommandBufferImpl::setLatchCHROMIUM( 393 void WebGraphicsContext3DCommandBufferImpl::setLatchCHROMIUM(
380 WGC3Duint latch_id) 394 WGC3Duint latch_id)
381 { 395 {
382 makeContextCurrent(); 396 localMakeContextCurrent();
383 glSetLatchCHROMIUM(latch_id); 397 CALL_GL_IMPL(SetLatchCHROMIUM)(latch_id);
384 glFlush(); // required to ensure set command is sent to GPU process 398 // required to ensure set command is sent to GPU process
399 CALL_GL_IMPL(Flush)();
385 } 400 }
386 401
387 void WebGraphicsContext3DCommandBufferImpl:: 402 void WebGraphicsContext3DCommandBufferImpl::
388 rateLimitOffscreenContextCHROMIUM() { 403 rateLimitOffscreenContextCHROMIUM() {
389 makeContextCurrent(); 404 localMakeContextCurrent();
390 glRateLimitOffscreenContextCHROMIUM(); 405 CALL_GL_IMPL(RateLimitOffscreenContextCHROMIUM)();
391 } 406 }
392 407
393 WebKit::WebString WebGraphicsContext3DCommandBufferImpl:: 408 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::
394 getRequestableExtensionsCHROMIUM() { 409 getRequestableExtensionsCHROMIUM() {
395 makeContextCurrent(); 410 localMakeContextCurrent();
396 return WebKit::WebString::fromUTF8(glGetRequestableExtensionsCHROMIUM()); 411 return WebKit::WebString::fromUTF8(
412 CALL_GL_IMPL(GetRequestableExtensionsCHROMIUM)());
397 } 413 }
398 414
399 void WebGraphicsContext3DCommandBufferImpl::requestExtensionCHROMIUM( 415 void WebGraphicsContext3DCommandBufferImpl::requestExtensionCHROMIUM(
400 const char* extension) { 416 const char* extension) {
401 makeContextCurrent(); 417 localMakeContextCurrent();
402 glRequestExtensionCHROMIUM(extension); 418 CALL_GL_IMPL(RequestExtensionCHROMIUM)(extension);
403 } 419 }
404 420
405 void WebGraphicsContext3DCommandBufferImpl::blitFramebufferCHROMIUM( 421 void WebGraphicsContext3DCommandBufferImpl::blitFramebufferCHROMIUM(
406 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, 422 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
407 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, 423 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
408 WGC3Dbitfield mask, WGC3Denum filter) { 424 WGC3Dbitfield mask, WGC3Denum filter) {
409 makeContextCurrent(); 425 localMakeContextCurrent();
410 glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, 426 CALL_GL_IMPL(BlitFramebufferEXT)(
411 dstX0, dstY0, dstX1, dstY1, 427 srcX0, srcY0, srcX1, srcY1,
412 mask, filter); 428 dstX0, dstY0, dstX1, dstY1,
429 mask, filter);
413 } 430 }
414 431
415 void WebGraphicsContext3DCommandBufferImpl:: 432 void WebGraphicsContext3DCommandBufferImpl::
416 renderbufferStorageMultisampleCHROMIUM( 433 renderbufferStorageMultisampleCHROMIUM(
417 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, 434 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
418 WGC3Dsizei width, WGC3Dsizei height) { 435 WGC3Dsizei width, WGC3Dsizei height) {
419 makeContextCurrent(); 436 localMakeContextCurrent();
420 glRenderbufferStorageMultisampleEXT(target, samples, internalformat, 437 CALL_GL_IMPL(RenderbufferStorageMultisampleEXT)(
421 width, height); 438 target, samples, internalformat, width, height);
422 } 439 }
423 440
424 // Helper macros to reduce the amount of code. 441 // Helper macros to reduce the amount of code.
425 442
426 #define DELEGATE_TO_GL(name, glname) \ 443 #define DELEGATE_TO_GL(name, glname) \
427 void WebGraphicsContext3DCommandBufferImpl::name() { \ 444 void WebGraphicsContext3DCommandBufferImpl::name() { \
428 makeContextCurrent(); \ 445 localMakeContextCurrent(); \
429 gl##glname(); \ 446 CALL_GL_IMPL(glname)(); \
430 } 447 }
431 448
432 #define DELEGATE_TO_GL_1(name, glname, t1) \ 449 #define DELEGATE_TO_GL_1(name, glname, t1) \
433 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ 450 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \
434 makeContextCurrent(); \ 451 localMakeContextCurrent(); \
435 gl##glname(a1); \ 452 CALL_GL_IMPL(glname)(a1); \
436 } 453 }
437 454
438 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \ 455 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
439 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ 456 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \
440 makeContextCurrent(); \ 457 localMakeContextCurrent(); \
441 return gl##glname(a1); \ 458 return CALL_GL_IMPL(glname)(a1); \
442 } 459 }
443 460
444 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \ 461 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
445 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \ 462 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \
446 makeContextCurrent(); \ 463 localMakeContextCurrent(); \
447 return gl##glname(a1) ? true : false; \ 464 return CALL_GL_IMPL(glname)(a1) ? true : false; \
448 } 465 }
449 466
450 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \ 467 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \
451 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \ 468 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \
452 makeContextCurrent(); \ 469 localMakeContextCurrent(); \
453 gl##glname(a1, a2); \ 470 CALL_GL_IMPL(glname)(a1, a2); \
454 } 471 }
455 472
456 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \ 473 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
457 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \ 474 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \
458 makeContextCurrent(); \ 475 localMakeContextCurrent(); \
459 return gl##glname(a1, a2); \ 476 return CALL_GL_IMPL(glname)(a1, a2); \
460 } 477 }
461 478
462 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \ 479 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
463 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3) { \ 480 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3) { \
464 makeContextCurrent(); \ 481 localMakeContextCurrent(); \
465 gl##glname(a1, a2, a3); \ 482 CALL_GL_IMPL(glname)(a1, a2, a3); \
466 } 483 }
467 484
468 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \ 485 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
469 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \ 486 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
470 makeContextCurrent(); \ 487 localMakeContextCurrent(); \
471 gl##glname(a1, a2, a3, a4); \ 488 CALL_GL_IMPL(glname)(a1, a2, a3, a4); \
472 } 489 }
473 490
474 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \ 491 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
475 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ 492 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
476 t4 a4, t5 a5) { \ 493 t4 a4, t5 a5) { \
477 makeContextCurrent(); \ 494 localMakeContextCurrent(); \
478 gl##glname(a1, a2, a3, a4, a5); \ 495 CALL_GL_IMPL(glname)(a1, a2, a3, a4, a5); \
479 } 496 }
480 497
481 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \ 498 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
482 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ 499 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
483 t4 a4, t5 a5, t6 a6) { \ 500 t4 a4, t5 a5, t6 a6) { \
484 makeContextCurrent(); \ 501 localMakeContextCurrent(); \
485 gl##glname(a1, a2, a3, a4, a5, a6); \ 502 CALL_GL_IMPL(glname)(a1, a2, a3, a4, a5, a6); \
486 } 503 }
487 504
488 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \ 505 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
489 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ 506 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
490 t4 a4, t5 a5, t6 a6, t7 a7) { \ 507 t4 a4, t5 a5, t6 a6, t7 a7) { \
491 makeContextCurrent(); \ 508 localMakeContextCurrent(); \
492 gl##glname(a1, a2, a3, a4, a5, a6, a7); \ 509 CALL_GL_IMPL(glname)(a1, a2, a3, a4, a5, a6, a7); \
493 } 510 }
494 511
495 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \ 512 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
496 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ 513 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
497 t4 a4, t5 a5, t6 a6, \ 514 t4 a4, t5 a5, t6 a6, \
498 t7 a7, t8 a8) { \ 515 t7 a7, t8 a8) { \
499 makeContextCurrent(); \ 516 localMakeContextCurrent(); \
500 gl##glname(a1, a2, a3, a4, a5, a6, a7, a8); \ 517 CALL_GL_IMPL(glname)(a1, a2, a3, a4, a5, a6, a7, a8); \
501 } 518 }
502 519
503 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ 520 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
504 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \ 521 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
505 t4 a4, t5 a5, t6 a6, \ 522 t4 a4, t5 a5, t6 a6, \
506 t7 a7, t8 a8, t9 a9) { \ 523 t7 a7, t8 a8, t9 a9) { \
507 makeContextCurrent(); \ 524 localMakeContextCurrent(); \
508 gl##glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ 525 CALL_GL_IMPL(glname)(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
509 } 526 }
510 527
511 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum) 528 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum)
512 529
513 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId) 530 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
514 531
515 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId, 532 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId,
516 WGC3Duint, const WGC3Dchar*) 533 WGC3Duint, const WGC3Dchar*)
517 534
518 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId) 535 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId)
519 536
520 void WebGraphicsContext3DCommandBufferImpl::bindFramebuffer( 537 void WebGraphicsContext3DCommandBufferImpl::bindFramebuffer(
521 WGC3Denum target, 538 WGC3Denum target,
522 WebGLId framebuffer) { 539 WebGLId framebuffer) {
523 makeContextCurrent(); 540 localMakeContextCurrent();
524 glBindFramebuffer(target, framebuffer); 541 CALL_GL_IMPL(BindFramebuffer)(target, framebuffer);
525 bound_fbo_ = framebuffer; 542 bound_fbo_ = framebuffer;
526 } 543 }
527 544
528 DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId) 545 DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId)
529 546
530 DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId) 547 DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId)
531 548
532 DELEGATE_TO_GL_4(blendColor, BlendColor, 549 DELEGATE_TO_GL_4(blendColor, BlendColor,
533 WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) 550 WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
534 551
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 604
588 DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray, 605 DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray,
589 WGC3Duint) 606 WGC3Duint)
590 607
591 DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei) 608 DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
592 609
593 void WebGraphicsContext3DCommandBufferImpl::drawElements(WGC3Denum mode, 610 void WebGraphicsContext3DCommandBufferImpl::drawElements(WGC3Denum mode,
594 WGC3Dsizei count, 611 WGC3Dsizei count,
595 WGC3Denum type, 612 WGC3Denum type,
596 WGC3Dintptr offset) { 613 WGC3Dintptr offset) {
597 makeContextCurrent(); 614 localMakeContextCurrent();
598 glDrawElements(mode, count, type, 615 CALL_GL_IMPL(DrawElements)(
599 reinterpret_cast<void*>(static_cast<intptr_t>(offset))); 616 mode, count, type,
617 reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
600 } 618 }
601 619
602 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) 620 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
603 621
604 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, 622 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray,
605 WGC3Duint) 623 WGC3Duint)
606 624
607 DELEGATE_TO_GL(finish, Finish) 625 DELEGATE_TO_GL(finish, Finish)
608 626
609 DELEGATE_TO_GL(flush, Flush) 627 DELEGATE_TO_GL(flush, Flush)
610 628
611 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer, 629 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer,
612 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId) 630 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
613 631
614 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D, 632 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D,
615 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint) 633 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
616 634
617 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum) 635 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
618 636
619 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum) 637 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum)
620 638
621 bool WebGraphicsContext3DCommandBufferImpl::getActiveAttrib( 639 bool WebGraphicsContext3DCommandBufferImpl::getActiveAttrib(
622 WebGLId program, WGC3Duint index, ActiveInfo& info) { 640 WebGLId program, WGC3Duint index, ActiveInfo& info) {
623 makeContextCurrent(); 641 localMakeContextCurrent();
624 if (!program) { 642 if (!program) {
625 synthesizeGLError(GL_INVALID_VALUE); 643 synthesizeGLError(GL_INVALID_VALUE);
626 return false; 644 return false;
627 } 645 }
628 GLint max_name_length = -1; 646 GLint max_name_length = -1;
629 glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); 647 CALL_GL_IMPL(GetProgramiv)(
648 program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
630 if (max_name_length < 0) 649 if (max_name_length < 0)
631 return false; 650 return false;
632 scoped_array<GLchar> name(new GLchar[max_name_length]); 651 scoped_array<GLchar> name(new GLchar[max_name_length]);
633 if (!name.get()) { 652 if (!name.get()) {
634 synthesizeGLError(GL_OUT_OF_MEMORY); 653 synthesizeGLError(GL_OUT_OF_MEMORY);
635 return false; 654 return false;
636 } 655 }
637 GLsizei length = 0; 656 GLsizei length = 0;
638 GLint size = -1; 657 GLint size = -1;
639 GLenum type = 0; 658 GLenum type = 0;
640 glGetActiveAttrib(program, index, max_name_length, 659 CALL_GL_IMPL(GetActiveAttrib)(
641 &length, &size, &type, name.get()); 660 program, index, max_name_length, &length, &size, &type, name.get());
642 if (size < 0) { 661 if (size < 0) {
643 return false; 662 return false;
644 } 663 }
645 info.name = WebKit::WebString::fromUTF8(name.get(), length); 664 info.name = WebKit::WebString::fromUTF8(name.get(), length);
646 info.type = type; 665 info.type = type;
647 info.size = size; 666 info.size = size;
648 return true; 667 return true;
649 } 668 }
650 669
651 bool WebGraphicsContext3DCommandBufferImpl::getActiveUniform( 670 bool WebGraphicsContext3DCommandBufferImpl::getActiveUniform(
652 WebGLId program, WGC3Duint index, ActiveInfo& info) { 671 WebGLId program, WGC3Duint index, ActiveInfo& info) {
653 makeContextCurrent(); 672 localMakeContextCurrent();
654 GLint max_name_length = -1; 673 GLint max_name_length = -1;
655 glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length); 674 CALL_GL_IMPL(GetProgramiv)(
675 program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
656 if (max_name_length < 0) 676 if (max_name_length < 0)
657 return false; 677 return false;
658 scoped_array<GLchar> name(new GLchar[max_name_length]); 678 scoped_array<GLchar> name(new GLchar[max_name_length]);
659 if (!name.get()) { 679 if (!name.get()) {
660 synthesizeGLError(GL_OUT_OF_MEMORY); 680 synthesizeGLError(GL_OUT_OF_MEMORY);
661 return false; 681 return false;
662 } 682 }
663 GLsizei length = 0; 683 GLsizei length = 0;
664 GLint size = -1; 684 GLint size = -1;
665 GLenum type = 0; 685 GLenum type = 0;
666 glGetActiveUniform(program, index, max_name_length, 686 CALL_GL_IMPL(GetActiveUniform)(
667 &length, &size, &type, name.get()); 687 program, index, max_name_length, &length, &size, &type, name.get());
668 if (size < 0) { 688 if (size < 0) {
669 return false; 689 return false;
670 } 690 }
671 info.name = WebKit::WebString::fromUTF8(name.get(), length); 691 info.name = WebKit::WebString::fromUTF8(name.get(), length);
672 info.type = type; 692 info.type = type;
673 info.size = size; 693 info.size = size;
674 return true; 694 return true;
675 } 695 }
676 696
677 DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders, 697 DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
(...skipping 13 matching lines...) Expand all
691 } 711 }
692 712
693 WGC3Denum WebGraphicsContext3DCommandBufferImpl::getError() { 713 WGC3Denum WebGraphicsContext3DCommandBufferImpl::getError() {
694 if (!synthetic_errors_.empty()) { 714 if (!synthetic_errors_.empty()) {
695 std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin(); 715 std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin();
696 WGC3Denum err = *iter; 716 WGC3Denum err = *iter;
697 synthetic_errors_.erase(iter); 717 synthetic_errors_.erase(iter);
698 return err; 718 return err;
699 } 719 }
700 720
701 makeContextCurrent(); 721 localMakeContextCurrent();
702 return glGetError(); 722 return CALL_GL_IMPL(GetError)();
703 } 723 }
704 724
705 bool WebGraphicsContext3DCommandBufferImpl::isContextLost() { 725 bool WebGraphicsContext3DCommandBufferImpl::isContextLost() {
706 return context_->IsCommandBufferContextLost(); 726 return context_->IsCommandBufferContextLost();
707 } 727 }
708 728
709 DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*) 729 DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
710 730
711 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv, 731 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv,
712 GetFramebufferAttachmentParameteriv, 732 GetFramebufferAttachmentParameteriv,
713 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*) 733 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*)
714 734
715 DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*) 735 DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*)
716 736
717 DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*) 737 DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
718 738
719 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getProgramInfoLog( 739 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getProgramInfoLog(
720 WebGLId program) { 740 WebGLId program) {
721 makeContextCurrent(); 741 localMakeContextCurrent();
722 GLint logLength = 0; 742 GLint logLength = 0;
723 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength); 743 CALL_GL_IMPL(GetProgramiv)(program, GL_INFO_LOG_LENGTH, &logLength);
724 if (!logLength) 744 if (!logLength)
725 return WebKit::WebString(); 745 return WebKit::WebString();
726 scoped_array<GLchar> log(new GLchar[logLength]); 746 scoped_array<GLchar> log(new GLchar[logLength]);
727 if (!log.get()) 747 if (!log.get())
728 return WebKit::WebString(); 748 return WebKit::WebString();
729 GLsizei returnedLogLength = 0; 749 GLsizei returnedLogLength = 0;
730 glGetProgramInfoLog(program, logLength, &returnedLogLength, log.get()); 750 CALL_GL_IMPL(GetProgramInfoLog)(
751 program, logLength, &returnedLogLength, log.get());
731 DCHECK_EQ(logLength, returnedLogLength + 1); 752 DCHECK_EQ(logLength, returnedLogLength + 1);
732 WebKit::WebString res = 753 WebKit::WebString res =
733 WebKit::WebString::fromUTF8(log.get(), returnedLogLength); 754 WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
734 return res; 755 return res;
735 } 756 }
736 757
737 DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv, 758 DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv,
738 WGC3Denum, WGC3Denum, WGC3Dint*) 759 WGC3Denum, WGC3Denum, WGC3Dint*)
739 760
740 DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*) 761 DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*)
741 762
742 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getShaderInfoLog( 763 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getShaderInfoLog(
743 WebGLId shader) { 764 WebGLId shader) {
744 makeContextCurrent(); 765 localMakeContextCurrent();
745 GLint logLength = 0; 766 GLint logLength = 0;
746 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); 767 CALL_GL_IMPL(GetShaderiv)(shader, GL_INFO_LOG_LENGTH, &logLength);
747 if (!logLength) 768 if (!logLength)
748 return WebKit::WebString(); 769 return WebKit::WebString();
749 scoped_array<GLchar> log(new GLchar[logLength]); 770 scoped_array<GLchar> log(new GLchar[logLength]);
750 if (!log.get()) 771 if (!log.get())
751 return WebKit::WebString(); 772 return WebKit::WebString();
752 GLsizei returnedLogLength = 0; 773 GLsizei returnedLogLength = 0;
753 glGetShaderInfoLog(shader, logLength, &returnedLogLength, log.get()); 774 CALL_GL_IMPL(GetShaderInfoLog)(
775 shader, logLength, &returnedLogLength, log.get());
754 DCHECK_EQ(logLength, returnedLogLength + 1); 776 DCHECK_EQ(logLength, returnedLogLength + 1);
755 WebKit::WebString res = 777 WebKit::WebString res =
756 WebKit::WebString::fromUTF8(log.get(), returnedLogLength); 778 WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
757 return res; 779 return res;
758 } 780 }
759 781
760 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getShaderSource( 782 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getShaderSource(
761 WebGLId shader) { 783 WebGLId shader) {
762 makeContextCurrent(); 784 localMakeContextCurrent();
763 GLint logLength = 0; 785 GLint logLength = 0;
764 glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength); 786 CALL_GL_IMPL(GetShaderiv)(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
765 if (!logLength) 787 if (!logLength)
766 return WebKit::WebString(); 788 return WebKit::WebString();
767 scoped_array<GLchar> log(new GLchar[logLength]); 789 scoped_array<GLchar> log(new GLchar[logLength]);
768 if (!log.get()) 790 if (!log.get())
769 return WebKit::WebString(); 791 return WebKit::WebString();
770 GLsizei returnedLogLength = 0; 792 GLsizei returnedLogLength = 0;
771 glGetShaderSource(shader, logLength, &returnedLogLength, log.get()); 793 CALL_GL_IMPL(GetShaderSource)(
794 shader, logLength, &returnedLogLength, log.get());
772 DCHECK_EQ(logLength, returnedLogLength + 1); 795 DCHECK_EQ(logLength, returnedLogLength + 1);
773 WebKit::WebString res = 796 WebKit::WebString res =
774 WebKit::WebString::fromUTF8(log.get(), returnedLogLength); 797 WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
775 return res; 798 return res;
776 } 799 }
777 800
778 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getString( 801 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getString(
779 WGC3Denum name) { 802 WGC3Denum name) {
780 makeContextCurrent(); 803 localMakeContextCurrent();
781 return WebKit::WebString::fromUTF8( 804 return WebKit::WebString::fromUTF8(
782 reinterpret_cast<const char*>(glGetString(name))); 805 reinterpret_cast<const char*>(CALL_GL_IMPL(GetString)(name)));
783 } 806 }
784 807
785 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv, 808 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
786 WGC3Denum, WGC3Denum, WGC3Dfloat*) 809 WGC3Denum, WGC3Denum, WGC3Dfloat*)
787 810
788 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv, 811 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
789 WGC3Denum, WGC3Denum, WGC3Dint*) 812 WGC3Denum, WGC3Denum, WGC3Dint*)
790 813
791 DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*) 814 DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
792 815
793 DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*) 816 DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
794 817
795 DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation, 818 DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
796 WebGLId, const WGC3Dchar*, WGC3Dint) 819 WebGLId, const WGC3Dchar*, WGC3Dint)
797 820
798 DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv, 821 DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
799 WGC3Duint, WGC3Denum, WGC3Dfloat*) 822 WGC3Duint, WGC3Denum, WGC3Dfloat*)
800 823
801 DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv, 824 DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
802 WGC3Duint, WGC3Denum, WGC3Dint*) 825 WGC3Duint, WGC3Denum, WGC3Dint*)
803 826
804 WGC3Dsizeiptr WebGraphicsContext3DCommandBufferImpl::getVertexAttribOffset( 827 WGC3Dsizeiptr WebGraphicsContext3DCommandBufferImpl::getVertexAttribOffset(
805 WGC3Duint index, WGC3Denum pname) { 828 WGC3Duint index, WGC3Denum pname) {
806 makeContextCurrent(); 829 localMakeContextCurrent();
807 GLvoid* value = NULL; 830 GLvoid* value = NULL;
808 // NOTE: If pname is ever a value that returns more then 1 element 831 // NOTE: If pname is ever a value that returns more then 1 element
809 // this will corrupt memory. 832 // this will corrupt memory.
810 glGetVertexAttribPointerv(index, pname, &value); 833 CALL_GL_IMPL(GetVertexAttribPointerv)(index, pname, &value);
811 return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value)); 834 return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value));
812 } 835 }
813 836
814 DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum) 837 DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
815 838
816 DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean) 839 DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
817 840
818 DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean) 841 DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
819 842
820 DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean) 843 DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean)
(...skipping 23 matching lines...) Expand all
844 867
845 DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage, 868 DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage,
846 WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei) 869 WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei)
847 870
848 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean) 871 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean)
849 872
850 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) 873 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
851 874
852 void WebGraphicsContext3DCommandBufferImpl::shaderSource( 875 void WebGraphicsContext3DCommandBufferImpl::shaderSource(
853 WebGLId shader, const WGC3Dchar* string) { 876 WebGLId shader, const WGC3Dchar* string) {
854 makeContextCurrent(); 877 localMakeContextCurrent();
855 GLint length = strlen(string); 878 GLint length = strlen(string);
856 glShaderSource(shader, 1, &string, &length); 879 CALL_GL_IMPL(ShaderSource)(shader, 1, &string, &length);
857 } 880 }
858 881
859 DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint) 882 DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
860 883
861 DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate, 884 DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
862 WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint) 885 WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
863 886
864 DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint) 887 DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
865 888
866 DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate, 889 DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
(...skipping 16 matching lines...) Expand all
883 906
884 void WebGraphicsContext3DCommandBufferImpl::texParameteri( 907 void WebGraphicsContext3DCommandBufferImpl::texParameteri(
885 WGC3Denum target, WGC3Denum pname, WGC3Dint param) { 908 WGC3Denum target, WGC3Denum pname, WGC3Dint param) {
886 // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in 909 // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
887 // GraphicsContext3D.cpp is strictly necessary to avoid seams at the 910 // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
888 // edge of cube maps, and, if it is, push it into the GLES2 service 911 // edge of cube maps, and, if it is, push it into the GLES2 service
889 // side code. 912 // side code.
890 if (pname == kTextureWrapR) { 913 if (pname == kTextureWrapR) {
891 return; 914 return;
892 } 915 }
893 makeContextCurrent(); 916 localMakeContextCurrent();
894 glTexParameteri(target, pname, param); 917 CALL_GL_IMPL(TexParameteri)(target, pname, param);
895 } 918 }
896 919
897 DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D, 920 DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
898 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, 921 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
899 WGC3Dsizei, WGC3Denum, WGC3Denum, const void*) 922 WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
900 923
901 DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat) 924 DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
902 925
903 DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei, 926 DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei,
904 const WGC3Dfloat*) 927 const WGC3Dfloat*)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 992
970 DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint, 993 DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint,
971 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) 994 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
972 995
973 DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint, 996 DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint,
974 const WGC3Dfloat*) 997 const WGC3Dfloat*)
975 998
976 void WebGraphicsContext3DCommandBufferImpl::vertexAttribPointer( 999 void WebGraphicsContext3DCommandBufferImpl::vertexAttribPointer(
977 WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized, 1000 WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
978 WGC3Dsizei stride, WGC3Dintptr offset) { 1001 WGC3Dsizei stride, WGC3Dintptr offset) {
979 makeContextCurrent(); 1002 localMakeContextCurrent();
980 1003
981 glVertexAttribPointer(index, size, type, normalized, stride, 1004 CALL_GL_IMPL(VertexAttribPointer)(
982 reinterpret_cast<void*>( 1005 index, size, type, normalized, stride,
983 static_cast<intptr_t>(offset))); 1006 reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
984 } 1007 }
985 1008
986 DELEGATE_TO_GL_4(viewport, Viewport, 1009 DELEGATE_TO_GL_4(viewport, Viewport,
987 WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) 1010 WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
988 1011
989 WebGLId WebGraphicsContext3DCommandBufferImpl::createBuffer() { 1012 WebGLId WebGraphicsContext3DCommandBufferImpl::createBuffer() {
990 makeContextCurrent(); 1013 localMakeContextCurrent();
991 GLuint o; 1014 GLuint o;
992 glGenBuffers(1, &o); 1015 CALL_GL_IMPL(GenBuffers)(1, &o);
993 return o; 1016 return o;
994 } 1017 }
995 1018
996 WebGLId WebGraphicsContext3DCommandBufferImpl::createFramebuffer() { 1019 WebGLId WebGraphicsContext3DCommandBufferImpl::createFramebuffer() {
997 makeContextCurrent(); 1020 localMakeContextCurrent();
998 GLuint o = 0; 1021 GLuint o = 0;
999 glGenFramebuffers(1, &o); 1022 CALL_GL_IMPL(GenFramebuffers)(1, &o);
1000 return o; 1023 return o;
1001 } 1024 }
1002 1025
1003 WebGLId WebGraphicsContext3DCommandBufferImpl::createProgram() { 1026 WebGLId WebGraphicsContext3DCommandBufferImpl::createProgram() {
1004 makeContextCurrent(); 1027 localMakeContextCurrent();
1005 return glCreateProgram(); 1028 return CALL_GL_IMPL(CreateProgram)();
1006 } 1029 }
1007 1030
1008 WebGLId WebGraphicsContext3DCommandBufferImpl::createRenderbuffer() { 1031 WebGLId WebGraphicsContext3DCommandBufferImpl::createRenderbuffer() {
1009 makeContextCurrent(); 1032 localMakeContextCurrent();
1010 GLuint o; 1033 GLuint o;
1011 glGenRenderbuffers(1, &o); 1034 CALL_GL_IMPL(GenRenderbuffers)(1, &o);
1012 return o; 1035 return o;
1013 } 1036 }
1014 1037
1015 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId); 1038 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId);
1016 1039
1017 WebGLId WebGraphicsContext3DCommandBufferImpl::createTexture() { 1040 WebGLId WebGraphicsContext3DCommandBufferImpl::createTexture() {
1018 makeContextCurrent(); 1041 localMakeContextCurrent();
1019 GLuint o; 1042 GLuint o;
1020 glGenTextures(1, &o); 1043 CALL_GL_IMPL(GenTextures)(1, &o);
1021 return o; 1044 return o;
1022 } 1045 }
1023 1046
1024 void WebGraphicsContext3DCommandBufferImpl::deleteBuffer(WebGLId buffer) { 1047 void WebGraphicsContext3DCommandBufferImpl::deleteBuffer(WebGLId buffer) {
1025 makeContextCurrent(); 1048 localMakeContextCurrent();
1026 glDeleteBuffers(1, &buffer); 1049 CALL_GL_IMPL(DeleteBuffers)(1, &buffer);
1027 } 1050 }
1028 1051
1029 void WebGraphicsContext3DCommandBufferImpl::deleteFramebuffer( 1052 void WebGraphicsContext3DCommandBufferImpl::deleteFramebuffer(
1030 WebGLId framebuffer) { 1053 WebGLId framebuffer) {
1031 makeContextCurrent(); 1054 localMakeContextCurrent();
1032 glDeleteFramebuffers(1, &framebuffer); 1055 CALL_GL_IMPL(DeleteFramebuffers)(1, &framebuffer);
1033 } 1056 }
1034 1057
1035 void WebGraphicsContext3DCommandBufferImpl::deleteProgram(WebGLId program) { 1058 void WebGraphicsContext3DCommandBufferImpl::deleteProgram(WebGLId program) {
1036 makeContextCurrent(); 1059 localMakeContextCurrent();
1037 glDeleteProgram(program); 1060 CALL_GL_IMPL(DeleteProgram)(program);
1038 } 1061 }
1039 1062
1040 void WebGraphicsContext3DCommandBufferImpl::deleteRenderbuffer( 1063 void WebGraphicsContext3DCommandBufferImpl::deleteRenderbuffer(
1041 WebGLId renderbuffer) { 1064 WebGLId renderbuffer) {
1042 makeContextCurrent(); 1065 localMakeContextCurrent();
1043 glDeleteRenderbuffers(1, &renderbuffer); 1066 CALL_GL_IMPL(DeleteRenderbuffers)(1, &renderbuffer);
1044 } 1067 }
1045 1068
1046 void WebGraphicsContext3DCommandBufferImpl::deleteShader(WebGLId shader) { 1069 void WebGraphicsContext3DCommandBufferImpl::deleteShader(WebGLId shader) {
1047 makeContextCurrent(); 1070 localMakeContextCurrent();
1048 glDeleteShader(shader); 1071 CALL_GL_IMPL(DeleteShader)(shader);
1049 } 1072 }
1050 1073
1051 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { 1074 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) {
1052 makeContextCurrent(); 1075 localMakeContextCurrent();
1053 glDeleteTextures(1, &texture); 1076 CALL_GL_IMPL(DeleteTextures)(1, &texture);
1054 } 1077 }
1055 1078
1056 void WebGraphicsContext3DCommandBufferImpl::copyTextureToCompositor( 1079 void WebGraphicsContext3DCommandBufferImpl::copyTextureToCompositor(
1057 WebGLId texture, WebGLId parentTexture) { 1080 WebGLId texture, WebGLId parentTexture) {
1058 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::copyTextureToCompositor"); 1081 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::copyTextureToCompositor");
1059 makeContextCurrent(); 1082 localMakeContextCurrent();
1060 glCopyTextureToParentTextureCHROMIUM(texture, parentTexture); 1083 CALL_GL_IMPL(CopyTextureToParentTextureCHROMIUM)(texture, parentTexture);
1061 glFlush(); 1084 CALL_GL_IMPL(Flush)();
1062 } 1085 }
1063 1086
1064 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { 1087 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() {
1065 // This may be called after tear-down of the RenderView. 1088 // This may be called after tear-down of the RenderView.
1066 RenderView* renderview = 1089 RenderView* renderview =
1067 web_view_ ? RenderView::FromWebView(web_view_) : NULL; 1090 web_view_ ? RenderView::FromWebView(web_view_) : NULL;
1068 if (renderview) 1091 if (renderview)
1069 renderview->OnViewContextSwapBuffersComplete(); 1092 renderview->OnViewContextSwapBuffersComplete();
1070 } 1093 }
1071 1094
1072 void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback( 1095 void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback(
1073 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) 1096 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb)
1074 { 1097 {
1075 context_lost_callback_ = cb; 1098 context_lost_callback_ = cb;
1076 } 1099 }
1077 1100
1078 void WebGraphicsContext3DCommandBufferImpl::OnContextLost() { 1101 void WebGraphicsContext3DCommandBufferImpl::OnContextLost() {
1079 if (context_lost_callback_) { 1102 if (context_lost_callback_) {
1080 context_lost_callback_->onContextLost(); 1103 context_lost_callback_->onContextLost();
1081 } 1104 }
1082 1105
1083 RenderView* renderview = 1106 RenderView* renderview =
1084 web_view_ ? RenderView::FromWebView(web_view_) : NULL; 1107 web_view_ ? RenderView::FromWebView(web_view_) : NULL;
1085 if (renderview) 1108 if (renderview)
1086 renderview->OnViewContextSwapBuffersAborted(); 1109 renderview->OnViewContextSwapBuffersAborted();
1087 } 1110 }
1088 1111
1089 #endif // defined(ENABLE_GPU) 1112 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698