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

Side by Side Diff: gpu/ipc/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc

Issue 2272153002: Add ClientNativePixmap multi-planar support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-native-pixmap-dmabug-multiple-planes
Patch Set: ifdef USE_OZONE for unused variables. Created 4 years, 2 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
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 "gpu/ipc/client/gpu_memory_buffer_impl_ozone_native_pixmap.h" 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_ozone_native_pixmap.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
(...skipping 17 matching lines...) Expand all
28 gfx::GpuMemoryBufferId id, 28 gfx::GpuMemoryBufferId id,
29 const gfx::Size& size, 29 const gfx::Size& size,
30 gfx::BufferFormat format, 30 gfx::BufferFormat format,
31 const DestructionCallback& callback, 31 const DestructionCallback& callback,
32 std::unique_ptr<ui::ClientNativePixmap> pixmap, 32 std::unique_ptr<ui::ClientNativePixmap> pixmap,
33 const std::vector<gfx::NativePixmapPlane>& planes, 33 const std::vector<gfx::NativePixmapPlane>& planes,
34 base::ScopedFD fd) 34 base::ScopedFD fd)
35 : GpuMemoryBufferImpl(id, size, format, callback), 35 : GpuMemoryBufferImpl(id, size, format, callback),
36 pixmap_(std::move(pixmap)), 36 pixmap_(std::move(pixmap)),
37 planes_(planes), 37 planes_(planes),
38 fd_(std::move(fd)), 38 fd_(std::move(fd)) {}
39 data_(nullptr) {}
40 39
41 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} 40 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {}
42 41
43 // static 42 // static
44 std::unique_ptr<GpuMemoryBufferImplOzoneNativePixmap> 43 std::unique_ptr<GpuMemoryBufferImplOzoneNativePixmap>
45 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( 44 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle(
46 const gfx::GpuMemoryBufferHandle& handle, 45 const gfx::GpuMemoryBufferHandle& handle,
47 const gfx::Size& size, 46 const gfx::Size& size,
48 gfx::BufferFormat format, 47 gfx::BufferFormat format,
49 gfx::BufferUsage usage, 48 gfx::BufferUsage usage,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 ->GetSurfaceFactoryOzone() 93 ->GetSurfaceFactoryOzone()
95 ->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, format, 94 ->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, format,
96 usage); 95 usage);
97 handle->type = gfx::OZONE_NATIVE_PIXMAP; 96 handle->type = gfx::OZONE_NATIVE_PIXMAP;
98 handle->native_pixmap_handle = pixmap->ExportHandle(); 97 handle->native_pixmap_handle = pixmap->ExportHandle();
99 return base::Bind(&FreeNativePixmapForTesting, pixmap); 98 return base::Bind(&FreeNativePixmapForTesting, pixmap);
100 } 99 }
101 100
102 bool GpuMemoryBufferImplOzoneNativePixmap::Map() { 101 bool GpuMemoryBufferImplOzoneNativePixmap::Map() {
103 DCHECK(!mapped_); 102 DCHECK(!mapped_);
104 DCHECK(!data_); 103 mapped_ = pixmap_->Map();
105 data_ = pixmap_->Map();
106 if (!data_)
107 return false;
108 mapped_ = true;
109 return mapped_; 104 return mapped_;
110 } 105 }
111 106
112 void* GpuMemoryBufferImplOzoneNativePixmap::memory(size_t plane) { 107 void* GpuMemoryBufferImplOzoneNativePixmap::memory(size_t plane) {
113 DCHECK(mapped_); 108 DCHECK(mapped_);
114 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); 109 return pixmap_->GetMemoryAddress(plane);
115 return data_;
116 } 110 }
117 111
118 void GpuMemoryBufferImplOzoneNativePixmap::Unmap() { 112 void GpuMemoryBufferImplOzoneNativePixmap::Unmap() {
119 DCHECK(mapped_); 113 DCHECK(mapped_);
120 DCHECK(data_);
121 pixmap_->Unmap(); 114 pixmap_->Unmap();
122 mapped_ = false; 115 mapped_ = false;
123 data_ = nullptr;
124 } 116 }
125 117
126 int GpuMemoryBufferImplOzoneNativePixmap::stride(size_t plane) const { 118 int GpuMemoryBufferImplOzoneNativePixmap::stride(size_t plane) const {
127 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); 119 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
128 int stride; 120 return pixmap_->GetStride(plane);
129 pixmap_->GetStride(&stride);
130 return stride;
131 } 121 }
132 122
133 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() 123 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle()
134 const { 124 const {
135 gfx::GpuMemoryBufferHandle handle; 125 gfx::GpuMemoryBufferHandle handle;
136 handle.type = gfx::OZONE_NATIVE_PIXMAP; 126 handle.type = gfx::OZONE_NATIVE_PIXMAP;
137 handle.id = id_; 127 handle.id = id_;
138 handle.native_pixmap_handle.fds.emplace_back(fd_.get(), 128 handle.native_pixmap_handle.fds.emplace_back(fd_.get(),
139 false /* auto_close */); 129 false /* auto_close */);
140 handle.native_pixmap_handle.planes = planes_; 130 handle.native_pixmap_handle.planes = planes_;
141 return handle; 131 return handle;
142 } 132 }
143 133
144 } // namespace gpu 134 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/client/gpu_memory_buffer_impl_ozone_native_pixmap.h ('k') | media/gpu/video_decode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698