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

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

Issue 2864483007: gpu: Use ANDROID_native_fence_sync instead of ARM_implicit_external_sync.
Patch Set: rebase Created 3 years, 6 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/gpu/gbm_surfaceless.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_surfaceless.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 28
29 } // namespace 29 } // namespace
30 30
31 GbmSurfaceless::GbmSurfaceless(GbmSurfaceFactory* surface_factory, 31 GbmSurfaceless::GbmSurfaceless(GbmSurfaceFactory* surface_factory,
32 std::unique_ptr<DrmWindowProxy> window, 32 std::unique_ptr<DrmWindowProxy> window,
33 gfx::AcceleratedWidget widget) 33 gfx::AcceleratedWidget widget)
34 : SurfacelessEGL(gfx::Size()), 34 : SurfacelessEGL(gfx::Size()),
35 surface_factory_(surface_factory), 35 surface_factory_(surface_factory),
36 window_(std::move(window)), 36 window_(std::move(window)),
37 widget_(widget), 37 widget_(widget),
38 has_implicit_external_sync_( 38 has_native_fence_sync_(HasEGLExtension("EGL_ANDROID_native_fence_sync")),
39 HasEGLExtension("EGL_ARM_implicit_external_sync")),
40 weak_factory_(this) { 39 weak_factory_(this) {
41 surface_factory_->RegisterSurface(window_->widget(), this); 40 surface_factory_->RegisterSurface(window_->widget(), this);
42 unsubmitted_frames_.push_back(base::MakeUnique<PendingFrame>()); 41 unsubmitted_frames_.push_back(base::MakeUnique<PendingFrame>());
43 } 42 }
44 43
45 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) { 44 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) {
46 planes_.push_back(plane); 45 planes_.push_back(plane);
47 } 46 }
48 47
49 bool GbmSurfaceless::Initialize(gl::GLSurfaceFormat format) { 48 bool GbmSurfaceless::Initialize(gl::GLSurfaceFormat format) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 109
111 SwapCompletionCallback surface_swap_callback = base::Bind( 110 SwapCompletionCallback surface_swap_callback = base::Bind(
112 &GbmSurfaceless::SwapCompleted, weak_factory_.GetWeakPtr(), callback); 111 &GbmSurfaceless::SwapCompleted, weak_factory_.GetWeakPtr(), callback);
113 112
114 PendingFrame* frame = unsubmitted_frames_.back().get(); 113 PendingFrame* frame = unsubmitted_frames_.back().get();
115 frame->callback = surface_swap_callback; 114 frame->callback = surface_swap_callback;
116 unsubmitted_frames_.push_back(base::MakeUnique<PendingFrame>()); 115 unsubmitted_frames_.push_back(base::MakeUnique<PendingFrame>());
117 116
118 // TODO: the following should be replaced by a per surface flush as it gets 117 // TODO: the following should be replaced by a per surface flush as it gets
119 // implemented in GL drivers. 118 // implemented in GL drivers.
120 EGLSyncKHR fence = InsertFence(has_implicit_external_sync_); 119 EGLSyncKHR fence = InsertFence(has_native_fence_sync_);
121 if (!fence) { 120 if (!fence) {
122 callback.Run(gfx::SwapResult::SWAP_FAILED); 121 callback.Run(gfx::SwapResult::SWAP_FAILED);
123 return; 122 return;
124 } 123 }
125 124
126 base::Closure fence_wait_task = 125 base::Closure fence_wait_task =
127 base::Bind(&WaitForFence, GetDisplay(), fence); 126 base::Bind(&WaitForFence, GetDisplay(), fence);
128 127
129 base::Closure fence_retired_callback = base::Bind( 128 base::Closure fence_retired_callback = base::Bind(
130 &GbmSurfaceless::FenceRetired, weak_factory_.GetWeakPtr(), fence, frame); 129 &GbmSurfaceless::FenceRetired, weak_factory_.GetWeakPtr(), fence, frame);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // propagate the failed state. 201 // propagate the failed state.
203 frame->callback.Run(gfx::SwapResult::SWAP_FAILED); 202 frame->callback.Run(gfx::SwapResult::SWAP_FAILED);
204 return; 203 return;
205 } 204 }
206 205
207 window_->SchedulePageFlip(planes_, frame->callback); 206 window_->SchedulePageFlip(planes_, frame->callback);
208 planes_.clear(); 207 planes_.clear();
209 } 208 }
210 } 209 }
211 210
212 EGLSyncKHR GbmSurfaceless::InsertFence(bool implicit) { 211 EGLSyncKHR GbmSurfaceless::InsertFence(bool native) {
213 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, 212 return eglCreateSyncKHR(
214 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, 213 GetDisplay(), native ? EGL_SYNC_NATIVE_FENCE_ANDROID : EGL_SYNC_FENCE_KHR,
215 EGL_NONE}; 214 nullptr);
216 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR,
217 implicit ? attrib_list : NULL);
218 } 215 }
219 216
220 void GbmSurfaceless::FenceRetired(EGLSyncKHR fence, PendingFrame* frame) { 217 void GbmSurfaceless::FenceRetired(EGLSyncKHR fence, PendingFrame* frame) {
221 eglDestroySyncKHR(GetDisplay(), fence); 218 eglDestroySyncKHR(GetDisplay(), fence);
222 frame->ready = true; 219 frame->ready = true;
223 SubmitFrame(); 220 SubmitFrame();
224 } 221 }
225 222
226 void GbmSurfaceless::SwapCompleted(const SwapCompletionCallback& callback, 223 void GbmSurfaceless::SwapCompleted(const SwapCompletionCallback& callback,
227 gfx::SwapResult result) { 224 gfx::SwapResult result) {
228 callback.Run(result); 225 callback.Run(result);
229 swap_buffers_pending_ = false; 226 swap_buffers_pending_ = false;
230 if (result == gfx::SwapResult::SWAP_FAILED) { 227 if (result == gfx::SwapResult::SWAP_FAILED) {
231 last_swap_buffers_result_ = false; 228 last_swap_buffers_result_ = false;
232 return; 229 return;
233 } 230 }
234 231
235 SubmitFrame(); 232 SubmitFrame();
236 } 233 }
237 234
238 } // namespace ui 235 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surfaceless.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698