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

Unified Diff: ppapi/proxy/ppapi_command_buffer_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: Remve base/memory/shared_memory.h from DEPS 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/ppapi_command_buffer_proxy.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppapi_command_buffer_proxy.cc
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc
index 6c1093c8d06c06893653dda0b45101538454b45d..33e63b66ae0da4200aec6212e14519822177cf85 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.cc
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc
@@ -15,9 +15,13 @@ namespace proxy {
PpapiCommandBufferProxy::PpapiCommandBufferProxy(
const ppapi::HostResource& resource,
- ProxyChannel* channel)
+ ProxyChannel* channel,
+ const SerializedHandle& shared_state)
: resource_(resource),
channel_(channel) {
+ shared_state_shm_.reset(
+ new base::SharedMemory(shared_state.shmem(), false));
+ shared_state_shm_->Map(shared_state.size());
}
PpapiCommandBufferProxy::~PpapiCommandBufferProxy() {
@@ -36,6 +40,7 @@ gpu::CommandBuffer::State PpapiCommandBufferProxy::GetLastState() {
int32 PpapiCommandBufferProxy::GetLastToken() {
ppapi::ProxyLock::AssertAcquiredDebugOnly();
+ TryUpdateState();
return last_state_.token;
}
@@ -54,35 +59,41 @@ void PpapiCommandBufferProxy::Flush(int32 put_offset) {
}
void PpapiCommandBufferProxy::WaitForTokenInRange(int32 start, int32 end) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
- bool success = false;
- gpu::CommandBuffer::State state;
- if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange(
- ppapi::API_ID_PPB_GRAPHICS_3D,
- resource_,
- start,
- end,
- &state,
- &success)))
- UpdateState(state, success);
+ TryUpdateState();
+ if (!InRange(start, end, last_state_.token) &&
+ last_state_.error == gpu::error::kNoError) {
+ bool success = false;
+ gpu::CommandBuffer::State state;
+ if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange(
+ ppapi::API_ID_PPB_GRAPHICS_3D,
+ resource_,
+ start,
+ end,
+ &state,
+ &success)))
+ UpdateState(state, success);
+ }
+ DCHECK(InRange(start, end, last_state_.token) ||
+ last_state_.error != gpu::error::kNoError);
}
void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32 start, int32 end) {
- if (last_state_.error != gpu::error::kNoError)
- return;
-
- bool success = false;
- gpu::CommandBuffer::State state;
- if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange(
- ppapi::API_ID_PPB_GRAPHICS_3D,
- resource_,
- start,
- end,
- &state,
- &success)))
- UpdateState(state, success);
+ TryUpdateState();
+ if (!InRange(start, end, last_state_.get_offset) &&
+ last_state_.error == gpu::error::kNoError) {
+ bool success = false;
+ gpu::CommandBuffer::State state;
+ if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange(
+ ppapi::API_ID_PPB_GRAPHICS_3D,
+ resource_,
+ start,
+ end,
+ &state,
+ &success)))
+ UpdateState(state, success);
+ }
+ DCHECK(InRange(start, end, last_state_.get_offset) ||
+ last_state_.error != gpu::error::kNoError);
}
void PpapiCommandBufferProxy::SetGetBuffer(int32 transfer_buffer_id) {
@@ -227,5 +238,15 @@ void PpapiCommandBufferProxy::UpdateState(
}
}
+void PpapiCommandBufferProxy::TryUpdateState() {
+ if (last_state_.error == gpu::error::kNoError)
+ shared_state()->Read(&last_state_);
+}
+
+gpu::CommandBufferSharedState* PpapiCommandBufferProxy::shared_state() const {
+ return reinterpret_cast<gpu::CommandBufferSharedState*>(
+ shared_state_shm_->memory());
+}
+
} // namespace proxy
} // namespace ppapi
« no previous file with comments | « ppapi/proxy/ppapi_command_buffer_proxy.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698