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

Powered by Google App Engine
This is Rietveld 408576698