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

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

Issue 2389203002: reflow comments in modules/webgl (Closed)
Patch Set: Created 4 years, 2 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
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 "modules/webgl/WebGL2RenderingContextBase.h" 5 #include "modules/webgl/WebGL2RenderingContextBase.h"
6 6
7 #include "bindings/modules/v8/WebGLAny.h" 7 #include "bindings/modules/v8/WebGLAny.h"
8 #include "core/frame/ImageBitmap.h" 8 #include "core/frame/ImageBitmap.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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 466 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
467 contextGL()->FramebufferTextureLayer(target, GL_DEPTH_ATTACHMENT, 467 contextGL()->FramebufferTextureLayer(target, GL_DEPTH_ATTACHMENT,
468 objectOrZero(texture), level, layer); 468 objectOrZero(texture), level, layer);
469 contextGL()->FramebufferTextureLayer(target, GL_STENCIL_ATTACHMENT, 469 contextGL()->FramebufferTextureLayer(target, GL_STENCIL_ATTACHMENT,
470 objectOrZero(texture), level, layer); 470 objectOrZero(texture), level, layer);
471 } else { 471 } else {
472 contextGL()->FramebufferTextureLayer(target, attachment, 472 contextGL()->FramebufferTextureLayer(target, attachment,
473 objectOrZero(texture), level, layer); 473 objectOrZero(texture), level, layer);
474 } 474 }
475 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 475 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
476 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT + STENCIL_ATTACHMENT. 476 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT +
477 // We divide it here so in WebGLFramebuffer, we don't have to handle DEPTH_S TENCIL_ATTACHMENT in WebGL 2. 477 // STENCIL_ATTACHMENT. We divide it here so in WebGLFramebuffer, we don't
478 // have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
478 framebufferBinding->setAttachmentForBoundFramebuffer( 479 framebufferBinding->setAttachmentForBoundFramebuffer(
479 target, GL_DEPTH_ATTACHMENT, textarget, texture, level, layer); 480 target, GL_DEPTH_ATTACHMENT, textarget, texture, level, layer);
480 framebufferBinding->setAttachmentForBoundFramebuffer( 481 framebufferBinding->setAttachmentForBoundFramebuffer(
481 target, GL_STENCIL_ATTACHMENT, textarget, texture, level, layer); 482 target, GL_STENCIL_ATTACHMENT, textarget, texture, level, layer);
482 } else { 483 } else {
483 framebufferBinding->setAttachmentForBoundFramebuffer( 484 framebufferBinding->setAttachmentForBoundFramebuffer(
484 target, attachment, textarget, texture, level, layer); 485 target, attachment, textarget, texture, level, layer);
485 } 486 }
486 applyStencilTest(); 487 applyStencilTest();
487 } 488 }
(...skipping 10 matching lines...) Expand all
498 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", 499 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter",
499 "invalid target"); 500 "invalid target");
500 return ScriptValue::createNull(scriptState); 501 return ScriptValue::createNull(scriptState);
501 } 502 }
502 503
503 switch (internalformat) { 504 switch (internalformat) {
504 // Renderbuffer doesn't support unsized internal formats, 505 // Renderbuffer doesn't support unsized internal formats,
505 // though GL_RGB and GL_RGBA are color-renderable. 506 // though GL_RGB and GL_RGBA are color-renderable.
506 case GL_RGB: 507 case GL_RGB:
507 case GL_RGBA: 508 case GL_RGBA:
508 // Multisampling is not supported for signed and unsigned integer internal f ormats. 509 // Multisampling is not supported for signed and unsigned integer internal
510 // formats.
509 case GL_R8UI: 511 case GL_R8UI:
510 case GL_R8I: 512 case GL_R8I:
511 case GL_R16UI: 513 case GL_R16UI:
512 case GL_R16I: 514 case GL_R16I:
513 case GL_R32UI: 515 case GL_R32UI:
514 case GL_R32I: 516 case GL_R32I:
515 case GL_RG8UI: 517 case GL_RG8UI:
516 case GL_RG8I: 518 case GL_RG8I:
517 case GL_RG16UI: 519 case GL_RG16UI:
518 case GL_RG16I: 520 case GL_RG16I:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 GLenum target, 592 GLenum target,
591 Vector<GLenum>& attachments) { 593 Vector<GLenum>& attachments) {
592 if (!validateFramebufferTarget(target)) { 594 if (!validateFramebufferTarget(target)) {
593 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); 595 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target");
594 return false; 596 return false;
595 } 597 }
596 598
597 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); 599 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
598 ASSERT(framebufferBinding || drawingBuffer()); 600 ASSERT(framebufferBinding || drawingBuffer());
599 if (!framebufferBinding) { 601 if (!framebufferBinding) {
600 // For the default framebuffer 602 // For the default framebuffer, translate GL_COLOR/GL_DEPTH/GL_STENCIL.
601 // Translate GL_COLOR/GL_DEPTH/GL_STENCIL, because the default framebuffer o f WebGL is not fb 0, it is an internal fbo 603 // The default framebuffer of WebGL is not fb 0, it is an internal fbo.
602 for (size_t i = 0; i < attachments.size(); ++i) { 604 for (size_t i = 0; i < attachments.size(); ++i) {
603 switch (attachments[i]) { 605 switch (attachments[i]) {
604 case GL_COLOR: 606 case GL_COLOR:
605 attachments[i] = GL_COLOR_ATTACHMENT0; 607 attachments[i] = GL_COLOR_ATTACHMENT0;
606 break; 608 break;
607 case GL_DEPTH: 609 case GL_DEPTH:
608 attachments[i] = GL_DEPTH_ATTACHMENT; 610 attachments[i] = GL_DEPTH_ATTACHMENT;
609 break; 611 break;
610 case GL_STENCIL: 612 case GL_STENCIL:
611 attachments[i] = GL_STENCIL_ATTACHMENT; 613 attachments[i] = GL_STENCIL_ATTACHMENT;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 const char* reason = "framebuffer incomplete"; 801 const char* reason = "framebuffer incomplete";
800 WebGLFramebuffer* framebuffer = getReadFramebufferBinding(); 802 WebGLFramebuffer* framebuffer = getReadFramebufferBinding();
801 if (framebuffer && 803 if (framebuffer &&
802 framebuffer->checkDepthStencilStatus(&reason) != 804 framebuffer->checkDepthStencilStatus(&reason) !=
803 GL_FRAMEBUFFER_COMPLETE) { 805 GL_FRAMEBUFFER_COMPLETE) {
804 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason); 806 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason);
805 return; 807 return;
806 } 808 }
807 809
808 long long size = buffer->getSize() - offset; 810 long long size = buffer->getSize() - offset;
809 // If size is negative, or size is not large enough to store pixels, those cas es 811 // If size is negative, or size is not large enough to store pixels, those
810 // are handled by validateReadPixelsFuncParameters to generate INVALID_OPERATI ON. 812 // cases are handled by validateReadPixelsFuncParameters to generate
813 // INVALID_OPERATION.
811 if (!validateReadPixelsFuncParameters(width, height, format, type, nullptr, 814 if (!validateReadPixelsFuncParameters(width, height, format, type, nullptr,
812 size)) 815 size))
813 return; 816 return;
814 817
815 clearIfComposited(); 818 clearIfComposited();
816 819
817 { 820 {
818 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); 821 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer);
819 contextGL()->ReadPixels(x, y, width, height, format, type, 822 contextGL()->ReadPixels(x, y, width, height, format, type,
820 reinterpret_cast<void*>(offset)); 823 reinterpret_cast<void*>(offset));
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 if (!m_framebufferBinding) { 2350 if (!m_framebufferBinding) {
2348 if (n != 1) { 2351 if (n != 1) {
2349 synthesizeGLError(GL_INVALID_OPERATION, "drawBuffers", 2352 synthesizeGLError(GL_INVALID_OPERATION, "drawBuffers",
2350 "the number of buffers is not 1"); 2353 "the number of buffers is not 1");
2351 return; 2354 return;
2352 } 2355 }
2353 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) { 2356 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) {
2354 synthesizeGLError(GL_INVALID_OPERATION, "drawBuffers", "BACK or NONE"); 2357 synthesizeGLError(GL_INVALID_OPERATION, "drawBuffers", "BACK or NONE");
2355 return; 2358 return;
2356 } 2359 }
2357 // Because the backbuffer is simulated on all current WebKit ports, we need to change BACK to COLOR_ATTACHMENT0. 2360 // Because the backbuffer is simulated on all current WebKit ports, we need
2361 // to change BACK to COLOR_ATTACHMENT0.
2358 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE; 2362 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE;
2359 contextGL()->DrawBuffersEXT(1, &value); 2363 contextGL()->DrawBuffersEXT(1, &value);
2360 setBackDrawBuffer(bufs[0]); 2364 setBackDrawBuffer(bufs[0]);
2361 } else { 2365 } else {
2362 if (n > maxDrawBuffers()) { 2366 if (n > maxDrawBuffers()) {
2363 synthesizeGLError(GL_INVALID_VALUE, "drawBuffers", 2367 synthesizeGLError(GL_INVALID_VALUE, "drawBuffers",
2364 "more than max draw buffers"); 2368 "more than max draw buffers");
2365 return; 2369 return;
2366 } 2370 }
2367 for (GLsizei i = 0; i < n; ++i) { 2371 for (GLsizei i = 0; i < n; ++i) {
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 if (isContextLost() || 4132 if (isContextLost() ||
4129 !validateGetFramebufferAttachmentParameterFunc(kFunctionName, target, 4133 !validateGetFramebufferAttachmentParameterFunc(kFunctionName, target,
4130 attachment)) 4134 attachment))
4131 return ScriptValue::createNull(scriptState); 4135 return ScriptValue::createNull(scriptState);
4132 4136
4133 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); 4137 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
4134 ASSERT(!framebufferBinding || framebufferBinding->object()); 4138 ASSERT(!framebufferBinding || framebufferBinding->object());
4135 4139
4136 // Default framebuffer (an internal fbo) 4140 // Default framebuffer (an internal fbo)
4137 if (!framebufferBinding) { 4141 if (!framebufferBinding) {
4138 // We can use creationAttributes() because in WebGL 2, they are required to be honored. 4142 // We can use creationAttributes() because in WebGL 2, they are required to
4143 // be honored.
4139 bool hasDepth = creationAttributes().depth(); 4144 bool hasDepth = creationAttributes().depth();
4140 bool hasStencil = creationAttributes().stencil(); 4145 bool hasStencil = creationAttributes().stencil();
4141 bool hasAlpha = creationAttributes().alpha(); 4146 bool hasAlpha = creationAttributes().alpha();
4142 bool missingImage = (attachment == GL_DEPTH && !hasDepth) || 4147 bool missingImage = (attachment == GL_DEPTH && !hasDepth) ||
4143 (attachment == GL_STENCIL && !hasStencil); 4148 (attachment == GL_STENCIL && !hasStencil);
4144 if (missingImage) { 4149 if (missingImage) {
4145 switch (pname) { 4150 switch (pname) {
4146 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 4151 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
4147 return WebGLAny(scriptState, GL_NONE); 4152 return WebGLAny(scriptState, GL_NONE);
4148 default: 4153 default:
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
4489 params.skipPixels = m_unpackSkipPixels; 4494 params.skipPixels = m_unpackSkipPixels;
4490 params.skipRows = m_unpackSkipRows; 4495 params.skipRows = m_unpackSkipRows;
4491 if (dimension == Tex3D) { 4496 if (dimension == Tex3D) {
4492 params.imageHeight = m_unpackImageHeight; 4497 params.imageHeight = m_unpackImageHeight;
4493 params.skipImages = m_unpackSkipImages; 4498 params.skipImages = m_unpackSkipImages;
4494 } 4499 }
4495 return params; 4500 return params;
4496 } 4501 }
4497 4502
4498 } // namespace blink 4503 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698