OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/test/test_gpu_memory_buffer_manager.h" | 5 #include "cc/test/test_gpu_memory_buffer_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return reinterpret_cast<uint8_t*>(shared_memory_->memory()) + offset_ + | 52 return reinterpret_cast<uint8_t*>(shared_memory_->memory()) + offset_ + |
53 gfx::BufferOffsetForBufferFormat(size_, format_, plane); | 53 gfx::BufferOffsetForBufferFormat(size_, format_, plane); |
54 } | 54 } |
55 void Unmap() override { | 55 void Unmap() override { |
56 DCHECK(mapped_); | 56 DCHECK(mapped_); |
57 shared_memory_->Unmap(); | 57 shared_memory_->Unmap(); |
58 mapped_ = false; | 58 mapped_ = false; |
59 } | 59 } |
60 gfx::Size GetSize() const override { return size_; } | 60 gfx::Size GetSize() const override { return size_; } |
61 gfx::BufferFormat GetFormat() const override { return format_; } | 61 gfx::BufferFormat GetFormat() const override { return format_; } |
62 int stride(size_t plane) const override { | 62 uint32_t stride(size_t plane) const override { |
63 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); | 63 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); |
64 return base::checked_cast<int>(gfx::RowSizeForBufferFormat( | 64 return base::checked_cast<uint32_t>(gfx::RowSizeForBufferFormat( |
65 size_.width(), format_, static_cast<int>(plane))); | 65 size_.width(), format_, static_cast<int>(plane))); |
66 } | 66 } |
67 gfx::GpuMemoryBufferId GetId() const override { return id_; } | 67 gfx::GpuMemoryBufferId GetId() const override { return id_; } |
68 gfx::GpuMemoryBufferHandle GetHandle() const override { | 68 gfx::GpuMemoryBufferHandle GetHandle() const override { |
69 gfx::GpuMemoryBufferHandle handle; | 69 gfx::GpuMemoryBufferHandle handle; |
70 handle.type = gfx::SHARED_MEMORY_BUFFER; | 70 handle.type = gfx::SHARED_MEMORY_BUFFER; |
71 handle.handle = shared_memory_->handle(); | 71 handle.handle = shared_memory_->handle(); |
72 handle.offset = base::checked_cast<uint32_t>(offset_); | 72 handle.offset = base::checked_cast<uint32_t>(offset_); |
73 handle.stride = base::checked_cast<int32_t>(stride_); | 73 handle.stride = base::checked_cast<uint32_t>(stride_); |
74 return handle; | 74 return handle; |
75 } | 75 } |
76 ClientBuffer AsClientBuffer() override { | 76 ClientBuffer AsClientBuffer() override { |
77 return reinterpret_cast<ClientBuffer>(this); | 77 return reinterpret_cast<ClientBuffer>(this); |
78 } | 78 } |
79 | 79 |
80 private: | 80 private: |
81 TestGpuMemoryBufferManager* manager_; | 81 TestGpuMemoryBufferManager* manager_; |
82 gfx::GpuMemoryBufferId id_; | 82 gfx::GpuMemoryBufferId id_; |
83 const gfx::Size size_; | 83 const gfx::Size size_; |
(...skipping 15 matching lines...) Expand all Loading... |
99 manager_->OnGpuMemoryBufferDestroyed(id_); | 99 manager_->OnGpuMemoryBufferDestroyed(id_); |
100 } | 100 } |
101 | 101 |
102 bool Map() override { return client_buffer_->Map(); } | 102 bool Map() override { return client_buffer_->Map(); } |
103 void* memory(size_t plane) override { return client_buffer_->memory(plane); } | 103 void* memory(size_t plane) override { return client_buffer_->memory(plane); } |
104 void Unmap() override { client_buffer_->Unmap(); } | 104 void Unmap() override { client_buffer_->Unmap(); } |
105 gfx::Size GetSize() const override { return client_buffer_->GetSize(); } | 105 gfx::Size GetSize() const override { return client_buffer_->GetSize(); } |
106 gfx::BufferFormat GetFormat() const override { | 106 gfx::BufferFormat GetFormat() const override { |
107 return client_buffer_->GetFormat(); | 107 return client_buffer_->GetFormat(); |
108 } | 108 } |
109 int stride(size_t plane) const override { | 109 uint32_t stride(size_t plane) const override { |
110 return client_buffer_->stride(plane); | 110 return client_buffer_->stride(plane); |
111 } | 111 } |
112 gfx::GpuMemoryBufferId GetId() const override { return id_; } | 112 gfx::GpuMemoryBufferId GetId() const override { return id_; } |
113 gfx::GpuMemoryBufferHandle GetHandle() const override { | 113 gfx::GpuMemoryBufferHandle GetHandle() const override { |
114 return client_buffer_->GetHandle(); | 114 return client_buffer_->GetHandle(); |
115 } | 115 } |
116 ClientBuffer AsClientBuffer() override { | 116 ClientBuffer AsClientBuffer() override { |
117 return client_buffer_->AsClientBuffer(); | 117 return client_buffer_->AsClientBuffer(); |
118 } | 118 } |
119 | 119 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 TestGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( | 193 TestGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( |
194 ClientBuffer buffer) { | 194 ClientBuffer buffer) { |
195 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer); | 195 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer); |
196 } | 196 } |
197 | 197 |
198 void TestGpuMemoryBufferManager::SetDestructionSyncToken( | 198 void TestGpuMemoryBufferManager::SetDestructionSyncToken( |
199 gfx::GpuMemoryBuffer* buffer, | 199 gfx::GpuMemoryBuffer* buffer, |
200 const gpu::SyncToken& sync_token) {} | 200 const gpu::SyncToken& sync_token) {} |
201 | 201 |
202 } // namespace cc | 202 } // namespace cc |
OLD | NEW |