Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Unified Diff: gpu/gles2_conform_support/egl/config.cc

Issue 1714883002: command_buffer_gles2: Implement EGL default Display as a global object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@command_buffer_gles2-multiple-contexts
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/gles2_conform_support/egl/config.h ('k') | gpu/gles2_conform_support/egl/context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/gles2_conform_support/egl/config.cc
diff --git a/gpu/gles2_conform_support/egl/config.cc b/gpu/gles2_conform_support/egl/config.cc
index d6ce3072c982e5f01c9194d6f1dcc9f21622e042..53bd440d7cb31bca7b3e61c78037dd7659b53e2d 100644
--- a/gpu/gles2_conform_support/egl/config.cc
+++ b/gpu/gles2_conform_support/egl/config.cc
@@ -3,10 +3,11 @@
// found in the LICENSE file.
#include "gpu/gles2_conform_support/egl/config.h"
+#include "base/logging.h"
namespace egl {
-Config::Config()
+Config::Config(EGLint surface_type)
: buffer_size_(0),
red_size_(0),
green_size_(0),
@@ -34,16 +35,37 @@ Config::Config()
sample_buffers_(0),
samples_(0),
stencil_size_(0),
- surface_type_(EGL_WINDOW_BIT),
+ surface_type_(surface_type),
transparent_type_(EGL_NONE),
transparent_red_value_(EGL_DONT_CARE),
transparent_green_value_(EGL_DONT_CARE),
transparent_blue_value_(EGL_DONT_CARE) {
+ DCHECK(surface_type == EGL_WINDOW_BIT || surface_type == EGL_PBUFFER_BIT);
}
Config::~Config() {
}
+bool Config::Matches(const EGLint* attrib_list) const {
+ DCHECK(ValidateAttributeList(attrib_list));
+ if (attrib_list) {
+ for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
+ switch (attrib_list[i]) {
+ case EGL_SURFACE_TYPE: {
+ EGLint requested_surface_type = attrib_list[i + 1];
+ if (requested_surface_type != EGL_DONT_CARE &&
+ (requested_surface_type & surface_type_) !=
+ requested_surface_type)
+ return false;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ return true;
+}
+
bool Config::GetAttrib(EGLint attribute, EGLint* value) const {
// TODO(alokp): Find out how to get correct values.
switch (attribute) {
@@ -149,4 +171,52 @@ bool Config::GetAttrib(EGLint attribute, EGLint* value) const {
return true;
}
+bool Config::ValidateAttributeList(const EGLint* attrib_list) {
+ if (attrib_list) {
+ for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
+ switch (attrib_list[i]) {
+ case EGL_ALPHA_MASK_SIZE:
+ case EGL_ALPHA_SIZE:
+ case EGL_BIND_TO_TEXTURE_RGB:
+ case EGL_BIND_TO_TEXTURE_RGBA:
+ case EGL_BLUE_SIZE:
+ case EGL_BUFFER_SIZE:
+ case EGL_COLOR_BUFFER_TYPE:
+ case EGL_CONFIG_CAVEAT:
+ case EGL_CONFIG_ID:
+ case EGL_CONFORMANT:
+ case EGL_DEPTH_SIZE:
+ case EGL_GREEN_SIZE:
+ case EGL_LEVEL:
+ case EGL_LUMINANCE_SIZE:
+ case EGL_MATCH_NATIVE_PIXMAP:
+ case EGL_NATIVE_RENDERABLE:
+ case EGL_MAX_SWAP_INTERVAL:
+ case EGL_MIN_SWAP_INTERVAL:
+ case EGL_RED_SIZE:
+ case EGL_SAMPLE_BUFFERS:
+ case EGL_SAMPLES:
+ case EGL_STENCIL_SIZE:
+ case EGL_RENDERABLE_TYPE:
+ case EGL_SURFACE_TYPE:
+ case EGL_MULTISAMPLE_RESOLVE_BOX_BIT:
+ case EGL_PBUFFER_BIT:
+ case EGL_PIXMAP_BIT:
+ case EGL_SWAP_BEHAVIOR_PRESERVED_BIT:
+ case EGL_VG_ALPHA_FORMAT_PRE_BIT:
+ case EGL_VG_COLORSPACE_LINEAR_BIT:
+ case EGL_WINDOW_BIT:
+ case EGL_TRANSPARENT_TYPE:
+ case EGL_TRANSPARENT_RED_VALUE:
+ case EGL_TRANSPARENT_GREEN_VALUE:
+ case EGL_TRANSPARENT_BLUE_VALUE:
+ break;
+ default:
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
} // namespace egl
« no previous file with comments | « gpu/gles2_conform_support/egl/config.h ('k') | gpu/gles2_conform_support/egl/context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698