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

Unified Diff: ppapi/proxy/ppb_graphics_3d_proxy.cc

Issue 2104403003: pepper: parse context creation attrib list on the plugin side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gpu_pref_size_in_attrs
Patch Set: rebase Created 4 years, 5 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 | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698