| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 struct FormatTypeCompare { | 116 struct FormatTypeCompare { |
| 117 bool operator() (const FormatType& lhs, const FormatType& rhs) const | 117 bool operator() (const FormatType& lhs, const FormatType& rhs) const |
| 118 { | 118 { |
| 119 return (lhs.internalformat < rhs.internalformat | 119 return (lhs.internalformat < rhs.internalformat |
| 120 || ((lhs.internalformat == rhs.internalformat) && (lhs.format < rhs.
format)) | 120 || ((lhs.internalformat == rhs.internalformat) && (lhs.format < rhs.
format)) |
| 121 || ((lhs.internalformat == rhs.internalformat) && (lhs.format == rhs
.format) && (lhs.type < rhs.type))); | 121 || ((lhs.internalformat == rhs.internalformat) && (lhs.format == rhs
.format) && (lhs.type < rhs.type))); |
| 122 } | 122 } |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 // ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubImage2
D to read from |
| 126 // a multisampled DrawingBuffer. In this situation, we need to blit to a single
sampled buffer |
| 127 // for reading, during which the bindings could be changed and need to be recove
red. |
| 128 class ScopedDrawingBufferBinder { |
| 129 STACK_ALLOCATED(); |
| 130 public: |
| 131 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer* fr
amebufferBinding) |
| 132 : m_drawingBuffer(drawingBuffer) |
| 133 , m_readFramebufferBinding(framebufferBinding) |
| 134 { |
| 135 // Commit DrawingBuffer if needed (e.g., for multisampling) |
| 136 if (!m_readFramebufferBinding && m_drawingBuffer) |
| 137 m_drawingBuffer->commit(); |
| 138 } |
| 139 |
| 140 ~ScopedDrawingBufferBinder() |
| 141 { |
| 142 // Restore DrawingBuffer if needed |
| 143 if (!m_readFramebufferBinding && m_drawingBuffer) |
| 144 m_drawingBuffer->restoreFramebufferBindings(); |
| 145 } |
| 146 |
| 147 private: |
| 148 DrawingBuffer* m_drawingBuffer; |
| 149 Member<WebGLFramebuffer> m_readFramebufferBinding; |
| 150 }; |
| 151 |
| 125 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
public Page::MultisamplingChangedObserver { | 152 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
public Page::MultisamplingChangedObserver { |
| 126 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); | 153 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); |
| 127 public: | 154 public: |
| 128 ~WebGLRenderingContextBase() override; | 155 ~WebGLRenderingContextBase() override; |
| 129 | 156 |
| 130 virtual unsigned version() const = 0; | 157 virtual unsigned version() const = 0; |
| 131 virtual String contextName() const = 0; | 158 virtual String contextName() const = 0; |
| 132 virtual void registerContextExtensions() = 0; | 159 virtual void registerContextExtensions() = 0; |
| 133 | 160 |
| 134 virtual void initializeNewContext(); | 161 virtual void initializeNewContext(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 GLboolean isFramebuffer(WebGLFramebuffer*); | 270 GLboolean isFramebuffer(WebGLFramebuffer*); |
| 244 GLboolean isProgram(WebGLProgram*); | 271 GLboolean isProgram(WebGLProgram*); |
| 245 GLboolean isRenderbuffer(WebGLRenderbuffer*); | 272 GLboolean isRenderbuffer(WebGLRenderbuffer*); |
| 246 GLboolean isShader(WebGLShader*); | 273 GLboolean isShader(WebGLShader*); |
| 247 GLboolean isTexture(WebGLTexture*); | 274 GLboolean isTexture(WebGLTexture*); |
| 248 | 275 |
| 249 void lineWidth(GLfloat); | 276 void lineWidth(GLfloat); |
| 250 void linkProgram(WebGLProgram*); | 277 void linkProgram(WebGLProgram*); |
| 251 void pixelStorei(GLenum pname, GLint param); | 278 void pixelStorei(GLenum pname, GLint param); |
| 252 void polygonOffset(GLfloat factor, GLfloat units); | 279 void polygonOffset(GLfloat factor, GLfloat units); |
| 253 void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum form
at, GLenum type, DOMArrayBufferView* pixels); | 280 virtual void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLe
num format, GLenum type, DOMArrayBufferView* pixels); |
| 254 void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width
, GLsizei height); | 281 void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width
, GLsizei height); |
| 255 void sampleCoverage(GLfloat value, GLboolean invert); | 282 void sampleCoverage(GLfloat value, GLboolean invert); |
| 256 void scissor(GLint x, GLint y, GLsizei width, GLsizei height); | 283 void scissor(GLint x, GLint y, GLsizei width, GLsizei height); |
| 257 void shaderSource(WebGLShader*, const String&); | 284 void shaderSource(WebGLShader*, const String&); |
| 258 void stencilFunc(GLenum func, GLint ref, GLuint mask); | 285 void stencilFunc(GLenum func, GLint ref, GLuint mask); |
| 259 void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); | 286 void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); |
| 260 void stencilMask(GLuint); | 287 void stencilMask(GLuint); |
| 261 void stencilMaskSeparate(GLenum face, GLuint mask); | 288 void stencilMaskSeparate(GLenum face, GLuint mask); |
| 262 void stencilOp(GLenum fail, GLenum zfail, GLenum zpass); | 289 void stencilOp(GLenum fail, GLenum zfail, GLenum zpass); |
| 263 void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
; | 290 void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 // Generates INVALID_ENUM and returns false if parameters are invalid. | 870 // Generates INVALID_ENUM and returns false if parameters are invalid. |
| 844 virtual bool validateReadPixelsFormatAndType(GLenum format, GLenum type); | 871 virtual bool validateReadPixelsFormatAndType(GLenum format, GLenum type); |
| 845 | 872 |
| 846 // Helper function to get expected ArrayBuffer view type for readPixels. | 873 // Helper function to get expected ArrayBuffer view type for readPixels. |
| 847 virtual DOMArrayBufferView::ViewType readPixelsExpectedArrayBufferViewType(G
Lenum type); | 874 virtual DOMArrayBufferView::ViewType readPixelsExpectedArrayBufferViewType(G
Lenum type); |
| 848 | 875 |
| 849 // Helper function to check format/type combination for readPixels. | 876 // Helper function to check format/type combination for readPixels. |
| 850 // Generates INVALID_OPERATION and returns false if the combination is unsup
ported. | 877 // Generates INVALID_OPERATION and returns false if the combination is unsup
ported. |
| 851 bool validateReadPixelsFormatTypeCombination(GLenum format, GLenum type, GLe
num readBufferInternalFormat, GLenum readBufferType); | 878 bool validateReadPixelsFormatTypeCombination(GLenum format, GLenum type, GLe
num readBufferInternalFormat, GLenum readBufferType); |
| 852 | 879 |
| 880 // Helper function to check parameters of readPixels. Returns true if all pa
rameters |
| 881 // are valid. Otherwise, generates appropriate error and returns false. |
| 882 bool validateReadPixelsFuncParameters(GLsizei width, GLsizei height, GLenum
format, GLenum type, long long bufferSize); |
| 883 |
| 853 virtual GLint getMaxTextureLevelForTarget(GLenum target); | 884 virtual GLint getMaxTextureLevelForTarget(GLenum target); |
| 854 | 885 |
| 855 // Helper function to check input level for functions {copy}Tex{Sub}Image. | 886 // Helper function to check input level for functions {copy}Tex{Sub}Image. |
| 856 // Generates GL error and returns false if level is invalid. | 887 // Generates GL error and returns false if level is invalid. |
| 857 bool validateTexFuncLevel(const char* functionName, GLenum target, GLint lev
el); | 888 bool validateTexFuncLevel(const char* functionName, GLenum target, GLint lev
el); |
| 858 | 889 |
| 859 // Helper function to check if a 64-bit value is non-negative and can fit in
to a 32-bit integer. | 890 // Helper function to check if a 64-bit value is non-negative and can fit in
to a 32-bit integer. |
| 860 // Generates GL error and returns false if not. | 891 // Generates GL error and returns false if not. |
| 861 bool validateValueFitNonNegInt32(const char* functionName, const char* param
Name, long long value); | 892 bool validateValueFitNonNegInt32(const char* functionName, const char* param
Name, long long value); |
| 862 | 893 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 static IntSize oldestContextSize(); | 1102 static IntSize oldestContextSize(); |
| 1072 }; | 1103 }; |
| 1073 | 1104 |
| 1074 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 1105 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
| 1075 | 1106 |
| 1076 } // namespace blink | 1107 } // namespace blink |
| 1077 | 1108 |
| 1078 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 1109 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
| 1079 | 1110 |
| 1080 #endif // WebGLRenderingContextBase_h | 1111 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |