Changeset 264889 in webkit
- Timestamp:
- Jul 25, 2020 12:48:56 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r264887 r264889 1 2020-07-25 Kenneth Russell <kbr@chromium.org> 2 3 [WebGL2] Context state updates 4 https://bugs.webkit.org/show_bug.cgi?id=209513 5 6 Reviewed by Dean Jackson. 7 8 Refactor a few methods related to context state to reduce 9 duplicated code between WebGL 1.0 and 2.0. No behavioral changes. 10 11 Covered by existing WebGL conformance tests. 12 13 * html/canvas/WebGL2RenderingContext.cpp: 14 (WebCore::WebGL2RenderingContext::validateCapability): 15 (WebCore::WebGL2RenderingContext::clear): Deleted. 16 (WebCore::WebGL2RenderingContext::hint): Deleted. 17 * html/canvas/WebGL2RenderingContext.h: 18 * html/canvas/WebGLRenderingContext.cpp: 19 (WebCore::WebGLRenderingContext::hint): Deleted. 20 (WebCore::WebGLRenderingContext::clear): Deleted. 21 (WebCore::WebGLRenderingContext::validateCapability): Deleted. 22 * html/canvas/WebGLRenderingContext.h: 23 * html/canvas/WebGLRenderingContextBase.cpp: 24 (WebCore::WebGLRenderingContextBase::clear): 25 (WebCore::WebGLRenderingContextBase::hint): 26 (WebCore::WebGLRenderingContextBase::validateCapability): 27 * html/canvas/WebGLRenderingContextBase.h: 28 1 29 2020-07-24 Brady Eidson <beidson@apple.com> 2 30 -
trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
r264845 r264889 1716 1716 } 1717 1717 1718 void WebGL2RenderingContext::clear(GCGLbitfield mask)1719 {1720 if (isContextLostOrPending())1721 return;1722 #if !USE(ANGLE)1723 if (mask & ~(GraphicsContextGL::COLOR_BUFFER_BIT | GraphicsContextGL::DEPTH_BUFFER_BIT | GraphicsContextGL::STENCIL_BUFFER_BIT)) {1724 synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "clear", "invalid mask");1725 return;1726 }1727 const char* reason = "framebuffer incomplete";1728 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContextGL(), &reason)) {1729 synthesizeGLError(GraphicsContextGL::INVALID_FRAMEBUFFER_OPERATION, "clear", reason);1730 return;1731 }1732 if (m_framebufferBinding && (mask & GraphicsContextGL::COLOR_BUFFER_BIT) && m_framebufferBinding->getColorBufferFormat() && isIntegerFormat(m_framebufferBinding->getColorBufferFormat())) {1733 synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "clear", "cannot clear an integer buffer");1734 return;1735 }1736 #endif1737 if (!clearIfComposited(mask))1738 m_context->clear(mask);1739 markContextChangedAndNotifyCanvasObserver();1740 }1741 1742 1718 void WebGL2RenderingContext::vertexAttribDivisor(GCGLuint index, GCGLuint divisor) 1743 1719 { … … 2964 2940 else 2965 2941 m_context->renderbufferStorage(target, internalformat, width, height); 2966 }2967 2968 void WebGL2RenderingContext::hint(GCGLenum target, GCGLenum mode)2969 {2970 if (isContextLostOrPending())2971 return;2972 bool isValid = false;2973 switch (target) {2974 case GraphicsContextGL::GENERATE_MIPMAP_HINT:2975 case GraphicsContextGL::FRAGMENT_SHADER_DERIVATIVE_HINT:2976 isValid = true;2977 break;2978 }2979 if (!isValid) {2980 synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "hint", "invalid target");2981 return;2982 }2983 m_context->hint(target, mode);2984 2942 } 2985 2943 … … 3348 3306 { 3349 3307 switch (cap) { 3350 case GraphicsContextGL::BLEND:3351 case GraphicsContextGL::CULL_FACE:3352 case GraphicsContextGL::DEPTH_TEST:3353 case GraphicsContextGL::DITHER:3354 case GraphicsContextGL::POLYGON_OFFSET_FILL:3355 case GraphicsContextGL::SAMPLE_ALPHA_TO_COVERAGE:3356 case GraphicsContextGL::SAMPLE_COVERAGE:3357 case GraphicsContextGL::SCISSOR_TEST:3358 case GraphicsContextGL::STENCIL_TEST:3359 3308 case GraphicsContextGL::RASTERIZER_DISCARD: 3360 3309 return true; 3361 3310 default: 3362 synthesizeGLError(GraphicsContextGL::INVALID_ENUM, functionName, "invalid capability"); 3363 return false; 3311 return WebGLRenderingContextBase::validateCapability(functionName, cap); 3364 3312 } 3365 3313 } -
trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h
r264845 r264889 179 179 180 180 // Writing to the drawing buffer 181 void clear(GCGLbitfield mask) final;182 181 void vertexAttribDivisor(GCGLuint index, GCGLuint divisor); 183 182 void drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei instanceCount); … … 256 255 void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView& dstData, GLuint dstOffset); 257 256 258 void hint(GCGLenum target, GCGLenum mode) final;259 257 GCGLuint maxTransformFeedbackSeparateAttribs() const; 260 258 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r264845 r264889 324 324 } 325 325 326 void WebGLRenderingContext::hint(GCGLenum target, GCGLenum mode)327 {328 if (isContextLostOrPending())329 return;330 bool isValid = false;331 switch (target) {332 case GraphicsContextGL::GENERATE_MIPMAP_HINT:333 isValid = true;334 break;335 case ExtensionsGL::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives336 if (m_oesStandardDerivatives)337 isValid = true;338 break;339 }340 if (!isValid) {341 synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "hint", "invalid target");342 return;343 }344 m_context->hint(target, mode);345 }346 347 void WebGLRenderingContext::clear(GCGLbitfield mask)348 {349 if (isContextLostOrPending())350 return;351 #if !USE(ANGLE)352 if (mask & ~(GraphicsContextGL::COLOR_BUFFER_BIT | GraphicsContextGL::DEPTH_BUFFER_BIT | GraphicsContextGL::STENCIL_BUFFER_BIT)) {353 synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "clear", "invalid mask");354 return;355 }356 const char* reason = "framebuffer incomplete";357 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) {358 synthesizeGLError(GraphicsContextGL::INVALID_FRAMEBUFFER_OPERATION, "clear", reason);359 return;360 }361 #endif362 if (!clearIfComposited(mask))363 m_context->clear(mask);364 markContextChangedAndNotifyCanvasObserver();365 }366 367 326 GCGLint WebGLRenderingContext::getMaxDrawBuffers() 368 327 { … … 471 430 } 472 431 473 bool WebGLRenderingContext::validateCapability(const char* functionName, GCGLenum cap)474 {475 switch (cap) {476 case GraphicsContextGL::BLEND:477 case GraphicsContextGL::CULL_FACE:478 case GraphicsContextGL::DEPTH_TEST:479 case GraphicsContextGL::DITHER:480 case GraphicsContextGL::POLYGON_OFFSET_FILL:481 case GraphicsContextGL::SAMPLE_ALPHA_TO_COVERAGE:482 case GraphicsContextGL::SAMPLE_COVERAGE:483 case GraphicsContextGL::SCISSOR_TEST:484 case GraphicsContextGL::STENCIL_TEST:485 return true;486 default:487 synthesizeGLError(GraphicsContextGL::INVALID_ENUM, functionName, "invalid capability");488 return false;489 }490 }491 492 432 } // namespace WebCore 493 433 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r264845 r264889 45 45 46 46 WebGLAny getFramebufferAttachmentParameter(GCGLenum target, GCGLenum attachment, GCGLenum pname) final; 47 void hint(GCGLenum target, GCGLenum mode) final;48 void clear(GCGLbitfield mask) final;49 47 50 48 GCGLint getMaxDrawBuffers() final; … … 53 51 bool validateIndexArrayConservative(GCGLenum type, unsigned& numElementsRequired) final; 54 52 bool validateBlendEquation(const char* functionName, GCGLenum mode) final; 55 bool validateCapability(const char* functionName, GCGLenum cap) final;56 53 57 54 private: -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r264845 r264889 1652 1652 return result; 1653 1653 #endif 1654 } 1655 1656 void WebGLRenderingContextBase::clear(GCGLbitfield mask) 1657 { 1658 if (isContextLostOrPending()) 1659 return; 1660 #if !USE(ANGLE) 1661 if (mask & ~(GraphicsContextGL::COLOR_BUFFER_BIT | GraphicsContextGL::DEPTH_BUFFER_BIT | GraphicsContextGL::STENCIL_BUFFER_BIT)) { 1662 synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "clear", "invalid mask"); 1663 return; 1664 } 1665 const char* reason = "framebuffer incomplete"; 1666 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { 1667 synthesizeGLError(GraphicsContextGL::INVALID_FRAMEBUFFER_OPERATION, "clear", reason); 1668 return; 1669 } 1670 #endif 1671 if (!clearIfComposited(mask)) 1672 m_context->clear(mask); 1673 markContextChangedAndNotifyCanvasObserver(); 1654 1674 } 1655 1675 … … 3692 3712 } 3693 3713 3714 void WebGLRenderingContextBase::hint(GCGLenum target, GCGLenum mode) 3715 { 3716 if (isContextLostOrPending()) 3717 return; 3718 bool isValid = false; 3719 switch (target) { 3720 case GraphicsContextGL::GENERATE_MIPMAP_HINT: 3721 isValid = true; 3722 break; 3723 case ExtensionsGL::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives, or core in WebGL 2.0 3724 if (m_oesStandardDerivatives || isWebGL2()) 3725 isValid = true; 3726 break; 3727 } 3728 if (!isValid) { 3729 synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "hint", "invalid target"); 3730 return; 3731 } 3732 m_context->hint(target, mode); 3733 } 3734 3694 3735 GCGLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) 3695 3736 { … … 6909 6950 } 6910 6951 6952 bool WebGLRenderingContextBase::validateCapability(const char* functionName, GCGLenum cap) 6953 { 6954 switch (cap) { 6955 case GraphicsContextGL::BLEND: 6956 case GraphicsContextGL::CULL_FACE: 6957 case GraphicsContextGL::DEPTH_TEST: 6958 case GraphicsContextGL::DITHER: 6959 case GraphicsContextGL::POLYGON_OFFSET_FILL: 6960 case GraphicsContextGL::SAMPLE_ALPHA_TO_COVERAGE: 6961 case GraphicsContextGL::SAMPLE_COVERAGE: 6962 case GraphicsContextGL::SCISSOR_TEST: 6963 case GraphicsContextGL::STENCIL_TEST: 6964 return true; 6965 default: 6966 synthesizeGLError(GraphicsContextGL::INVALID_ENUM, functionName, "invalid capability"); 6967 return false; 6968 } 6969 } 6970 6911 6971 bool WebGLRenderingContextBase::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, const Float32List& v, GCGLsizei requiredMinSize, GCGLuint srcOffset, GCGLuint srcLength) 6912 6972 { -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r264845 r264889 142 142 143 143 GCGLenum checkFramebufferStatus(GCGLenum target); 144 v irtual void clear(GCGLbitfield mask) = 0;144 void clear(GCGLbitfield mask); 145 145 void clearColor(GCGLfloat red, GCGLfloat green, GCGLfloat blue, GCGLfloat alpha); 146 146 void clearDepth(GCGLfloat); … … 224 224 void setPreventBufferClearForInspector(bool value) { m_preventBufferClearForInspector = value; } 225 225 226 v irtual void hint(GCGLenum target, GCGLenum mode) = 0;226 void hint(GCGLenum target, GCGLenum mode); 227 227 GCGLboolean isBuffer(WebGLBuffer*); 228 228 bool isContextLost() const; … … 964 964 965 965 // Helper function to validate a GL capability. 966 virtual bool validateCapability(const char* functionName, GCGLenum) = 0;966 virtual bool validateCapability(const char* functionName, GCGLenum); 967 967 968 968 // Helper function to validate input parameters for uniform functions.
Note: See TracChangeset
for help on using the changeset viewer.