| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/gles2_conform_support/egl/config.h" | 5 #include "gpu/gles2_conform_support/egl/config.h" |
| 6 #include "base/logging.h" | |
| 7 | 6 |
| 8 namespace egl { | 7 namespace egl { |
| 9 | 8 |
| 10 Config::Config(EGLint surface_type) | 9 Config::Config() |
| 11 : buffer_size_(0), | 10 : buffer_size_(0), |
| 12 red_size_(0), | 11 red_size_(0), |
| 13 green_size_(0), | 12 green_size_(0), |
| 14 blue_size_(0), | 13 blue_size_(0), |
| 15 luminance_size_(0), | 14 luminance_size_(0), |
| 16 alpha_size_(0), | 15 alpha_size_(0), |
| 17 alpha_mask_size_(0), | 16 alpha_mask_size_(0), |
| 18 bind_to_texture_rgb_(EGL_FALSE), | 17 bind_to_texture_rgb_(EGL_FALSE), |
| 19 bind_to_texture_rgba_(EGL_FALSE), | 18 bind_to_texture_rgba_(EGL_FALSE), |
| 20 color_buffer_type_(EGL_RGB_BUFFER), | 19 color_buffer_type_(EGL_RGB_BUFFER), |
| 21 config_caveat_(EGL_NONE), | 20 config_caveat_(EGL_NONE), |
| 22 config_id_(EGL_DONT_CARE), | 21 config_id_(EGL_DONT_CARE), |
| 23 conformant_(EGL_OPENGL_ES2_BIT), | 22 conformant_(EGL_OPENGL_ES2_BIT), |
| 24 depth_size_(0), | 23 depth_size_(0), |
| 25 level_(0), | 24 level_(0), |
| 26 max_pbuffer_width_(0), | 25 max_pbuffer_width_(0), |
| 27 max_pbuffer_height_(0), | 26 max_pbuffer_height_(0), |
| 28 max_pbuffer_pixels_(0), | 27 max_pbuffer_pixels_(0), |
| 29 min_swap_interval_(EGL_DONT_CARE), | 28 min_swap_interval_(EGL_DONT_CARE), |
| 30 max_swap_interval_(EGL_DONT_CARE), | 29 max_swap_interval_(EGL_DONT_CARE), |
| 31 native_renderable_(EGL_TRUE), | 30 native_renderable_(EGL_TRUE), |
| 32 native_visual_id_(0), | 31 native_visual_id_(0), |
| 33 native_visual_type_(EGL_DONT_CARE), | 32 native_visual_type_(EGL_DONT_CARE), |
| 34 renderable_type_(EGL_OPENGL_ES2_BIT), | 33 renderable_type_(EGL_OPENGL_ES2_BIT), |
| 35 sample_buffers_(0), | 34 sample_buffers_(0), |
| 36 samples_(0), | 35 samples_(0), |
| 37 stencil_size_(0), | 36 stencil_size_(0), |
| 38 surface_type_(surface_type), | 37 surface_type_(EGL_WINDOW_BIT), |
| 39 transparent_type_(EGL_NONE), | 38 transparent_type_(EGL_NONE), |
| 40 transparent_red_value_(EGL_DONT_CARE), | 39 transparent_red_value_(EGL_DONT_CARE), |
| 41 transparent_green_value_(EGL_DONT_CARE), | 40 transparent_green_value_(EGL_DONT_CARE), |
| 42 transparent_blue_value_(EGL_DONT_CARE) { | 41 transparent_blue_value_(EGL_DONT_CARE) { |
| 43 DCHECK(surface_type == EGL_WINDOW_BIT || surface_type == EGL_PBUFFER_BIT); | |
| 44 } | 42 } |
| 45 | 43 |
| 46 Config::~Config() { | 44 Config::~Config() { |
| 47 } | 45 } |
| 48 | 46 |
| 49 bool Config::Matches(const EGLint* attrib_list) const { | |
| 50 DCHECK(ValidateAttributeList(attrib_list)); | |
| 51 if (attrib_list) { | |
| 52 for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) { | |
| 53 switch (attrib_list[i]) { | |
| 54 case EGL_SURFACE_TYPE: { | |
| 55 EGLint requested_surface_type = attrib_list[i + 1]; | |
| 56 if (requested_surface_type != EGL_DONT_CARE && | |
| 57 (requested_surface_type & surface_type_) != | |
| 58 requested_surface_type) | |
| 59 return false; | |
| 60 } | |
| 61 default: | |
| 62 break; | |
| 63 } | |
| 64 } | |
| 65 } | |
| 66 return true; | |
| 67 } | |
| 68 | |
| 69 bool Config::GetAttrib(EGLint attribute, EGLint* value) const { | 47 bool Config::GetAttrib(EGLint attribute, EGLint* value) const { |
| 70 // TODO(alokp): Find out how to get correct values. | 48 // TODO(alokp): Find out how to get correct values. |
| 71 switch (attribute) { | 49 switch (attribute) { |
| 72 case EGL_BUFFER_SIZE: | 50 case EGL_BUFFER_SIZE: |
| 73 *value = buffer_size_; | 51 *value = buffer_size_; |
| 74 break; | 52 break; |
| 75 case EGL_RED_SIZE: | 53 case EGL_RED_SIZE: |
| 76 *value = red_size_; | 54 *value = red_size_; |
| 77 break; | 55 break; |
| 78 case EGL_GREEN_SIZE: | 56 case EGL_GREEN_SIZE: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 break; | 142 break; |
| 165 case EGL_TRANSPARENT_BLUE_VALUE: | 143 case EGL_TRANSPARENT_BLUE_VALUE: |
| 166 *value = transparent_blue_value_; | 144 *value = transparent_blue_value_; |
| 167 break; | 145 break; |
| 168 default: | 146 default: |
| 169 return false; | 147 return false; |
| 170 } | 148 } |
| 171 return true; | 149 return true; |
| 172 } | 150 } |
| 173 | 151 |
| 174 bool Config::ValidateAttributeList(const EGLint* attrib_list) { | |
| 175 if (attrib_list) { | |
| 176 for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) { | |
| 177 switch (attrib_list[i]) { | |
| 178 case EGL_ALPHA_MASK_SIZE: | |
| 179 case EGL_ALPHA_SIZE: | |
| 180 case EGL_BIND_TO_TEXTURE_RGB: | |
| 181 case EGL_BIND_TO_TEXTURE_RGBA: | |
| 182 case EGL_BLUE_SIZE: | |
| 183 case EGL_BUFFER_SIZE: | |
| 184 case EGL_COLOR_BUFFER_TYPE: | |
| 185 case EGL_CONFIG_CAVEAT: | |
| 186 case EGL_CONFIG_ID: | |
| 187 case EGL_CONFORMANT: | |
| 188 case EGL_DEPTH_SIZE: | |
| 189 case EGL_GREEN_SIZE: | |
| 190 case EGL_LEVEL: | |
| 191 case EGL_LUMINANCE_SIZE: | |
| 192 case EGL_MATCH_NATIVE_PIXMAP: | |
| 193 case EGL_NATIVE_RENDERABLE: | |
| 194 case EGL_MAX_SWAP_INTERVAL: | |
| 195 case EGL_MIN_SWAP_INTERVAL: | |
| 196 case EGL_RED_SIZE: | |
| 197 case EGL_SAMPLE_BUFFERS: | |
| 198 case EGL_SAMPLES: | |
| 199 case EGL_STENCIL_SIZE: | |
| 200 case EGL_RENDERABLE_TYPE: | |
| 201 case EGL_SURFACE_TYPE: | |
| 202 case EGL_MULTISAMPLE_RESOLVE_BOX_BIT: | |
| 203 case EGL_PBUFFER_BIT: | |
| 204 case EGL_PIXMAP_BIT: | |
| 205 case EGL_SWAP_BEHAVIOR_PRESERVED_BIT: | |
| 206 case EGL_VG_ALPHA_FORMAT_PRE_BIT: | |
| 207 case EGL_VG_COLORSPACE_LINEAR_BIT: | |
| 208 case EGL_WINDOW_BIT: | |
| 209 case EGL_TRANSPARENT_TYPE: | |
| 210 case EGL_TRANSPARENT_RED_VALUE: | |
| 211 case EGL_TRANSPARENT_GREEN_VALUE: | |
| 212 case EGL_TRANSPARENT_BLUE_VALUE: | |
| 213 break; | |
| 214 default: | |
| 215 return false; | |
| 216 } | |
| 217 } | |
| 218 } | |
| 219 return true; | |
| 220 } | |
| 221 | |
| 222 } // namespace egl | 152 } // namespace egl |
| OLD | NEW |