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

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

Issue 1432963003: [Ozone] Extends the lifetime of VaapiWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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_buffer.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <gbm.h> 9 #include <gbm.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/posix/eintr_wrapper.h" 13 #include "base/posix/eintr_wrapper.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "ui/gfx/geometry/size_conversions.h" 15 #include "ui/gfx/geometry/size_conversions.h"
16 #include "ui/gfx/native_pixmap_handle_ozone.h" 16 #include "ui/gfx/native_pixmap_handle_ozone.h"
17 #include "ui/ozone/platform/drm/common/drm_util.h" 17 #include "ui/ozone/platform/drm/common/drm_util.h"
18 #include "ui/ozone/platform/drm/gpu/drm_window.h" 18 #include "ui/ozone/platform/drm/gpu/drm_window.h"
19 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 19 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
20 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" 20 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
21 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" 21 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
22 #include "ui/ozone/public/ozone_platform.h"
23 #include "ui/ozone/public/surface_factory_ozone.h"
22 24
23 namespace { 25 namespace {
24 // Optimal format for rendering on overlay. 26 // Optimal format for rendering on overlay.
25 const gfx::BufferFormat kOverlayRenderFormat = gfx::BufferFormat::UYVY_422; 27 const gfx::BufferFormat kOverlayRenderFormat = gfx::BufferFormat::UYVY_422;
26 } // namespace 28 } // namespace
27 29
28 namespace ui { 30 namespace ui {
29 31
30 GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, 32 GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
31 gbm_bo* bo, 33 gbm_bo* bo,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 88 }
87 89
88 void GbmPixmap::SetProcessingCallback( 90 void GbmPixmap::SetProcessingCallback(
89 const ProcessingCallback& processing_callback) { 91 const ProcessingCallback& processing_callback) {
90 processing_callback_ = processing_callback; 92 processing_callback_ = processing_callback;
91 } 93 }
92 94
93 scoped_refptr<NativePixmap> GbmPixmap::GetProcessedPixmap( 95 scoped_refptr<NativePixmap> GbmPixmap::GetProcessedPixmap(
94 gfx::Size target_size, 96 gfx::Size target_size,
95 gfx::BufferFormat target_format) { 97 gfx::BufferFormat target_format) {
96 return processing_callback_.Run(target_size, target_format); 98 ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
99 ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
100 // Create a buffer from Ozone.
101 scoped_refptr<ui::NativePixmap> processed_pixmap =
102 factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, target_size,
103 target_format, gfx::BufferUsage::SCANOUT);
104 if (!processed_pixmap) {
105 LOG(ERROR) << "Failed creating an Ozone NativePixmap for processing";
106 return nullptr;
107 }
108 if (!processing_callback_.Run(this, processed_pixmap)) {
109 LOG(ERROR) << "Failed processing NativePixmap";
110 return nullptr;
111 }
112 return processed_pixmap;
97 } 113 }
98 114
99 gfx::NativePixmapHandle GbmPixmap::ExportHandle() { 115 gfx::NativePixmapHandle GbmPixmap::ExportHandle() {
100 gfx::NativePixmapHandle handle; 116 gfx::NativePixmapHandle handle;
101 117
102 base::ScopedFD dmabuf_fd(HANDLE_EINTR(dup(dma_buf_.get()))); 118 base::ScopedFD dmabuf_fd(HANDLE_EINTR(dup(dma_buf_.get())));
103 if (!dmabuf_fd.is_valid()) { 119 if (!dmabuf_fd.is_valid()) {
104 PLOG(ERROR) << "dup"; 120 PLOG(ERROR) << "dup";
105 return handle; 121 return handle;
106 } 122 }
(...skipping 15 matching lines...) Expand all
122 } 138 }
123 139
124 int GbmPixmap::GetDmaBufPitch() const { 140 int GbmPixmap::GetDmaBufPitch() const {
125 return dma_buf_pitch_; 141 return dma_buf_pitch_;
126 } 142 }
127 143
128 gfx::BufferFormat GbmPixmap::GetBufferFormat() const { 144 gfx::BufferFormat GbmPixmap::GetBufferFormat() const {
129 return GetBufferFormatFromFourCCFormat(buffer_->GetFramebufferPixelFormat()); 145 return GetBufferFormatFromFourCCFormat(buffer_->GetFramebufferPixelFormat());
130 } 146 }
131 147
148 gfx::Size GbmPixmap::GetBufferSize() const {
149 return buffer_->GetSize();
150 }
151
132 bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 152 bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
133 int plane_z_order, 153 int plane_z_order,
134 gfx::OverlayTransform plane_transform, 154 gfx::OverlayTransform plane_transform,
135 const gfx::Rect& display_bounds, 155 const gfx::Rect& display_bounds,
136 const gfx::RectF& crop_rect) { 156 const gfx::RectF& crop_rect) {
137 gfx::Size target_size; 157 gfx::Size target_size;
138 gfx::BufferFormat target_format; 158 gfx::BufferFormat target_format;
139 if (plane_z_order && ShouldApplyProcessing(display_bounds, crop_rect, 159 if (plane_z_order && ShouldApplyProcessing(display_bounds, crop_rect,
140 &target_size, &target_format)) { 160 &target_size, &target_format)) {
141 scoped_refptr<NativePixmap> processed_pixmap = 161 scoped_refptr<NativePixmap> processed_pixmap =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 gfx::Size pixmap_size = buffer_->GetSize(); 200 gfx::Size pixmap_size = buffer_->GetSize();
181 // If the required size is not integer-sized, round it to the next integer. 201 // If the required size is not integer-sized, round it to the next integer.
182 *target_size = gfx::ToCeiledSize( 202 *target_size = gfx::ToCeiledSize(
183 gfx::SizeF(display_bounds.width() / crop_rect.width(), 203 gfx::SizeF(display_bounds.width() / crop_rect.width(),
184 display_bounds.height() / crop_rect.height())); 204 display_bounds.height() / crop_rect.height()));
185 205
186 return pixmap_size != *target_size || GetBufferFormat() != *target_format; 206 return pixmap_size != *target_size || GetBufferFormat() != *target_format;
187 } 207 }
188 208
189 } // namespace ui 209 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer.h ('k') | ui/ozone/platform/headless/headless_surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698