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

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

Issue 1071273002: NotForReview: Implement zero/one-copy texture for ozone freon using Intel DRM Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after ClientNativePixmap is introduced Created 5 years, 4 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
« no previous file with comments | « ui/ozone/platform/drm/gbm.gypi ('k') | ui/ozone/platform/drm/gpu/intel_drm_pixmap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "third_party/khronos/EGL/egl.h" 10 #include "third_party/khronos/EGL/egl.h"
11 #include "ui/ozone/common/egl_util.h" 11 #include "ui/ozone/common/egl_util.h"
12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
13 #include "ui/ozone/platform/drm/gpu/drm_window.h" 13 #include "ui/ozone/platform/drm/gpu/drm_window.h"
14 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" 14 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
15 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 15 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
16 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" 16 #include "ui/ozone/platform/drm/gpu/gbm_surface.h"
17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" 17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
19 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 19 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
20 #include "ui/ozone/public/native_pixmap.h" 20 #include "ui/ozone/public/native_pixmap.h"
21 #include "ui/ozone/public/surface_ozone_canvas.h" 21 #include "ui/ozone/public/surface_ozone_canvas.h"
22 #include "ui/ozone/public/surface_ozone_egl.h" 22 #include "ui/ozone/public/surface_ozone_egl.h"
23 23
24 #if defined(OZONE_USE_VGEM_MAP)
25 #include "base/command_line.h"
26 #include "ui/ozone/platform/drm/gpu/intel_drm_pixmap.h"
27 #include "ui/ozone/public/ozone_switches.h"
28 #endif
29
24 namespace ui { 30 namespace ui {
25 31
26 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) 32 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless)
27 : DrmSurfaceFactory(nullptr), 33 : DrmSurfaceFactory(nullptr),
28 allow_surfaceless_(allow_surfaceless), 34 allow_surfaceless_(allow_surfaceless),
29 drm_device_manager_(nullptr) {} 35 drm_device_manager_(nullptr) {}
30 36
31 GbmSurfaceFactory::~GbmSurfaceFactory() { 37 GbmSurfaceFactory::~GbmSurfaceFactory() {
32 DCHECK(thread_checker_.CalledOnValidThread()); 38 DCHECK(thread_checker_.CalledOnValidThread());
33 } 39 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 gfx::BufferUsage usage) { 117 gfx::BufferUsage usage) {
112 #if !defined(OS_CHROMEOS) 118 #if !defined(OS_CHROMEOS)
113 // Support for memory mapping accelerated buffers requires some 119 // Support for memory mapping accelerated buffers requires some
114 // CrOS-specific patches (using vgem). 120 // CrOS-specific patches (using vgem).
115 DCHECK_EQ(gfx::BufferUsage::SCANOUT, usage); 121 DCHECK_EQ(gfx::BufferUsage::SCANOUT, usage);
116 #endif 122 #endif
117 123
118 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); 124 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
119 DCHECK(gbm); 125 DCHECK(gbm);
120 126
127 #if defined(OZONE_USE_VGEM_MAP)
128 bool enable_intel_drm = base::CommandLine::ForCurrentProcess()->HasSwitch(
129 switches::kOzoneUseIntelDrm);
130 if (enable_intel_drm && usage == gfx::BufferUsage::MAP) {
131 scoped_refptr<IntelDrmPixmap> pixmap = IntelDrmPixmap::Create(
132 base::FileDescriptor(gbm->get_fd(), false), format, size);
133 if (!pixmap.get())
134 return nullptr;
135 return pixmap;
136 }
137 #endif
138
121 scoped_refptr<GbmBuffer> buffer = 139 scoped_refptr<GbmBuffer> buffer =
122 GbmBuffer::CreateBuffer(gbm, format, size, usage); 140 GbmBuffer::CreateBuffer(gbm, format, size, usage);
123 if (!buffer.get()) 141 if (!buffer.get())
124 return nullptr; 142 return nullptr;
125 143
126 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); 144 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_));
127 if (!pixmap->Initialize()) 145 if (!pixmap->Initialize())
128 return nullptr; 146 return nullptr;
129 147
130 return pixmap; 148 return pixmap;
131 } 149 }
132 150
133 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { 151 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
134 DCHECK(thread_checker_.CalledOnValidThread()); 152 DCHECK(thread_checker_.CalledOnValidThread());
135 return allow_surfaceless_; 153 return allow_surfaceless_;
136 } 154 }
137 155
138 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( 156 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice(
139 gfx::AcceleratedWidget widget) { 157 gfx::AcceleratedWidget widget) {
140 return static_cast<GbmDevice*>( 158 return static_cast<GbmDevice*>(
141 drm_device_manager_->GetDrmDevice(widget).get()); 159 drm_device_manager_->GetDrmDevice(widget).get());
142 } 160 }
143 161
144 } // namespace ui 162 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gbm.gypi ('k') | ui/ozone/platform/drm/gpu/intel_drm_pixmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698