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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1435183002: WebGL 2: fix the bug in invalidate-framebuffer.html (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/webgl/WebGL2RenderingContextBase.h" 6 #include "modules/webgl/WebGL2RenderingContextBase.h"
7 7
8 #include "bindings/modules/v8/WebGLAny.h" 8 #include "bindings/modules/v8/WebGLAny.h"
9 #include "core/html/HTMLCanvasElement.h" 9 #include "core/html/HTMLCanvasElement.h"
10 #include "core/html/HTMLImageElement.h" 10 #include "core/html/HTMLImageElement.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 values[ii] = 0; 364 values[ii] = 0;
365 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES , length, values.get()); 365 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES , length, values.get());
366 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len gth)); 366 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len gth));
367 } 367 }
368 default: 368 default:
369 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d parameter name"); 369 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d parameter name");
370 return ScriptValue::createNull(scriptState); 370 return ScriptValue::createNull(scriptState);
371 } 371 }
372 } 372 }
373 373
374 void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, Vector<GLe num>& attachments) 374 bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functi onName, GLenum target, const Vector<GLenum>& attachments, Vector<GLenum>& transl atedAttachments)
375 {
376 GLsizei size = attachments.size();
377 translatedAttachments.resize(size);
378
379 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
380 ASSERT(framebufferBinding || drawingBuffer());
381 if (!framebufferBinding) {
382 // For the default framebuffer
383 // Translate GL_COLOR/GL_DEPTH/GL_STENCIL, because the default framebuff er of WebGL is not fb 0, it is an internal fbo
384 for (GLsizei i = 0; i < size; ++i) {
385 switch (attachments[i]) {
386 case GL_COLOR:
387 translatedAttachments[i] = GL_COLOR_ATTACHMENT0;
388 break;
389 case GL_DEPTH:
390 translatedAttachments[i] = GL_DEPTH_ATTACHMENT;
391 break;
392 case GL_STENCIL:
393 translatedAttachments[i] = GL_STENCIL_ATTACHMENT;
394 break;
395 default:
396 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attach ment");
397 return false;
398 }
399 }
400 } else {
401 // For the FBO
402 for (GLsizei i = 0; i < size; ++i) {
403 switch (attachments[i]) {
404 case GL_COLOR_ATTACHMENT0:
405 case GL_DEPTH_ATTACHMENT:
406 case GL_STENCIL_ATTACHMENT:
407 case GL_DEPTH_STENCIL_ATTACHMENT:
408 translatedAttachments[i] = attachments[i];
409 break;
410 default:
411 if (attachments[i] > GL_COLOR_ATTACHMENT0
412 && attachments[i] < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxColorAttachments())) {
413 translatedAttachments[i] = attachments[i];
414 break;
415 }
416 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid a ttachment");
417 return false;
418 }
419 }
420 }
421 return true;
422 }
423
424 void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, const Vect or<GLenum>& attachments)
375 { 425 {
376 if (isContextLost()) 426 if (isContextLost())
377 return; 427 return;
378 428
379 webContext()->invalidateFramebuffer(target, attachments.size(), attachments. data()); 429 if (!validateFramebufferTarget(target)) {
430 synthesizeGLError(GL_INVALID_ENUM, "invalidateFramebuffer", "invalid tar get");
431 return;
432 }
433
434 Vector<GLenum> translatedAttachments;
435 if (!checkAndTranslateAttachments("invalidateFramebuffer", target, attachmen ts, translatedAttachments))
436 return;
437
438 webContext()->invalidateFramebuffer(target, translatedAttachments.size(), tr anslatedAttachments.data());
380 } 439 }
381 440
382 void WebGL2RenderingContextBase::invalidateSubFramebuffer(GLenum target, Vector< GLenum>& attachments, GLint x, GLint y, GLsizei width, GLsizei height) 441 void WebGL2RenderingContextBase::invalidateSubFramebuffer(GLenum target, const V ector<GLenum>& attachments, GLint x, GLint y, GLsizei width, GLsizei height)
383 { 442 {
384 if (isContextLost()) 443 if (isContextLost())
385 return; 444 return;
386 445
387 webContext()->invalidateSubFramebuffer(target, attachments.size(), attachmen ts.data(), x, y, width, height); 446 if (!validateFramebufferTarget(target)) {
447 synthesizeGLError(GL_INVALID_ENUM, "invalidateFramebuffer", "invalid tar get");
448 return;
449 }
450
451 if (width < 0 || height < 0) {
452 synthesizeGLError(GL_INVALID_VALUE, "invalidateSubFramebuffer", "invalid width or height");
453 return;
454 }
455
456 Vector<GLenum> translatedAttachments;
457 if (!checkAndTranslateAttachments("invalidateSubFramebuffer", target, attach ments, translatedAttachments))
458 return;
459
460 webContext()->invalidateSubFramebuffer(target, translatedAttachments.size(), translatedAttachments.data(), x, y, width, height);
388 } 461 }
389 462
390 void WebGL2RenderingContextBase::readBuffer(GLenum mode) 463 void WebGL2RenderingContextBase::readBuffer(GLenum mode)
391 { 464 {
392 if (isContextLost()) 465 if (isContextLost())
393 return; 466 return;
394 467
395 switch (mode) { 468 switch (mode) {
396 case GL_BACK: 469 case GL_BACK:
397 case GL_NONE: 470 case GL_NONE:
(...skipping 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 3151 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
3079 { 3152 {
3080 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 3153 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
3081 return m_readFramebufferBinding->colorBufferFormat(); 3154 return m_readFramebufferBinding->colorBufferFormat();
3082 if (m_requestedAttributes.alpha()) 3155 if (m_requestedAttributes.alpha())
3083 return GL_RGBA; 3156 return GL_RGBA;
3084 return GL_RGB; 3157 return GL_RGB;
3085 } 3158 }
3086 3159
3087 } // namespace blink 3160 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698