OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/feature/compositor/blimp_gpu_memory_buffer_manager.h" | 5 #include "blimp/client/feature/compositor/blimp_gpu_memory_buffer_manager.h" |
6 | 6 |
| 7 #include <GLES2/gl2.h> |
7 #include <stddef.h> | 8 #include <stddef.h> |
8 #include <stdint.h> | 9 #include <stdint.h> |
9 | 10 |
10 #include <memory> | 11 #include <memory> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
14 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
15 #include "ui/gfx/buffer_format_util.h" | 16 #include "ui/gfx/buffer_format_util.h" |
16 #include "ui/gfx/gpu_memory_buffer.h" | 17 #include "ui/gfx/gpu_memory_buffer.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 size_t stride_; | 95 size_t stride_; |
95 bool mapped_; | 96 bool mapped_; |
96 }; | 97 }; |
97 | 98 |
98 } // namespace | 99 } // namespace |
99 | 100 |
100 BlimpGpuMemoryBufferManager::BlimpGpuMemoryBufferManager() {} | 101 BlimpGpuMemoryBufferManager::BlimpGpuMemoryBufferManager() {} |
101 | 102 |
102 BlimpGpuMemoryBufferManager::~BlimpGpuMemoryBufferManager() {} | 103 BlimpGpuMemoryBufferManager::~BlimpGpuMemoryBufferManager() {} |
103 | 104 |
| 105 // static |
| 106 cc::BufferToTextureTargetMap |
| 107 BlimpGpuMemoryBufferManager::GetDefaultBufferToTextureTargetMap() { |
| 108 cc::BufferToTextureTargetMap image_targets; |
| 109 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); |
| 110 ++usage_idx) { |
| 111 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); |
| 112 for (int format_idx = 0; |
| 113 format_idx <= static_cast<int>(gfx::BufferFormat::LAST); |
| 114 ++format_idx) { |
| 115 gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); |
| 116 image_targets.insert(cc::BufferToTextureTargetMap::value_type( |
| 117 cc::BufferToTextureTargetKey(usage, format), GL_TEXTURE_2D)); |
| 118 } |
| 119 } |
| 120 return image_targets; |
| 121 } |
| 122 |
104 std::unique_ptr<gfx::GpuMemoryBuffer> | 123 std::unique_ptr<gfx::GpuMemoryBuffer> |
105 BlimpGpuMemoryBufferManager::AllocateGpuMemoryBuffer( | 124 BlimpGpuMemoryBufferManager::AllocateGpuMemoryBuffer( |
106 const gfx::Size& size, | 125 const gfx::Size& size, |
107 gfx::BufferFormat format, | 126 gfx::BufferFormat format, |
108 gfx::BufferUsage usage, | 127 gfx::BufferUsage usage, |
109 gpu::SurfaceHandle surface_handle) { | 128 gpu::SurfaceHandle surface_handle) { |
110 DCHECK_EQ(gpu::kNullSurfaceHandle, surface_handle) | 129 DCHECK_EQ(gpu::kNullSurfaceHandle, surface_handle) |
111 << "Blimp should not be allocating scanout buffers"; | 130 << "Blimp should not be allocating scanout buffers"; |
112 std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); | 131 std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); |
113 const size_t buffer_size = gfx::BufferSizeForBufferFormat(size, format); | 132 const size_t buffer_size = gfx::BufferSizeForBufferFormat(size, format); |
(...skipping 26 matching lines...) Expand all Loading... |
140 } | 159 } |
141 | 160 |
142 void BlimpGpuMemoryBufferManager::SetDestructionSyncToken( | 161 void BlimpGpuMemoryBufferManager::SetDestructionSyncToken( |
143 gfx::GpuMemoryBuffer* buffer, | 162 gfx::GpuMemoryBuffer* buffer, |
144 const gpu::SyncToken& sync_token) { | 163 const gpu::SyncToken& sync_token) { |
145 NOTIMPLEMENTED(); | 164 NOTIMPLEMENTED(); |
146 } | 165 } |
147 | 166 |
148 } // namespace client | 167 } // namespace client |
149 } // namespace blimp | 168 } // namespace blimp |
OLD | NEW |