| 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 "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" |
| 11 #include "core/html/HTMLVideoElement.h" | 11 #include "core/html/HTMLVideoElement.h" |
| 12 #include "core/html/ImageData.h" | 12 #include "core/html/ImageData.h" |
| 13 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
| 14 #include "modules/webgl/WebGLActiveInfo.h" | 14 #include "modules/webgl/WebGLActiveInfo.h" |
| 15 #include "modules/webgl/WebGLBuffer.h" | 15 #include "modules/webgl/WebGLBuffer.h" |
| 16 #include "modules/webgl/WebGLFenceSync.h" | 16 #include "modules/webgl/WebGLFenceSync.h" |
| 17 #include "modules/webgl/WebGLFramebuffer.h" | 17 #include "modules/webgl/WebGLFramebuffer.h" |
| 18 #include "modules/webgl/WebGLProgram.h" | 18 #include "modules/webgl/WebGLProgram.h" |
| 19 #include "modules/webgl/WebGLQuery.h" | 19 #include "modules/webgl/WebGLQuery.h" |
| 20 #include "modules/webgl/WebGLRenderbuffer.h" | 20 #include "modules/webgl/WebGLRenderbuffer.h" |
| 21 #include "modules/webgl/WebGLSampler.h" | 21 #include "modules/webgl/WebGLSampler.h" |
| 22 #include "modules/webgl/WebGLSync.h" | 22 #include "modules/webgl/WebGLSync.h" |
| 23 #include "modules/webgl/WebGLTexture.h" | 23 #include "modules/webgl/WebGLTexture.h" |
| 24 #include "modules/webgl/WebGLTransformFeedback.h" | 24 #include "modules/webgl/WebGLTransformFeedback.h" |
| 25 #include "modules/webgl/WebGLUniformLocation.h" | 25 #include "modules/webgl/WebGLUniformLocation.h" |
| 26 #include "modules/webgl/WebGLVertexArrayObject.h" | 26 #include "modules/webgl/WebGLVertexArrayObject.h" |
| 27 #include "platform/CheckedInt.h" | 27 #include "platform/CheckedInt.h" |
| 28 #include "public/platform/WebGraphicsContext3DProvider.h" | 28 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 29 #include "wtf/OwnPtr.h" | 29 #include "wtf/PtrUtil.h" |
| 30 #include "wtf/PassOwnPtr.h" | |
| 31 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 31 #include <memory> |
| 32 | 32 |
| 33 using WTF::String; | 33 using WTF::String; |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 GLsync syncObjectOrZero(const WebGLSync* object) | 39 GLsync syncObjectOrZero(const WebGLSync* object) |
| 40 { | 40 { |
| 41 return object ? object->object() : nullptr; | 41 return object ? object->object() : nullptr; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 GL_COMPRESSED_RG11_EAC, | 107 GL_COMPRESSED_RG11_EAC, |
| 108 GL_COMPRESSED_SIGNED_RG11_EAC, | 108 GL_COMPRESSED_SIGNED_RG11_EAC, |
| 109 GL_COMPRESSED_RGB8_ETC2, | 109 GL_COMPRESSED_RGB8_ETC2, |
| 110 GL_COMPRESSED_SRGB8_ETC2, | 110 GL_COMPRESSED_SRGB8_ETC2, |
| 111 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, | 111 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, |
| 112 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, | 112 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, |
| 113 GL_COMPRESSED_RGBA8_ETC2_EAC, | 113 GL_COMPRESSED_RGBA8_ETC2_EAC, |
| 114 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, | 114 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passed
Canvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLCon
textAttributes& requestedAttributes) | 117 WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passed
Canvas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const Web
GLContextAttributes& requestedAttributes) |
| 118 : WebGLRenderingContextBase(passedCanvas, std::move(contextProvider), reques
tedAttributes) | 118 : WebGLRenderingContextBase(passedCanvas, std::move(contextProvider), reques
tedAttributes) |
| 119 { | 119 { |
| 120 m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, k
SupportedInternalFormatsStorage + WTF_ARRAY_LENGTH(kSupportedInternalFormatsStor
age)); | 120 m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, k
SupportedInternalFormatsStorage + WTF_ARRAY_LENGTH(kSupportedInternalFormatsStor
age)); |
| 121 m_supportedInternalFormatsStorage.insert(kCompressedTextureFormatsETC2EAC, k
CompressedTextureFormatsETC2EAC + WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2
EAC)); | 121 m_supportedInternalFormatsStorage.insert(kCompressedTextureFormatsETC2EAC, k
CompressedTextureFormatsETC2EAC + WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2
EAC)); |
| 122 m_compressedTextureFormatsETC2EAC.insert(kCompressedTextureFormatsETC2EAC, k
CompressedTextureFormatsETC2EAC + WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2
EAC)); | 122 m_compressedTextureFormatsETC2EAC.insert(kCompressedTextureFormatsETC2EAC, k
CompressedTextureFormatsETC2EAC + WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2
EAC)); |
| 123 m_compressedTextureFormats.append(kCompressedTextureFormatsETC2EAC, WTF_ARRA
Y_LENGTH(kCompressedTextureFormatsETC2EAC)); | 123 m_compressedTextureFormats.append(kCompressedTextureFormatsETC2EAC, WTF_ARRA
Y_LENGTH(kCompressedTextureFormatsETC2EAC)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() | 126 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() |
| 127 { | 127 { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 floatType = true; | 398 floatType = true; |
| 399 break; | 399 break; |
| 400 default: | 400 default: |
| 401 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d internalformat"); | 401 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d internalformat"); |
| 402 return ScriptValue::createNull(scriptState); | 402 return ScriptValue::createNull(scriptState); |
| 403 } | 403 } |
| 404 | 404 |
| 405 switch (pname) { | 405 switch (pname) { |
| 406 case GL_SAMPLES: | 406 case GL_SAMPLES: |
| 407 { | 407 { |
| 408 OwnPtr<GLint[]> values; | 408 std::unique_ptr<GLint[]> values; |
| 409 GLint length = -1; | 409 GLint length = -1; |
| 410 if (!floatType) { | 410 if (!floatType) { |
| 411 contextGL()->GetInternalformativ(target, internalformat, GL_NUM_
SAMPLE_COUNTS, 1, &length); | 411 contextGL()->GetInternalformativ(target, internalformat, GL_NUM_
SAMPLE_COUNTS, 1, &length); |
| 412 if (length <= 0) | 412 if (length <= 0) |
| 413 return WebGLAny(scriptState, DOMInt32Array::create(0)); | 413 return WebGLAny(scriptState, DOMInt32Array::create(0)); |
| 414 | 414 |
| 415 values = adoptArrayPtr(new GLint[length]); | 415 values = wrapArrayUnique(new GLint[length]); |
| 416 for (GLint ii = 0; ii < length; ++ii) | 416 for (GLint ii = 0; ii < length; ++ii) |
| 417 values[ii] = 0; | 417 values[ii] = 0; |
| 418 contextGL()->GetInternalformativ(target, internalformat, GL_SAMP
LES, length, values.get()); | 418 contextGL()->GetInternalformativ(target, internalformat, GL_SAMP
LES, length, values.get()); |
| 419 } else { | 419 } else { |
| 420 length = 1; | 420 length = 1; |
| 421 values = adoptArrayPtr(new GLint[1]); | 421 values = wrapArrayUnique(new GLint[1]); |
| 422 values[0] = 1; | 422 values[0] = 1; |
| 423 } | 423 } |
| 424 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len
gth)); | 424 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len
gth)); |
| 425 } | 425 } |
| 426 default: | 426 default: |
| 427 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); | 427 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); |
| 428 return ScriptValue::createNull(scriptState); | 428 return ScriptValue::createNull(scriptState); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 | 431 |
| (...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 if (index >= static_cast<GLuint>(maxIndex)) { | 2147 if (index >= static_cast<GLuint>(maxIndex)) { |
| 2148 synthesizeGLError(GL_INVALID_VALUE, "getTransformFeedbackVarying", "inva
lid index"); | 2148 synthesizeGLError(GL_INVALID_VALUE, "getTransformFeedbackVarying", "inva
lid index"); |
| 2149 return nullptr; | 2149 return nullptr; |
| 2150 } | 2150 } |
| 2151 | 2151 |
| 2152 GLint maxNameLength = -1; | 2152 GLint maxNameLength = -1; |
| 2153 contextGL()->GetProgramiv(objectOrZero(program), GL_TRANSFORM_FEEDBACK_VARYI
NG_MAX_LENGTH, &maxNameLength); | 2153 contextGL()->GetProgramiv(objectOrZero(program), GL_TRANSFORM_FEEDBACK_VARYI
NG_MAX_LENGTH, &maxNameLength); |
| 2154 if (maxNameLength <= 0) { | 2154 if (maxNameLength <= 0) { |
| 2155 return nullptr; | 2155 return nullptr; |
| 2156 } | 2156 } |
| 2157 OwnPtr<GLchar[]> name = adoptArrayPtr(new GLchar[maxNameLength]); | 2157 std::unique_ptr<GLchar[]> name = wrapArrayUnique(new GLchar[maxNameLength]); |
| 2158 GLsizei length = 0; | 2158 GLsizei length = 0; |
| 2159 GLsizei size = 0; | 2159 GLsizei size = 0; |
| 2160 GLenum type = 0; | 2160 GLenum type = 0; |
| 2161 contextGL()->GetTransformFeedbackVarying(objectOrZero(program), index, maxNa
meLength, &length, &size, &type, name.get()); | 2161 contextGL()->GetTransformFeedbackVarying(objectOrZero(program), index, maxNa
meLength, &length, &size, &type, name.get()); |
| 2162 | 2162 |
| 2163 if (length == 0 || size == 0 || type == 0) { | 2163 if (length == 0 || size == 0 || type == 0) { |
| 2164 return nullptr; | 2164 return nullptr; |
| 2165 } | 2165 } |
| 2166 | 2166 |
| 2167 return WebGLActiveInfo::create(String(name.get(), length), type, size); | 2167 return WebGLActiveInfo::create(String(name.get(), length), type, size); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 if (!validateUniformBlockIndex("getActiveUniformBlockName", program, uniform
BlockIndex)) | 2492 if (!validateUniformBlockIndex("getActiveUniformBlockName", program, uniform
BlockIndex)) |
| 2493 return String(); | 2493 return String(); |
| 2494 | 2494 |
| 2495 GLint maxNameLength = -1; | 2495 GLint maxNameLength = -1; |
| 2496 contextGL()->GetProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MAX
_NAME_LENGTH, &maxNameLength); | 2496 contextGL()->GetProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MAX
_NAME_LENGTH, &maxNameLength); |
| 2497 if (maxNameLength <= 0) { | 2497 if (maxNameLength <= 0) { |
| 2498 // This state indicates that there are no active uniform blocks | 2498 // This state indicates that there are no active uniform blocks |
| 2499 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniformBlockName", "invali
d uniform block index"); | 2499 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniformBlockName", "invali
d uniform block index"); |
| 2500 return String(); | 2500 return String(); |
| 2501 } | 2501 } |
| 2502 OwnPtr<GLchar[]> name = adoptArrayPtr(new GLchar[maxNameLength]); | 2502 std::unique_ptr<GLchar[]> name = wrapArrayUnique(new GLchar[maxNameLength]); |
| 2503 | 2503 |
| 2504 GLsizei length = 0; | 2504 GLsizei length = 0; |
| 2505 contextGL()->GetActiveUniformBlockName(objectOrZero(program), uniformBlockIn
dex, maxNameLength, &length, name.get()); | 2505 contextGL()->GetActiveUniformBlockName(objectOrZero(program), uniformBlockIn
dex, maxNameLength, &length, name.get()); |
| 2506 | 2506 |
| 2507 return String(name.get(), length); | 2507 return String(name.get(), length); |
| 2508 } | 2508 } |
| 2509 | 2509 |
| 2510 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) | 2510 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) |
| 2511 { | 2511 { |
| 2512 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) | 2512 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 params.skipPixels = m_unpackSkipPixels; | 3459 params.skipPixels = m_unpackSkipPixels; |
| 3460 params.skipRows = m_unpackSkipRows; | 3460 params.skipRows = m_unpackSkipRows; |
| 3461 if (dimension == Tex3D) { | 3461 if (dimension == Tex3D) { |
| 3462 params.imageHeight = m_unpackImageHeight; | 3462 params.imageHeight = m_unpackImageHeight; |
| 3463 params.skipImages = m_unpackSkipImages; | 3463 params.skipImages = m_unpackSkipImages; |
| 3464 } | 3464 } |
| 3465 return params; | 3465 return params; |
| 3466 } | 3466 } |
| 3467 | 3467 |
| 3468 } // namespace blink | 3468 } // namespace blink |
| OLD | NEW |