Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / common / gpu / client / command_buffer_proxy_impl.cc
index 4dd189c..74a4089 100644 (file)
@@ -147,7 +147,7 @@ bool CommandBufferProxyImpl::Initialize() {
   if (!base::SharedMemory::IsHandleValid(handle))
     return false;
 
-  bool result;
+  bool result = false;
   if (!Send(new GpuCommandBufferMsg_Initialize(
       route_id_, handle, &result, &capabilities_))) {
     LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize.";
@@ -307,24 +307,21 @@ gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer(
   if (last_state_.error != gpu::error::kNoError)
     return NULL;
 
-  int32 new_id = channel_->ReserveGpuMemoryBufferId();
-  DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end());
-
-  scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer(
+  scoped_ptr<gfx::GpuMemoryBuffer> buffer(
       channel_->factory()->AllocateGpuMemoryBuffer(
           width, height, internalformat, usage));
-  if (!gpu_memory_buffer)
+  if (!buffer)
     return NULL;
 
-  DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer(
-             gpu_memory_buffer->GetHandle()));
+  DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer(buffer->GetHandle()));
+
+  int32 new_id = channel_->ReserveGpuMemoryBufferId();
 
   // This handle is owned by the GPU process and must be passed to it or it
   // will leak. In otherwords, do not early out on error between here and the
   // sending of the RegisterGpuMemoryBuffer IPC below.
   gfx::GpuMemoryBufferHandle handle =
-      channel_->ShareGpuMemoryBufferToGpuProcess(
-          gpu_memory_buffer->GetHandle());
+      channel_->ShareGpuMemoryBufferToGpuProcess(buffer->GetHandle());
 
   if (!Send(new GpuCommandBufferMsg_RegisterGpuMemoryBuffer(
                 route_id_,
@@ -337,22 +334,19 @@ gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer(
   }
 
   *id = new_id;
-  gpu_memory_buffers_[new_id] = gpu_memory_buffer.release();
-  return gpu_memory_buffers_[new_id];
+  DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end());
+  return gpu_memory_buffers_.add(new_id, buffer.Pass()).first->second;
 }
 
 void CommandBufferProxyImpl::DestroyGpuMemoryBuffer(int32 id) {
   if (last_state_.error != gpu::error::kNoError)
     return;
 
-  // Remove the gpu memory buffer from the client side cache.
-  GpuMemoryBufferMap::iterator it = gpu_memory_buffers_.find(id);
-  if (it != gpu_memory_buffers_.end()) {
-    delete it->second;
-    gpu_memory_buffers_.erase(it);
-  }
+  Send(new GpuCommandBufferMsg_UnregisterGpuMemoryBuffer(route_id_, id));
 
-  Send(new GpuCommandBufferMsg_DestroyGpuMemoryBuffer(route_id_, id));
+  // Remove the gpu memory buffer from the client side cache.
+  DCHECK(gpu_memory_buffers_.find(id) != gpu_memory_buffers_.end());
+  channel_->factory()->DeleteGpuMemoryBuffer(gpu_memory_buffers_.take(id));
 }
 
 int CommandBufferProxyImpl::GetRouteID() const {
@@ -377,7 +371,7 @@ uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) {
     return 0;
 
   int32 stream_id = channel_->GenerateRouteID();
-  bool succeeded;
+  bool succeeded = false;
   Send(new GpuCommandBufferMsg_CreateStreamTexture(
       route_id_, texture_id, stream_id, &succeeded));
   if (!succeeded) {
@@ -392,10 +386,26 @@ uint32 CommandBufferProxyImpl::InsertSyncPoint() {
     return 0;
 
   uint32 sync_point = 0;
-  Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, &sync_point));
+  Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, true, &sync_point));
   return sync_point;
 }
 
+uint32_t CommandBufferProxyImpl::InsertFutureSyncPoint() {
+  if (last_state_.error != gpu::error::kNoError)
+    return 0;
+
+  uint32 sync_point = 0;
+  Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, false, &sync_point));
+  return sync_point;
+}
+
+void CommandBufferProxyImpl::RetireSyncPoint(uint32_t sync_point) {
+  if (last_state_.error != gpu::error::kNoError)
+    return;
+
+  Send(new GpuCommandBufferMsg_RetireSyncPoint(route_id_, sync_point));
+}
+
 void CommandBufferProxyImpl::SignalSyncPoint(uint32 sync_point,
                                              const base::Closure& callback) {
   if (last_state_.error != gpu::error::kNoError)