OLD | NEW |
---|---|
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 "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
12 #include "ui/ozone/common/egl_util.h" | 12 #include "ui/ozone/common/egl_util.h" |
13 #include "ui/ozone/platform/drm/common/drm_util.h" | |
13 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" |
14 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" | 15 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" |
15 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 16 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
16 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
17 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" | 18 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
18 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 19 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
19 #include "ui/ozone/public/native_pixmap.h" | 20 #include "ui/ozone/public/native_pixmap.h" |
20 #include "ui/ozone/public/surface_ozone_canvas.h" | 21 #include "ui/ozone/public/surface_ozone_canvas.h" |
21 #include "ui/ozone/public/surface_ozone_egl.h" | 22 #include "ui/ozone/public/surface_ozone_egl.h" |
22 | 23 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 } | 97 } |
97 | 98 |
98 scoped_ptr<SurfaceOzoneEGL> | 99 scoped_ptr<SurfaceOzoneEGL> |
99 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( | 100 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( |
100 gfx::AcceleratedWidget widget) { | 101 gfx::AcceleratedWidget widget) { |
101 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
102 return make_scoped_ptr( | 103 return make_scoped_ptr( |
103 new GbmSurfaceless(drm_thread_->CreateDrmWindowProxy(widget), this)); | 104 new GbmSurfaceless(drm_thread_->CreateDrmWindowProxy(widget), this)); |
104 } | 105 } |
105 | 106 |
107 bool GbmSurfaceFactory::GetSupportedFormats( | |
spang
2016/01/20 18:52:24
Why does this take a usage parameter?
This is che
william.xie
2016/01/21 02:14:02
Thanks Michael, I documented the concern in the AP
| |
108 gfx::BufferUsage buffer_usage, | |
109 std::vector<gfx::BufferFormat>* support_formats) { | |
110 auto it = support_formats_map_.find(buffer_usage); | |
111 if (it != support_formats_map_.end()) { | |
112 *support_formats = it->second; | |
113 return true; | |
114 } | |
115 | |
116 switch (buffer_usage) { | |
117 case gfx::BufferUsage::SCANOUT: | |
118 if (drm_thread_ != nullptr) { | |
119 std::vector<uint32_t> fourcc_formats; | |
120 drm_thread_->GetSupportedFormats(&fourcc_formats); | |
121 for (auto& fourcc : fourcc_formats) | |
122 support_formats->push_back(GetBufferFormatFromFourCCFormat(fourcc)); | |
123 support_formats_map_.insert( | |
124 std::make_pair(buffer_usage, *support_formats)); | |
125 return true; | |
126 } | |
127 default: | |
128 return false; | |
129 } | |
130 | |
131 return false; | |
132 } | |
133 | |
106 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 134 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
107 gfx::AcceleratedWidget widget, | 135 gfx::AcceleratedWidget widget, |
108 gfx::Size size, | 136 gfx::Size size, |
109 gfx::BufferFormat format, | 137 gfx::BufferFormat format, |
110 gfx::BufferUsage usage) { | 138 gfx::BufferUsage usage) { |
111 #if !defined(OS_CHROMEOS) | 139 #if !defined(OS_CHROMEOS) |
112 // Support for memory mapping accelerated buffers requires some | 140 // Support for memory mapping accelerated buffers requires some |
113 // CrOS-specific patches (using vgem). | 141 // CrOS-specific patches (using vgem). |
114 DCHECK(gfx::BufferUsage::SCANOUT == usage); | 142 DCHECK(gfx::BufferUsage::SCANOUT == usage); |
115 #endif | 143 #endif |
(...skipping 11 matching lines...) Expand all Loading... | |
127 } | 155 } |
128 | 156 |
129 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( | 157 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( |
130 const gfx::NativePixmapHandle& handle) { | 158 const gfx::NativePixmapHandle& handle) { |
131 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); | 159 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); |
132 pixmap->Initialize(base::ScopedFD(handle.fd.fd), handle.stride); | 160 pixmap->Initialize(base::ScopedFD(handle.fd.fd), handle.stride); |
133 return pixmap; | 161 return pixmap; |
134 } | 162 } |
135 | 163 |
136 } // namespace ui | 164 } // namespace ui |
OLD | NEW |