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

Side by Side Diff: components/mus/gles2/ozone_gpu_memory_buffer.cc

Issue 1906623003: Convert //components/mus from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 "components/mus/gles2/ozone_gpu_memory_buffer.h" 5 #include "components/mus/gles2/ozone_gpu_memory_buffer.h"
6 6
7 #include "ui/gfx/buffer_format_util.h" 7 #include "ui/gfx/buffer_format_util.h"
8 #include "ui/ozone/public/client_native_pixmap.h" 8 #include "ui/ozone/public/client_native_pixmap.h"
9 #include "ui/ozone/public/client_native_pixmap_factory.h" 9 #include "ui/ozone/public/client_native_pixmap_factory.h"
10 #include "ui/ozone/public/native_pixmap.h" 10 #include "ui/ozone/public/native_pixmap.h"
11 #include "ui/ozone/public/ozone_platform.h" 11 #include "ui/ozone/public/ozone_platform.h"
12 #include "ui/ozone/public/surface_factory_ozone.h" 12 #include "ui/ozone/public/surface_factory_ozone.h"
13 13
14 namespace mus { 14 namespace mus {
15 15
16 OzoneGpuMemoryBuffer::OzoneGpuMemoryBuffer( 16 OzoneGpuMemoryBuffer::OzoneGpuMemoryBuffer(
17 gfx::GpuMemoryBufferId id, 17 gfx::GpuMemoryBufferId id,
18 const gfx::Size& size, 18 const gfx::Size& size,
19 gfx::BufferFormat format, 19 gfx::BufferFormat format,
20 scoped_ptr<ui::ClientNativePixmap> client_pixmap, 20 std::unique_ptr<ui::ClientNativePixmap> client_pixmap,
21 scoped_refptr<ui::NativePixmap> native_pixmap) 21 scoped_refptr<ui::NativePixmap> native_pixmap)
22 : GpuMemoryBufferImpl(id, size, format), 22 : GpuMemoryBufferImpl(id, size, format),
23 client_pixmap_(std::move(client_pixmap)), 23 client_pixmap_(std::move(client_pixmap)),
24 native_pixmap_(native_pixmap) {} 24 native_pixmap_(native_pixmap) {}
25 25
26 OzoneGpuMemoryBuffer::~OzoneGpuMemoryBuffer() { 26 OzoneGpuMemoryBuffer::~OzoneGpuMemoryBuffer() {
27 DCHECK(!mapped_); 27 DCHECK(!mapped_);
28 } 28 }
29 29
30 // static 30 // static
31 OzoneGpuMemoryBuffer* OzoneGpuMemoryBuffer::FromClientBuffer( 31 OzoneGpuMemoryBuffer* OzoneGpuMemoryBuffer::FromClientBuffer(
32 ClientBuffer buffer) { 32 ClientBuffer buffer) {
33 return reinterpret_cast<OzoneGpuMemoryBuffer*>(buffer); 33 return reinterpret_cast<OzoneGpuMemoryBuffer*>(buffer);
34 } 34 }
35 35
36 // static 36 // static
37 scoped_ptr<gfx::GpuMemoryBuffer> 37 std::unique_ptr<gfx::GpuMemoryBuffer>
38 OzoneGpuMemoryBuffer::CreateOzoneGpuMemoryBuffer( 38 OzoneGpuMemoryBuffer::CreateOzoneGpuMemoryBuffer(
39 const gfx::Size& size, 39 const gfx::Size& size,
40 gfx::BufferFormat format, 40 gfx::BufferFormat format,
41 gfx::BufferUsage usage, 41 gfx::BufferUsage usage,
42 gfx::AcceleratedWidget widget) { 42 gfx::AcceleratedWidget widget) {
43 scoped_refptr<ui::NativePixmap> pixmap = 43 scoped_refptr<ui::NativePixmap> pixmap =
44 ui::OzonePlatform::GetInstance() 44 ui::OzonePlatform::GetInstance()
45 ->GetSurfaceFactoryOzone() 45 ->GetSurfaceFactoryOzone()
46 ->CreateNativePixmap(widget, size, format, usage); 46 ->CreateNativePixmap(widget, size, format, usage);
47 47
48 DCHECK(pixmap) << "need pixmap to exist!"; 48 DCHECK(pixmap) << "need pixmap to exist!";
49 49
50 if (!pixmap.get()) { 50 if (!pixmap.get()) {
51 DLOG(ERROR) << "Failed to create pixmap " << size.width() << "x" 51 DLOG(ERROR) << "Failed to create pixmap " << size.width() << "x"
52 << size.height() << " format " << static_cast<int>(format) 52 << size.height() << " format " << static_cast<int>(format)
53 << ", usage " << static_cast<int>(usage); 53 << ", usage " << static_cast<int>(usage);
54 return nullptr; 54 return nullptr;
55 } 55 }
56 56
57 // We construct a ui::NativePixmapHandle 57 // We construct a ui::NativePixmapHandle
58 gfx::NativePixmapHandle native_pixmap_handle = pixmap->ExportHandle(); 58 gfx::NativePixmapHandle native_pixmap_handle = pixmap->ExportHandle();
59 DCHECK(ui::ClientNativePixmapFactory::GetInstance()) 59 DCHECK(ui::ClientNativePixmapFactory::GetInstance())
60 << "need me a ClientNativePixmapFactory"; 60 << "need me a ClientNativePixmapFactory";
61 scoped_ptr<ui::ClientNativePixmap> client_native_pixmap = 61 std::unique_ptr<ui::ClientNativePixmap> client_native_pixmap =
62 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle( 62 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle(
63 native_pixmap_handle, size, usage); 63 native_pixmap_handle, size, usage);
64 64
65 scoped_ptr<OzoneGpuMemoryBuffer> nb( 65 std::unique_ptr<OzoneGpuMemoryBuffer> nb(
66 new OzoneGpuMemoryBuffer(gfx::GpuMemoryBufferId(0), size, format, 66 new OzoneGpuMemoryBuffer(gfx::GpuMemoryBufferId(0), size, format,
67 std::move(client_native_pixmap), pixmap)); 67 std::move(client_native_pixmap), pixmap));
68 return std::move(nb); 68 return std::move(nb);
69 } 69 }
70 70
71 bool OzoneGpuMemoryBuffer::Map() { 71 bool OzoneGpuMemoryBuffer::Map() {
72 DCHECK(!mapped_); 72 DCHECK(!mapped_);
73 if (!client_pixmap_->Map()) 73 if (!client_pixmap_->Map())
74 return false; 74 return false;
75 mapped_ = true; 75 mapped_ = true;
(...skipping 30 matching lines...) Expand all
106 return gfx::OZONE_NATIVE_PIXMAP; 106 return gfx::OZONE_NATIVE_PIXMAP;
107 } 107 }
108 108
109 #if defined(USE_OZONE) 109 #if defined(USE_OZONE)
110 scoped_refptr<ui::NativePixmap> OzoneGpuMemoryBuffer::GetNativePixmap() { 110 scoped_refptr<ui::NativePixmap> OzoneGpuMemoryBuffer::GetNativePixmap() {
111 return native_pixmap_; 111 return native_pixmap_;
112 } 112 }
113 #endif 113 #endif
114 114
115 } // namespace mus 115 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/gles2/ozone_gpu_memory_buffer.h ('k') | components/mus/gles2/raster_thread_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698