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

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

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: Created 5 years, 3 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.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_surface.h"
6 6
7 #include <gbm.h> 7 #include <gbm.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" 11 #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
12 #include "ui/ozone/platform/drm/gpu/drm_window.h" 12 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
13 #include "ui/ozone/platform/drm/gpu/gbm_buffer_base.h" 13 #include "ui/ozone/platform/drm/gpu/gbm_buffer_base.h"
14 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 14 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
15 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 15 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
16 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 16 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
17 17
18 namespace ui { 18 namespace ui {
19 19
20 namespace { 20 namespace {
21 21
22 void DoNothing(gfx::SwapResult) { 22 void DoNothing(gfx::SwapResult) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 // static 78 // static
79 void GbmSurfaceBuffer::Destroy(gbm_bo* buffer, void* data) { 79 void GbmSurfaceBuffer::Destroy(gbm_bo* buffer, void* data) {
80 GbmSurfaceBuffer* scoped_buffer = static_cast<GbmSurfaceBuffer*>(data); 80 GbmSurfaceBuffer* scoped_buffer = static_cast<GbmSurfaceBuffer*>(data);
81 scoped_buffer->self_ = NULL; 81 scoped_buffer->self_ = NULL;
82 } 82 }
83 83
84 } // namespace 84 } // namespace
85 85
86 GbmSurface::GbmSurface(DrmWindow* window, const scoped_refptr<GbmDevice>& gbm) 86 GbmSurface::GbmSurface(scoped_ptr<DrmWindowProxy> window,
87 : GbmSurfaceless(window, NULL), 87 const scoped_refptr<GbmDevice>& gbm)
88 : GbmSurfaceless(window.Pass()),
88 gbm_(gbm), 89 gbm_(gbm),
89 native_surface_(NULL), 90 native_surface_(NULL),
90 current_buffer_(NULL), 91 current_buffer_(NULL),
91 weak_factory_(this) { 92 weak_factory_(this) {}
92 }
93 93
94 GbmSurface::~GbmSurface() { 94 GbmSurface::~GbmSurface() {
95 if (current_buffer_) 95 if (current_buffer_)
96 gbm_surface_release_buffer(native_surface_, current_buffer_); 96 gbm_surface_release_buffer(native_surface_, current_buffer_);
97 97
98 if (native_surface_) 98 if (native_surface_)
99 gbm_surface_destroy(native_surface_); 99 gbm_surface_destroy(native_surface_);
100 } 100 }
101 101
102 bool GbmSurface::Initialize() { 102 bool GbmSurface::Initialize() {
103 // If we're initializing the surface without a controller (possible on startup 103 // If we're initializing the surface without a controller (possible on startup
104 // where the surface creation can happen before the native window 104 // where the surface creation can happen before the native window
105 // IPCs arrive), initialize the size to a valid value such that surface 105 // IPCs arrive), initialize the size to a valid value such that surface
106 // creation doesn't fail. 106 // creation doesn't fail.
107 gfx::Size size(1, 1); 107 gfx::Size size(1, 1);
108 if (window_->GetController()) { 108 if (!window_->GetBounds().size().IsEmpty()) {
109 size = window_->GetController()->GetModeSize(); 109 size = window_->GetBounds().size();
110 } 110 }
111 // TODO(dnicoara) Check underlying system support for pixel format. 111 // TODO(dnicoara) Check underlying system support for pixel format.
112 native_surface_ = gbm_surface_create( 112 native_surface_ = gbm_surface_create(
113 gbm_->device(), size.width(), size.height(), GBM_BO_FORMAT_XRGB8888, 113 gbm_->device(), size.width(), size.height(), GBM_BO_FORMAT_XRGB8888,
114 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); 114 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
115 115
116 if (!native_surface_) 116 if (!native_surface_)
117 return false; 117 return false;
118 118
119 size_ = size; 119 size_ = size;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 gfx::SwapResult result) { 169 gfx::SwapResult result) {
170 // If there was a frontbuffer, it is no longer active. Release it back to GBM. 170 // If there was a frontbuffer, it is no longer active. Release it back to GBM.
171 if (current_buffer_) 171 if (current_buffer_)
172 gbm_surface_release_buffer(native_surface_, current_buffer_); 172 gbm_surface_release_buffer(native_surface_, current_buffer_);
173 173
174 current_buffer_ = pending_buffer; 174 current_buffer_ = pending_buffer;
175 callback.Run(result); 175 callback.Run(result);
176 } 176 }
177 177
178 } // namespace ui 178 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698