OLD | NEW |
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 381 } |
382 | 382 |
383 void GLSurfaceOzoneSurfaceless::SubmitFrame() { | 383 void GLSurfaceOzoneSurfaceless::SubmitFrame() { |
384 DCHECK(!unsubmitted_frames_.empty()); | 384 DCHECK(!unsubmitted_frames_.empty()); |
385 | 385 |
386 if (unsubmitted_frames_.front()->ready && !swap_buffers_pending_) { | 386 if (unsubmitted_frames_.front()->ready && !swap_buffers_pending_) { |
387 scoped_ptr<PendingFrame> frame(unsubmitted_frames_.front()); | 387 scoped_ptr<PendingFrame> frame(unsubmitted_frames_.front()); |
388 unsubmitted_frames_.weak_erase(unsubmitted_frames_.begin()); | 388 unsubmitted_frames_.weak_erase(unsubmitted_frames_.begin()); |
389 swap_buffers_pending_ = true; | 389 swap_buffers_pending_ = true; |
390 | 390 |
391 last_swap_buffers_result_ = | 391 if (!frame->ScheduleOverlayPlanes(widget_)) { |
392 frame->ScheduleOverlayPlanes(widget_) && | 392 // |callback| is a wrapper for SwapCompleted(). Call it to properly |
393 ozone_surface_->OnSwapBuffersAsync(frame->callback); | 393 // propagate the failed state. |
| 394 frame->callback.Run(gfx::SwapResult::SWAP_FAILED); |
| 395 return; |
| 396 } |
| 397 |
| 398 ozone_surface_->OnSwapBuffersAsync(frame->callback); |
394 } | 399 } |
395 } | 400 } |
396 | 401 |
397 EGLSyncKHR GLSurfaceOzoneSurfaceless::InsertFence() { | 402 EGLSyncKHR GLSurfaceOzoneSurfaceless::InsertFence() { |
398 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, | 403 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, |
399 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, | 404 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, |
400 EGL_NONE}; | 405 EGL_NONE}; |
401 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); | 406 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); |
402 } | 407 } |
403 | 408 |
404 void GLSurfaceOzoneSurfaceless::FenceRetired(EGLSyncKHR fence, | 409 void GLSurfaceOzoneSurfaceless::FenceRetired(EGLSyncKHR fence, |
405 PendingFrame* frame) { | 410 PendingFrame* frame) { |
406 eglDestroySyncKHR(GetDisplay(), fence); | 411 eglDestroySyncKHR(GetDisplay(), fence); |
407 frame->ready = true; | 412 frame->ready = true; |
408 SubmitFrame(); | 413 SubmitFrame(); |
409 } | 414 } |
410 | 415 |
411 void GLSurfaceOzoneSurfaceless::SwapCompleted( | 416 void GLSurfaceOzoneSurfaceless::SwapCompleted( |
412 const SwapCompletionCallback& callback, | 417 const SwapCompletionCallback& callback, |
413 gfx::SwapResult result) { | 418 gfx::SwapResult result) { |
414 callback.Run(result); | 419 callback.Run(result); |
415 swap_buffers_pending_ = false; | 420 swap_buffers_pending_ = false; |
| 421 if (result == gfx::SwapResult::SWAP_FAILED) { |
| 422 last_swap_buffers_result_ = false; |
| 423 return; |
| 424 } |
416 | 425 |
417 SubmitFrame(); | 426 SubmitFrame(); |
418 } | 427 } |
419 | 428 |
420 // This provides surface-like semantics implemented through surfaceless. | 429 // This provides surface-like semantics implemented through surfaceless. |
421 // A framebuffer is bound automatically. | 430 // A framebuffer is bound automatically. |
422 class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl | 431 class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl |
423 : public GLSurfaceOzoneSurfaceless { | 432 : public GLSurfaceOzoneSurfaceless { |
424 public: | 433 public: |
425 GLSurfaceOzoneSurfacelessSurfaceImpl( | 434 GLSurfaceOzoneSurfacelessSurfaceImpl( |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 } | 723 } |
715 } | 724 } |
716 | 725 |
717 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 726 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
718 return ui::OzonePlatform::GetInstance() | 727 return ui::OzonePlatform::GetInstance() |
719 ->GetSurfaceFactoryOzone() | 728 ->GetSurfaceFactoryOzone() |
720 ->GetNativeDisplay(); | 729 ->GetNativeDisplay(); |
721 } | 730 } |
722 | 731 |
723 } // namespace gfx | 732 } // namespace gfx |
OLD | NEW |