1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
|
/*
* Copyright (C) 2015-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#if ENABLE(WEBGL)
#include "WebGLRenderingContextBase.h"
#include <memory>
#include <optional>
namespace WebCore {
#if ENABLE(WEB_CODECS)
class WebCodecsVideoFrame;
#endif
class WebGLQuery;
class WebGLSampler;
class WebGLSync;
class WebGLTransformFeedback;
class WebGLVertexArrayObject;
class WebGL2RenderingContext final : public WebGLRenderingContextBase {
WTF_MAKE_ISO_ALLOCATED(WebGL2RenderingContext);
public:
static std::unique_ptr<WebGL2RenderingContext> create(CanvasBase&, Ref<GraphicsContextGL>&&, GraphicsContextGLAttributes);
~WebGL2RenderingContext();
// Context state
void pixelStorei(GCGLenum pname, GCGLint param) override;
// Buffer objects
using WebGLRenderingContextBase::bufferData;
using WebGLRenderingContextBase::bufferSubData;
void bufferData(GCGLenum target, const ArrayBufferView& data, GCGLenum usage, GCGLuint srcOffset, GCGLuint length);
void bufferSubData(GCGLenum target, long long offset, const ArrayBufferView& data, GCGLuint srcOffset, GCGLuint length);
void copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLint64 readOffset, GCGLint64 writeOffset, GCGLint64 size);
void getBufferSubData(GCGLenum target, long long srcByteOffset, RefPtr<ArrayBufferView>&& dstData, GCGLuint dstOffset = 0, GCGLuint length = 0);
// Framebuffer objects
WebGLAny getFramebufferAttachmentParameter(GCGLenum target, GCGLenum attachment, GCGLenum pname) final;
void bindFramebuffer(GCGLenum target, WebGLFramebuffer*) final;
void blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGLint srcX1, GCGLint srcY1, GCGLint dstX0, GCGLint dstY0, GCGLint dstX1, GCGLint dstY1, GCGLbitfield mask, GCGLenum filter);
void deleteFramebuffer(WebGLFramebuffer*) final;
void framebufferTextureLayer(GCGLenum target, GCGLenum attachment, WebGLTexture*, GCGLint level, GCGLint layer);
WebGLAny getInternalformatParameter(GCGLenum target, GCGLenum internalformat, GCGLenum pname);
void invalidateFramebuffer(GCGLenum target, const Vector<GCGLenum>& attachments);
void invalidateSubFramebuffer(GCGLenum target, const Vector<GCGLenum>& attachments, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height);
void readBuffer(GCGLenum src);
// Renderbuffer objects
void renderbufferStorageMultisample(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height);
// Texture objects
WebGLAny getTexParameter(GCGLenum target, GCGLenum pname) final;
void texStorage2D(GCGLenum target, GCGLsizei levels, GCGLenum internalFormat, GCGLsizei width, GCGLsizei height);
void texStorage3D(GCGLenum target, GCGLsizei levels, GCGLenum internalFormat, GCGLsizei width, GCGLsizei height, GCGLsizei depth);
using TexImageSource = std::variant<RefPtr<ImageBitmap>, RefPtr<ImageData>, RefPtr<HTMLImageElement>, RefPtr<HTMLCanvasElement>
#if ENABLE(VIDEO)
, RefPtr<HTMLVideoElement>
#endif
#if ENABLE(OFFSCREEN_CANVAS)
, RefPtr<OffscreenCanvas>
#endif
#if ENABLE(WEB_CODECS)
, RefPtr<WebCodecsVideoFrame>
#endif
>;
// Must override the WebGL 1.0 signatures to add extra validation.
void texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&&) override;
ExceptionOr<void> texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLenum format, GCGLenum type, std::optional<TexImageSource>) override;
// WebGL 2.0 entry points:
void texImage2D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLintptr offset);
ExceptionOr<void> texImage2D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, TexImageSource&&);
void texImage2D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& srcData, GCGLuint srcOffset);
void texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, GCGLint64 pboOffset);
ExceptionOr<void> texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, TexImageSource&&);
void texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& pixels);
void texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& srcData, GCGLuint srcOffset);
// Must override the WebGL 1.0 signature to add extra validation.
void texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&&) override;
ExceptionOr<void> texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLenum format, GCGLenum type, std::optional<TexImageSource>&&) override;
// WebGL 2.0 entry points:
void texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr pboOffset);
ExceptionOr<void> texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, TexImageSource&&);
void texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& srcData, GCGLuint srcOffset);
void texSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLint64 pboOffset);
void texSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& pixels, GCGLuint srcOffset);
ExceptionOr<void> texSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, TexImageSource&&);
void copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height);
// Must override the WebGL 1.0 signature in order to add extra validation.
void compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, ArrayBufferView& srcData);
// WebGL 2.0 entry points:
void compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLsizei imageSize, GCGLint64 offset);
void compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, ArrayBufferView& srcData, GCGLuint srcOffset, GCGLuint srcLengthOverride);
void compressedTexImage3D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLsizei imageSize, GCGLint64 offset);
void compressedTexImage3D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, ArrayBufferView& srcData, GCGLuint srcOffset, GCGLuint srcLengthOverride);
// Must override the WebGL 1.0 signature in order to add extra validation.
void compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, ArrayBufferView& srcData);
// WebGL 2.0 entry points:
void compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset);
void compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, ArrayBufferView& srcData, GCGLuint srcOffset, GCGLuint srcLengthOverride);
void compressedTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLint64 offset);
void compressedTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, ArrayBufferView& srcData, GCGLuint srcOffset, GCGLuint srcLengthOverride);
// Programs and shaders
GCGLint getFragDataLocation(WebGLProgram&, const String& name);
// Uniforms and attributes
using Uint32List = TypedList<Uint32Array, uint32_t>;
using Float32List = TypedList<Float32Array, float>;
void uniform1ui(const WebGLUniformLocation*, GCGLuint v0);
void uniform2ui(const WebGLUniformLocation*, GCGLuint v0, GCGLuint v1);
void uniform3ui(const WebGLUniformLocation*, GCGLuint v0, GCGLuint v1, GCGLuint v2);
void uniform4ui(const WebGLUniformLocation*, GCGLuint v0, GCGLuint v1, GCGLuint v2, GCGLuint v3);
void uniform1uiv(const WebGLUniformLocation*, Uint32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform2uiv(const WebGLUniformLocation*, Uint32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform3uiv(const WebGLUniformLocation*, Uint32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform4uiv(const WebGLUniformLocation*, Uint32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix2x3fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& value, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix3x2fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& value, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix2x4fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& value, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix4x2fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& value, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix3x4fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& value, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix4x3fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& value, GCGLuint srcOffset, GCGLuint srcLength);
void vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint y, GCGLint z, GCGLint w);
void vertexAttribI4iv(GCGLuint index, Int32List&& v);
void vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLuint y, GCGLuint z, GCGLuint w);
void vertexAttribI4uiv(GCGLuint index, Uint32List&& v);
void vertexAttribIPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLsizei stride, GCGLint64 offset);
using WebGLRenderingContextBase::uniform1fv;
using WebGLRenderingContextBase::uniform2fv;
using WebGLRenderingContextBase::uniform3fv;
using WebGLRenderingContextBase::uniform4fv;
void uniform1fv(const WebGLUniformLocation*, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform2fv(const WebGLUniformLocation*, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform3fv(const WebGLUniformLocation*, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform4fv(const WebGLUniformLocation*, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
using WebGLRenderingContextBase::uniform1iv;
using WebGLRenderingContextBase::uniform2iv;
using WebGLRenderingContextBase::uniform3iv;
using WebGLRenderingContextBase::uniform4iv;
void uniform1iv(const WebGLUniformLocation*, Int32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform2iv(const WebGLUniformLocation*, Int32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform3iv(const WebGLUniformLocation*, Int32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniform4iv(const WebGLUniformLocation*, Int32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
using WebGLRenderingContextBase::uniformMatrix2fv;
using WebGLRenderingContextBase::uniformMatrix3fv;
using WebGLRenderingContextBase::uniformMatrix4fv;
void uniformMatrix2fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix3fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
void uniformMatrix4fv(const WebGLUniformLocation*, GCGLboolean transpose, Float32List&& data, GCGLuint srcOffset, GCGLuint srcLength);
// Writing to the drawing buffer
void vertexAttribDivisor(GCGLuint index, GCGLuint divisor);
void drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei instanceCount);
void drawElementsInstanced(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLint64 offset, GCGLsizei instanceCount);
void drawRangeElements(GCGLenum mode, GCGLuint start, GCGLuint end, GCGLsizei count, GCGLenum type, GCGLint64 offset);
// Multiple render targets
void drawBuffers(const Vector<GCGLenum>& buffers);
void clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, Int32List&& values, GCGLuint srcOffset);
void clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, Uint32List&& values, GCGLuint srcOffset);
void clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, Float32List&& values, GCGLuint srcOffset);
void clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil);
// Query objects
RefPtr<WebGLQuery> createQuery();
void deleteQuery(WebGLQuery*);
GCGLboolean isQuery(WebGLQuery*);
void beginQuery(GCGLenum target, WebGLQuery&);
void endQuery(GCGLenum target);
WebGLAny getQuery(GCGLenum target, GCGLenum pname);
WebGLAny getQueryParameter(WebGLQuery&, GCGLenum pname);
// Sampler objects
RefPtr<WebGLSampler> createSampler();
void deleteSampler(WebGLSampler*);
GCGLboolean isSampler(WebGLSampler*);
void bindSampler(GCGLuint unit, WebGLSampler*);
void samplerParameteri(WebGLSampler&, GCGLenum pname, GCGLint param);
void samplerParameterf(WebGLSampler&, GCGLenum pname, GCGLfloat param);
WebGLAny getSamplerParameter(WebGLSampler&, GCGLenum pname);
// Sync objects
RefPtr<WebGLSync> fenceSync(GCGLenum condition, GCGLbitfield flags);
GCGLboolean isSync(WebGLSync*);
void deleteSync(WebGLSync*);
GCGLenum clientWaitSync(WebGLSync&, GCGLbitfield flags, GCGLuint64 timeout);
void waitSync(WebGLSync&, GCGLbitfield flags, GCGLint64 timeout);
WebGLAny getSyncParameter(WebGLSync&, GCGLenum pname);
// Transform feedback
RefPtr<WebGLTransformFeedback> createTransformFeedback();
void deleteTransformFeedback(WebGLTransformFeedback* id);
GCGLboolean isTransformFeedback(WebGLTransformFeedback* id);
void bindTransformFeedback(GCGLenum target, WebGLTransformFeedback* id);
void beginTransformFeedback(GCGLenum primitiveMode);
void endTransformFeedback();
void transformFeedbackVaryings(WebGLProgram&, const Vector<String>& varyings, GCGLenum bufferMode);
RefPtr<WebGLActiveInfo> getTransformFeedbackVarying(WebGLProgram&, GCGLuint index);
void pauseTransformFeedback();
void resumeTransformFeedback();
// Uniform buffer objects and transform feedback buffers
void bindBufferBase(GCGLenum target, GCGLuint index, WebGLBuffer*);
void bindBufferRange(GCGLenum target, GCGLuint index, WebGLBuffer*, GCGLint64 offset, GCGLint64 size);
WebGLAny getIndexedParameter(GCGLenum target, GCGLuint index);
std::optional<Vector<GCGLuint>> getUniformIndices(WebGLProgram&, const Vector<String>& uniformNames);
WebGLAny getActiveUniforms(WebGLProgram&, const Vector<GCGLuint>& uniformIndices, GCGLenum pname);
GCGLuint getUniformBlockIndex(WebGLProgram&, const String& uniformBlockName);
WebGLAny getActiveUniformBlockParameter(WebGLProgram&, GCGLuint uniformBlockIndex, GCGLenum pname);
WebGLAny getActiveUniformBlockName(WebGLProgram&, GCGLuint uniformBlockIndex);
void uniformBlockBinding(WebGLProgram&, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding);
// Vertex array objects
RefPtr<WebGLVertexArrayObject> createVertexArray();
void deleteVertexArray(WebGLVertexArrayObject* vertexArray);
GCGLboolean isVertexArray(WebGLVertexArrayObject* vertexArray);
void bindVertexArray(WebGLVertexArrayObject* vertexArray);
WebGLExtension* getExtension(const String&) final;
std::optional<Vector<String>> getSupportedExtensions() final;
WebGLAny getParameter(GCGLenum pname) final;
// Must override the WebGL 1.0 signature in order to add extra validation.
void readPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& pixels) override;
void readPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset);
void readPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, ArrayBufferView& dstData, GCGLuint dstOffset);
GCGLuint maxTransformFeedbackSeparateAttribs() const;
bool checkAndTranslateAttachments(const char* functionName, GCGLenum, Vector<GCGLenum>&);
void addMembersToOpaqueRoots(JSC::AbstractSlotVisitor&) override;
bool isTransformFeedbackActiveAndNotPaused();
private:
WebGL2RenderingContext(CanvasBase&, Ref<GraphicsContextGL>&&, GraphicsContextGLAttributes);
bool isWebGL2() const final { return true; }
void initializeNewContext() final;
RefPtr<ArrayBufferView> arrayBufferViewSliceFactory(const char* const functionName, const ArrayBufferView& data, unsigned startByte, unsigned bytelength);
RefPtr<ArrayBufferView> sliceArrayBufferView(const char* const functionName, const ArrayBufferView& data, GCGLuint srcOffset, GCGLuint length);
long long getInt64Parameter(GCGLenum) final;
Vector<bool> getIndexedBooleanArrayParameter(GCGLenum pname, GCGLuint index);
void initializeVertexArrayObjects() final;
bool validateBufferTarget(const char* functionName, GCGLenum target) final;
bool validateBufferTargetCompatibility(const char*, GCGLenum, WebGLBuffer*);
WebGLBuffer* validateBufferDataParameters(const char* functionName, GCGLenum target, GCGLenum usage) final;
WebGLBuffer* validateBufferDataTarget(const char* functionName, GCGLenum target) final;
bool validateAndCacheBufferBinding(const AbstractLocker&, const char* functionName, GCGLenum target, WebGLBuffer*) final;
GCGLint getMaxDrawBuffers() final;
GCGLint getMaxColorAttachments() final;
bool validateBlendEquation(const char* functionName, GCGLenum mode) final;
bool validateCapability(const char* functionName, GCGLenum cap) final;
template<typename T, typename TypedArrayType>
std::optional<std::span<const T>> validateClearBuffer(const char* functionName, GCGLenum buffer, TypedList<TypedArrayType, T>& values, GCGLuint srcOffset);
bool validateFramebufferTarget(GCGLenum target) final;
WebGLFramebuffer* getFramebufferBinding(GCGLenum target) final;
WebGLFramebuffer* getReadFramebufferBinding() final;
void restoreCurrentFramebuffer() final;
bool validateNonDefaultFramebufferAttachment(const char* functionName, GCGLenum attachment);
enum ActiveQueryKey { SamplesPassed = 0, PrimitivesWritten = 1, TimeElapsed = 2, NumKeys = 3 };
std::optional<ActiveQueryKey> validateQueryTarget(const char* functionName, GCGLenum target);
void renderbufferStorageImpl(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, const char* functionName) final;
void renderbufferStorageHelper(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height);
bool setIndexedBufferBinding(const char *functionName, GCGLenum target, GCGLuint index, WebGLBuffer*);
IntRect getTextureSourceSubRectangle(GCGLsizei width, GCGLsizei height);
RefPtr<WebGLTexture> validateTexImageBinding(TexImageFunctionID, GCGLenum) final;
// Helper function to check texture 3D target and texture bound to the target.
// Generate GL errors and return 0 if target is invalid or texture bound is
// null. Otherwise, return the texture bound to the target.
RefPtr<WebGLTexture> validateTexture3DBinding(const char* functionName, GCGLenum target);
// Helper function to check immutable texture 2D target and texture bound to the target.
// Generate GL errors and return 0 if target is invalid or texture bound is
// null. Otherwise, return the texture bound to the target.
RefPtr<WebGLTexture> validateTextureStorage2DBinding(const char* functionName, GCGLenum target);
bool validateTexFuncLayer(const char*, GCGLenum texTarget, GCGLint layer);
GCGLint maxTextureLevelForTarget(GCGLenum target) final;
void uncacheDeletedBuffer(const AbstractLocker&, WebGLBuffer*) final;
enum class ClearBufferCaller : uint8_t {
ClearBufferiv,
ClearBufferuiv,
ClearBufferfv,
ClearBufferfi
};
void updateBuffersToAutoClear(ClearBufferCaller, GCGLenum buffer, GCGLint drawbuffer);
RefPtr<WebGLFramebuffer> m_readFramebufferBinding;
RefPtr<WebGLTransformFeedback> m_boundTransformFeedback;
RefPtr<WebGLTransformFeedback> m_defaultTransformFeedback;
RefPtr<WebGLBuffer> m_boundCopyReadBuffer;
RefPtr<WebGLBuffer> m_boundCopyWriteBuffer;
RefPtr<WebGLBuffer> m_boundPixelPackBuffer;
RefPtr<WebGLBuffer> m_boundPixelUnpackBuffer;
RefPtr<WebGLBuffer> m_boundTransformFeedbackBuffer;
RefPtr<WebGLBuffer> m_boundUniformBuffer;
Vector<RefPtr<WebGLBuffer>> m_boundIndexedUniformBuffers;
RefPtr<WebGLQuery> m_activeQueries[ActiveQueryKey::NumKeys];
Vector<RefPtr<WebGLSampler>> m_boundSamplers;
GCGLint m_uniformBufferOffsetAlignment { 0 };
GCGLuint m_maxTransformFeedbackSeparateAttribs { 0 };
GCGLint m_max3DTextureSize { 0 };
GCGLint m_max3DTextureLevel { 0 };
GCGLint m_maxArrayTextureLayers { 0 };
};
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGL2RenderingContext, isWebGL2())
#endif // WEBGL
|