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

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

Issue 821023003: [Ozone-DRI] Listen for swap events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-swap
Patch Set: Added comment 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_surfaceless.cc » ('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/logging.h" 10 #include "base/logging.h"
10 #include "ui/ozone/platform/dri/dri_buffer.h" 11 #include "ui/ozone/platform/dri/dri_buffer.h"
11 #include "ui/ozone/platform/dri/dri_window_delegate.h" 12 #include "ui/ozone/platform/dri/dri_window_delegate.h"
12 #include "ui/ozone/platform/dri/dri_wrapper.h" 13 #include "ui/ozone/platform/dri/dri_wrapper.h"
13 #include "ui/ozone/platform/dri/gbm_buffer_base.h" 14 #include "ui/ozone/platform/dri/gbm_buffer_base.h"
14 #include "ui/ozone/platform/dri/hardware_display_controller.h" 15 #include "ui/ozone/platform/dri/hardware_display_controller.h"
15 #include "ui/ozone/platform/dri/scanout_buffer.h" 16 #include "ui/ozone/platform/dri/scanout_buffer.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 } // namespace 77 } // namespace
77 78
78 GbmSurface::GbmSurface(DriWindowDelegate* window_delegate, 79 GbmSurface::GbmSurface(DriWindowDelegate* window_delegate,
79 gbm_device* device, 80 gbm_device* device,
80 DriWrapper* dri) 81 DriWrapper* dri)
81 : GbmSurfaceless(window_delegate), 82 : GbmSurfaceless(window_delegate),
82 gbm_device_(device), 83 gbm_device_(device),
83 dri_(dri), 84 dri_(dri),
84 native_surface_(NULL), 85 native_surface_(NULL),
85 current_buffer_(NULL) { 86 current_buffer_(NULL),
87 weak_factory_(this) {
86 } 88 }
87 89
88 GbmSurface::~GbmSurface() { 90 GbmSurface::~GbmSurface() {
89 if (current_buffer_) 91 if (current_buffer_)
90 gbm_surface_release_buffer(native_surface_, current_buffer_); 92 gbm_surface_release_buffer(native_surface_, current_buffer_);
91 93
92 if (native_surface_) 94 if (native_surface_)
93 gbm_surface_destroy(native_surface_); 95 gbm_surface_destroy(native_surface_);
94 } 96 }
95 97
(...skipping 27 matching lines...) Expand all
123 } 125 }
124 126
125 bool GbmSurface::ResizeNativeWindow(const gfx::Size& viewport_size) { 127 bool GbmSurface::ResizeNativeWindow(const gfx::Size& viewport_size) {
126 if (size_ == viewport_size) 128 if (size_ == viewport_size)
127 return true; 129 return true;
128 130
129 return false; 131 return false;
130 } 132 }
131 133
132 bool GbmSurface::OnSwapBuffers() { 134 bool GbmSurface::OnSwapBuffers() {
135 NOTREACHED();
136 return false;
137 }
138
139 bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
133 DCHECK(native_surface_); 140 DCHECK(native_surface_);
134 141
135 gbm_bo* pending_buffer = gbm_surface_lock_front_buffer(native_surface_); 142 gbm_bo* pending_buffer = gbm_surface_lock_front_buffer(native_surface_);
136 scoped_refptr<GbmSurfaceBuffer> primary = 143 scoped_refptr<GbmSurfaceBuffer> primary =
137 GbmSurfaceBuffer::GetBuffer(pending_buffer); 144 GbmSurfaceBuffer::GetBuffer(pending_buffer);
138 if (!primary.get()) { 145 if (!primary.get()) {
139 primary = GbmSurfaceBuffer::CreateBuffer(dri_, pending_buffer); 146 primary = GbmSurfaceBuffer::CreateBuffer(dri_, pending_buffer);
140 if (!primary.get()) { 147 if (!primary.get()) {
141 LOG(ERROR) << "Failed to associate the buffer with the controller"; 148 LOG(ERROR) << "Failed to associate the buffer with the controller";
149 callback.Run();
142 return false; 150 return false;
143 } 151 }
144 } 152 }
145 153
146 // The primary buffer is a special case. 154 // The primary buffer is a special case.
147 if (window_delegate_->GetController()) 155 if (window_delegate_->GetController())
148 window_delegate_->GetController()->QueueOverlayPlane(OverlayPlane(primary)); 156 window_delegate_->GetController()->QueueOverlayPlane(OverlayPlane(primary));
149 157
150 if (!GbmSurfaceless::OnSwapBuffers()) 158 if (!GbmSurfaceless::OnSwapBuffersAsync(
159 base::Bind(&GbmSurface::OnSwapBuffersCallback,
160 weak_factory_.GetWeakPtr(), callback, pending_buffer))) {
161 callback.Run();
151 return false; 162 return false;
163 }
152 164
165 return true;
166 }
167
168 void GbmSurface::OnSwapBuffersCallback(const SwapCompletionCallback& callback,
169 gbm_bo* pending_buffer) {
153 // 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.
154 if (current_buffer_) 171 if (current_buffer_)
155 gbm_surface_release_buffer(native_surface_, current_buffer_); 172 gbm_surface_release_buffer(native_surface_, current_buffer_);
156 173
157 current_buffer_ = pending_buffer; 174 current_buffer_ = pending_buffer;
158 return true;
159 }
160
161 bool GbmSurface::OnSwapBuffersAsync(const SwapCompletionCallback& callback) {
162 bool success = OnSwapBuffers();
163 callback.Run(); 175 callback.Run();
164 return success;
165 } 176 }
166 177
167 } // namespace ui 178 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_surface.h ('k') | ui/ozone/platform/dri/gbm_surfaceless.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698