Bug 1700051: part 26) Correct typo in comment of `mozInlineSpellWordUtil::BuildSoftTe...
[gecko.git] / dom / canvas / WebGL2Context.h
blob60a8ce429463c7e435ced1f5e910465262f7ba36
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WEBGL2CONTEXT_H_
7 #define WEBGL2CONTEXT_H_
9 #include "WebGLContext.h"
11 namespace mozilla {
13 class ErrorResult;
14 class HostWebGLContext;
15 class WebGLSampler;
16 class WebGLSync;
17 class WebGLTransformFeedback;
18 class WebGLVertexArrayObject;
19 namespace dom {
20 class OwningUnsignedLongOrUint32ArrayOrBoolean;
21 class OwningWebGLBufferOrLongLong;
22 } // namespace dom
24 class WebGL2Context final : public WebGLContext {
25 friend class WebGLContext;
27 public:
28 WebGL2Context(HostWebGLContext& host, const webgl::InitContextDesc& desc)
29 : WebGLContext(host, desc) {}
31 virtual bool IsWebGL2() const override { return true; }
33 // -------------------------------------------------------------------------
34 // Buffer objects - WebGL2ContextBuffers.cpp
36 void CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
37 uint64_t readOffset, uint64_t writeOffset,
38 uint64_t size) const;
39 bool GetBufferSubData(GLenum target, uint64_t srcByteOffset,
40 const Range<uint8_t>& dest) const;
42 // -------------------------------------------------------------------------
43 // Framebuffer objects - WebGL2ContextFramebuffers.cpp
45 void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
46 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
47 GLbitfield mask, GLenum filter);
49 void InvalidateFramebuffer(GLenum target,
50 const Range<const GLenum>& attachments);
51 void InvalidateSubFramebuffer(GLenum target,
52 const Range<const GLenum>& attachments, GLint x,
53 GLint y, GLsizei width, GLsizei height);
54 void ReadBuffer(GLenum mode);
56 // -------------------------------------------------------------------------
57 // Renderbuffer objects - WebGL2ContextRenderbuffers.cpp
59 Maybe<std::vector<int32_t>> GetInternalformatParameter(GLenum target,
60 GLenum internalformat,
61 GLenum pname) const;
63 // -------------------------------------------------------------------------
64 // Texture objects - WebGL2ContextTextures.cpp
66 // GL 3.0 & ES 3.0
67 void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
68 void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
70 // -------------------------------------------------------------------------
71 // Writing to the drawing buffer
73 /* Implemented in WebGLContext
74 void VertexAttribDivisor(GLuint index, GLuint divisor);
75 void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
76 GLsizei instanceCount);
77 void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
78 WebGLintptr offset, GLsizei instanceCount);
81 // ------------------------------------------------------------------------
82 // Multiple Render Targets - WebGL2ContextMRTs.cpp
84 private:
85 bool ValidateClearBuffer(GLenum buffer, GLint drawBuffer,
86 webgl::AttribBaseType funcType);
88 public:
89 void ClearBufferfi(GLenum buffer, GLint drawBuffer, GLfloat depth,
90 GLint stencil);
91 void ClearBufferTv(GLenum buffer, GLint drawBuffer,
92 const webgl::TypedQuad& data);
94 // -------------------------------------------------------------------------
95 // Sampler Objects - WebGL2ContextSamplers.cpp
97 RefPtr<WebGLSampler> CreateSampler();
98 void BindSampler(GLuint unit, WebGLSampler* sampler);
99 void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
100 void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
101 Maybe<double> GetSamplerParameter(const WebGLSampler& sampler,
102 GLenum pname) const;
104 // -------------------------------------------------------------------------
105 // Sync objects - WebGL2ContextSync.cpp
107 const GLuint64 kMaxClientWaitSyncTimeoutNS =
108 1000 * 1000 * 1000; // 1000ms in ns.
110 RefPtr<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
111 GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags,
112 GLuint64 timeout);
114 // -------------------------------------------------------------------------
115 // Transform Feedback - WebGL2ContextTransformFeedback.cpp
117 RefPtr<WebGLTransformFeedback> CreateTransformFeedback();
118 void BindTransformFeedback(WebGLTransformFeedback* tf);
119 void BeginTransformFeedback(GLenum primitiveMode);
120 void EndTransformFeedback();
121 void PauseTransformFeedback();
122 void ResumeTransformFeedback();
123 void TransformFeedbackVaryings(WebGLProgram& program,
124 const std::vector<std::string>& varyings,
125 GLenum bufferMode) const;
127 // -------------------------------------------------------------------------
128 // Uniform Buffer Objects and Transform Feedback Buffers -
129 // WebGL2ContextUniforms.cpp
130 // TODO(djg): Implemented in WebGLContext
132 void BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer);
133 void BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
134 WebGLintptr offset, WebGLsizeiptr size);
136 Maybe<double> GetParameter(GLenum pname) override;
137 Maybe<double> GetIndexedParameter(GLenum pname, uint32_t index) const;
139 // Make the inline version from the superclass visible here.
140 using WebGLContext::GetParameter;
142 void UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
143 GLuint uniformBlockBinding);
145 private:
146 virtual UniquePtr<webgl::FormatUsageAuthority> CreateFormatUsage(
147 gl::GLContext* gl) const override;
149 virtual bool IsTexParamValid(GLenum pname) const override;
151 void UpdateBoundQuery(GLenum target, WebGLQuery* query);
154 } // namespace mozilla
156 #endif