Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 NOTREACHED(); | 360 NOTREACHED(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void CommandBufferProxyImpl::SetContextLostReason( | 363 void CommandBufferProxyImpl::SetContextLostReason( |
| 364 gpu::error::ContextLostReason reason) { | 364 gpu::error::ContextLostReason reason) { |
| 365 // Not implemented in proxy. | 365 // Not implemented in proxy. |
| 366 NOTREACHED(); | 366 NOTREACHED(); |
| 367 } | 367 } |
| 368 | 368 |
| 369 bool CommandBufferProxyImpl::SupportsGpuMemoryBuffer() { | 369 bool CommandBufferProxyImpl::SupportsGpuMemoryBuffer() { |
| 370 return false; | 370 return true; |
|
piman
2013/10/21 21:57:00
Won't this force impl-side painting to go through
reveman
2013/10/22 16:26:11
It's disabled by default. You need to use --enable
| |
| 371 } | 371 } |
| 372 | 372 |
| 373 gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( | 373 gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( |
| 374 size_t width, | 374 size_t width, |
| 375 size_t height, | 375 size_t height, |
| 376 unsigned internalformat, | 376 unsigned internalformat, |
| 377 int32* id) { | 377 int32* id) { |
| 378 NOTREACHED(); | 378 *id = -1; |
| 379 return NULL; | 379 |
| 380 if (last_state_.error != gpu::error::kNoError) | |
| 381 return NULL; | |
| 382 | |
| 383 int32 new_id = channel_->ReserveGpuMemoryBufferId(); | |
| 384 DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); | |
| 385 | |
| 386 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer( | |
| 387 channel_->factory()->AllocateGpuMemoryBuffer(width, | |
| 388 height, | |
| 389 internalformat)); | |
| 390 if (!gpu_memory_buffer) | |
| 391 return NULL; | |
| 392 | |
|
piman
2013/10/21 21:57:00
nit: can we DCHECK the handle type here?
reveman
2013/10/22 16:26:11
Hm, I'd prefer to keep this code type agnostic. Ca
| |
| 393 // This handle is owned by the GPU process and must be passed to it or it | |
| 394 // will leak. In otherwords, do not early out on error between here and the | |
| 395 // sending of the RegisterGpuMemoryBuffer IPC below. | |
| 396 gfx::GpuMemoryBufferHandle handle = | |
| 397 channel_->ShareGpuMemoryBufferToGpuProcess( | |
| 398 gpu_memory_buffer->GetHandle()); | |
| 399 | |
| 400 if (!Send(new GpuCommandBufferMsg_RegisterGpuMemoryBuffer( | |
| 401 route_id_, | |
| 402 new_id, | |
| 403 handle, | |
| 404 width, | |
| 405 height, | |
| 406 internalformat))) { | |
| 407 return NULL; | |
| 408 } | |
| 409 | |
| 410 *id = new_id; | |
| 411 gpu_memory_buffers_[new_id] = gpu_memory_buffer.get(); | |
| 412 return gpu_memory_buffer.release(); | |
|
piman
2013/10/21 21:57:00
nit: these 2 lines would be a bit clearer if writt
reveman
2013/10/22 16:26:11
switched to this in latest patch.
| |
| 380 } | 413 } |
| 381 | 414 |
| 382 void CommandBufferProxyImpl::DestroyGpuMemoryBuffer(int32 id) { | 415 void CommandBufferProxyImpl::DestroyGpuMemoryBuffer(int32 id) { |
| 383 NOTREACHED(); | 416 if (last_state_.error != gpu::error::kNoError) |
| 417 return; | |
| 418 | |
| 419 // Remove the gpu memory buffer from the client side cache. | |
| 420 GpuMemoryBufferMap::iterator it = gpu_memory_buffers_.find(id); | |
| 421 if (it != gpu_memory_buffers_.end()) { | |
| 422 delete it->second; | |
| 423 gpu_memory_buffers_.erase(it); | |
| 424 } | |
| 425 | |
| 426 Send(new GpuCommandBufferMsg_DestroyGpuMemoryBuffer(route_id_, id)); | |
| 384 } | 427 } |
| 385 | 428 |
| 386 int CommandBufferProxyImpl::GetRouteID() const { | 429 int CommandBufferProxyImpl::GetRouteID() const { |
| 387 return route_id_; | 430 return route_id_; |
| 388 } | 431 } |
| 389 | 432 |
| 390 bool CommandBufferProxyImpl::Echo(const base::Closure& callback) { | 433 bool CommandBufferProxyImpl::Echo(const base::Closure& callback) { |
| 391 if (last_state_.error != gpu::error::kNoError) { | 434 if (last_state_.error != gpu::error::kNoError) { |
| 392 return false; | 435 return false; |
| 393 } | 436 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 void CommandBufferProxyImpl::SendManagedMemoryStats( | 601 void CommandBufferProxyImpl::SendManagedMemoryStats( |
| 559 const GpuManagedMemoryStats& stats) { | 602 const GpuManagedMemoryStats& stats) { |
| 560 if (last_state_.error != gpu::error::kNoError) | 603 if (last_state_.error != gpu::error::kNoError) |
| 561 return; | 604 return; |
| 562 | 605 |
| 563 Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, | 606 Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, |
| 564 stats)); | 607 stats)); |
| 565 } | 608 } |
| 566 | 609 |
| 567 } // namespace content | 610 } // namespace content |
| OLD | NEW |