| 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 15 matching lines...) Expand all Loading... |
| 26 #include "modules/webgl/WebGLVertexArrayObject.h" | 26 #include "modules/webgl/WebGLVertexArrayObject.h" |
| 27 #include "platform/CheckedInt.h" | 27 #include "platform/CheckedInt.h" |
| 28 #include "platform/NotImplemented.h" | 28 #include "platform/NotImplemented.h" |
| 29 #include "wtf/OwnPtr.h" | 29 #include "wtf/OwnPtr.h" |
| 30 #include "wtf/PassOwnPtr.h" | 30 #include "wtf/PassOwnPtr.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 WGC3Dsync syncObjectOrZero(const WebGLSync* object) | 36 GLsync syncObjectOrZero(const WebGLSync* object) |
| 37 { | 37 { |
| 38 return object ? object->object() : 0; | 38 return object ? object->object() : nullptr; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // These enums are from manual pages for glTexStorage2D/glTexStorage3D. | 43 // These enums are from manual pages for glTexStorage2D/glTexStorage3D. |
| 44 const GLenum kSupportedInternalFormatsStorage[] = { | 44 const GLenum kSupportedInternalFormatsStorage[] = { |
| 45 GL_R8, | 45 GL_R8, |
| 46 GL_R8_SNORM, | 46 GL_R8_SNORM, |
| 47 GL_R16F, | 47 GL_R16F, |
| 48 GL_R32F, | 48 GL_R32F, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 memcpy(returnedData->data(), mappedData, returnedData->byteLength()); | 246 memcpy(returnedData->data(), mappedData, returnedData->byteLength()); |
| 247 | 247 |
| 248 webContext()->unmapBuffer(target); | 248 webContext()->unmapBuffer(target); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void WebGL2RenderingContextBase::blitFramebuffer(GLint srcX0, GLint srcY0, GLint
srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfi
eld mask, GLenum filter) | 251 void WebGL2RenderingContextBase::blitFramebuffer(GLint srcX0, GLint srcY0, GLint
srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfi
eld mask, GLenum filter) |
| 252 { | 252 { |
| 253 if (isContextLost()) | 253 if (isContextLost()) |
| 254 return; | 254 return; |
| 255 | 255 |
| 256 webContext()->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dst
Y0, dstX1, dstY1, mask, filter); | 256 contextGL()->BlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY
0, dstX1, dstY1, mask, filter); |
| 257 } | 257 } |
| 258 | 258 |
| 259 bool WebGL2RenderingContextBase::validateTexFuncLayer(const char* functionName,
GLenum texTarget, GLint layer) | 259 bool WebGL2RenderingContextBase::validateTexFuncLayer(const char* functionName,
GLenum texTarget, GLint layer) |
| 260 { | 260 { |
| 261 if (layer < 0) { | 261 if (layer < 0) { |
| 262 synthesizeGLError(GL_INVALID_VALUE, functionName, "layer out of range"); | 262 synthesizeGLError(GL_INVALID_VALUE, functionName, "layer out of range"); |
| 263 return false; | 263 return false; |
| 264 } | 264 } |
| 265 switch (texTarget) { | 265 switch (texTarget) { |
| 266 case GL_TEXTURE_3D: | 266 case GL_TEXTURE_3D: |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 return; | 1515 return; |
| 1516 } | 1516 } |
| 1517 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) | 1517 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) |
| 1518 return; | 1518 return; |
| 1519 if (!m_boundArrayBuffer) { | 1519 if (!m_boundArrayBuffer) { |
| 1520 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun
d ARRAY_BUFFER"); | 1520 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun
d ARRAY_BUFFER"); |
| 1521 return; | 1521 return; |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 m_boundVertexArrayObject->setArrayBufferForAttrib(index, m_boundArrayBuffer)
; | 1524 m_boundVertexArrayObject->setArrayBufferForAttrib(index, m_boundArrayBuffer)
; |
| 1525 webContext()->vertexAttribIPointer(index, size, type, stride, static_cast<GL
intptr>(offset)); | 1525 contextGL()->VertexAttribIPointer(index, size, type, stride, reinterpret_cas
t<void*>(static_cast<intptr_t>(offset))); |
| 1526 } | 1526 } |
| 1527 | 1527 |
| 1528 /* Writing to the drawing buffer */ | 1528 /* Writing to the drawing buffer */ |
| 1529 void WebGL2RenderingContextBase::vertexAttribDivisor(GLuint index, GLuint diviso
r) | 1529 void WebGL2RenderingContextBase::vertexAttribDivisor(GLuint index, GLuint diviso
r) |
| 1530 { | 1530 { |
| 1531 if (isContextLost()) | 1531 if (isContextLost()) |
| 1532 return; | 1532 return; |
| 1533 | 1533 |
| 1534 if (index >= m_maxVertexAttribs) { | 1534 if (index >= m_maxVertexAttribs) { |
| 1535 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisor", "index out of
range"); | 1535 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisor", "index out of
range"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 { | 1568 { |
| 1569 if (!validateDrawElements("drawRangeElements", type, offset)) | 1569 if (!validateDrawElements("drawRangeElements", type, offset)) |
| 1570 return; | 1570 return; |
| 1571 | 1571 |
| 1572 if (transformFeedbackActive() && !transformFeedbackPaused()) { | 1572 if (transformFeedbackActive() && !transformFeedbackPaused()) { |
| 1573 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "transform
feedback is active and not paused"); | 1573 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "transform
feedback is active and not paused"); |
| 1574 return; | 1574 return; |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 clearIfComposited(); | 1577 clearIfComposited(); |
| 1578 webContext()->drawRangeElements(mode, start, end, count, type, static_cast<G
Lintptr>(offset)); | 1578 contextGL()->DrawRangeElements(mode, start, end, count, type, reinterpret_ca
st<void*>(static_cast<intptr_t>(offset))); |
| 1579 markContextChanged(CanvasChanged); | 1579 markContextChanged(CanvasChanged); |
| 1580 } | 1580 } |
| 1581 | 1581 |
| 1582 void WebGL2RenderingContextBase::drawBuffers(const Vector<GLenum>& buffers) | 1582 void WebGL2RenderingContextBase::drawBuffers(const Vector<GLenum>& buffers) |
| 1583 { | 1583 { |
| 1584 if (isContextLost()) | 1584 if (isContextLost()) |
| 1585 return; | 1585 return; |
| 1586 | 1586 |
| 1587 GLsizei n = buffers.size(); | 1587 GLsizei n = buffers.size(); |
| 1588 const GLenum* bufs = buffers.data(); | 1588 const GLenum* bufs = buffers.data(); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 WebGLSync* o = WebGLFenceSync::create(this, condition, flags); | 2085 WebGLSync* o = WebGLFenceSync::create(this, condition, flags); |
| 2086 addSharedObject(o); | 2086 addSharedObject(o); |
| 2087 return o; | 2087 return o; |
| 2088 } | 2088 } |
| 2089 | 2089 |
| 2090 GLboolean WebGL2RenderingContextBase::isSync(WebGLSync* sync) | 2090 GLboolean WebGL2RenderingContextBase::isSync(WebGLSync* sync) |
| 2091 { | 2091 { |
| 2092 if (isContextLost() || !sync) | 2092 if (isContextLost() || !sync) |
| 2093 return 0; | 2093 return 0; |
| 2094 | 2094 |
| 2095 return webContext()->isSync(sync->object()); | 2095 return contextGL()->IsSync(sync->object()); |
| 2096 } | 2096 } |
| 2097 | 2097 |
| 2098 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) | 2098 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) |
| 2099 { | 2099 { |
| 2100 deleteObject(sync); | 2100 deleteObject(sync); |
| 2101 } | 2101 } |
| 2102 | 2102 |
| 2103 GLenum WebGL2RenderingContextBase::clientWaitSync(WebGLSync* sync, GLbitfield fl
ags, GLint64 timeout) | 2103 GLenum WebGL2RenderingContextBase::clientWaitSync(WebGLSync* sync, GLbitfield fl
ags, GLint64 timeout) |
| 2104 { | 2104 { |
| 2105 if (isContextLost() || !validateWebGLObject("clientWaitSync", sync)) | 2105 if (isContextLost() || !validateWebGLObject("clientWaitSync", sync)) |
| 2106 return GL_WAIT_FAILED; | 2106 return GL_WAIT_FAILED; |
| 2107 | 2107 |
| 2108 if (timeout < -1) { | 2108 if (timeout < -1) { |
| 2109 synthesizeGLError(GL_INVALID_VALUE, "clientWaitSync", "timeout < -1"); | 2109 synthesizeGLError(GL_INVALID_VALUE, "clientWaitSync", "timeout < -1"); |
| 2110 return GL_WAIT_FAILED; | 2110 return GL_WAIT_FAILED; |
| 2111 } | 2111 } |
| 2112 | 2112 |
| 2113 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint
64>(timeout); | 2113 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint
64>(timeout); |
| 2114 return webContext()->clientWaitSync(syncObjectOrZero(sync), flags, timeout64
); | 2114 return contextGL()->ClientWaitSync(syncObjectOrZero(sync), flags, timeout64)
; |
| 2115 } | 2115 } |
| 2116 | 2116 |
| 2117 void WebGL2RenderingContextBase::waitSync(WebGLSync* sync, GLbitfield flags, GLi
nt64 timeout) | 2117 void WebGL2RenderingContextBase::waitSync(WebGLSync* sync, GLbitfield flags, GLi
nt64 timeout) |
| 2118 { | 2118 { |
| 2119 if (isContextLost() || !validateWebGLObject("waitSync", sync)) | 2119 if (isContextLost() || !validateWebGLObject("waitSync", sync)) |
| 2120 return; | 2120 return; |
| 2121 | 2121 |
| 2122 if (timeout < -1) { | 2122 if (timeout < -1) { |
| 2123 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "timeout < -1"); | 2123 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "timeout < -1"); |
| 2124 return; | 2124 return; |
| 2125 } | 2125 } |
| 2126 | 2126 |
| 2127 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint
64>(timeout); | 2127 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint
64>(timeout); |
| 2128 webContext()->waitSync(syncObjectOrZero(sync), flags, timeout64); | 2128 contextGL()->WaitSync(syncObjectOrZero(sync), flags, timeout64); |
| 2129 } | 2129 } |
| 2130 | 2130 |
| 2131 ScriptValue WebGL2RenderingContextBase::getSyncParameter(ScriptState* scriptStat
e, WebGLSync* sync, GLenum pname) | 2131 ScriptValue WebGL2RenderingContextBase::getSyncParameter(ScriptState* scriptStat
e, WebGLSync* sync, GLenum pname) |
| 2132 { | 2132 { |
| 2133 if (isContextLost() || !validateWebGLObject("getSyncParameter", sync)) | 2133 if (isContextLost() || !validateWebGLObject("getSyncParameter", sync)) |
| 2134 return ScriptValue::createNull(scriptState); | 2134 return ScriptValue::createNull(scriptState); |
| 2135 | 2135 |
| 2136 switch (pname) { | 2136 switch (pname) { |
| 2137 case GL_OBJECT_TYPE: | 2137 case GL_OBJECT_TYPE: |
| 2138 case GL_SYNC_STATUS: | 2138 case GL_SYNC_STATUS: |
| 2139 case GL_SYNC_CONDITION: | 2139 case GL_SYNC_CONDITION: |
| 2140 case GL_SYNC_FLAGS: | 2140 case GL_SYNC_FLAGS: |
| 2141 { | 2141 { |
| 2142 GLint value = 0; | 2142 GLint value = 0; |
| 2143 GLsizei length = -1; | 2143 GLsizei length = -1; |
| 2144 webContext()->getSynciv(syncObjectOrZero(sync), pname, 1, &length, &
value); | 2144 contextGL()->GetSynciv(syncObjectOrZero(sync), pname, 1, &length, &v
alue); |
| 2145 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2145 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 2146 } | 2146 } |
| 2147 default: | 2147 default: |
| 2148 synthesizeGLError(GL_INVALID_ENUM, "getSyncParameter", "invalid paramete
r name"); | 2148 synthesizeGLError(GL_INVALID_ENUM, "getSyncParameter", "invalid paramete
r name"); |
| 2149 return ScriptValue::createNull(scriptState); | 2149 return ScriptValue::createNull(scriptState); |
| 2150 } | 2150 } |
| 2151 } | 2151 } |
| 2152 | 2152 |
| 2153 WebGLTransformFeedback* WebGL2RenderingContextBase::createTransformFeedback() | 2153 WebGLTransformFeedback* WebGL2RenderingContextBase::createTransformFeedback() |
| 2154 { | 2154 { |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3608 params.skipPixels = m_unpackSkipPixels; | 3608 params.skipPixels = m_unpackSkipPixels; |
| 3609 params.skipRows = m_unpackSkipRows; | 3609 params.skipRows = m_unpackSkipRows; |
| 3610 if (dimension == Tex3D) { | 3610 if (dimension == Tex3D) { |
| 3611 params.imageHeight = m_unpackImageHeight; | 3611 params.imageHeight = m_unpackImageHeight; |
| 3612 params.skipImages = m_unpackSkipImages; | 3612 params.skipImages = m_unpackSkipImages; |
| 3613 } | 3613 } |
| 3614 return params; | 3614 return params; |
| 3615 } | 3615 } |
| 3616 | 3616 |
| 3617 } // namespace blink | 3617 } // namespace blink |
| OLD | NEW |