| 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 "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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 m_boundTransformFeedbackBuffer = nullptr; | 141 m_boundTransformFeedbackBuffer = nullptr; |
| 142 m_boundUniformBuffer = nullptr; | 142 m_boundUniformBuffer = nullptr; |
| 143 | 143 |
| 144 m_currentBooleanOcclusionQuery = nullptr; | 144 m_currentBooleanOcclusionQuery = nullptr; |
| 145 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; | 145 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; |
| 146 | 146 |
| 147 m_max3DTextureSize = 0; | 147 m_max3DTextureSize = 0; |
| 148 webContext()->getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max3DTextureSize); | 148 webContext()->getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max3DTextureSize); |
| 149 m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize, m_
max3DTextureSize, m_max3DTextureSize); | 149 m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize, m_
max3DTextureSize, m_max3DTextureSize); |
| 150 | 150 |
| 151 m_maxArrayTextureLayers = 0; |
| 152 webContext()->getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_maxArrayTextureLay
ers); |
| 153 |
| 151 GLint numCombinedTextureImageUnits = 0; | 154 GLint numCombinedTextureImageUnits = 0; |
| 152 webContext()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedT
extureImageUnits); | 155 webContext()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedT
extureImageUnits); |
| 153 m_samplerUnits.clear(); | 156 m_samplerUnits.clear(); |
| 154 m_samplerUnits.resize(numCombinedTextureImageUnits); | 157 m_samplerUnits.resize(numCombinedTextureImageUnits); |
| 155 | 158 |
| 156 GLint maxTransformFeedbackSeparateAttribs = 0; | 159 GLint maxTransformFeedbackSeparateAttribs = 0; |
| 157 webContext()->getIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTr
ansformFeedbackSeparateAttribs); | 160 webContext()->getIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTr
ansformFeedbackSeparateAttribs); |
| 158 m_boundIndexedTransformFeedbackBuffers.clear(); | 161 m_boundIndexedTransformFeedbackBuffers.clear(); |
| 159 m_boundIndexedTransformFeedbackBuffers.resize(maxTransformFeedbackSeparateAt
tribs); | 162 m_boundIndexedTransformFeedbackBuffers.resize(maxTransformFeedbackSeparateAt
tribs); |
| 160 | 163 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 239 } |
| 237 | 240 |
| 238 void WebGL2RenderingContextBase::blitFramebuffer(GLint srcX0, GLint srcY0, GLint
srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfi
eld mask, GLenum filter) | 241 void WebGL2RenderingContextBase::blitFramebuffer(GLint srcX0, GLint srcY0, GLint
srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfi
eld mask, GLenum filter) |
| 239 { | 242 { |
| 240 if (isContextLost()) | 243 if (isContextLost()) |
| 241 return; | 244 return; |
| 242 | 245 |
| 243 webContext()->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dst
Y0, dstX1, dstY1, mask, filter); | 246 webContext()->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dst
Y0, dstX1, dstY1, mask, filter); |
| 244 } | 247 } |
| 245 | 248 |
| 246 void WebGL2RenderingContextBase::framebufferTextureLayer(GLenum target, GLenum a
ttachment, const WebGLTexture* texture, GLint level, GLint layer) | 249 bool WebGL2RenderingContextBase::validateTexFuncLayer(const char* functionName,
GLenum texTarget, GLint layer) |
| 247 { | 250 { |
| 248 if (isContextLost()) | 251 if (layer < 0) { |
| 252 synthesizeGLError(GL_INVALID_VALUE, functionName, "layer out of range"); |
| 253 return false; |
| 254 } |
| 255 switch (texTarget) { |
| 256 case GL_TEXTURE_3D: |
| 257 if (layer > m_max3DTextureSize - 1) { |
| 258 synthesizeGLError(GL_INVALID_VALUE, functionName, "layer out of rang
e"); |
| 259 return false; |
| 260 } |
| 261 break; |
| 262 case GL_TEXTURE_2D_ARRAY: |
| 263 if (layer > m_maxArrayTextureLayers - 1) { |
| 264 synthesizeGLError(GL_INVALID_VALUE, functionName, "layer out of rang
e"); |
| 265 return false; |
| 266 } |
| 267 break; |
| 268 default: |
| 269 ASSERT_NOT_REACHED(); |
| 270 return false; |
| 271 } |
| 272 return true; |
| 273 } |
| 274 |
| 275 void WebGL2RenderingContextBase::framebufferTextureLayer(ScriptState* scriptStat
e, GLenum target, GLenum attachment, WebGLTexture* texture, GLint level, GLint l
ayer) |
| 276 { |
| 277 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
eLayer", target, attachment)) |
| 249 return; | 278 return; |
| 250 | |
| 251 if (texture && !texture->validate(contextGroup(), this)) { | 279 if (texture && !texture->validate(contextGroup(), this)) { |
| 252 synthesizeGLError(GL_INVALID_VALUE, "framebufferTextureLayer", "no textu
re or texture not from this context"); | 280 synthesizeGLError(GL_INVALID_VALUE, "framebufferTextureLayer", "no textu
re or texture not from this context"); |
| 253 return; | 281 return; |
| 254 } | 282 } |
| 283 GLenum textarget = texture ? texture->getTarget() : 0; |
| 284 if (texture) { |
| 285 if (textarget != GL_TEXTURE_3D && textarget != GL_TEXTURE_2D_ARRAY) { |
| 286 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTextureLayer", "
invalid texture type"); |
| 287 return; |
| 288 } |
| 289 if (!validateTexFuncLayer("framebufferTextureLayer", textarget, layer)) |
| 290 return; |
| 291 if (!validateTexFuncLevel("framebufferTextureLayer", textarget, level)) |
| 292 return; |
| 293 } |
| 255 | 294 |
| 295 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
| 296 if (!framebufferBinding || !framebufferBinding->object()) { |
| 297 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTextureLayer", "no f
ramebuffer bound"); |
| 298 return; |
| 299 } |
| 256 webContext()->framebufferTextureLayer(target, attachment, objectOrZero(textu
re), level, layer); | 300 webContext()->framebufferTextureLayer(target, attachment, objectOrZero(textu
re), level, layer); |
| 301 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex
target, texture, level, layer); |
| 302 applyStencilTest(); |
| 303 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", attachm
ent, texture); |
| 257 } | 304 } |
| 258 | 305 |
| 259 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState*
scriptState, GLenum target, GLenum internalformat, GLenum pname) | 306 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState*
scriptState, GLenum target, GLenum internalformat, GLenum pname) |
| 260 { | 307 { |
| 261 if (isContextLost()) | 308 if (isContextLost()) |
| 262 return ScriptValue::createNull(scriptState); | 309 return ScriptValue::createNull(scriptState); |
| 263 | 310 |
| 264 if (target != GL_RENDERBUFFER) { | 311 if (target != GL_RENDERBUFFER) { |
| 265 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d target"); | 312 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d target"); |
| 266 return ScriptValue::createNull(scriptState); | 313 return ScriptValue::createNull(scriptState); |
| (...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2962 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 3009 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
| 2963 { | 3010 { |
| 2964 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 3011 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
| 2965 return m_readFramebufferBinding->colorBufferFormat(); | 3012 return m_readFramebufferBinding->colorBufferFormat(); |
| 2966 if (m_requestedAttributes.alpha()) | 3013 if (m_requestedAttributes.alpha()) |
| 2967 return GL_RGBA; | 3014 return GL_RGBA; |
| 2968 return GL_RGB; | 3015 return GL_RGB; |
| 2969 } | 3016 } |
| 2970 | 3017 |
| 2971 } // namespace blink | 3018 } // namespace blink |
| OLD | NEW |