| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 #include "bindings/modules/v8/WebGLAny.h" | 8 #include "bindings/modules/v8/WebGLAny.h" |
| 9 #include "core/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
| 10 #include "core/html/HTMLCanvasElement.h" | 10 #include "core/html/HTMLCanvasElement.h" |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 bool WebGL2RenderingContextBase::CheckAndTranslateAttachments( | 603 bool WebGL2RenderingContextBase::CheckAndTranslateAttachments( |
| 604 const char* function_name, | 604 const char* function_name, |
| 605 GLenum target, | 605 GLenum target, |
| 606 Vector<GLenum>& attachments) { | 606 Vector<GLenum>& attachments) { |
| 607 if (!ValidateFramebufferTarget(target)) { | 607 if (!ValidateFramebufferTarget(target)) { |
| 608 SynthesizeGLError(GL_INVALID_ENUM, function_name, "invalid target"); | 608 SynthesizeGLError(GL_INVALID_ENUM, function_name, "invalid target"); |
| 609 return false; | 609 return false; |
| 610 } | 610 } |
| 611 | 611 |
| 612 WebGLFramebuffer* framebuffer_binding = GetFramebufferBinding(target); | 612 WebGLFramebuffer* framebuffer_binding = GetFramebufferBinding(target); |
| 613 ASSERT(framebuffer_binding || GetDrawingBuffer()); | 613 DCHECK(framebuffer_binding || GetDrawingBuffer()); |
| 614 if (!framebuffer_binding) { | 614 if (!framebuffer_binding) { |
| 615 // For the default framebuffer, translate GL_COLOR/GL_DEPTH/GL_STENCIL. | 615 // For the default framebuffer, translate GL_COLOR/GL_DEPTH/GL_STENCIL. |
| 616 // The default framebuffer of WebGL is not fb 0, it is an internal fbo. | 616 // The default framebuffer of WebGL is not fb 0, it is an internal fbo. |
| 617 for (size_t i = 0; i < attachments.size(); ++i) { | 617 for (size_t i = 0; i < attachments.size(); ++i) { |
| 618 switch (attachments[i]) { | 618 switch (attachments[i]) { |
| 619 case GL_COLOR: | 619 case GL_COLOR: |
| 620 attachments[i] = GL_COLOR_ATTACHMENT0; | 620 attachments[i] = GL_COLOR_ATTACHMENT0; |
| 621 break; | 621 break; |
| 622 case GL_DEPTH: | 622 case GL_DEPTH: |
| 623 attachments[i] = GL_DEPTH_ATTACHMENT; | 623 attachments[i] = GL_DEPTH_ATTACHMENT; |
| (...skipping 4682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5306 bool WebGL2RenderingContextBase::ValidateGetFramebufferAttachmentParameterFunc( | 5306 bool WebGL2RenderingContextBase::ValidateGetFramebufferAttachmentParameterFunc( |
| 5307 const char* function_name, | 5307 const char* function_name, |
| 5308 GLenum target, | 5308 GLenum target, |
| 5309 GLenum attachment) { | 5309 GLenum attachment) { |
| 5310 if (!ValidateFramebufferTarget(target)) { | 5310 if (!ValidateFramebufferTarget(target)) { |
| 5311 SynthesizeGLError(GL_INVALID_ENUM, function_name, "invalid target"); | 5311 SynthesizeGLError(GL_INVALID_ENUM, function_name, "invalid target"); |
| 5312 return false; | 5312 return false; |
| 5313 } | 5313 } |
| 5314 | 5314 |
| 5315 WebGLFramebuffer* framebuffer_binding = GetFramebufferBinding(target); | 5315 WebGLFramebuffer* framebuffer_binding = GetFramebufferBinding(target); |
| 5316 ASSERT(framebuffer_binding || GetDrawingBuffer()); | 5316 DCHECK(framebuffer_binding || GetDrawingBuffer()); |
| 5317 if (!framebuffer_binding) { | 5317 if (!framebuffer_binding) { |
| 5318 // for the default framebuffer | 5318 // for the default framebuffer |
| 5319 switch (attachment) { | 5319 switch (attachment) { |
| 5320 case GL_BACK: | 5320 case GL_BACK: |
| 5321 case GL_DEPTH: | 5321 case GL_DEPTH: |
| 5322 case GL_STENCIL: | 5322 case GL_STENCIL: |
| 5323 break; | 5323 break; |
| 5324 default: | 5324 default: |
| 5325 SynthesizeGLError(GL_INVALID_ENUM, function_name, "invalid attachment"); | 5325 SynthesizeGLError(GL_INVALID_ENUM, function_name, "invalid attachment"); |
| 5326 return false; | 5326 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5357 ScriptState* script_state, | 5357 ScriptState* script_state, |
| 5358 GLenum target, | 5358 GLenum target, |
| 5359 GLenum attachment, | 5359 GLenum attachment, |
| 5360 GLenum pname) { | 5360 GLenum pname) { |
| 5361 const char kFunctionName[] = "getFramebufferAttachmentParameter"; | 5361 const char kFunctionName[] = "getFramebufferAttachmentParameter"; |
| 5362 if (isContextLost() || !ValidateGetFramebufferAttachmentParameterFunc( | 5362 if (isContextLost() || !ValidateGetFramebufferAttachmentParameterFunc( |
| 5363 kFunctionName, target, attachment)) | 5363 kFunctionName, target, attachment)) |
| 5364 return ScriptValue::CreateNull(script_state); | 5364 return ScriptValue::CreateNull(script_state); |
| 5365 | 5365 |
| 5366 WebGLFramebuffer* framebuffer_binding = GetFramebufferBinding(target); | 5366 WebGLFramebuffer* framebuffer_binding = GetFramebufferBinding(target); |
| 5367 ASSERT(!framebuffer_binding || framebuffer_binding->Object()); | 5367 DCHECK(!framebuffer_binding || framebuffer_binding->Object()); |
| 5368 | 5368 |
| 5369 // Default framebuffer (an internal fbo) | 5369 // Default framebuffer (an internal fbo) |
| 5370 if (!framebuffer_binding) { | 5370 if (!framebuffer_binding) { |
| 5371 // We can use creationAttributes() because in WebGL 2, they are required to | 5371 // We can use creationAttributes() because in WebGL 2, they are required to |
| 5372 // be honored. | 5372 // be honored. |
| 5373 bool has_depth = CreationAttributes().depth(); | 5373 bool has_depth = CreationAttributes().depth(); |
| 5374 bool has_stencil = CreationAttributes().stencil(); | 5374 bool has_stencil = CreationAttributes().stencil(); |
| 5375 bool has_alpha = CreationAttributes().alpha(); | 5375 bool has_alpha = CreationAttributes().alpha(); |
| 5376 bool missing_image = (attachment == GL_DEPTH && !has_depth) || | 5376 bool missing_image = (attachment == GL_DEPTH && !has_depth) || |
| 5377 (attachment == GL_STENCIL && !has_stencil); | 5377 (attachment == GL_STENCIL && !has_stencil); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5440 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 5440 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5441 return WebGLAny(script_state, GL_NONE); | 5441 return WebGLAny(script_state, GL_NONE); |
| 5442 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 5442 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5443 return ScriptValue::CreateNull(script_state); | 5443 return ScriptValue::CreateNull(script_state); |
| 5444 default: | 5444 default: |
| 5445 SynthesizeGLError(GL_INVALID_OPERATION, kFunctionName, | 5445 SynthesizeGLError(GL_INVALID_OPERATION, kFunctionName, |
| 5446 "invalid parameter name"); | 5446 "invalid parameter name"); |
| 5447 return ScriptValue::CreateNull(script_state); | 5447 return ScriptValue::CreateNull(script_state); |
| 5448 } | 5448 } |
| 5449 } | 5449 } |
| 5450 ASSERT(attachment_object->IsTexture() || attachment_object->IsRenderbuffer()); | 5450 DCHECK(attachment_object->IsTexture() || attachment_object->IsRenderbuffer()); |
| 5451 | 5451 |
| 5452 switch (pname) { | 5452 switch (pname) { |
| 5453 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 5453 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5454 if (attachment_object->IsTexture()) | 5454 if (attachment_object->IsTexture()) |
| 5455 return WebGLAny(script_state, GL_TEXTURE); | 5455 return WebGLAny(script_state, GL_TEXTURE); |
| 5456 return WebGLAny(script_state, GL_RENDERBUFFER); | 5456 return WebGLAny(script_state, GL_RENDERBUFFER); |
| 5457 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 5457 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5458 return WebGLAny(script_state, attachment_object); | 5458 return WebGLAny(script_state, attachment_object); |
| 5459 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | 5459 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 5460 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: | 5460 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5770 | 5770 |
| 5771 void WebGL2RenderingContextBase:: | 5771 void WebGL2RenderingContextBase:: |
| 5772 DrawingBufferClientRestorePixelUnpackBufferBinding() { | 5772 DrawingBufferClientRestorePixelUnpackBufferBinding() { |
| 5773 if (!ContextGL()) | 5773 if (!ContextGL()) |
| 5774 return; | 5774 return; |
| 5775 ContextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, | 5775 ContextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, |
| 5776 ObjectOrZero(bound_pixel_unpack_buffer_.Get())); | 5776 ObjectOrZero(bound_pixel_unpack_buffer_.Get())); |
| 5777 } | 5777 } |
| 5778 | 5778 |
| 5779 } // namespace blink | 5779 } // namespace blink |
| OLD | NEW |