Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: cc/test/test_gpu_memory_buffer_manager.cc

Issue 1957583002: cc: Add GpuMemoryBufferId to TextureMailbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unsigned -> signed Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | components/exo/buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/numerics/safe_conversions.h" 12 #include "base/numerics/safe_conversions.h"
13 #include "ui/gfx/buffer_format_util.h" 13 #include "ui/gfx/buffer_format_util.h"
14 #include "ui/gfx/gpu_memory_buffer.h" 14 #include "ui/gfx/gpu_memory_buffer.h"
15 15
16 namespace cc { 16 namespace cc {
17 namespace { 17 namespace {
18 18
19 int g_gpu_memory_buffer_id_counter = 0;
20
19 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 21 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
20 public: 22 public:
21 GpuMemoryBufferImpl(const gfx::Size& size, 23 GpuMemoryBufferImpl(const gfx::Size& size,
22 gfx::BufferFormat format, 24 gfx::BufferFormat format,
23 std::unique_ptr<base::SharedMemory> shared_memory, 25 std::unique_ptr<base::SharedMemory> shared_memory,
24 size_t offset, 26 size_t offset,
25 size_t stride) 27 size_t stride)
26 : size_(size), 28 : id_(++g_gpu_memory_buffer_id_counter),
29 size_(size),
27 format_(format), 30 format_(format),
28 shared_memory_(std::move(shared_memory)), 31 shared_memory_(std::move(shared_memory)),
29 offset_(offset), 32 offset_(offset),
30 stride_(stride), 33 stride_(stride),
31 mapped_(false), 34 mapped_(false),
32 is_in_use_by_window_server_(false) {} 35 is_in_use_by_window_server_(false) {}
33 36
34 // Overridden from gfx::GpuMemoryBuffer: 37 // Overridden from gfx::GpuMemoryBuffer:
35 bool Map() override { 38 bool Map() override {
36 DCHECK(!mapped_); 39 DCHECK(!mapped_);
(...skipping 18 matching lines...) Expand all
55 bool IsInUseByMacOSWindowServer() const override { 58 bool IsInUseByMacOSWindowServer() const override {
56 return is_in_use_by_window_server_; 59 return is_in_use_by_window_server_;
57 } 60 }
58 gfx::Size GetSize() const override { return size_; } 61 gfx::Size GetSize() const override { return size_; }
59 gfx::BufferFormat GetFormat() const override { return format_; } 62 gfx::BufferFormat GetFormat() const override { return format_; }
60 int stride(size_t plane) const override { 63 int stride(size_t plane) const override {
61 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); 64 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
62 return base::checked_cast<int>(gfx::RowSizeForBufferFormat( 65 return base::checked_cast<int>(gfx::RowSizeForBufferFormat(
63 size_.width(), format_, static_cast<int>(plane))); 66 size_.width(), format_, static_cast<int>(plane)));
64 } 67 }
65 gfx::GpuMemoryBufferId GetId() const override { 68 gfx::GpuMemoryBufferId GetId() const override { return id_; }
66 NOTREACHED();
67 return gfx::GpuMemoryBufferId(0);
68 }
69 gfx::GpuMemoryBufferHandle GetHandle() const override { 69 gfx::GpuMemoryBufferHandle GetHandle() const override {
70 gfx::GpuMemoryBufferHandle handle; 70 gfx::GpuMemoryBufferHandle handle;
71 handle.type = gfx::SHARED_MEMORY_BUFFER; 71 handle.type = gfx::SHARED_MEMORY_BUFFER;
72 handle.handle = shared_memory_->handle(); 72 handle.handle = shared_memory_->handle();
73 handle.offset = base::checked_cast<uint32_t>(offset_); 73 handle.offset = base::checked_cast<uint32_t>(offset_);
74 handle.stride = base::checked_cast<int32_t>(stride_); 74 handle.stride = base::checked_cast<int32_t>(stride_);
75 return handle; 75 return handle;
76 } 76 }
77 ClientBuffer AsClientBuffer() override { 77 ClientBuffer AsClientBuffer() override {
78 return reinterpret_cast<ClientBuffer>(this); 78 return reinterpret_cast<ClientBuffer>(this);
79 } 79 }
80 80
81 void SetIsInUseByMacOSWindowServer(bool value) { 81 void SetIsInUseByMacOSWindowServer(bool value) {
82 is_in_use_by_window_server_ = value; 82 is_in_use_by_window_server_ = value;
83 } 83 }
84 84
85 private: 85 private:
86 gfx::GpuMemoryBufferId id_;
86 const gfx::Size size_; 87 const gfx::Size size_;
87 gfx::BufferFormat format_; 88 gfx::BufferFormat format_;
88 std::unique_ptr<base::SharedMemory> shared_memory_; 89 std::unique_ptr<base::SharedMemory> shared_memory_;
89 size_t offset_; 90 size_t offset_;
90 size_t stride_; 91 size_t stride_;
91 bool mapped_; 92 bool mapped_;
92 bool is_in_use_by_window_server_; 93 bool is_in_use_by_window_server_;
93 }; 94 };
94 95
95 } // namespace 96 } // namespace
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 TestGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( 142 TestGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer(
142 ClientBuffer buffer) { 143 ClientBuffer buffer) {
143 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer); 144 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer);
144 } 145 }
145 146
146 void TestGpuMemoryBufferManager::SetDestructionSyncToken( 147 void TestGpuMemoryBufferManager::SetDestructionSyncToken(
147 gfx::GpuMemoryBuffer* buffer, 148 gfx::GpuMemoryBuffer* buffer,
148 const gpu::SyncToken& sync_token) {} 149 const gpu::SyncToken& sync_token) {}
149 150
150 } // namespace cc 151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | components/exo/buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698