Chromium Code Reviews| 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 |
| 13 #include "base/hash.h" | |
| 12 #include "base/logging.h" | 14 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 14 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
| 15 #include "ui/gfx/buffer_format_util.h" | 17 #include "ui/gfx/buffer_format_util.h" |
| 16 #include "ui/gfx/gpu_memory_buffer.h" | 18 #include "ui/gfx/gpu_memory_buffer.h" |
| 17 | 19 |
| 20 namespace { | |
|
Khushal
2016/08/02 06:39:01
Doesn't look like GetDefaultBufferToTextureTargetM
David Trainor- moved to gerrit
2016/08/02 15:37:27
Crap. done.
| |
| 21 | |
| 22 using GpuMemoryBufferConfigurationKey = | |
| 23 std::pair<gfx::BufferFormat, gfx::BufferUsage>; | |
| 24 using GpuMemoryBufferConfigurationSet = | |
| 25 base::hash_set<GpuMemoryBufferConfigurationKey>; | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 namespace BASE_HASH_NAMESPACE { | |
| 30 | |
| 31 template <> | |
| 32 struct hash<GpuMemoryBufferConfigurationKey> { | |
| 33 size_t operator()(const GpuMemoryBufferConfigurationKey& key) const { | |
| 34 return base::HashInts(static_cast<int>(key.first), | |
| 35 static_cast<int>(key.second)); | |
| 36 } | |
| 37 }; | |
| 38 | |
| 39 } // namespace BASE_HASH_NAMESPACE | |
| 40 | |
| 18 namespace blimp { | 41 namespace blimp { |
| 19 namespace client { | 42 namespace client { |
| 20 | 43 |
| 21 namespace { | 44 namespace { |
| 22 | 45 |
| 23 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 46 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
| 24 public: | 47 public: |
| 25 GpuMemoryBufferImpl(const gfx::Size& size, | 48 GpuMemoryBufferImpl(const gfx::Size& size, |
| 26 gfx::BufferFormat format, | 49 gfx::BufferFormat format, |
| 27 std::unique_ptr<base::SharedMemory> shared_memory, | 50 std::unique_ptr<base::SharedMemory> shared_memory, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 size_t stride_; | 117 size_t stride_; |
| 95 bool mapped_; | 118 bool mapped_; |
| 96 }; | 119 }; |
| 97 | 120 |
| 98 } // namespace | 121 } // namespace |
| 99 | 122 |
| 100 BlimpGpuMemoryBufferManager::BlimpGpuMemoryBufferManager() {} | 123 BlimpGpuMemoryBufferManager::BlimpGpuMemoryBufferManager() {} |
| 101 | 124 |
| 102 BlimpGpuMemoryBufferManager::~BlimpGpuMemoryBufferManager() {} | 125 BlimpGpuMemoryBufferManager::~BlimpGpuMemoryBufferManager() {} |
| 103 | 126 |
| 127 // static | |
| 128 cc::BufferToTextureTargetMap | |
| 129 BlimpGpuMemoryBufferManager::GetDefaultBufferToTextureTargetMap() { | |
| 130 cc::BufferToTextureTargetMap image_targets; | |
| 131 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); | |
| 132 ++usage_idx) { | |
| 133 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); | |
| 134 for (int format_idx = 0; | |
| 135 format_idx <= static_cast<int>(gfx::BufferFormat::LAST); | |
| 136 ++format_idx) { | |
| 137 gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); | |
| 138 image_targets.insert(cc::BufferToTextureTargetMap::value_type( | |
| 139 cc::BufferToTextureTargetKey(usage, format), GL_TEXTURE_2D)); | |
| 140 } | |
| 141 } | |
| 142 return image_targets; | |
| 143 } | |
| 144 | |
| 104 std::unique_ptr<gfx::GpuMemoryBuffer> | 145 std::unique_ptr<gfx::GpuMemoryBuffer> |
| 105 BlimpGpuMemoryBufferManager::AllocateGpuMemoryBuffer( | 146 BlimpGpuMemoryBufferManager::AllocateGpuMemoryBuffer( |
| 106 const gfx::Size& size, | 147 const gfx::Size& size, |
| 107 gfx::BufferFormat format, | 148 gfx::BufferFormat format, |
| 108 gfx::BufferUsage usage, | 149 gfx::BufferUsage usage, |
| 109 gpu::SurfaceHandle surface_handle) { | 150 gpu::SurfaceHandle surface_handle) { |
| 110 DCHECK_EQ(gpu::kNullSurfaceHandle, surface_handle) | 151 DCHECK_EQ(gpu::kNullSurfaceHandle, surface_handle) |
| 111 << "Blimp should not be allocating scanout buffers"; | 152 << "Blimp should not be allocating scanout buffers"; |
| 112 std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); | 153 std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); |
| 113 const size_t buffer_size = gfx::BufferSizeForBufferFormat(size, format); | 154 const size_t buffer_size = gfx::BufferSizeForBufferFormat(size, format); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 140 } | 181 } |
| 141 | 182 |
| 142 void BlimpGpuMemoryBufferManager::SetDestructionSyncToken( | 183 void BlimpGpuMemoryBufferManager::SetDestructionSyncToken( |
| 143 gfx::GpuMemoryBuffer* buffer, | 184 gfx::GpuMemoryBuffer* buffer, |
| 144 const gpu::SyncToken& sync_token) { | 185 const gpu::SyncToken& sync_token) { |
| 145 NOTIMPLEMENTED(); | 186 NOTIMPLEMENTED(); |
| 146 } | 187 } |
| 147 | 188 |
| 148 } // namespace client | 189 } // namespace client |
| 149 } // namespace blimp | 190 } // namespace blimp |
| OLD | NEW |