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

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: EGL_KHR_fence_sync DCHECK Created 3 years, 7 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 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 106
108 SwapCompletionCallback surface_swap_callback = base::Bind( 107 SwapCompletionCallback surface_swap_callback = base::Bind(
109 &GbmSurfaceless::SwapCompleted, weak_factory_.GetWeakPtr(), callback); 108 &GbmSurfaceless::SwapCompleted, weak_factory_.GetWeakPtr(), callback);
110 109
111 PendingFrame* frame = unsubmitted_frames_.back().get(); 110 PendingFrame* frame = unsubmitted_frames_.back().get();
112 frame->callback = surface_swap_callback; 111 frame->callback = surface_swap_callback;
113 unsubmitted_frames_.push_back(base::MakeUnique<PendingFrame>()); 112 unsubmitted_frames_.push_back(base::MakeUnique<PendingFrame>());
114 113
115 // TODO: the following should be replaced by a per surface flush as it gets 114 // TODO: the following should be replaced by a per surface flush as it gets
116 // implemented in GL drivers. 115 // implemented in GL drivers.
117 EGLSyncKHR fence = InsertFence(has_implicit_external_sync_); 116 EGLSyncKHR fence = InsertFence(has_native_fence_sync_);
118 if (!fence) { 117 if (!fence) {
119 callback.Run(gfx::SwapResult::SWAP_FAILED); 118 callback.Run(gfx::SwapResult::SWAP_FAILED);
120 return; 119 return;
121 } 120 }
122 121
123 base::Closure fence_wait_task = 122 base::Closure fence_wait_task =
124 base::Bind(&WaitForFence, GetDisplay(), fence); 123 base::Bind(&WaitForFence, GetDisplay(), fence);
125 124
126 base::Closure fence_retired_callback = base::Bind( 125 base::Closure fence_retired_callback = base::Bind(
127 &GbmSurfaceless::FenceRetired, weak_factory_.GetWeakPtr(), fence, frame); 126 &GbmSurfaceless::FenceRetired, weak_factory_.GetWeakPtr(), fence, frame);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // propagate the failed state. 198 // propagate the failed state.
200 frame->callback.Run(gfx::SwapResult::SWAP_FAILED); 199 frame->callback.Run(gfx::SwapResult::SWAP_FAILED);
201 return; 200 return;
202 } 201 }
203 202
204 window_->SchedulePageFlip(planes_, frame->callback); 203 window_->SchedulePageFlip(planes_, frame->callback);
205 planes_.clear(); 204 planes_.clear();
206 } 205 }
207 } 206 }
208 207
209 EGLSyncKHR GbmSurfaceless::InsertFence(bool implicit) { 208 EGLSyncKHR GbmSurfaceless::InsertFence(bool native) {
210 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, 209 return eglCreateSyncKHR(
211 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, 210 GetDisplay(), native ? EGL_SYNC_NATIVE_FENCE_ANDROID : EGL_SYNC_FENCE_KHR,
212 EGL_NONE}; 211 nullptr);
213 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR,
214 implicit ? attrib_list : NULL);
215 } 212 }
216 213
217 void GbmSurfaceless::FenceRetired(EGLSyncKHR fence, PendingFrame* frame) { 214 void GbmSurfaceless::FenceRetired(EGLSyncKHR fence, PendingFrame* frame) {
218 eglDestroySyncKHR(GetDisplay(), fence); 215 eglDestroySyncKHR(GetDisplay(), fence);
219 frame->ready = true; 216 frame->ready = true;
220 SubmitFrame(); 217 SubmitFrame();
221 } 218 }
222 219
223 void GbmSurfaceless::SwapCompleted(const SwapCompletionCallback& callback, 220 void GbmSurfaceless::SwapCompleted(const SwapCompletionCallback& callback,
224 gfx::SwapResult result) { 221 gfx::SwapResult result) {
225 callback.Run(result); 222 callback.Run(result);
226 swap_buffers_pending_ = false; 223 swap_buffers_pending_ = false;
227 if (result == gfx::SwapResult::SWAP_FAILED) { 224 if (result == gfx::SwapResult::SWAP_FAILED) {
228 last_swap_buffers_result_ = false; 225 last_swap_buffers_result_ = false;
229 return; 226 return;
230 } 227 }
231 228
232 SubmitFrame(); 229 SubmitFrame();
233 } 230 }
234 231
235 } // namespace ui 232 } // namespace ui
OLDNEW
« gpu/config/gpu_driver_bug_list.json ('K') | « 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