tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WebGL2Context.h (6328B)


      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/. */
      5 
      6 #ifndef WEBGL2CONTEXT_H_
      7 #define WEBGL2CONTEXT_H_
      8 
      9 #include "WebGLContext.h"
     10 
     11 namespace mozilla {
     12 
     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
     23 
     24 class WebGL2Context final : public WebGLContext {
     25  friend class WebGLContext;
     26 
     27 public:
     28  WebGL2Context(HostWebGLContext* host, const webgl::InitContextDesc& desc)
     29      : WebGLContext(host, desc) {}
     30 
     31  virtual bool IsWebGL2() const override { return true; }
     32 
     33  virtual WebGL2Context* AsWebGL2() override { return this; }
     34 
     35  // -------------------------------------------------------------------------
     36  // Buffer objects - WebGL2ContextBuffers.cpp
     37 
     38  void CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
     39                         uint64_t readOffset, uint64_t writeOffset,
     40                         uint64_t size) const;
     41  bool GetBufferSubData(GLenum target, uint64_t srcByteOffset,
     42                        const Range<uint8_t>& dest, uint64_t numRows = 0,
     43                        uint64_t rowDataWidth = 0, uint64_t srcStride = 0,
     44                        uint64_t destStride = 0) const;
     45 
     46  // -------------------------------------------------------------------------
     47  // Framebuffer objects - WebGL2ContextFramebuffers.cpp
     48 
     49  void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
     50                       GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
     51                       GLbitfield mask, GLenum filter);
     52 
     53  void InvalidateFramebuffer(GLenum target,
     54                             const Span<const GLenum>& attachments);
     55  void InvalidateSubFramebuffer(GLenum target,
     56                                const Span<const GLenum>& attachments, GLint x,
     57                                GLint y, GLsizei width, GLsizei height);
     58  void ReadBuffer(GLenum mode);
     59 
     60  // -------------------------------------------------------------------------
     61  // Renderbuffer objects - WebGL2ContextRenderbuffers.cpp
     62 
     63  Maybe<std::vector<int32_t>> GetInternalformatParameter(GLenum target,
     64                                                         GLenum internalformat,
     65                                                         GLenum pname) const;
     66 
     67  // -------------------------------------------------------------------------
     68  // Texture objects - WebGL2ContextTextures.cpp
     69 
     70  // GL 3.0 & ES 3.0
     71  void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
     72  void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
     73 
     74  // -------------------------------------------------------------------------
     75  // Writing to the drawing buffer
     76 
     77  /* Implemented in WebGLContext
     78  void VertexAttribDivisor(GLuint index, GLuint divisor);
     79  void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
     80                           GLsizei instanceCount);
     81  void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
     82                             WebGLintptr offset, GLsizei instanceCount);
     83  */
     84 
     85  // ------------------------------------------------------------------------
     86  // Multiple Render Targets - WebGL2ContextMRTs.cpp
     87 
     88 private:
     89  bool ValidateClearBuffer(GLenum buffer, GLint drawBuffer,
     90                           webgl::AttribBaseType funcType);
     91 
     92 public:
     93  void ClearBufferfi(GLenum buffer, GLint drawBuffer, GLfloat depth,
     94                     GLint stencil);
     95  void ClearBufferTv(GLenum buffer, GLint drawBuffer,
     96                     const webgl::TypedQuad& data);
     97 
     98  // -------------------------------------------------------------------------
     99  // Sampler Objects - WebGL2ContextSamplers.cpp
    100 
    101  RefPtr<WebGLSampler> CreateSampler();
    102  void BindSampler(GLuint unit, WebGLSampler* sampler);
    103  void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
    104  void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
    105  Maybe<double> GetSamplerParameter(const WebGLSampler& sampler,
    106                                    GLenum pname) const;
    107 
    108  // -------------------------------------------------------------------------
    109  // Sync objects - WebGL2ContextSync.cpp
    110 
    111  RefPtr<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
    112  GLenum ClientWaitSync(WebGLSync& sync, GLbitfield flags, GLuint64 timeout);
    113 
    114  // -------------------------------------------------------------------------
    115  // Transform Feedback - WebGL2ContextTransformFeedback.cpp
    116 
    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;
    126 
    127  // -------------------------------------------------------------------------
    128  // Uniform Buffer Objects and Transform Feedback Buffers -
    129  // WebGL2ContextUniforms.cpp
    130  // TODO(djg): Implemented in WebGLContext
    131  /*
    132      void BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer);
    133      void BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
    134                           WebGLintptr offset, WebGLsizeiptr size);
    135  */
    136  Maybe<double> GetParameter(GLenum pname) override;
    137  Maybe<double> GetIndexedParameter(GLenum pname, uint32_t index) const;
    138 
    139  // Make the inline version from the superclass visible here.
    140  using WebGLContext::GetParameter;
    141 
    142  void UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
    143                           GLuint uniformBlockBinding);
    144 
    145 private:
    146  virtual std::unique_ptr<webgl::FormatUsageAuthority> CreateFormatUsage(
    147      gl::GLContext* gl) const override;
    148 
    149  virtual bool IsTexParamValid(GLenum pname) const override;
    150 
    151  void UpdateBoundQuery(GLenum target, WebGLQuery* query);
    152 };
    153 
    154 }  // namespace mozilla
    155 
    156 #endif