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

Side by Side Diff: ui/gl/gl_surface_ozone.cc

Issue 1084173004: Adding status to swap complete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change swapbuffers return Created 5 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 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/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 bool Resize(const gfx::Size& size) override { 50 bool Resize(const gfx::Size& size) override {
51 if (!ozone_surface_->ResizeNativeWindow(size)) { 51 if (!ozone_surface_->ResizeNativeWindow(size)) {
52 if (!ReinitializeNativeSurface() || 52 if (!ReinitializeNativeSurface() ||
53 !ozone_surface_->ResizeNativeWindow(size)) 53 !ozone_surface_->ResizeNativeWindow(size))
54 return false; 54 return false;
55 } 55 }
56 56
57 return NativeViewGLSurfaceEGL::Resize(size); 57 return NativeViewGLSurfaceEGL::Resize(size);
58 } 58 }
59 bool SwapBuffers() override { 59 gfx::SwapResult SwapBuffers() override {
60 if (!NativeViewGLSurfaceEGL::SwapBuffers()) 60 if (!NativeViewGLSurfaceEGL::SwapBuffers())
61 return false; 61 return gfx::SWAP_FAILED;
62 62
63 return ozone_surface_->OnSwapBuffers(); 63 return ozone_surface_->OnSwapBuffers() ? gfx::SWAP_ACK : gfx::SWAP_FAILED;
64 } 64 }
65 bool ScheduleOverlayPlane(int z_order, 65 bool ScheduleOverlayPlane(int z_order,
66 OverlayTransform transform, 66 OverlayTransform transform,
67 GLImage* image, 67 GLImage* image,
68 const Rect& bounds_rect, 68 const Rect& bounds_rect,
69 const RectF& crop_rect) override { 69 const RectF& crop_rect) override {
70 return image->ScheduleOverlayPlane( 70 return image->ScheduleOverlayPlane(
71 widget_, z_order, transform, bounds_rect, crop_rect); 71 widget_, z_order, transform, bounds_rect, crop_rect);
72 } 72 }
73 73
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (!vsync_provider_) 135 if (!vsync_provider_)
136 return false; 136 return false;
137 return true; 137 return true;
138 } 138 }
139 bool Resize(const gfx::Size& size) override { 139 bool Resize(const gfx::Size& size) override {
140 if (!ozone_surface_->ResizeNativeWindow(size)) 140 if (!ozone_surface_->ResizeNativeWindow(size))
141 return false; 141 return false;
142 142
143 return SurfacelessEGL::Resize(size); 143 return SurfacelessEGL::Resize(size);
144 } 144 }
145 bool SwapBuffers() override { 145 gfx::SwapResult SwapBuffers() override {
146 glFlush(); 146 glFlush();
147 // TODO: the following should be replaced by a per surface flush as it gets 147 // TODO: the following should be replaced by a per surface flush as it gets
148 // implemented in GL drivers. 148 // implemented in GL drivers.
149 if (has_implicit_external_sync_) { 149 if (has_implicit_external_sync_) {
150 EGLSyncKHR fence = InsertFence(); 150 EGLSyncKHR fence = InsertFence();
151 if (!fence) 151 if (!fence)
152 return false; 152 return gfx::SWAP_FAILED;
153 153
154 EGLDisplay display = GetDisplay(); 154 EGLDisplay display = GetDisplay();
155 WaitForFence(display, fence); 155 WaitForFence(display, fence);
156 eglDestroySyncKHR(display, fence); 156 eglDestroySyncKHR(display, fence);
157 } else if (ozone_surface_->IsUniversalDisplayLinkDevice()) { 157 } else if (ozone_surface_->IsUniversalDisplayLinkDevice()) {
158 glFinish(); 158 glFinish();
159 } 159 }
160 160
161 unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_); 161 unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_);
162 unsubmitted_frames_.back()->overlays.clear(); 162 unsubmitted_frames_.back()->overlays.clear();
163 163
164 return ozone_surface_->OnSwapBuffers(); 164 return ozone_surface_->OnSwapBuffers() ? gfx::SWAP_ACK : gfx::SWAP_FAILED;
165 } 165 }
166 bool ScheduleOverlayPlane(int z_order, 166 bool ScheduleOverlayPlane(int z_order,
167 OverlayTransform transform, 167 OverlayTransform transform,
168 GLImage* image, 168 GLImage* image,
169 const Rect& bounds_rect, 169 const Rect& bounds_rect,
170 const RectF& crop_rect) override { 170 const RectF& crop_rect) override {
171 unsubmitted_frames_.back()->overlays.push_back(PendingFrame::Overlay( 171 unsubmitted_frames_.back()->overlays.push_back(PendingFrame::Overlay(
172 z_order, transform, image, bounds_rect, crop_rect)); 172 z_order, transform, image, bounds_rect, crop_rect));
173 return true; 173 return true;
174 } 174 }
175 bool IsOffscreen() override { return false; } 175 bool IsOffscreen() override { return false; }
176 VSyncProvider* GetVSyncProvider() override { return vsync_provider_.get(); } 176 VSyncProvider* GetVSyncProvider() override { return vsync_provider_.get(); }
177 bool SupportsPostSubBuffer() override { return true; } 177 bool SupportsPostSubBuffer() override { return true; }
178 bool PostSubBuffer(int x, int y, int width, int height) override { 178 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override {
179 // The actual sub buffer handling is handled at higher layers. 179 // The actual sub buffer handling is handled at higher layers.
180 SwapBuffers(); 180 return SwapBuffers();
181 return true;
182 } 181 }
183 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override { 182 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override {
184 // If last swap failed, don't try to schedule new ones. 183 // If last swap failed, don't try to schedule new ones.
185 if (!last_swap_buffers_result_) 184 if (!last_swap_buffers_result_)
186 return false; 185 return false;
187 186
188 glFlush(); 187 glFlush();
189 188
190 base::Closure surface_swap_callback = 189 SwapCompletionCallback surface_swap_callback =
191 base::Bind(&GLSurfaceOzoneSurfaceless::SwapCompleted, 190 base::Bind(&GLSurfaceOzoneSurfaceless::SwapCompleted,
192 weak_factory_.GetWeakPtr(), callback); 191 weak_factory_.GetWeakPtr(), callback);
193 192
194 PendingFrame* frame = unsubmitted_frames_.back(); 193 PendingFrame* frame = unsubmitted_frames_.back();
195 frame->callback = surface_swap_callback; 194 frame->callback = surface_swap_callback;
196 unsubmitted_frames_.push_back(new PendingFrame()); 195 unsubmitted_frames_.push_back(new PendingFrame());
197 196
198 // TODO: the following should be replaced by a per surface flush as it gets 197 // TODO: the following should be replaced by a per surface flush as it gets
199 // implemented in GL drivers. 198 // implemented in GL drivers.
200 if (has_implicit_external_sync_) { 199 if (has_implicit_external_sync_) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 EGL_NONE}; 290 EGL_NONE};
292 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); 291 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list);
293 } 292 }
294 293
295 void FenceRetired(EGLSyncKHR fence, PendingFrame* frame) { 294 void FenceRetired(EGLSyncKHR fence, PendingFrame* frame) {
296 eglDestroySyncKHR(GetDisplay(), fence); 295 eglDestroySyncKHR(GetDisplay(), fence);
297 frame->ready = true; 296 frame->ready = true;
298 SubmitFrame(); 297 SubmitFrame();
299 } 298 }
300 299
301 void SwapCompleted(const SwapCompletionCallback& callback) { 300 void SwapCompleted(const SwapCompletionCallback& callback,
302 callback.Run(); 301 gfx::SwapResult result) {
302 callback.Run(result);
303 swap_buffers_pending_ = false; 303 swap_buffers_pending_ = false;
304 304
305 SubmitFrame(); 305 SubmitFrame();
306 } 306 }
307 307
308 // The native surface. Deleting this is allowed to free the EGLNativeWindow. 308 // The native surface. Deleting this is allowed to free the EGLNativeWindow.
309 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; 309 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_;
310 AcceleratedWidget widget_; 310 AcceleratedWidget widget_;
311 scoped_ptr<VSyncProvider> vsync_provider_; 311 scoped_ptr<VSyncProvider> vsync_provider_;
312 ScopedVector<PendingFrame> unsubmitted_frames_; 312 ScopedVector<PendingFrame> unsubmitted_frames_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 351 }
352 352
353 bool Resize(const gfx::Size& size) override { 353 bool Resize(const gfx::Size& size) override {
354 if (size == GetSize()) 354 if (size == GetSize())
355 return true; 355 return true;
356 return GLSurfaceOzoneSurfaceless::Resize(size) && CreatePixmaps(); 356 return GLSurfaceOzoneSurfaceless::Resize(size) && CreatePixmaps();
357 } 357 }
358 358
359 bool SupportsPostSubBuffer() override { return false; } 359 bool SupportsPostSubBuffer() override { return false; }
360 360
361 bool SwapBuffers() override { 361 gfx::SwapResult SwapBuffers() override {
362 if (!images_[current_surface_]->ScheduleOverlayPlane( 362 if (!images_[current_surface_]->ScheduleOverlayPlane(
363 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, 363 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE,
364 gfx::Rect(GetSize()), gfx::RectF(1, 1))) 364 gfx::Rect(GetSize()), gfx::RectF(1, 1)))
365 return false; 365 return gfx::SWAP_FAILED;
366 if (!GLSurfaceOzoneSurfaceless::SwapBuffers()) 366 if (!GLSurfaceOzoneSurfaceless::SwapBuffers())
367 return false; 367 return gfx::SWAP_FAILED;
368 current_surface_ ^= 1; 368 current_surface_ ^= 1;
369 BindFramebuffer(); 369 BindFramebuffer();
370 return true; 370 return gfx::SWAP_ACK;
371 } 371 }
372 372
373 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override { 373 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override {
374 if (!images_[current_surface_]->ScheduleOverlayPlane( 374 if (!images_[current_surface_]->ScheduleOverlayPlane(
375 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE, 375 widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE,
376 gfx::Rect(GetSize()), gfx::RectF(1, 1))) 376 gfx::Rect(GetSize()), gfx::RectF(1, 1)))
377 return false; 377 return false;
378 if (!GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback)) 378 if (!GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback))
379 return false; 379 return false;
380 current_surface_ ^= 1; 380 current_surface_ ^= 1;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 NOTREACHED(); 581 NOTREACHED();
582 return NULL; 582 return NULL;
583 } 583 }
584 } 584 }
585 585
586 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 586 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
587 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); 587 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay();
588 } 588 }
589 589
590 } // namespace gfx 590 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_osmesa.cc ('k') | ui/gl/gl_surface_stub.h » ('j') | ui/gl/gl_surface_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698