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

Side by Side Diff: ui/ozone/platform/dri/gbm_surface.cc

Issue 812933003: [Ozone-Dri] Create GbmWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-wrapper
Patch Set: Rebased Created 5 years, 11 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/dri/gbm_surface.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.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/dri/gbm_surface.h" 5 #include "ui/ozone/platform/dri/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/dri/dri_buffer.h" 11 #include "ui/ozone/platform/dri/dri_buffer.h"
12 #include "ui/ozone/platform/dri/dri_window_delegate.h" 12 #include "ui/ozone/platform/dri/dri_window_delegate.h"
13 #include "ui/ozone/platform/dri/dri_wrapper.h"
14 #include "ui/ozone/platform/dri/gbm_buffer_base.h" 13 #include "ui/ozone/platform/dri/gbm_buffer_base.h"
14 #include "ui/ozone/platform/dri/gbm_wrapper.h"
15 #include "ui/ozone/platform/dri/hardware_display_controller.h" 15 #include "ui/ozone/platform/dri/hardware_display_controller.h"
16 #include "ui/ozone/platform/dri/scanout_buffer.h" 16 #include "ui/ozone/platform/dri/scanout_buffer.h"
17 17
18 namespace ui { 18 namespace ui {
19 19
20 namespace { 20 namespace {
21 21
22 class GbmSurfaceBuffer : public GbmBufferBase { 22 class GbmSurfaceBuffer : public GbmBufferBase {
23 public: 23 public:
24 static scoped_refptr<GbmSurfaceBuffer> CreateBuffer(DriWrapper* dri, 24 static scoped_refptr<GbmSurfaceBuffer> CreateBuffer(DriWrapper* dri,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 // static 71 // static
72 void GbmSurfaceBuffer::Destroy(gbm_bo* buffer, void* data) { 72 void GbmSurfaceBuffer::Destroy(gbm_bo* buffer, void* data) {
73 GbmSurfaceBuffer* scoped_buffer = static_cast<GbmSurfaceBuffer*>(data); 73 GbmSurfaceBuffer* scoped_buffer = static_cast<GbmSurfaceBuffer*>(data);
74 scoped_buffer->self_ = NULL; 74 scoped_buffer->self_ = NULL;
75 } 75 }
76 76
77 } // namespace 77 } // namespace
78 78
79 GbmSurface::GbmSurface(DriWindowDelegate* window_delegate, 79 GbmSurface::GbmSurface(DriWindowDelegate* window_delegate, GbmWrapper* gbm)
80 gbm_device* device,
81 DriWrapper* dri)
82 : GbmSurfaceless(window_delegate), 80 : GbmSurfaceless(window_delegate),
83 gbm_device_(device), 81 gbm_(gbm),
84 dri_(dri),
85 native_surface_(NULL), 82 native_surface_(NULL),
86 current_buffer_(NULL), 83 current_buffer_(NULL),
87 weak_factory_(this) { 84 weak_factory_(this) {
88 } 85 }
89 86
90 GbmSurface::~GbmSurface() { 87 GbmSurface::~GbmSurface() {
91 if (current_buffer_) 88 if (current_buffer_)
92 gbm_surface_release_buffer(native_surface_, current_buffer_); 89 gbm_surface_release_buffer(native_surface_, current_buffer_);
93 90
94 if (native_surface_) 91 if (native_surface_)
95 gbm_surface_destroy(native_surface_); 92 gbm_surface_destroy(native_surface_);
96 } 93 }
97 94
98 bool GbmSurface::Initialize() { 95 bool GbmSurface::Initialize() {
99 // If we're initializing the surface without a controller (possible on startup 96 // If we're initializing the surface without a controller (possible on startup
100 // where the surface creation can happen before the native window delegate 97 // where the surface creation can happen before the native window delegate
101 // IPCs arrive), initialize the size to a valid value such that surface 98 // IPCs arrive), initialize the size to a valid value such that surface
102 // creation doesn't fail. 99 // creation doesn't fail.
103 gfx::Size size(1, 1); 100 gfx::Size size(1, 1);
104 if (window_delegate_->GetController()) { 101 if (window_delegate_->GetController()) {
105 size = window_delegate_->GetController()->GetModeSize(); 102 size = window_delegate_->GetController()->GetModeSize();
106 } 103 }
107 // TODO(dnicoara) Check underlying system support for pixel format. 104 // TODO(dnicoara) Check underlying system support for pixel format.
108 native_surface_ = 105 native_surface_ = gbm_surface_create(
109 gbm_surface_create(gbm_device_, 106 gbm_->device(), size.width(), size.height(), GBM_BO_FORMAT_XRGB8888,
110 size.width(), 107 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
111 size.height(),
112 GBM_BO_FORMAT_XRGB8888,
113 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
114 108
115 if (!native_surface_) 109 if (!native_surface_)
116 return false; 110 return false;
117 111
118 size_ = size; 112 size_ = size;
119 return true; 113 return true;
120 } 114 }
121 115
122 intptr_t GbmSurface::GetNativeWindow() { 116 intptr_t GbmSurface::GetNativeWindow() {
123 DCHECK(native_surface_); 117 DCHECK(native_surface_);
(...skipping 11 matching lines...) Expand all
135 return OnSwapBuffersAsync(base::Bind(&base::DoNothing)); 129 return OnSwapBuffersAsync(base::Bind(&base::DoNothing));
136 } 130 }
137 131
138 bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) { 132 bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
139 DCHECK(native_surface_); 133 DCHECK(native_surface_);
140 134
141 gbm_bo* pending_buffer = gbm_surface_lock_front_buffer(native_surface_); 135 gbm_bo* pending_buffer = gbm_surface_lock_front_buffer(native_surface_);
142 scoped_refptr<GbmSurfaceBuffer> primary = 136 scoped_refptr<GbmSurfaceBuffer> primary =
143 GbmSurfaceBuffer::GetBuffer(pending_buffer); 137 GbmSurfaceBuffer::GetBuffer(pending_buffer);
144 if (!primary.get()) { 138 if (!primary.get()) {
145 primary = GbmSurfaceBuffer::CreateBuffer(dri_, pending_buffer); 139 primary = GbmSurfaceBuffer::CreateBuffer(gbm_, pending_buffer);
146 if (!primary.get()) { 140 if (!primary.get()) {
147 LOG(ERROR) << "Failed to associate the buffer with the controller"; 141 LOG(ERROR) << "Failed to associate the buffer with the controller";
148 callback.Run(); 142 callback.Run();
149 return false; 143 return false;
150 } 144 }
151 } 145 }
152 146
153 // The primary buffer is a special case. 147 // The primary buffer is a special case.
154 if (window_delegate_->GetController()) 148 if (window_delegate_->GetController())
155 window_delegate_->GetController()->QueueOverlayPlane(OverlayPlane(primary)); 149 window_delegate_->GetController()->QueueOverlayPlane(OverlayPlane(primary));
(...skipping 12 matching lines...) Expand all
168 gbm_bo* pending_buffer) { 162 gbm_bo* pending_buffer) {
169 // If there was a frontbuffer, it is no longer active. Release it back to GBM. 163 // If there was a frontbuffer, it is no longer active. Release it back to GBM.
170 if (current_buffer_) 164 if (current_buffer_)
171 gbm_surface_release_buffer(native_surface_, current_buffer_); 165 gbm_surface_release_buffer(native_surface_, current_buffer_);
172 166
173 current_buffer_ = pending_buffer; 167 current_buffer_ = pending_buffer;
174 callback.Run(); 168 callback.Run();
175 } 169 }
176 170
177 } // namespace ui 171 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_surface.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698