Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_validation.h
blobf4059edb1b4ca7a9315a4fae98add1dd64228aaf
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Contains various validation functions for the GLES2 service.
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_H_
10 #include <algorithm>
11 #include <vector>
12 #define GLES2_GPU_SERVICE 1
13 #include "gpu/command_buffer/common/gles2_cmd_format.h"
15 namespace gpu {
16 namespace gles2 {
18 // ValueValidator returns true if a value is valid.
19 template <typename T>
20 class ValueValidator {
21 public:
22 ValueValidator() {}
24 ValueValidator(const T* valid_values, int num_values) {
25 AddValues(valid_values, num_values);
28 void AddValue(const T value) {
29 if (!IsValid(value)) {
30 valid_values_.push_back(value);
34 void AddValues(const T* valid_values, int num_values) {
35 for (int ii = 0; ii < num_values; ++ii) {
36 AddValue(valid_values[ii]);
40 void RemoveValues(const T* invalid_values, int num_values) {
41 for (int ii = 0; ii < num_values; ++ii) {
42 auto iter = std::find(
43 valid_values_.begin(), valid_values_.end(), invalid_values[ii]);
44 if (iter != valid_values_.end()) {
45 valid_values_.erase(iter);
46 DCHECK(!IsValid(invalid_values[ii]));
51 bool IsValid(const T value) const {
52 return std::find(valid_values_.begin(), valid_values_.end(), value) !=
53 valid_values_.end();
56 const std::vector<T>& GetValues() const {
57 return valid_values_;
60 private:
61 std::vector<T> valid_values_;
64 struct Validators {
65 Validators();
67 void UpdateValuesES3();
69 #include "gpu/command_buffer/service/gles2_cmd_validation_autogen.h"
72 } // namespace gles2
73 } // namespace gpu
75 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_H_