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

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

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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 "gpu/ipc/common/gpu_memory_buffer_support.h" 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
10 #include "ui/gfx/buffer_format_util.h" 11 #include "ui/gfx/buffer_format_util.h"
11 #include "ui/ozone/public/client_native_pixmap_factory.h" 12 #include "ui/ozone/public/client_native_pixmap_factory.h"
12 #include "ui/ozone/public/native_pixmap.h" 13 #include "ui/ozone/public/native_pixmap.h"
13 #include "ui/ozone/public/ozone_platform.h" 14 #include "ui/ozone/public/ozone_platform.h"
14 #include "ui/ozone/public/surface_factory_ozone.h" 15 #include "ui/ozone/public/surface_factory_ozone.h"
15 16
16 namespace gpu { 17 namespace gpu {
17 namespace { 18 namespace {
18 19
19 void FreeNativePixmapForTesting(scoped_refptr<ui::NativePixmap> native_pixmap) { 20 void FreeNativePixmapForTesting(scoped_refptr<ui::NativePixmap> native_pixmap) {
20 // Nothing to do here. |native_pixmap| will be freed when this function 21 // Nothing to do here. |native_pixmap| will be freed when this function
21 // returns and reference count drops to 0. 22 // returns and reference count drops to 0.
22 } 23 }
23 24
24 } // namespace 25 } // namespace
25 26
26 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap( 27 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap(
27 gfx::GpuMemoryBufferId id, 28 gfx::GpuMemoryBufferId id,
28 const gfx::Size& size, 29 const gfx::Size& size,
29 gfx::BufferFormat format, 30 gfx::BufferFormat format,
30 const DestructionCallback& callback, 31 const DestructionCallback& callback,
31 scoped_ptr<ui::ClientNativePixmap> pixmap) 32 std::unique_ptr<ui::ClientNativePixmap> pixmap)
32 : GpuMemoryBufferImpl(id, size, format, callback), 33 : GpuMemoryBufferImpl(id, size, format, callback),
33 pixmap_(std::move(pixmap)), 34 pixmap_(std::move(pixmap)),
34 data_(nullptr) {} 35 data_(nullptr) {}
35 36
36 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} 37 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {}
37 38
38 // static 39 // static
39 scoped_ptr<GpuMemoryBufferImplOzoneNativePixmap> 40 std::unique_ptr<GpuMemoryBufferImplOzoneNativePixmap>
40 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( 41 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle(
41 const gfx::GpuMemoryBufferHandle& handle, 42 const gfx::GpuMemoryBufferHandle& handle,
42 const gfx::Size& size, 43 const gfx::Size& size,
43 gfx::BufferFormat format, 44 gfx::BufferFormat format,
44 gfx::BufferUsage usage, 45 gfx::BufferUsage usage,
45 const DestructionCallback& callback) { 46 const DestructionCallback& callback) {
46 scoped_ptr<ui::ClientNativePixmap> native_pixmap = 47 std::unique_ptr<ui::ClientNativePixmap> native_pixmap =
47 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle( 48 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle(
48 handle.native_pixmap_handle, size, usage); 49 handle.native_pixmap_handle, size, usage);
49 DCHECK(native_pixmap); 50 DCHECK(native_pixmap);
50 return make_scoped_ptr(new GpuMemoryBufferImplOzoneNativePixmap( 51 return base::WrapUnique(new GpuMemoryBufferImplOzoneNativePixmap(
51 handle.id, size, format, callback, std::move(native_pixmap))); 52 handle.id, size, format, callback, std::move(native_pixmap)));
52 } 53 }
53 54
54 // static 55 // static
55 bool GpuMemoryBufferImplOzoneNativePixmap::IsConfigurationSupported( 56 bool GpuMemoryBufferImplOzoneNativePixmap::IsConfigurationSupported(
56 gfx::BufferFormat format, 57 gfx::BufferFormat format,
57 gfx::BufferUsage usage) { 58 gfx::BufferUsage usage) {
58 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); 59 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
59 } 60 }
60 61
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() 109 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle()
109 const { 110 const {
110 gfx::GpuMemoryBufferHandle handle; 111 gfx::GpuMemoryBufferHandle handle;
111 handle.type = gfx::OZONE_NATIVE_PIXMAP; 112 handle.type = gfx::OZONE_NATIVE_PIXMAP;
112 handle.id = id_; 113 handle.id = id_;
113 return handle; 114 return handle;
114 } 115 }
115 116
116 } // namespace gpu 117 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/client/gpu_memory_buffer_impl_ozone_native_pixmap.h ('k') | gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698