Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1812243003: Remove methods from WebGraphicsContext3D that wrap type casts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simples-tplus
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 ? reinterpret_cast<GLsync>(object->object()) : nullptr;
piman 2016/03/19 01:28:35 nit: no need for the reinterpret_cast
danakj 2016/03/21 22:02:38 Done.
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
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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 return; 1499 return;
1500 } 1500 }
1501 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) 1501 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset))
1502 return; 1502 return;
1503 if (!m_boundArrayBuffer) { 1503 if (!m_boundArrayBuffer) {
1504 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun d ARRAY_BUFFER"); 1504 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun d ARRAY_BUFFER");
1505 return; 1505 return;
1506 } 1506 }
1507 1507
1508 m_boundVertexArrayObject->setArrayBufferForAttrib(index, m_boundArrayBuffer) ; 1508 m_boundVertexArrayObject->setArrayBufferForAttrib(index, m_boundArrayBuffer) ;
1509 webContext()->vertexAttribIPointer(index, size, type, stride, static_cast<GL intptr>(offset)); 1509 contextGL()->VertexAttribIPointer(index, size, type, stride, reinterpret_cas t<void*>(static_cast<intptr_t>(offset)));
1510 } 1510 }
1511 1511
1512 /* Writing to the drawing buffer */ 1512 /* Writing to the drawing buffer */
1513 void WebGL2RenderingContextBase::vertexAttribDivisor(GLuint index, GLuint diviso r) 1513 void WebGL2RenderingContextBase::vertexAttribDivisor(GLuint index, GLuint diviso r)
1514 { 1514 {
1515 if (isContextLost()) 1515 if (isContextLost())
1516 return; 1516 return;
1517 1517
1518 if (index >= m_maxVertexAttribs) { 1518 if (index >= m_maxVertexAttribs) {
1519 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisor", "index out of range"); 1519 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisor", "index out of range");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 { 1552 {
1553 if (!validateDrawElements("drawRangeElements", type, offset)) 1553 if (!validateDrawElements("drawRangeElements", type, offset))
1554 return; 1554 return;
1555 1555
1556 if (transformFeedbackActive() && !transformFeedbackPaused()) { 1556 if (transformFeedbackActive() && !transformFeedbackPaused()) {
1557 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "transform feedback is active and not paused"); 1557 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "transform feedback is active and not paused");
1558 return; 1558 return;
1559 } 1559 }
1560 1560
1561 clearIfComposited(); 1561 clearIfComposited();
1562 webContext()->drawRangeElements(mode, start, end, count, type, static_cast<G Lintptr>(offset)); 1562 contextGL()->DrawRangeElements(mode, start, end, count, type, reinterpret_ca st<void*>(static_cast<intptr_t>(offset)));
1563 markContextChanged(CanvasChanged); 1563 markContextChanged(CanvasChanged);
1564 } 1564 }
1565 1565
1566 void WebGL2RenderingContextBase::drawBuffers(const Vector<GLenum>& buffers) 1566 void WebGL2RenderingContextBase::drawBuffers(const Vector<GLenum>& buffers)
1567 { 1567 {
1568 if (isContextLost()) 1568 if (isContextLost())
1569 return; 1569 return;
1570 1570
1571 GLsizei n = buffers.size(); 1571 GLsizei n = buffers.size();
1572 const GLenum* bufs = buffers.data(); 1572 const GLenum* bufs = buffers.data();
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 WebGLSync* o = WebGLFenceSync::create(this, condition, flags); 2069 WebGLSync* o = WebGLFenceSync::create(this, condition, flags);
2070 addSharedObject(o); 2070 addSharedObject(o);
2071 return o; 2071 return o;
2072 } 2072 }
2073 2073
2074 GLboolean WebGL2RenderingContextBase::isSync(WebGLSync* sync) 2074 GLboolean WebGL2RenderingContextBase::isSync(WebGLSync* sync)
2075 { 2075 {
2076 if (isContextLost() || !sync) 2076 if (isContextLost() || !sync)
2077 return 0; 2077 return 0;
2078 2078
2079 return webContext()->isSync(sync->object()); 2079 return contextGL()->IsSync(sync->object());
2080 } 2080 }
2081 2081
2082 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) 2082 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync)
2083 { 2083 {
2084 deleteObject(sync); 2084 deleteObject(sync);
2085 } 2085 }
2086 2086
2087 GLenum WebGL2RenderingContextBase::clientWaitSync(WebGLSync* sync, GLbitfield fl ags, GLint64 timeout) 2087 GLenum WebGL2RenderingContextBase::clientWaitSync(WebGLSync* sync, GLbitfield fl ags, GLint64 timeout)
2088 { 2088 {
2089 if (isContextLost() || !validateWebGLObject("clientWaitSync", sync)) 2089 if (isContextLost() || !validateWebGLObject("clientWaitSync", sync))
2090 return GL_WAIT_FAILED; 2090 return GL_WAIT_FAILED;
2091 2091
2092 if (timeout < -1) { 2092 if (timeout < -1) {
2093 synthesizeGLError(GL_INVALID_VALUE, "clientWaitSync", "timeout < -1"); 2093 synthesizeGLError(GL_INVALID_VALUE, "clientWaitSync", "timeout < -1");
2094 return GL_WAIT_FAILED; 2094 return GL_WAIT_FAILED;
2095 } 2095 }
2096 2096
2097 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint 64>(timeout); 2097 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint 64>(timeout);
2098 return webContext()->clientWaitSync(syncObjectOrZero(sync), flags, timeout64 ); 2098 return contextGL()->ClientWaitSync(syncObjectOrZero(sync), flags, timeout64) ;
2099 } 2099 }
2100 2100
2101 void WebGL2RenderingContextBase::waitSync(WebGLSync* sync, GLbitfield flags, GLi nt64 timeout) 2101 void WebGL2RenderingContextBase::waitSync(WebGLSync* sync, GLbitfield flags, GLi nt64 timeout)
2102 { 2102 {
2103 if (isContextLost() || !validateWebGLObject("waitSync", sync)) 2103 if (isContextLost() || !validateWebGLObject("waitSync", sync))
2104 return; 2104 return;
2105 2105
2106 if (timeout < -1) { 2106 if (timeout < -1) {
2107 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "timeout < -1"); 2107 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "timeout < -1");
2108 return; 2108 return;
2109 } 2109 }
2110 2110
2111 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint 64>(timeout); 2111 GLuint64 timeout64 = timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint 64>(timeout);
2112 webContext()->waitSync(syncObjectOrZero(sync), flags, timeout64); 2112 contextGL()->WaitSync(syncObjectOrZero(sync), flags, timeout64);
2113 } 2113 }
2114 2114
2115 ScriptValue WebGL2RenderingContextBase::getSyncParameter(ScriptState* scriptStat e, WebGLSync* sync, GLenum pname) 2115 ScriptValue WebGL2RenderingContextBase::getSyncParameter(ScriptState* scriptStat e, WebGLSync* sync, GLenum pname)
2116 { 2116 {
2117 if (isContextLost() || !validateWebGLObject("getSyncParameter", sync)) 2117 if (isContextLost() || !validateWebGLObject("getSyncParameter", sync))
2118 return ScriptValue::createNull(scriptState); 2118 return ScriptValue::createNull(scriptState);
2119 2119
2120 switch (pname) { 2120 switch (pname) {
2121 case GL_OBJECT_TYPE: 2121 case GL_OBJECT_TYPE:
2122 case GL_SYNC_STATUS: 2122 case GL_SYNC_STATUS:
2123 case GL_SYNC_CONDITION: 2123 case GL_SYNC_CONDITION:
2124 case GL_SYNC_FLAGS: 2124 case GL_SYNC_FLAGS:
2125 { 2125 {
2126 GLint value = 0; 2126 GLint value = 0;
2127 GLsizei length = -1; 2127 GLsizei length = -1;
2128 webContext()->getSynciv(syncObjectOrZero(sync), pname, 1, &length, & value); 2128 contextGL()->GetSynciv(syncObjectOrZero(sync), pname, 1, &length, &v alue);
2129 return WebGLAny(scriptState, static_cast<unsigned>(value)); 2129 return WebGLAny(scriptState, static_cast<unsigned>(value));
2130 } 2130 }
2131 default: 2131 default:
2132 synthesizeGLError(GL_INVALID_ENUM, "getSyncParameter", "invalid paramete r name"); 2132 synthesizeGLError(GL_INVALID_ENUM, "getSyncParameter", "invalid paramete r name");
2133 return ScriptValue::createNull(scriptState); 2133 return ScriptValue::createNull(scriptState);
2134 } 2134 }
2135 } 2135 }
2136 2136
2137 WebGLTransformFeedback* WebGL2RenderingContextBase::createTransformFeedback() 2137 WebGLTransformFeedback* WebGL2RenderingContextBase::createTransformFeedback()
2138 { 2138 {
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 params.skipPixels = m_unpackSkipPixels; 3592 params.skipPixels = m_unpackSkipPixels;
3593 params.skipRows = m_unpackSkipRows; 3593 params.skipRows = m_unpackSkipRows;
3594 if (dimension == Tex3D) { 3594 if (dimension == Tex3D) {
3595 params.imageHeight = m_unpackImageHeight; 3595 params.imageHeight = m_unpackImageHeight;
3596 params.skipImages = m_unpackSkipImages; 3596 params.skipImages = m_unpackSkipImages;
3597 } 3597 }
3598 return params; 3598 return params;
3599 } 3599 }
3600 3600
3601 } // namespace blink 3601 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698