summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw.h
blob: aa579c1890ae811f204e9fe6c17544ab8a0c6b71 (plain)
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
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_MULTI_DRAW_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_MULTI_DRAW_H_

#include "third_party/blink/renderer/bindings/modules/v8/int32_array_or_long_sequence.h"
#include "third_party/blink/renderer/modules/webgl/webgl_extension.h"
#include "third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {

class WebGLMultiDraw final : public WebGLExtension,
                             public WebGLMultiDrawCommon {
  DEFINE_WRAPPERTYPEINFO();

 public:
  static WebGLMultiDraw* Create(WebGLRenderingContextBase*);
  static bool Supported(WebGLRenderingContextBase*);
  static const char* ExtensionName();

  explicit WebGLMultiDraw(WebGLRenderingContextBase*);
  WebGLExtensionName GetName() const override;

  void multiDrawArraysWEBGL(GLenum mode,
                            Int32ArrayOrLongSequence firstsList,
                            GLuint firstsOffset,
                            Int32ArrayOrLongSequence countsList,
                            GLuint countsOffset,
                            GLsizei drawcount) {
    multiDrawArraysImpl(mode, MakeSpan(firstsList), firstsOffset,
                        MakeSpan(countsList), countsOffset, drawcount);
  }

  void multiDrawElementsWEBGL(GLenum mode,
                              Int32ArrayOrLongSequence countsList,
                              GLuint countsOffset,
                              GLenum type,
                              Int32ArrayOrLongSequence offsetsList,
                              GLuint offsetsOffset,
                              GLsizei drawcount) {
    multiDrawElementsImpl(mode, MakeSpan(countsList), countsOffset, type,
                          MakeSpan(offsetsList), offsetsOffset, drawcount);
  }

  void multiDrawArraysInstancedWEBGL(
      GLenum mode,
      Int32ArrayOrLongSequence firstsList,
      GLuint firstsOffset,
      Int32ArrayOrLongSequence countsList,
      GLuint countsOffset,
      Int32ArrayOrLongSequence instanceCountsList,
      GLuint instanceCountsOffset,
      GLsizei drawcount) {
    multiDrawArraysInstancedImpl(mode, MakeSpan(firstsList), firstsOffset,
                                 MakeSpan(countsList), countsOffset,
                                 MakeSpan(instanceCountsList),
                                 instanceCountsOffset, drawcount);
  }

  void multiDrawElementsInstancedWEBGL(
      GLenum mode,
      Int32ArrayOrLongSequence countsList,
      GLuint countsOffset,
      GLenum type,
      Int32ArrayOrLongSequence offsetsList,
      GLuint offsetsOffset,
      Int32ArrayOrLongSequence instanceCountsList,
      GLuint instanceCountsOffset,
      GLsizei drawcount) {
    multiDrawElementsInstancedImpl(mode, MakeSpan(countsList), countsOffset,
                                   type, MakeSpan(offsetsList), offsetsOffset,
                                   MakeSpan(instanceCountsList),
                                   instanceCountsOffset, drawcount);
  }

 private:
  void multiDrawArraysImpl(GLenum mode,
                           const base::span<const int32_t>& firsts,
                           GLuint firstsOffset,
                           const base::span<const int32_t>& counts,
                           GLuint countsOffset,
                           GLsizei drawcount);

  void multiDrawElementsImpl(GLenum mode,
                             const base::span<const int32_t>& counts,
                             GLuint countsOffset,
                             GLenum type,
                             const base::span<const int32_t>& offsets,
                             GLuint offsetsOffset,
                             GLsizei drawcount);

  void multiDrawArraysInstancedImpl(
      GLenum mode,
      const base::span<const int32_t>& firsts,
      GLuint firstsOffset,
      const base::span<const int32_t>& counts,
      GLuint countsOffset,
      const base::span<const int32_t>& instanceCounts,
      GLuint instanceCountsOffset,
      GLsizei drawcount);

  void multiDrawElementsInstancedImpl(
      GLenum mode,
      const base::span<const int32_t>& counts,
      GLuint countsOffset,
      GLenum type,
      const base::span<const int32_t>& offsets,
      GLuint offsetsOffset,
      const base::span<const int32_t>& instanceCounts,
      GLuint instanceCountsOffset,
      GLsizei drawcount);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_MULTI_DRAW_H_