Index: gpu/command_buffer/common/gles2_cmd_utils.cc |
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc |
index 25eafcd8a267fdf55826ac44a5120e77822578b0..40444bb4ce3bb67228b534793d4bb1bed2dbd927 100644 |
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc |
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc |
@@ -715,7 +715,28 @@ bool GLES2Util::ParseUniformName( |
return true; |
} |
-ContextCreationAttribParser::ContextCreationAttribParser() |
+namespace { |
+ |
+// From <EGL/egl.h>. |
+const int32 EGL_ALPHA_SIZE = 0x3021; |
+const int32 EGL_BLUE_SIZE = 0x3022; |
+const int32 EGL_GREEN_SIZE = 0x3023; |
+const int32 EGL_RED_SIZE = 0x3024; |
+const int32 EGL_DEPTH_SIZE = 0x3025; |
+const int32 EGL_STENCIL_SIZE = 0x3026; |
+const int32 EGL_SAMPLES = 0x3031; |
+const int32 EGL_SAMPLE_BUFFERS = 0x3032; |
+const int32 EGL_NONE = 0x3038; |
+const int32 EGL_SWAP_BEHAVIOR = 0x3093; |
+const int32 EGL_BUFFER_PRESERVED = 0x3094; |
+ |
+// Chromium only. |
+const int32 SHARE_RESOURCES = 0x10000; |
+const int32 BIND_GENERATES_RESOURCES = 0x10001; |
+ |
+} // namespace |
+ |
+ContextCreationAttribHelper::ContextCreationAttribHelper() |
: alpha_size_(-1), |
blue_size_(-1), |
green_size_(-1), |
@@ -729,24 +750,49 @@ ContextCreationAttribParser::ContextCreationAttribParser() |
bind_generates_resource_(true) { |
} |
-bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) { |
- // From <EGL/egl.h>. |
- const int32 EGL_ALPHA_SIZE = 0x3021; |
- const int32 EGL_BLUE_SIZE = 0x3022; |
- const int32 EGL_GREEN_SIZE = 0x3023; |
- const int32 EGL_RED_SIZE = 0x3024; |
- const int32 EGL_DEPTH_SIZE = 0x3025; |
- const int32 EGL_STENCIL_SIZE = 0x3026; |
- const int32 EGL_SAMPLES = 0x3031; |
- const int32 EGL_SAMPLE_BUFFERS = 0x3032; |
- const int32 EGL_NONE = 0x3038; |
- const int32 EGL_SWAP_BEHAVIOR = 0x3093; |
- const int32 EGL_BUFFER_PRESERVED = 0x3094; |
- |
- // Chromium only. |
- const int32 SHARE_RESOURCES = 0x10000; |
- const int32 BIND_GENERATES_RESOURCES = 0x10001; |
+void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { |
+ if (alpha_size_ != -1) { |
+ attribs->push_back(EGL_ALPHA_SIZE); |
+ attribs->push_back(alpha_size_); |
+ } |
+ if (blue_size_ != -1) { |
+ attribs->push_back(EGL_BLUE_SIZE); |
+ attribs->push_back(blue_size_); |
+ } |
+ if (green_size_ != -1) { |
+ attribs->push_back(EGL_GREEN_SIZE); |
+ attribs->push_back(green_size_); |
+ } |
+ if (red_size_ != -1) { |
+ attribs->push_back(EGL_RED_SIZE); |
+ attribs->push_back(red_size_); |
+ } |
+ if (depth_size_ != -1) { |
+ attribs->push_back(EGL_DEPTH_SIZE); |
+ attribs->push_back(depth_size_); |
+ } |
+ if (stencil_size_ != -1) { |
+ attribs->push_back(EGL_STENCIL_SIZE); |
+ attribs->push_back(stencil_size_); |
+ } |
+ if (samples_ != -1) { |
+ attribs->push_back(EGL_SAMPLES); |
+ attribs->push_back(samples_); |
+ } |
+ if (sample_buffers_ != -1) { |
+ attribs->push_back(EGL_SAMPLE_BUFFERS); |
+ attribs->push_back(sample_buffers_); |
+ } |
+ attribs->push_back(EGL_SWAP_BEHAVIOR); |
+ attribs->push_back(buffer_preserved_); |
+ attribs->push_back(SHARE_RESOURCES); |
+ attribs->push_back(share_resources_ ? 1 : 0); |
+ attribs->push_back(BIND_GENERATES_RESOURCES); |
+ attribs->push_back(bind_generates_resource_ ? 1 : 0); |
+ attribs->push_back(EGL_NONE); |
+} |
+bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
for (size_t i = 0; i < attribs.size(); i += 2) { |
const int32 attrib = attribs[i]; |
if (i + 1 >= attribs.size()) { |