| 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 0c21e377733751873561ff42642fd1df3a818fba..81df45b71ed82b2e2ba0c7fcce52dcb7cd08a2cf 100644
|
| --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc
|
| +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
|
| @@ -172,24 +172,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;
|
| @@ -240,16 +258,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);
|
|
|
| @@ -258,13 +272,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));
|
|
|