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 "gpu/ipc/client/command_buffer_proxy_impl.h" | 5 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 } | 511 } |
512 | 512 |
513 void CommandBufferProxyImpl::DestroyImage(int32_t id) { | 513 void CommandBufferProxyImpl::DestroyImage(int32_t id) { |
514 CheckLock(); | 514 CheckLock(); |
515 if (last_state_.error != gpu::error::kNoError) | 515 if (last_state_.error != gpu::error::kNoError) |
516 return; | 516 return; |
517 | 517 |
518 auto it = image_gmb_ids_map_.find(id); | 518 auto it = image_gmb_ids_map_.find(id); |
519 if (it != image_gmb_ids_map_.end()) | 519 if (it != image_gmb_ids_map_.end()) |
520 image_gmb_ids_map_.erase(it); | 520 image_gmb_ids_map_.erase(it); |
| 521 auto it2 = image_gmb_map_.find(id); |
| 522 if (it2 != image_gmb_map_.end()) |
| 523 image_gmb_map_.erase(it2); |
521 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); | 524 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); |
522 } | 525 } |
523 | 526 |
524 int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( | 527 int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( |
525 size_t width, | 528 size_t width, |
526 size_t height, | 529 size_t height, |
527 unsigned internal_format, | 530 unsigned internal_format, |
528 unsigned usage) { | 531 unsigned usage) { |
529 CheckLock(); | 532 CheckLock(); |
530 std::unique_ptr<gfx::GpuMemoryBuffer> buffer( | 533 std::unique_ptr<gfx::GpuMemoryBuffer> buffer( |
531 channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( | 534 channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( |
532 gfx::Size(width, height), | 535 gfx::Size(width, height), |
533 gpu::DefaultBufferFormatForImageFormat(internal_format), | 536 gpu::DefaultBufferFormatForImageFormat(internal_format), |
534 gfx::BufferUsage::SCANOUT, gpu::kNullSurfaceHandle)); | 537 gfx::BufferUsage::SCANOUT, gpu::kNullSurfaceHandle)); |
535 if (!buffer) | 538 if (!buffer) |
536 return -1; | 539 return -1; |
537 | 540 |
538 return CreateImage(buffer->AsClientBuffer(), width, height, internal_format); | 541 int32_t result = |
| 542 CreateImage(buffer->AsClientBuffer(), width, height, internal_format); |
| 543 if (result != -1) |
| 544 image_gmb_map_[result] = std::move(buffer); |
| 545 return result; |
539 } | 546 } |
540 | 547 |
541 int32_t CommandBufferProxyImpl::GetImageGpuMemoryBufferId(unsigned image_id) { | 548 int32_t CommandBufferProxyImpl::GetImageGpuMemoryBufferId(unsigned image_id) { |
542 CheckLock(); | 549 CheckLock(); |
543 auto it = image_gmb_ids_map_.find(image_id); | 550 auto it = image_gmb_ids_map_.find(image_id); |
544 if (it != image_gmb_ids_map_.end()) | 551 if (it != image_gmb_ids_map_.end()) |
545 return it->second; | 552 return it->second; |
546 return -1; | 553 return -1; |
547 } | 554 } |
548 | 555 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 return; | 873 return; |
867 channel_->FlushPendingStream(stream_id_); | 874 channel_->FlushPendingStream(stream_id_); |
868 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); | 875 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); |
869 channel_->RemoveRoute(route_id_); | 876 channel_->RemoveRoute(route_id_); |
870 channel_ = nullptr; | 877 channel_ = nullptr; |
871 if (gpu_control_client_) | 878 if (gpu_control_client_) |
872 gpu_control_client_->OnGpuControlLostContext(); | 879 gpu_control_client_->OnGpuControlLostContext(); |
873 } | 880 } |
874 | 881 |
875 } // namespace gpu | 882 } // namespace gpu |
OLD | NEW |