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

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_surface_factory.cc

Issue 2148983002: gpu: Take surface handle into account when importing buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: avoid crash in DrmDeviceManager::GetDrmDevice when passed invalid widget Created 4 years, 5 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 "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
6 6
7 #include <gbm.h> 7 #include <gbm.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 scoped_refptr<GbmBuffer> buffer = 105 scoped_refptr<GbmBuffer> buffer =
106 drm_thread_->CreateBuffer(widget, size, format, usage); 106 drm_thread_->CreateBuffer(widget, size, format, usage);
107 if (!buffer.get()) 107 if (!buffer.get())
108 return nullptr; 108 return nullptr;
109 109
110 return make_scoped_refptr(new GbmPixmap(this, buffer)); 110 return make_scoped_refptr(new GbmPixmap(this, buffer));
111 } 111 }
112 112
113 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( 113 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle(
114 gfx::AcceleratedWidget widget,
114 gfx::Size size, 115 gfx::Size size,
115 gfx::BufferFormat format, 116 gfx::BufferFormat format,
116 const gfx::NativePixmapHandle& handle) { 117 const gfx::NativePixmapHandle& handle) {
117 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format); 118 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format);
118 if (handle.planes.size() != num_planes || 119 if (handle.planes.size() != num_planes ||
119 (handle.fds.size() != 1 && handle.fds.size() != num_planes)) { 120 (handle.fds.size() != 1 && handle.fds.size() != num_planes)) {
120 return nullptr; 121 return nullptr;
121 } 122 }
122 std::vector<base::ScopedFD> scoped_fds; 123 std::vector<base::ScopedFD> scoped_fds;
123 for (auto& fd : handle.fds) { 124 for (auto& fd : handle.fds) {
124 scoped_fds.emplace_back(fd.fd); 125 scoped_fds.emplace_back(fd.fd);
125 } 126 }
126 127
127 std::vector<gfx::NativePixmapPlane> planes; 128 std::vector<gfx::NativePixmapPlane> planes;
128 129
129 for (const auto& plane : handle.planes) { 130 for (const auto& plane : handle.planes) {
130 planes.push_back(plane); 131 planes.push_back(plane);
131 } 132 }
132 133
133 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( 134 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds(
134 size, format, std::move(scoped_fds), planes); 135 widget, size, format, std::move(scoped_fds), planes);
135 if (!buffer) 136 if (!buffer)
136 return nullptr; 137 return nullptr;
137 return make_scoped_refptr(new GbmPixmap(this, buffer)); 138 return make_scoped_refptr(new GbmPixmap(this, buffer));
138 } 139 }
139 140
140 } // namespace ui 141 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surface_factory.h ('k') | ui/ozone/public/surface_factory_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698