Chromium Code Reviews| 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" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 contextGL()->FramebufferTextureLayer(target, GL_DEPTH_ATTACHMENT, object OrZero(texture), level, layer); | 314 contextGL()->FramebufferTextureLayer(target, GL_DEPTH_ATTACHMENT, object OrZero(texture), level, layer); |
| 315 contextGL()->FramebufferTextureLayer(target, GL_STENCIL_ATTACHMENT, obje ctOrZero(texture), level, layer); | 315 contextGL()->FramebufferTextureLayer(target, GL_STENCIL_ATTACHMENT, obje ctOrZero(texture), level, layer); |
| 316 } else { | 316 } else { |
| 317 contextGL()->FramebufferTextureLayer(target, attachment, objectOrZero(te xture), level, layer); | 317 contextGL()->FramebufferTextureLayer(target, attachment, objectOrZero(te xture), level, layer); |
| 318 } | 318 } |
| 319 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 319 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 320 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. | 320 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. |
| 321 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2. | 321 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2. |
| 322 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, textarget, texture, level, layer); | 322 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, textarget, texture, level, layer); |
| 323 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, textarget, texture, level, layer); | 323 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, textarget, texture, level, layer); |
| 324 preserveObjectWrapper(scriptState, framebufferBinding, V8HiddenValue::we bglAttachments(scriptState->isolate()), framebufferBinding->getPersistentCache() , GL_DEPTH_ATTACHMENT, texture); | 324 preserveObjectWrapper(scriptState, framebufferBinding, V8PrivateProperty ::getWebGLFramebufferAttachments(scriptState->isolate()), GL_DEPTH_ATTACHMENT, t exture); |
| 325 preserveObjectWrapper(scriptState, framebufferBinding, V8HiddenValue::we bglAttachments(scriptState->isolate()), framebufferBinding->getPersistentCache() , GL_STENCIL_ATTACHMENT, texture); | 325 preserveObjectWrapper(scriptState, framebufferBinding, V8PrivateProperty ::getWebGLFramebufferAttachments(scriptState->isolate()), GL_STENCIL_ATTACHMENT, texture); |
| 326 } else { | 326 } else { |
| 327 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, textarget, texture, level, layer); | 327 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, textarget, texture, level, layer); |
| 328 preserveObjectWrapper(scriptState, framebufferBinding, V8HiddenValue::we bglAttachments(scriptState->isolate()), framebufferBinding->getPersistentCache() , attachment, texture); | 328 preserveObjectWrapper(scriptState, framebufferBinding, V8PrivateProperty ::getWebGLFramebufferAttachments(scriptState->isolate()), attachment, texture); |
|
Yuki
2016/06/02 13:07:22
Could you tell us why you need to preserve the wra
Ken Russell (switch to Gerrit)
2016/06/03 00:59:19
Yes, the wrapper objects need to be kept alive, pe
| |
| 329 } | 329 } |
| 330 applyStencilTest(); | 330 applyStencilTest(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState* scriptState, GLenum target, GLenum internalformat, GLenum pname) | 333 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState* scriptState, GLenum target, GLenum internalformat, GLenum pname) |
| 334 { | 334 { |
| 335 if (isContextLost()) | 335 if (isContextLost()) |
| 336 return ScriptValue::createNull(scriptState); | 336 return ScriptValue::createNull(scriptState); |
| 337 | 337 |
| 338 if (target != GL_RENDERBUFFER) { | 338 if (target != GL_RENDERBUFFER) { |
| (...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1771 break; | 1771 break; |
| 1772 default: | 1772 default: |
| 1773 synthesizeGLError(GL_INVALID_ENUM, "beginQuery", "invalid target"); | 1773 synthesizeGLError(GL_INVALID_ENUM, "beginQuery", "invalid target"); |
| 1774 return; | 1774 return; |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 if (!query->getTarget()) | 1777 if (!query->getTarget()) |
| 1778 query->setTarget(target); | 1778 query->setTarget(target); |
| 1779 | 1779 |
| 1780 contextGL()->BeginQueryEXT(target, query->object()); | 1780 contextGL()->BeginQueryEXT(target, query->object()); |
| 1781 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglQueries(scriptS tate->isolate()), &m_queryWrappers, static_cast<uint32_t>(target), query); | 1781 preserveObjectWrapper(scriptState, this, V8PrivateProperty::getWebGLRenderin gContextQueries(scriptState->isolate()), static_cast<uint32_t>(target), query); |
| 1782 } | 1782 } |
| 1783 | 1783 |
| 1784 void WebGL2RenderingContextBase::endQuery(GLenum target) | 1784 void WebGL2RenderingContextBase::endQuery(GLenum target) |
| 1785 { | 1785 { |
| 1786 if (isContextLost()) | 1786 if (isContextLost()) |
| 1787 return; | 1787 return; |
| 1788 | 1788 |
| 1789 switch (target) { | 1789 switch (target) { |
| 1790 case GL_ANY_SAMPLES_PASSED: | 1790 case GL_ANY_SAMPLES_PASSED: |
| 1791 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: | 1791 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1931 | 1931 |
| 1932 if (unit >= m_samplerUnits.size()) { | 1932 if (unit >= m_samplerUnits.size()) { |
| 1933 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", "texture unit out of range"); | 1933 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", "texture unit out of range"); |
| 1934 return; | 1934 return; |
| 1935 } | 1935 } |
| 1936 | 1936 |
| 1937 m_samplerUnits[unit] = sampler; | 1937 m_samplerUnits[unit] = sampler; |
| 1938 | 1938 |
| 1939 contextGL()->BindSampler(unit, objectOrZero(sampler)); | 1939 contextGL()->BindSampler(unit, objectOrZero(sampler)); |
| 1940 | 1940 |
| 1941 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglSamplers(script State->isolate()), &m_samplerWrappers, static_cast<uint32_t>(unit), sampler); | 1941 preserveObjectWrapper(scriptState, this, V8PrivateProperty::getWebGLRenderin gContextSamplers(scriptState->isolate()), static_cast<uint32_t>(unit), sampler); |
| 1942 } | 1942 } |
| 1943 | 1943 |
| 1944 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, GLenum pname, GLfloat paramf, GLint parami, bool isFloat) | 1944 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, GLenum pname, GLfloat paramf, GLint parami, bool isFloat) |
| 1945 { | 1945 { |
| 1946 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler)) | 1946 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler)) |
| 1947 return; | 1947 return; |
| 1948 | 1948 |
| 1949 GLint param = isFloat ? static_cast<GLint>(paramf) : parami; | 1949 GLint param = isFloat ? static_cast<GLint>(paramf) : parami; |
| 1950 switch (pname) { | 1950 switch (pname) { |
| 1951 case GL_TEXTURE_MAX_LOD: | 1951 case GL_TEXTURE_MAX_LOD: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2190 if (transformFeedbackActive() && !transformFeedbackPaused()) { | 2190 if (transformFeedbackActive() && !transformFeedbackPaused()) { |
| 2191 synthesizeGLError(GL_INVALID_OPERATION, "bindTransformFeedback", "transf orm feedback is active and not paused"); | 2191 synthesizeGLError(GL_INVALID_OPERATION, "bindTransformFeedback", "transf orm feedback is active and not paused"); |
| 2192 return; | 2192 return; |
| 2193 } | 2193 } |
| 2194 | 2194 |
| 2195 m_transformFeedbackBinding = feedback; | 2195 m_transformFeedbackBinding = feedback; |
| 2196 | 2196 |
| 2197 contextGL()->BindTransformFeedback(target, objectOrZero(feedback)); | 2197 contextGL()->BindTransformFeedback(target, objectOrZero(feedback)); |
| 2198 if (feedback) { | 2198 if (feedback) { |
| 2199 feedback->setTarget(target); | 2199 feedback->setTarget(target); |
| 2200 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglMisc(script State->isolate()), &m_miscWrappers, static_cast<uint32_t>(PreservedTransformFeed back), feedback); | 2200 preserveObjectWrapper(scriptState, this, V8PrivateProperty::getWebGLRend eringContextMisc(scriptState->isolate()), static_cast<uint32_t>(PreservedTransfo rmFeedback), feedback); |
| 2201 } | 2201 } |
| 2202 | 2202 |
| 2203 } | 2203 } |
| 2204 | 2204 |
| 2205 void WebGL2RenderingContextBase::beginTransformFeedback(GLenum primitiveMode) | 2205 void WebGL2RenderingContextBase::beginTransformFeedback(GLenum primitiveMode) |
| 2206 { | 2206 { |
| 2207 if (isContextLost()) | 2207 if (isContextLost()) |
| 2208 return; | 2208 return; |
| 2209 if (!validateTransformFeedbackPrimitiveMode("beginTransformFeedback", primit iveMode)) | 2209 if (!validateTransformFeedbackPrimitiveMode("beginTransformFeedback", primit iveMode)) |
| 2210 return; | 2210 return; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2731 case GL_READ_FRAMEBUFFER: | 2731 case GL_READ_FRAMEBUFFER: |
| 2732 m_readFramebufferBinding = buffer; | 2732 m_readFramebufferBinding = buffer; |
| 2733 break; | 2733 break; |
| 2734 default: | 2734 default: |
| 2735 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 2735 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
| 2736 return; | 2736 return; |
| 2737 } | 2737 } |
| 2738 | 2738 |
| 2739 setFramebuffer(target, buffer); | 2739 setFramebuffer(target, buffer); |
| 2740 if (scriptState) { | 2740 if (scriptState) { |
| 2741 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglMisc(script State->isolate()), &m_miscWrappers, static_cast<uint32_t>(PreservedFramebuffer), buffer); | 2741 preserveObjectWrapper(scriptState, this, V8PrivateProperty::getWebGLRend eringContextMisc(scriptState->isolate()), static_cast<uint32_t>(PreservedFramebu ffer), buffer); |
| 2742 } | 2742 } |
| 2743 } | 2743 } |
| 2744 | 2744 |
| 2745 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer ) | 2745 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer ) |
| 2746 { | 2746 { |
| 2747 if (!deleteObject(framebuffer)) | 2747 if (!deleteObject(framebuffer)) |
| 2748 return; | 2748 return; |
| 2749 GLenum target = 0; | 2749 GLenum target = 0; |
| 2750 if (framebuffer == m_framebufferBinding) { | 2750 if (framebuffer == m_framebufferBinding) { |
| 2751 if (framebuffer == m_readFramebufferBinding) { | 2751 if (framebuffer == m_readFramebufferBinding) { |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3603 params.skipPixels = m_unpackSkipPixels; | 3603 params.skipPixels = m_unpackSkipPixels; |
| 3604 params.skipRows = m_unpackSkipRows; | 3604 params.skipRows = m_unpackSkipRows; |
| 3605 if (dimension == Tex3D) { | 3605 if (dimension == Tex3D) { |
| 3606 params.imageHeight = m_unpackImageHeight; | 3606 params.imageHeight = m_unpackImageHeight; |
| 3607 params.skipImages = m_unpackSkipImages; | 3607 params.skipImages = m_unpackSkipImages; |
| 3608 } | 3608 } |
| 3609 return params; | 3609 return params; |
| 3610 } | 3610 } |
| 3611 | 3611 |
| 3612 } // namespace blink | 3612 } // namespace blink |
| OLD | NEW |