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

Side by Side Diff: content/common/gpu/client/command_buffer_proxy_impl.cc

Issue 654223006: Cleanup GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/client/command_buffer_proxy_impl.h" 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, 302 int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer,
303 size_t width, 303 size_t width,
304 size_t height, 304 size_t height,
305 unsigned internalformat) { 305 unsigned internalformat) {
306 if (last_state_.error != gpu::error::kNoError) 306 if (last_state_.error != gpu::error::kNoError)
307 return -1; 307 return -1;
308 308
309 int32 new_id = channel_->ReserveImageId(); 309 int32 new_id = channel_->ReserveImageId();
310 310
311 gpu::GpuMemoryBufferManager* memory_buffer_manager =
312 channel_->gpu_memory_buffer_manager();
311 gfx::GpuMemoryBuffer* gpu_memory_buffer = 313 gfx::GpuMemoryBuffer* gpu_memory_buffer =
312 channel_->gpu_memory_buffer_manager()->GpuMemoryBufferFromClientBuffer( 314 memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer);
313 buffer);
314 DCHECK(gpu_memory_buffer); 315 DCHECK(gpu_memory_buffer);
315 316
316 // This handle is owned by the GPU process and must be passed to it or it 317 // This handle is owned by the GPU process and must be passed to it or it
317 // will leak. In otherwords, do not early out on error between here and the 318 // will leak. In otherwords, do not early out on error between here and the
318 // sending of the CreateImage IPC below. 319 // sending of the CreateImage IPC below.
319 gfx::GpuMemoryBufferHandle handle = 320 gfx::GpuMemoryBufferHandle handle =
320 channel_->ShareGpuMemoryBufferToGpuProcess( 321 channel_->ShareGpuMemoryBufferToGpuProcess(
reveman 2014/10/31 11:39:36 Maybe you can pass a route_id_ or an InserSyncPoin
321 gpu_memory_buffer->GetHandle()); 322 gpu_memory_buffer->GetHandle());
322 323
323 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( 324 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
324 internalformat, gpu_memory_buffer->GetFormat())); 325 internalformat, gpu_memory_buffer->GetFormat()));
325 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, 326 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_,
326 new_id, 327 new_id,
327 handle, 328 handle,
328 gfx::Size(width, height), 329 gfx::Size(width, height),
329 gpu_memory_buffer->GetFormat(), 330 gpu_memory_buffer->GetFormat(),
330 internalformat))) { 331 internalformat))) {
331 return -1; 332 return -1;
332 } 333 }
333 334
335 if (memory_buffer_manager->NeedsDestructionSyncPoint(handle.type)) {
336 memory_buffer_manager->RecordDestructionSyncPoint(buffer,
337 InsertSyncPoint());
338 }
339
334 return new_id; 340 return new_id;
335 } 341 }
336 342
337 void CommandBufferProxyImpl::DestroyImage(int32 id) { 343 void CommandBufferProxyImpl::DestroyImage(int32 id) {
338 if (last_state_.error != gpu::error::kNoError) 344 if (last_state_.error != gpu::error::kNoError)
339 return; 345 return;
340 346
341 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); 347 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id));
342 } 348 }
343 349
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (!ui::LatencyInfo::Verify( 531 if (!ui::LatencyInfo::Verify(
526 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { 532 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) {
527 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>()); 533 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>());
528 return; 534 return;
529 } 535 }
530 swap_buffers_completion_callback_.Run(latency_info); 536 swap_buffers_completion_callback_.Run(latency_info);
531 } 537 }
532 } 538 }
533 539
534 } // namespace content 540 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698