summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.cc')
-rw-r--r--chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.cc b/chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.cc
new file mode 100644
index 00000000000..93dca19698a
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.cc
@@ -0,0 +1,50 @@
+// 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.
+
+#include "third_party/blink/renderer/modules/webgl/webgl_multi_draw_common.h"
+
+namespace blink {
+
+bool WebGLMultiDrawCommon::ValidateDrawcount(
+ WebGLExtensionScopedContext* scoped,
+ const char* function_name,
+ GLsizei drawcount) {
+ if (drawcount < 0) {
+ scoped->Context()->SynthesizeGLError(GL_INVALID_VALUE, function_name,
+ "negative drawcount");
+ return false;
+ }
+ return true;
+}
+
+bool WebGLMultiDrawCommon::ValidateArray(WebGLExtensionScopedContext* scoped,
+ const char* function_name,
+ const char* outOfBoundsDescription,
+ size_t size,
+ GLuint offset,
+ GLsizei drawcount) {
+ if (static_cast<uint32_t>(drawcount) > size) {
+ scoped->Context()->SynthesizeGLError(GL_INVALID_OPERATION, function_name,
+ "drawcount out of bounds");
+ return false;
+ }
+ if (offset >= size) {
+ scoped->Context()->SynthesizeGLError(GL_INVALID_OPERATION, function_name,
+ outOfBoundsDescription);
+ return false;
+ }
+ return true;
+}
+
+base::span<const int32_t> WebGLMultiDrawCommon::MakeSpan(
+ const Int32ArrayOrLongSequence& array) {
+ if (array.IsInt32Array()) {
+ return base::span<const int32_t>(array.GetAsInt32Array().View()->Data(),
+ array.GetAsInt32Array().View()->length());
+ }
+ return base::span<const int32_t>(array.GetAsLongSequence().data(),
+ array.GetAsLongSequence().size());
+}
+
+} // namespace blink