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

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

Powered by Google App Engine
This is Rietveld 408576698