Index: ppapi/proxy/ppb_graphics_3d_proxy.cc |
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc |
index ca29adc29bdfca26847a6a3d13cae1fd8d6d6f68..ac08224b5063d8f18578ac41367fdd56b7fc3fa7 100644 |
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc |
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc |
@@ -175,24 +175,42 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( |
share_gles2 = share_graphics->gles2_impl(); |
} |
+ gpu::gles2::ContextCreationAttribHelper attrib_helper; |
std::vector<int32_t> attribs; |
if (attrib_list) { |
- for (const int32_t* attr = attrib_list; |
- attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
+ for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
attr += 2) { |
- attribs.push_back(attr[0]); |
- attribs.push_back(attr[1]); |
+ switch (attr[0]) { |
+ case PP_GRAPHICS3DATTRIB_WIDTH: |
+ attrib_helper.offscreen_framebuffer_size.set_width(attr[1]); |
+ break; |
+ case PP_GRAPHICS3DATTRIB_HEIGHT: |
+ attrib_helper.offscreen_framebuffer_size.set_height(attr[1]); |
+ break; |
+ case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: |
+ attrib_helper.gpu_preference = |
+ (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) |
+ ? gl::PreferIntegratedGpu |
+ : gl::PreferDiscreteGpu; |
+ break; |
+ default: |
+ attribs.push_back(attr[0]); |
+ attribs.push_back(attr[1]); |
+ break; |
+ } |
} |
+ attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
} |
- attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
+ if (!attrib_helper.Parse(attribs)) |
+ return 0; |
HostResource result; |
gpu::Capabilities capabilities; |
ppapi::proxy::SerializedHandle shared_state; |
gpu::CommandBufferId command_buffer_id; |
- dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D, |
- instance, share_host, attribs, &result, &capabilities, &shared_state, |
- &command_buffer_id)); |
+ dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( |
+ API_ID_PPB_GRAPHICS_3D, instance, share_host, attrib_helper, &result, |
+ &capabilities, &shared_state, &command_buffer_id)); |
if (result.is_null()) |
return 0; |
@@ -243,16 +261,12 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
void PPB_Graphics3D_Proxy::OnMsgCreate( |
PP_Instance instance, |
HostResource share_context, |
- const std::vector<int32_t>& attribs, |
+ const gpu::gles2::ContextCreationAttribHelper& attrib_helper, |
HostResource* result, |
gpu::Capabilities* capabilities, |
SerializedHandle* shared_state, |
gpu::CommandBufferId* command_buffer_id) { |
shared_state->set_null_shmem(); |
- if (attribs.empty() || |
- attribs.back() != PP_GRAPHICS3DATTRIB_NONE || |
- !(attribs.size() & 1)) |
- return; // Bad message. |
thunk::EnterResourceCreation enter(instance); |
@@ -261,13 +275,9 @@ void PPB_Graphics3D_Proxy::OnMsgCreate( |
base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle(); |
result->SetHostResource( |
- instance, |
- enter.functions()->CreateGraphics3DRaw(instance, |
- share_context.host_resource(), |
- &attribs.front(), |
- capabilities, |
- &handle, |
- command_buffer_id)); |
+ instance, enter.functions()->CreateGraphics3DRaw( |
+ instance, share_context.host_resource(), attrib_helper, |
+ capabilities, &handle, command_buffer_id)); |
if (!result->is_null()) { |
shared_state->set_shmem(TransportSHMHandle(dispatcher(), handle), |
sizeof(gpu::CommandBuffer::State)); |