diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index fc600e39b3f1be..8901681a599a66 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -1829,37 +1829,6 @@ uint32_t GLES2Util::ConvertToSizedFormat(uint32_t format, uint32_t type) { return format; } -namespace { - -// GL context configuration attributes. Those in the 16-bit range are the same -// as used by EGL. Those outside the 16-bit range are unique to Chromium. -// Attributes are matched using a closest fit algorithm. - -// From . -#include -#include -const int32_t kAlphaSize = 0x3021; // EGL_ALPHA_SIZE -const int32_t kBlueSize = 0x3022; // EGL_BLUE_SIZE -const int32_t kGreenSize = 0x3023; // EGL_GREEN_SIZE -const int32_t kRedSize = 0x3024; // EGL_RED_SIZE -const int32_t kDepthSize = 0x3025; // EGL_DEPTH_SIZE -const int32_t kStencilSize = 0x3026; // EGL_STENCIL_SIZE -const int32_t kSamples = 0x3031; // EGL_SAMPLES -const int32_t kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS -const int32_t kNone = 0x3038; // EGL_NONE -const int32_t kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR -const int32_t kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED -const int32_t kSingleBuffer = 0x3085; // EGL_SINGLE_BUFFER - -// Chromium only. -const int32_t kBindGeneratesResource = 0x10000; -const int32_t kFailIfMajorPerfCaveat = 0x10001; -const int32_t kLoseContextWhenOutOfMemory = 0x10002; -const int32_t kShouldUseNativeGMBForBackbuffer = 0x10003; -const int32_t kContextType = 0x10004; - -} // namespace - bool IsWebGLContextType(ContextType context_type) { // Switch statement to cause a compile-time error if we miss a case. switch (context_type) { @@ -1910,78 +1879,6 @@ ContextCreationAttribHelper::ContextCreationAttribHelper() = default; ContextCreationAttribHelper::ContextCreationAttribHelper( const ContextCreationAttribHelper& other) = default; -bool ContextCreationAttribHelper::Parse(const std::vector& attribs) { - for (size_t i = 0; i < attribs.size(); i += 2) { - const int32_t attrib = attribs[i]; - if (i + 1 >= attribs.size()) { - if (attrib == kNone) { - return true; - } - - DLOG(ERROR) << "Missing value after context creation attribute: " - << attrib; - return false; - } - - const int32_t value = attribs[i + 1]; - switch (attrib) { - case kAlphaSize: - alpha_size = value; - break; - case kBlueSize: - blue_size = value; - break; - case kGreenSize: - green_size = value; - break; - case kRedSize: - red_size = value; - break; - case kDepthSize: - depth_size = value; - break; - case kStencilSize: - stencil_size = value; - break; - case kSamples: - samples = value; - break; - case kSampleBuffers: - sample_buffers = value; - break; - case kSwapBehavior: - buffer_preserved = value == kBufferPreserved; - break; - case kBindGeneratesResource: - bind_generates_resource = value != 0; - break; - case kFailIfMajorPerfCaveat: - fail_if_major_perf_caveat = value != 0; - break; - case kLoseContextWhenOutOfMemory: - lose_context_when_out_of_memory = value != 0; - break; - case kShouldUseNativeGMBForBackbuffer: - should_use_native_gmb_for_backbuffer = value != 0; - break; - case kSingleBuffer: - single_buffer = value != 0; - break; - case kContextType: - context_type = static_cast(value); - break; - case kNone: - // Terminate list, even if more attributes. - return true; - default: - DLOG(ERROR) << "Invalid context creation attribute: " << attrib; - return false; - } - } - - return true; -} - #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" } // namespace gles2 diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index 0044d5b0cad63c..66c2991b97422d 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -323,8 +323,6 @@ struct GLES2_UTILS_EXPORT ContextCreationAttribHelper { ContextCreationAttribHelper(); ContextCreationAttribHelper(const ContextCreationAttribHelper& other); - bool Parse(const std::vector& attribs); - gfx::Size offscreen_framebuffer_size; gl::GpuPreference gpu_preference = gl::PreferIntegratedGpu; // -1 if invalid or unspecified. diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index b2cd6e5fa83c46..973e46de902926 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -169,36 +169,61 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( } gpu::gles2::ContextCreationAttribHelper attrib_helper; - std::vector attribs; if (attrib_list) { for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; attr += 2) { - switch (attr[0]) { + int32_t key = attr[0]; + int32_t value = attr[1]; + switch (key) { + case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: + attrib_helper.alpha_size = value; + break; + case PP_GRAPHICS3DATTRIB_BLUE_SIZE: + attrib_helper.blue_size = value; + break; + case PP_GRAPHICS3DATTRIB_GREEN_SIZE: + attrib_helper.green_size = value; + break; + case PP_GRAPHICS3DATTRIB_RED_SIZE: + attrib_helper.red_size = value; + break; + case PP_GRAPHICS3DATTRIB_DEPTH_SIZE: + attrib_helper.depth_size = value; + break; + case PP_GRAPHICS3DATTRIB_STENCIL_SIZE: + attrib_helper.stencil_size = value; + break; + case PP_GRAPHICS3DATTRIB_SAMPLES: + attrib_helper.samples = value; + break; + case PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: + attrib_helper.sample_buffers = value; + break; + case PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: + attrib_helper.buffer_preserved = + value == PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED; + break; case PP_GRAPHICS3DATTRIB_WIDTH: - attrib_helper.offscreen_framebuffer_size.set_width(attr[1]); + attrib_helper.offscreen_framebuffer_size.set_width(value); break; case PP_GRAPHICS3DATTRIB_HEIGHT: - attrib_helper.offscreen_framebuffer_size.set_height(attr[1]); + attrib_helper.offscreen_framebuffer_size.set_height(value); break; case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: attrib_helper.gpu_preference = - (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) + (value == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) ? gl::PreferIntegratedGpu : gl::PreferDiscreteGpu; break; case PP_GRAPHICS3DATTRIB_SINGLE_BUFFER: - attrib_helper.single_buffer = !!attr[1]; + attrib_helper.single_buffer = !!value; break; default: - attribs.push_back(attr[0]); - attribs.push_back(attr[1]); - break; + DLOG(ERROR) << "Invalid context creation attribute: " << attr[0]; + return 0; } } - attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); } - if (!attrib_helper.Parse(attribs)) - return 0; HostResource result; gpu::Capabilities capabilities;