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

Unified Diff: ppapi/proxy/ppb_graphics_3d_proxy.cc

Issue 547733002: [Pepper GL] Use shared state to fix a memory leak in MapSub GL extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 6 years, 3 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 4bb7b8dc4a21c53c9297e667e76807186e8546d8..b3dc645f8fead7c4430533996d24fea71fddcdf8 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -28,10 +28,10 @@ namespace {
const int32 kCommandBufferSize = 1024 * 1024;
const int32 kTransferBufferSize = 1024 * 1024;
-base::SharedMemoryHandle TransportSHMHandle(Dispatcher* dispatcher,
- base::SharedMemory* shm) {
- base::PlatformFile source =
- IPC::PlatformFileForTransitToPlatformFile(shm->handle());
+base::SharedMemoryHandle TransportSHMHandle(
+ Dispatcher* dispatcher,
+ const base::SharedMemoryHandle& handle) {
+ base::PlatformFile source = IPC::PlatformFileForTransitToPlatformFile(handle);
// Don't close the handle, it doesn't belong to us.
return dispatcher->ShareHandleWithRemote(source, false);
}
@@ -52,13 +52,14 @@ Graphics3D::~Graphics3D() {
DestroyGLES2Impl();
}
-bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2) {
+bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2,
+ const SerializedHandle& shared_state) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this);
if (!dispatcher)
return false;
command_buffer_.reset(
- new PpapiCommandBufferProxy(host_resource(), dispatcher));
+ new PpapiCommandBufferProxy(host_resource(), dispatcher, shared_state));
return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize,
share_gles2);
@@ -167,13 +168,17 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource(
attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
HostResource result;
- dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(
- API_ID_PPB_GRAPHICS_3D, instance, share_host, attribs, &result));
+ ppapi::proxy::SerializedHandle shared_state;
+ //(
+ // ppapi::proxy::SerializedHandle::SHARED_MEMORY);
piman 2014/09/08 21:02:04 nit: bogus comment?
Peng 2014/09/08 21:12:22 Done.
+ dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D,
+ instance, share_host, attribs, &result, &shared_state));
+
if (result.is_null())
return 0;
scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result));
- if (!graphics_3d->Init(share_gles2))
+ if (!graphics_3d->Init(share_gles2, shared_state))
return 0;
return graphics_3d->GetReference();
}
@@ -218,7 +223,9 @@ 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,
- HostResource* result) {
+ HostResource* result,
+ SerializedHandle* shared_state) {
+ shared_state->set_null_shmem();
if (attribs.empty() ||
attribs.back() != PP_GRAPHICS3DATTRIB_NONE ||
!(attribs.size() & 1))
@@ -226,12 +233,19 @@ void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance,
thunk::EnterResourceCreation enter(instance);
- if (enter.succeeded()) {
- result->SetHostResource(
+ if (!enter.succeeded())
+ return;
+
+ base::SharedMemoryHandle handle = IPC::InvalidPlatformFileForTransit();
+ result->SetHostResource(
instance,
enter.functions()->CreateGraphics3DRaw(instance,
share_context.host_resource(),
- &attribs.front()));
+ &attribs.front(),
+ &handle));
+ if (!result->is_null()) {
+ shared_state->set_shmem(TransportSHMHandle(dispatcher(), handle),
+ sizeof(gpu::CommandBuffer::State));
}
}
@@ -284,7 +298,7 @@ void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer(
const HostResource& context,
uint32 size,
int32* id,
- ppapi::proxy::SerializedHandle* transfer_buffer) {
+ SerializedHandle* transfer_buffer) {
transfer_buffer->set_null_shmem();
EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
if (enter.succeeded()) {
@@ -296,7 +310,7 @@ void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer(
static_cast<gpu::SharedMemoryBufferBacking*>(buffer->backing());
DCHECK(backing && backing->shared_memory());
transfer_buffer->set_shmem(
- TransportSHMHandle(dispatcher(), backing->shared_memory()),
+ TransportSHMHandle(dispatcher(), backing->shared_memory()->handle()),
buffer->size());
} else {
*id = -1;
« 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