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 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 WebGLVertexArrayObject* WebGL2RenderingContextBase::createVertexArray() | 2058 WebGLVertexArrayObject* WebGL2RenderingContextBase::createVertexArray() |
2059 { | 2059 { |
2060 if (isContextLost()) | 2060 if (isContextLost()) |
2061 return nullptr; | 2061 return nullptr; |
2062 | 2062 |
2063 WebGLVertexArrayObject* o = WebGLVertexArrayObject::create(this, WebGLVertex
ArrayObjectBase::VaoTypeUser); | 2063 WebGLVertexArrayObject* o = WebGLVertexArrayObject::create(this, WebGLVertex
ArrayObjectBase::VaoTypeUser); |
2064 addContextObject(o); | 2064 addContextObject(o); |
2065 return o; | 2065 return o; |
2066 } | 2066 } |
2067 | 2067 |
2068 void WebGL2RenderingContextBase::deleteVertexArray(WebGLVertexArrayObject* verte
xArray) | 2068 void WebGL2RenderingContextBase::deleteVertexArray(ScriptState* scriptState, Web
GLVertexArrayObject* vertexArray) |
2069 { | 2069 { |
2070 if (isContextLost() || !vertexArray) | 2070 if (isContextLost() || !vertexArray) |
2071 return; | 2071 return; |
2072 | 2072 |
2073 if (!vertexArray->isDefaultObject() && vertexArray == m_boundVertexArrayObje
ct) | 2073 if (!vertexArray->isDefaultObject() && vertexArray == m_boundVertexArrayObje
ct) |
2074 setBoundVertexArrayObject(nullptr); | 2074 setBoundVertexArrayObject(scriptState, nullptr); |
2075 | 2075 |
2076 vertexArray->deleteObject(webContext()); | 2076 vertexArray->deleteObject(webContext()); |
2077 } | 2077 } |
2078 | 2078 |
2079 GLboolean WebGL2RenderingContextBase::isVertexArray(WebGLVertexArrayObject* vert
exArray) | 2079 GLboolean WebGL2RenderingContextBase::isVertexArray(WebGLVertexArrayObject* vert
exArray) |
2080 { | 2080 { |
2081 if (isContextLost() || !vertexArray) | 2081 if (isContextLost() || !vertexArray) |
2082 return 0; | 2082 return 0; |
2083 | 2083 |
2084 if (!vertexArray->hasEverBeenBound()) | 2084 if (!vertexArray->hasEverBeenBound()) |
2085 return 0; | 2085 return 0; |
2086 | 2086 |
2087 return webContext()->isVertexArrayOES(vertexArray->object()); | 2087 return webContext()->isVertexArrayOES(vertexArray->object()); |
2088 } | 2088 } |
2089 | 2089 |
2090 void WebGL2RenderingContextBase::bindVertexArray(WebGLVertexArrayObject* vertexA
rray) | 2090 void WebGL2RenderingContextBase::bindVertexArray(ScriptState* scriptState, WebGL
VertexArrayObject* vertexArray) |
2091 { | 2091 { |
2092 if (isContextLost()) | 2092 if (isContextLost()) |
2093 return; | 2093 return; |
2094 | 2094 |
2095 if (vertexArray && (vertexArray->isDeleted() || !vertexArray->validate(0, th
is))) { | 2095 if (vertexArray && (vertexArray->isDeleted() || !vertexArray->validate(0, th
is))) { |
2096 webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 2096 webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
2097 return; | 2097 return; |
2098 } | 2098 } |
2099 | 2099 |
2100 if (vertexArray && !vertexArray->isDefaultObject() && vertexArray->object())
{ | 2100 if (vertexArray && !vertexArray->isDefaultObject() && vertexArray->object())
{ |
2101 webContext()->bindVertexArrayOES(objectOrZero(vertexArray)); | 2101 webContext()->bindVertexArrayOES(objectOrZero(vertexArray)); |
2102 | 2102 |
2103 vertexArray->setHasEverBeenBound(); | 2103 vertexArray->setHasEverBeenBound(); |
2104 setBoundVertexArrayObject(vertexArray); | 2104 setBoundVertexArrayObject(scriptState, vertexArray); |
2105 } else { | 2105 } else { |
2106 webContext()->bindVertexArrayOES(0); | 2106 webContext()->bindVertexArrayOES(0); |
2107 setBoundVertexArrayObject(nullptr); | 2107 setBoundVertexArrayObject(scriptState, nullptr); |
2108 } | 2108 } |
2109 } | 2109 } |
2110 | 2110 |
2111 void WebGL2RenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer
* buffer) | 2111 void WebGL2RenderingContextBase::bindFramebuffer(ScriptState* scriptState, GLenu
m target, WebGLFramebuffer* buffer) |
2112 { | 2112 { |
2113 bool deleted; | 2113 bool deleted; |
2114 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 2114 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
2115 return; | 2115 return; |
2116 | 2116 |
2117 if (deleted) | 2117 if (deleted) |
2118 buffer = 0; | 2118 buffer = 0; |
2119 | 2119 |
2120 switch (target) { | 2120 switch (target) { |
2121 case GL_DRAW_FRAMEBUFFER: | 2121 case GL_DRAW_FRAMEBUFFER: |
2122 break; | 2122 break; |
2123 case GL_FRAMEBUFFER: | 2123 case GL_FRAMEBUFFER: |
2124 case GL_READ_FRAMEBUFFER: | 2124 case GL_READ_FRAMEBUFFER: |
2125 m_readFramebufferBinding = buffer; | 2125 m_readFramebufferBinding = buffer; |
2126 break; | 2126 break; |
2127 default: | 2127 default: |
2128 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 2128 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
2129 return; | 2129 return; |
2130 } | 2130 } |
2131 | 2131 |
2132 setFramebuffer(target, buffer); | 2132 setFramebuffer(target, buffer); |
| 2133 if (scriptState) |
| 2134 preserveObjectWrapper(scriptState, this, "framebuffer", 0, buffer); |
2133 } | 2135 } |
2134 | 2136 |
2135 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer
) | 2137 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer
) |
2136 { | 2138 { |
2137 if (!deleteObject(framebuffer)) | 2139 if (!deleteObject(framebuffer)) |
2138 return; | 2140 return; |
2139 GLenum target = 0; | 2141 GLenum target = 0; |
2140 if (framebuffer == m_framebufferBinding) { | 2142 if (framebuffer == m_framebufferBinding) { |
2141 if (framebuffer == m_readFramebufferBinding) { | 2143 if (framebuffer == m_readFramebufferBinding) { |
2142 target = GL_FRAMEBUFFER; | 2144 target = GL_FRAMEBUFFER; |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2940 if (m_boundTransformFeedbackBuffer == buffer) | 2942 if (m_boundTransformFeedbackBuffer == buffer) |
2941 m_boundTransformFeedbackBuffer = nullptr; | 2943 m_boundTransformFeedbackBuffer = nullptr; |
2942 if (m_boundUniformBuffer == buffer) | 2944 if (m_boundUniformBuffer == buffer) |
2943 m_boundUniformBuffer = nullptr; | 2945 m_boundUniformBuffer = nullptr; |
2944 | 2946 |
2945 WebGLRenderingContextBase::removeBoundBuffer(buffer); | 2947 WebGLRenderingContextBase::removeBoundBuffer(buffer); |
2946 } | 2948 } |
2947 | 2949 |
2948 void WebGL2RenderingContextBase::restoreCurrentFramebuffer() | 2950 void WebGL2RenderingContextBase::restoreCurrentFramebuffer() |
2949 { | 2951 { |
2950 bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get()); | 2952 bindFramebuffer(nullptr, GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get()); |
2951 bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get()); | 2953 bindFramebuffer(nullptr, GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get()
); |
2952 } | 2954 } |
2953 | 2955 |
2954 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 2956 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
2955 { | 2957 { |
2956 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 2958 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
2957 return m_readFramebufferBinding->colorBufferFormat(); | 2959 return m_readFramebufferBinding->colorBufferFormat(); |
2958 if (m_requestedAttributes.alpha()) | 2960 if (m_requestedAttributes.alpha()) |
2959 return GL_RGBA; | 2961 return GL_RGBA; |
2960 return GL_RGB; | 2962 return GL_RGB; |
2961 } | 2963 } |
2962 | 2964 |
2963 } // namespace blink | 2965 } // namespace blink |
OLD | NEW |