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

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

Issue 6350016: Refactor WebGraphicsContext3D to use WGC3D types which match corresponding GL... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: This is the ugly but safe and correct way Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" 7 #include "chrome/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/logging.h" 19 #include "base/logging.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/renderer/gpu_channel_host.h" 22 #include "chrome/renderer/gpu_channel_host.h"
23 #include "chrome/renderer/render_thread.h" 23 #include "chrome/renderer/render_thread.h"
24 #include "chrome/renderer/render_view.h" 24 #include "chrome/renderer/render_view.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
26 26
27 #if defined(USE_WGC3D_TYPES)
28
27 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() 29 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
28 : context_(NULL), 30 : context_(NULL),
29 web_view_(NULL), 31 web_view_(NULL),
30 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
31 plugin_handle_(NULL), 33 plugin_handle_(NULL),
32 #endif // defined(OS_MACOSX) 34 #endif // defined(OS_MACOSX)
33 cached_width_(0), 35 cached_width_(0),
34 cached_height_(0), 36 cached_height_(0),
35 bound_fbo_(0) { 37 bound_fbo_(0) {
36 } 38 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 183 }
182 184
183 int WebGraphicsContext3DCommandBufferImpl::width() { 185 int WebGraphicsContext3DCommandBufferImpl::width() {
184 return cached_width_; 186 return cached_width_;
185 } 187 }
186 188
187 int WebGraphicsContext3DCommandBufferImpl::height() { 189 int WebGraphicsContext3DCommandBufferImpl::height() {
188 return cached_height_; 190 return cached_height_;
189 } 191 }
190 192
193 bool WebGraphicsContext3DCommandBufferImpl::isGLES2Compliant() {
194 return true;
195 }
196
197 WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() {
198 DCHECK(context_);
199 return ggl::GetParentTextureId(context_);
200 }
201
202 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() {
203 // Copies the contents of the off-screen render target into the texture
204 // used by the compositor.
205 ggl::SwapBuffers(context_);
206 }
207
208 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) {
209 cached_width_ = width;
210 cached_height_ = height;
211 makeContextCurrent();
212
213 if (web_view_) {
214 #if defined(OS_MACOSX)
215 ggl::ResizeOnscreenContext(context_, gfx::Size(width, height));
216 #else
217 glResizeCHROMIUM(width, height);
218 #endif
219 } else {
220 ggl::ResizeOffscreenContext(context_, gfx::Size(width, height));
221 // Force a SwapBuffers to get the framebuffer to resize.
222 ggl::SwapBuffers(context_);
223 }
224
225 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
226 scanline_.reset(new uint8[width * 4]);
227 #endif // FLIP_FRAMEBUFFER_VERTICALLY
228 }
229
230 WebGLId WebGraphicsContext3DCommandBufferImpl::createCompositorTexture(
231 WGC3Dsizei width, WGC3Dsizei height) {
232 makeContextCurrent();
233 return ggl::CreateParentTexture(context_, gfx::Size(width, height));
234 }
235
236 void WebGraphicsContext3DCommandBufferImpl::deleteCompositorTexture(
237 WebGLId parent_texture) {
238 makeContextCurrent();
239 ggl::DeleteParentTexture(context_, parent_texture);
240 }
241
242 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
243 void WebGraphicsContext3DCommandBufferImpl::FlipVertically(
244 uint8* framebuffer,
245 unsigned int width,
246 unsigned int height) {
247 uint8* scanline = scanline_.get();
248 if (!scanline)
249 return;
250 unsigned int row_bytes = width * 4;
251 unsigned int count = height / 2;
252 for (unsigned int i = 0; i < count; i++) {
253 uint8* row_a = framebuffer + i * row_bytes;
254 uint8* row_b = framebuffer + (height - i - 1) * row_bytes;
255 // TODO(kbr): this is where the multiplication of the alpha
256 // channel into the color buffer will need to occur if the
257 // user specifies the "premultiplyAlpha" flag in the context
258 // creation attributes.
259 memcpy(scanline, row_b, row_bytes);
260 memcpy(row_b, row_a, row_bytes);
261 memcpy(row_a, scanline, row_bytes);
262 }
263 }
264 #endif
265
266 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer(
267 unsigned char* pixels,
268 size_t buffer_size) {
269 if (buffer_size != static_cast<size_t>(4 * width() * height())) {
270 return false;
271 }
272
273 makeContextCurrent();
274
275 // Earlier versions of this code used the GPU to flip the
276 // framebuffer vertically before reading it back for compositing
277 // via software. This code was quite complicated, used a lot of
278 // GPU memory, and didn't provide an obvious speedup. Since this
279 // vertical flip is only a temporary solution anyway until Chrome
280 // is fully GPU composited, it wasn't worth the complexity.
281
282 bool mustRestoreFBO = (bound_fbo_ != 0);
283 if (mustRestoreFBO) {
284 glBindFramebuffer(GL_FRAMEBUFFER, 0);
285 }
286 glReadPixels(0, 0, cached_width_, cached_height_,
287 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
288
289 // Swizzle red and blue channels
290 // TODO(kbr): expose GL_BGRA as extension
291 for (size_t i = 0; i < buffer_size; i += 4) {
292 std::swap(pixels[i], pixels[i + 2]);
293 }
294
295 if (mustRestoreFBO) {
296 glBindFramebuffer(GL_FRAMEBUFFER, bound_fbo_);
297 }
298
299 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
300 if (pixels) {
301 FlipVertically(pixels, cached_width_, cached_height_);
302 }
303 #endif
304
305 return true;
306 }
307
308 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError(
309 WGC3Denum error) {
310 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
311 synthetic_errors_.end()) {
312 synthetic_errors_.push_back(error);
313 }
314 }
315
316 void* WebGraphicsContext3DCommandBufferImpl::mapBufferSubDataCHROMIUM(
317 WGC3Denum target,
318 WGC3Dintptr offset,
319 WGC3Dsizeiptr size,
320 WGC3Denum access) {
321 return glMapBufferSubDataCHROMIUM(target, offset, size, access);
322 }
323
324 void WebGraphicsContext3DCommandBufferImpl::unmapBufferSubDataCHROMIUM(
325 const void* mem) {
326 return glUnmapBufferSubDataCHROMIUM(mem);
327 }
328
329 void* WebGraphicsContext3DCommandBufferImpl::mapTexSubImage2DCHROMIUM(
330 WGC3Denum target,
331 WGC3Dint level,
332 WGC3Dint xoffset,
333 WGC3Dint yoffset,
334 WGC3Dsizei width,
335 WGC3Dsizei height,
336 WGC3Denum format,
337 WGC3Denum type,
338 WGC3Denum access) {
339 return glMapTexSubImage2DCHROMIUM(
340 target, level, xoffset, yoffset, width, height, format, type, access);
341 }
342
343 void WebGraphicsContext3DCommandBufferImpl::unmapTexSubImage2DCHROMIUM(
344 const void* mem) {
345 glUnmapTexSubImage2DCHROMIUM(mem);
346 }
347
348 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM(
349 WebGLId texture, WebGLId parentTexture) {
350 copyTextureToCompositor(texture, parentTexture);
351 }
352
353 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::
354 getRequestableExtensionsCHROMIUM() {
355 return WebKit::WebString::fromUTF8(glGetRequestableExtensionsCHROMIUM());
356 }
357
358 void WebGraphicsContext3DCommandBufferImpl::requestExtensionCHROMIUM(
359 const char* extension) {
360 glRequestExtensionCHROMIUM(extension);
361 }
362
363 // Helper macros to reduce the amount of code.
364
365 #define DELEGATE_TO_GL(name, glname) \
366 void WebGraphicsContext3DCommandBufferImpl::name() { \
367 makeContextCurrent(); \
368 gl##glname(); \
369 }
370
371 #define DELEGATE_TO_GL_1(name, glname, t1) \
372 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \
373 makeContextCurrent(); \
374 gl##glname(a1); \
375 }
376
377 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
378 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \
379 makeContextCurrent(); \
380 return gl##glname(a1); \
381 }
382
383 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
384 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1) { \
385 makeContextCurrent(); \
386 return gl##glname(a1) ? true : false; \
387 }
388
389 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \
390 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \
391 makeContextCurrent(); \
392 gl##glname(a1, a2); \
393 }
394
395 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
396 rt WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2) { \
397 makeContextCurrent(); \
398 return gl##glname(a1, a2); \
399 }
400
401 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
402 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3) { \
403 makeContextCurrent(); \
404 gl##glname(a1, a2, a3); \
405 }
406
407 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
408 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
409 makeContextCurrent(); \
410 gl##glname(a1, a2, a3, a4); \
411 }
412
413 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
414 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
415 t4 a4, t5 a5) { \
416 makeContextCurrent(); \
417 gl##glname(a1, a2, a3, a4, a5); \
418 }
419
420 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
421 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
422 t4 a4, t5 a5, t6 a6) { \
423 makeContextCurrent(); \
424 gl##glname(a1, a2, a3, a4, a5, a6); \
425 }
426
427 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
428 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
429 t4 a4, t5 a5, t6 a6, t7 a7) { \
430 makeContextCurrent(); \
431 gl##glname(a1, a2, a3, a4, a5, a6, a7); \
432 }
433
434 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
435 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
436 t4 a4, t5 a5, t6 a6, \
437 t7 a7, t8 a8) { \
438 makeContextCurrent(); \
439 gl##glname(a1, a2, a3, a4, a5, a6, a7, a8); \
440 }
441
442 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
443 void WebGraphicsContext3DCommandBufferImpl::name(t1 a1, t2 a2, t3 a3, \
444 t4 a4, t5 a5, t6 a6, \
445 t7 a7, t8 a8, t9 a9) { \
446 makeContextCurrent(); \
447 gl##glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
448 }
449
450 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum)
451
452 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
453
454 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId,
455 WGC3Duint, const WGC3Dchar*)
456
457 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId)
458
459 void WebGraphicsContext3DCommandBufferImpl::bindFramebuffer(
460 WGC3Denum target,
461 WebGLId framebuffer) {
462 makeContextCurrent();
463 glBindFramebuffer(target, framebuffer);
464 bound_fbo_ = framebuffer;
465 }
466
467 DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId)
468
469 DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId)
470
471 DELEGATE_TO_GL_4(blendColor, BlendColor,
472 WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
473
474 DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum)
475
476 DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate,
477 WGC3Denum, WGC3Denum)
478
479 DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum)
480
481 DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate,
482 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
483
484 DELEGATE_TO_GL_4(bufferData, BufferData,
485 WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum)
486
487 DELEGATE_TO_GL_4(bufferSubData, BufferSubData,
488 WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*)
489
490 DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus,
491 WGC3Denum, WGC3Denum)
492
493 DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield)
494
495 DELEGATE_TO_GL_4(clearColor, ClearColor,
496 WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
497
498 DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf)
499
500 DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint)
501
502 DELEGATE_TO_GL_4(colorMask, ColorMask,
503 WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean)
504
505 DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId)
506
507 DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D,
508 WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
509 WGC3Dsizei, WGC3Dsizei, WGC3Dint)
510
511 DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D,
512 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
513 WGC3Dsizei, WGC3Dsizei)
514
515 DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum)
516
517 DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum)
518
519 DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean)
520
521 DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf)
522
523 DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId)
524
525 DELEGATE_TO_GL_1(disable, Disable, WGC3Denum)
526
527 DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray,
528 WGC3Duint)
529
530 DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
531
532 void WebGraphicsContext3DCommandBufferImpl::drawElements(WGC3Denum mode,
533 WGC3Dsizei count,
534 WGC3Denum type,
535 WGC3Dintptr offset) {
536 makeContextCurrent();
537 glDrawElements(mode, count, type,
538 reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
539 }
540
541 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
542
543 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray,
544 WGC3Duint)
545
546 DELEGATE_TO_GL(finish, Finish)
547
548 DELEGATE_TO_GL(flush, Flush)
549
550 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer,
551 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
552
553 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D,
554 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
555
556 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
557
558 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum)
559
560 bool WebGraphicsContext3DCommandBufferImpl::getActiveAttrib(
561 WebGLId program, WGC3Duint index, ActiveInfo& info) {
562 makeContextCurrent();
563 if (!program) {
564 synthesizeGLError(GL_INVALID_VALUE);
565 return false;
566 }
567 GLint max_name_length = -1;
568 glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
569 if (max_name_length < 0)
570 return false;
571 scoped_array<GLchar> name(new GLchar[max_name_length]);
572 if (!name.get()) {
573 synthesizeGLError(GL_OUT_OF_MEMORY);
574 return false;
575 }
576 GLsizei length = 0;
577 GLint size = -1;
578 GLenum type = 0;
579 glGetActiveAttrib(program, index, max_name_length,
580 &length, &size, &type, name.get());
581 if (size < 0) {
582 return false;
583 }
584 info.name = WebKit::WebString::fromUTF8(name.get(), length);
585 info.type = type;
586 info.size = size;
587 return true;
588 }
589
590 bool WebGraphicsContext3DCommandBufferImpl::getActiveUniform(
591 WebGLId program, WGC3Duint index, ActiveInfo& info) {
592 makeContextCurrent();
593 GLint max_name_length = -1;
594 glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
595 if (max_name_length < 0)
596 return false;
597 scoped_array<GLchar> name(new GLchar[max_name_length]);
598 if (!name.get()) {
599 synthesizeGLError(GL_OUT_OF_MEMORY);
600 return false;
601 }
602 GLsizei length = 0;
603 GLint size = -1;
604 GLenum type = 0;
605 glGetActiveUniform(program, index, max_name_length,
606 &length, &size, &type, name.get());
607 if (size < 0) {
608 return false;
609 }
610 info.name = WebKit::WebString::fromUTF8(name.get(), length);
611 info.type = type;
612 info.size = size;
613 return true;
614 }
615
616 DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
617 WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*)
618
619 DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation,
620 WebGLId, const WGC3Dchar*, WGC3Dint)
621
622 DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*)
623
624 DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv,
625 WGC3Denum, WGC3Denum, WGC3Dint*)
626
627 WebKit::WebGraphicsContext3D::Attributes
628 WebGraphicsContext3DCommandBufferImpl::getContextAttributes() {
629 return attributes_;
630 }
631
632 WGC3Denum WebGraphicsContext3DCommandBufferImpl::getError() {
633 if (synthetic_errors_.size() > 0) {
634 std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin();
635 WGC3Denum err = *iter;
636 synthetic_errors_.erase(iter);
637 return err;
638 }
639
640 makeContextCurrent();
641 return glGetError();
642 }
643
644 bool WebGraphicsContext3DCommandBufferImpl::isContextLost() {
645 return ggl::IsCommandBufferContextLost(context_);
646 }
647
648 DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
649
650 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv,
651 GetFramebufferAttachmentParameteriv,
652 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*)
653
654 DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*)
655
656 DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
657
658 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getProgramInfoLog(
659 WebGLId program) {
660 makeContextCurrent();
661 GLint logLength = 0;
662 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
663 if (!logLength)
664 return WebKit::WebString();
665 scoped_array<GLchar> log(new GLchar[logLength]);
666 if (!log.get())
667 return WebKit::WebString();
668 GLsizei returnedLogLength = 0;
669 glGetProgramInfoLog(program, logLength, &returnedLogLength, log.get());
670 DCHECK_EQ(logLength, returnedLogLength + 1);
671 WebKit::WebString res =
672 WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
673 return res;
674 }
675
676 DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv,
677 WGC3Denum, WGC3Denum, WGC3Dint*)
678
679 DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*)
680
681 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getShaderInfoLog(
682 WebGLId shader) {
683 makeContextCurrent();
684 GLint logLength = 0;
685 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
686 if (!logLength)
687 return WebKit::WebString();
688 scoped_array<GLchar> log(new GLchar[logLength]);
689 if (!log.get())
690 return WebKit::WebString();
691 GLsizei returnedLogLength = 0;
692 glGetShaderInfoLog(shader, logLength, &returnedLogLength, log.get());
693 DCHECK_EQ(logLength, returnedLogLength + 1);
694 WebKit::WebString res =
695 WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
696 return res;
697 }
698
699 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getShaderSource(
700 WebGLId shader) {
701 makeContextCurrent();
702 GLint logLength = 0;
703 glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
704 if (!logLength)
705 return WebKit::WebString();
706 scoped_array<GLchar> log(new GLchar[logLength]);
707 if (!log.get())
708 return WebKit::WebString();
709 GLsizei returnedLogLength = 0;
710 glGetShaderSource(shader, logLength, &returnedLogLength, log.get());
711 DCHECK_EQ(logLength, returnedLogLength + 1);
712 WebKit::WebString res =
713 WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
714 return res;
715 }
716
717 WebKit::WebString WebGraphicsContext3DCommandBufferImpl::getString(
718 WGC3Denum name) {
719 makeContextCurrent();
720 return WebKit::WebString::fromUTF8(
721 reinterpret_cast<const char*>(glGetString(name)));
722 }
723
724 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
725 WGC3Denum, WGC3Denum, WGC3Dfloat*)
726
727 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
728 WGC3Denum, WGC3Denum, WGC3Dint*)
729
730 DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
731
732 DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
733
734 DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
735 WebGLId, const WGC3Dchar*, WGC3Dint)
736
737 DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
738 WGC3Duint, WGC3Denum, WGC3Dfloat*)
739
740 DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
741 WGC3Duint, WGC3Denum, WGC3Dint*)
742
743 WGC3Dsizeiptr WebGraphicsContext3DCommandBufferImpl::getVertexAttribOffset(
744 WGC3Duint index, WGC3Denum pname) {
745 makeContextCurrent();
746 GLvoid* value = NULL;
747 // NOTE: If pname is ever a value that returns more then 1 element
748 // this will corrupt memory.
749 glGetVertexAttribPointerv(index, pname, &value);
750 return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value));
751 }
752
753 DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
754
755 DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
756
757 DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
758
759 DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean)
760
761 DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean)
762
763 DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean)
764
765 DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean)
766
767 DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean)
768
769 DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat)
770
771 DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId)
772
773 DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint)
774
775 DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat)
776
777 DELEGATE_TO_GL_7(readPixels, ReadPixels,
778 WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum,
779 WGC3Denum, void*)
780
781 void WebGraphicsContext3DCommandBufferImpl::releaseShaderCompiler() {
782 }
783
784 DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage,
785 WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei)
786
787 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean)
788
789 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
790
791 void WebGraphicsContext3DCommandBufferImpl::shaderSource(
792 WebGLId shader, const WGC3Dchar* string) {
793 makeContextCurrent();
794 GLint length = strlen(string);
795 glShaderSource(shader, 1, &string, &length);
796 }
797
798 DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
799
800 DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
801 WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
802
803 DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
804
805 DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
806 WGC3Denum, WGC3Duint)
807
808 DELEGATE_TO_GL_3(stencilOp, StencilOp,
809 WGC3Denum, WGC3Denum, WGC3Denum)
810
811 DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate,
812 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
813
814 DELEGATE_TO_GL_9(texImage2D, TexImage2D,
815 WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei,
816 WGC3Dint, WGC3Denum, WGC3Denum, const void*)
817
818 DELEGATE_TO_GL_3(texParameterf, TexParameterf,
819 WGC3Denum, WGC3Denum, WGC3Dfloat);
820
821 static const unsigned int kTextureWrapR = 0x8072;
822
823 void WebGraphicsContext3DCommandBufferImpl::texParameteri(
824 WGC3Denum target, WGC3Denum pname, WGC3Dint param) {
825 // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
826 // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
827 // edge of cube maps, and, if it is, push it into the GLES2 service
828 // side code.
829 if (pname == kTextureWrapR) {
830 return;
831 }
832 makeContextCurrent();
833 glTexParameteri(target, pname, param);
834 }
835
836 DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
837 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
838 WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
839
840 DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
841
842 DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei,
843 const WGC3Dfloat*)
844
845 DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint)
846
847 DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
848
849 DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat)
850
851 DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei,
852 const WGC3Dfloat*)
853
854 DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint)
855
856 DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
857
858 DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint,
859 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
860
861 DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei,
862 const WGC3Dfloat*)
863
864 DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
865
866 DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
867
868 DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint,
869 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
870
871 DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei,
872 const WGC3Dfloat*)
873
874 DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint,
875 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
876
877 DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
878
879 DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv,
880 WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
881
882 DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv,
883 WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
884
885 DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv,
886 WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
887
888 DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId)
889
890 DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId)
891
892 DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat)
893
894 DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint,
895 const WGC3Dfloat*)
896
897 DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint,
898 WGC3Dfloat, WGC3Dfloat)
899
900 DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint,
901 const WGC3Dfloat*)
902
903 DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint,
904 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
905
906 DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint,
907 const WGC3Dfloat*)
908
909 DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint,
910 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
911
912 DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint,
913 const WGC3Dfloat*)
914
915 void WebGraphicsContext3DCommandBufferImpl::vertexAttribPointer(
916 WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
917 WGC3Dsizei stride, WGC3Dintptr offset) {
918 makeContextCurrent();
919
920 glVertexAttribPointer(index, size, type, normalized, stride,
921 reinterpret_cast<void*>(
922 static_cast<intptr_t>(offset)));
923 }
924
925 DELEGATE_TO_GL_4(viewport, Viewport,
926 WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
927
928 WebGLId WebGraphicsContext3DCommandBufferImpl::createBuffer() {
929 makeContextCurrent();
930 GLuint o;
931 glGenBuffers(1, &o);
932 return o;
933 }
934
935 WebGLId WebGraphicsContext3DCommandBufferImpl::createFramebuffer() {
936 makeContextCurrent();
937 GLuint o = 0;
938 glGenFramebuffers(1, &o);
939 return o;
940 }
941
942 WebGLId WebGraphicsContext3DCommandBufferImpl::createProgram() {
943 makeContextCurrent();
944 return glCreateProgram();
945 }
946
947 WebGLId WebGraphicsContext3DCommandBufferImpl::createRenderbuffer() {
948 makeContextCurrent();
949 GLuint o;
950 glGenRenderbuffers(1, &o);
951 return o;
952 }
953
954 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId);
955
956 WebGLId WebGraphicsContext3DCommandBufferImpl::createTexture() {
957 makeContextCurrent();
958 GLuint o;
959 glGenTextures(1, &o);
960 return o;
961 }
962
963 void WebGraphicsContext3DCommandBufferImpl::deleteBuffer(WebGLId buffer) {
964 makeContextCurrent();
965 glDeleteBuffers(1, &buffer);
966 }
967
968 void WebGraphicsContext3DCommandBufferImpl::deleteFramebuffer(
969 WebGLId framebuffer) {
970 makeContextCurrent();
971 glDeleteFramebuffers(1, &framebuffer);
972 }
973
974 void WebGraphicsContext3DCommandBufferImpl::deleteProgram(WebGLId program) {
975 makeContextCurrent();
976 glDeleteProgram(program);
977 }
978
979 void WebGraphicsContext3DCommandBufferImpl::deleteRenderbuffer(
980 WebGLId renderbuffer) {
981 makeContextCurrent();
982 glDeleteRenderbuffers(1, &renderbuffer);
983 }
984
985 void WebGraphicsContext3DCommandBufferImpl::deleteShader(WebGLId shader) {
986 makeContextCurrent();
987 glDeleteShader(shader);
988 }
989
990 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) {
991 makeContextCurrent();
992 glDeleteTextures(1, &texture);
993 }
994
995 void WebGraphicsContext3DCommandBufferImpl::copyTextureToCompositor(
996 WebGLId texture, WebGLId parentTexture) {
997 makeContextCurrent();
998 glCopyTextureToParentTextureCHROMIUM(texture, parentTexture);
999 glFlush();
1000 }
1001
1002 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffers() {
1003 // This may be called after tear-down of the RenderView.
1004 RenderView* renderview =
1005 web_view_ ? RenderView::FromWebView(web_view_) : NULL;
1006 if (renderview)
1007 renderview->DidFlushPaint();
1008 }
1009
1010 #else // USE_WGC3D_TYPES
1011
1012 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
1013 : context_(NULL),
1014 web_view_(NULL),
1015 #if defined(OS_MACOSX)
1016 plugin_handle_(NULL),
1017 #endif // defined(OS_MACOSX)
1018 cached_width_(0),
1019 cached_height_(0),
1020 bound_fbo_(0) {
1021 }
1022
1023 WebGraphicsContext3DCommandBufferImpl::
1024 ~WebGraphicsContext3DCommandBufferImpl() {
1025 #if defined(OS_MACOSX)
1026 if (web_view_) {
1027 DCHECK(plugin_handle_ != gfx::kNullPluginWindow);
1028 RenderView* renderview = RenderView::FromWebView(web_view_);
1029 // The RenderView might already have been freed, but in its
1030 // destructor it destroys all fake plugin window handles it
1031 // allocated.
1032 if (renderview) {
1033 renderview->DestroyFakePluginWindowHandle(plugin_handle_);
1034 }
1035 plugin_handle_ = gfx::kNullPluginWindow;
1036 }
1037 #endif
1038 if (context_) {
1039 ggl::DestroyContext(context_);
1040 }
1041 }
1042
1043 static const char* kWebGraphicsContext3DPerferredGLExtensions =
1044 "GL_OES_packed_depth_stencil "
1045 "GL_OES_depth24 "
1046 "GL_CHROMIUM_webglsl";
1047
1048 bool WebGraphicsContext3DCommandBufferImpl::initialize(
1049 WebGraphicsContext3D::Attributes attributes,
1050 WebKit::WebView* web_view,
1051 bool render_directly_to_web_view) {
1052 RenderThread* render_thread = RenderThread::current();
1053 if (!render_thread)
1054 return false;
1055 GpuChannelHost* host = render_thread->EstablishGpuChannelSync();
1056 if (!host)
1057 return false;
1058 DCHECK(host->state() == GpuChannelHost::kConnected);
1059
1060 // Convert WebGL context creation attributes into GGL/EGL size requests.
1061 const int alpha_size = attributes.alpha ? 8 : 0;
1062 const int depth_size = attributes.depth ? 24 : 0;
1063 const int stencil_size = attributes.stencil ? 8 : 0;
1064 const int samples = attributes.antialias ? 4 : 0;
1065 const int sample_buffers = attributes.antialias ? 1 : 0;
1066 const int32 attribs[] = {
1067 ggl::GGL_ALPHA_SIZE, alpha_size,
1068 ggl::GGL_DEPTH_SIZE, depth_size,
1069 ggl::GGL_STENCIL_SIZE, stencil_size,
1070 ggl::GGL_SAMPLES, samples,
1071 ggl::GGL_SAMPLE_BUFFERS, sample_buffers,
1072 ggl::GGL_NONE,
1073 };
1074
1075 GPUInfo gpu_info = host->gpu_info();
1076 UMA_HISTOGRAM_ENUMERATION(
1077 "GPU.WebGraphicsContext3D_Init_CanLoseContext",
1078 attributes.canRecoverFromContextLoss * 2 + gpu_info.can_lose_context(),
1079 4);
1080 if (attributes.canRecoverFromContextLoss == false) {
1081 if (gpu_info.can_lose_context())
1082 return false;
1083 }
1084
1085 if (render_directly_to_web_view) {
1086 RenderView* renderview = RenderView::FromWebView(web_view);
1087 if (!renderview)
1088 return false;
1089 gfx::NativeViewId view_id;
1090 #if !defined(OS_MACOSX)
1091 view_id = renderview->host_window();
1092 #else
1093 plugin_handle_ = renderview->AllocateFakePluginWindowHandle(
1094 /*opaque=*/true, /*root=*/true);
1095 view_id = static_cast<gfx::NativeViewId>(plugin_handle_);
1096 #endif
1097 web_view_ = web_view;
1098 context_ = ggl::CreateViewContext(
1099 host,
1100 view_id,
1101 renderview->routing_id(),
1102 kWebGraphicsContext3DPerferredGLExtensions,
1103 attribs);
1104 if (context_) {
1105 ggl::SetSwapBuffersCallback(
1106 context_,
1107 NewCallback(this,
1108 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffers));
1109 }
1110 } else {
1111 bool compositing_enabled = !CommandLine::ForCurrentProcess()->HasSwitch(
1112 switches::kDisableAcceleratedCompositing);
1113 ggl::Context* parent_context = NULL;
1114 // If GPU compositing is enabled we need to create a GL context that shares
1115 // resources with the compositor's context.
1116 if (compositing_enabled) {
1117 // Asking for the WebGraphicsContext3D on the WebView will force one to
1118 // be created if it doesn't already exist. When the compositor is created
1119 // for the view it will use the same context.
1120 WebKit::WebGraphicsContext3D* view_context =
1121 web_view->graphicsContext3D();
1122 if (view_context) {
1123 WebGraphicsContext3DCommandBufferImpl* context_impl =
1124 static_cast<WebGraphicsContext3DCommandBufferImpl*>(view_context);
1125 parent_context = context_impl->context_;
1126 }
1127 }
1128 context_ = ggl::CreateOffscreenContext(
1129 host,
1130 parent_context,
1131 gfx::Size(1, 1),
1132 kWebGraphicsContext3DPerferredGLExtensions,
1133 attribs);
1134 web_view_ = NULL;
1135 }
1136 if (!context_)
1137 return false;
1138 // TODO(gman): Remove this.
1139 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1140 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) {
1141 DisableShaderTranslation(context_);
1142 }
1143
1144 // Set attributes_ from created offscreen context.
1145 {
1146 attributes_ = attributes;
1147 GLint alpha_bits = 0;
1148 getIntegerv(GL_ALPHA_BITS, &alpha_bits);
1149 attributes_.alpha = alpha_bits > 0;
1150 GLint depth_bits = 0;
1151 getIntegerv(GL_DEPTH_BITS, &depth_bits);
1152 attributes_.depth = depth_bits > 0;
1153 GLint stencil_bits = 0;
1154 getIntegerv(GL_STENCIL_BITS, &stencil_bits);
1155 attributes_.stencil = stencil_bits > 0;
1156 GLint samples = 0;
1157 getIntegerv(GL_SAMPLES, &samples);
1158 attributes_.antialias = samples > 0;
1159 }
1160
1161 return true;
1162 }
1163
1164 bool WebGraphicsContext3DCommandBufferImpl::makeContextCurrent() {
1165 return ggl::MakeCurrent(context_);
1166 }
1167
1168 int WebGraphicsContext3DCommandBufferImpl::width() {
1169 return cached_width_;
1170 }
1171
1172 int WebGraphicsContext3DCommandBufferImpl::height() {
1173 return cached_height_;
1174 }
1175
191 int WebGraphicsContext3DCommandBufferImpl::sizeInBytes(int type) { 1176 int WebGraphicsContext3DCommandBufferImpl::sizeInBytes(int type) {
192 switch (type) { 1177 switch (type) {
193 case GL_BYTE: 1178 case GL_BYTE:
194 return sizeof(GLbyte); 1179 return sizeof(GLbyte);
195 case GL_UNSIGNED_BYTE: 1180 case GL_UNSIGNED_BYTE:
196 return sizeof(GLubyte); 1181 return sizeof(GLubyte);
197 case GL_SHORT: 1182 case GL_SHORT:
198 return sizeof(GLshort); 1183 return sizeof(GLshort);
199 case GL_UNSIGNED_SHORT: 1184 case GL_UNSIGNED_SHORT:
200 return sizeof(GLushort); 1185 return sizeof(GLushort);
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 } 2020 }
1036 2021
1037 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffers() { 2022 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffers() {
1038 // This may be called after tear-down of the RenderView. 2023 // This may be called after tear-down of the RenderView.
1039 RenderView* renderview = 2024 RenderView* renderview =
1040 web_view_ ? RenderView::FromWebView(web_view_) : NULL; 2025 web_view_ ? RenderView::FromWebView(web_view_) : NULL;
1041 if (renderview) 2026 if (renderview)
1042 renderview->DidFlushPaint(); 2027 renderview->DidFlushPaint();
1043 } 2028 }
1044 2029
2030 #endif // USE_WGC3D_TYPES
2031
1045 #endif // defined(ENABLE_GPU) 2032 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698