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 } else { | |
396 ozone_surface_->OnSwapBuffersAsync(frame->callback); | |
spang
2015/11/12 01:34:07
I think you should return in the error path instea
dnicoara
2015/11/12 15:16:52
Done.
| |
397 } | |
394 } | 398 } |
395 } | 399 } |
396 | 400 |
397 EGLSyncKHR GLSurfaceOzoneSurfaceless::InsertFence() { | 401 EGLSyncKHR GLSurfaceOzoneSurfaceless::InsertFence() { |
398 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, | 402 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, |
399 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, | 403 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, |
400 EGL_NONE}; | 404 EGL_NONE}; |
401 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); | 405 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); |
402 } | 406 } |
403 | 407 |
404 void GLSurfaceOzoneSurfaceless::FenceRetired(EGLSyncKHR fence, | 408 void GLSurfaceOzoneSurfaceless::FenceRetired(EGLSyncKHR fence, |
405 PendingFrame* frame) { | 409 PendingFrame* frame) { |
406 eglDestroySyncKHR(GetDisplay(), fence); | 410 eglDestroySyncKHR(GetDisplay(), fence); |
407 frame->ready = true; | 411 frame->ready = true; |
408 SubmitFrame(); | 412 SubmitFrame(); |
409 } | 413 } |
410 | 414 |
411 void GLSurfaceOzoneSurfaceless::SwapCompleted( | 415 void GLSurfaceOzoneSurfaceless::SwapCompleted( |
412 const SwapCompletionCallback& callback, | 416 const SwapCompletionCallback& callback, |
413 gfx::SwapResult result) { | 417 gfx::SwapResult result) { |
414 callback.Run(result); | 418 callback.Run(result); |
415 swap_buffers_pending_ = false; | 419 swap_buffers_pending_ = false; |
416 | 420 if (result == gfx::SwapResult::SWAP_FAILED) |
417 SubmitFrame(); | 421 last_swap_buffers_result_ = false; |
422 else | |
423 SubmitFrame(); | |
spang
2015/11/12 01:34:07
same comment, avoid putting success path flow into
dnicoara
2015/11/12 15:16:52
Done.
| |
418 } | 424 } |
419 | 425 |
420 // This provides surface-like semantics implemented through surfaceless. | 426 // This provides surface-like semantics implemented through surfaceless. |
421 // A framebuffer is bound automatically. | 427 // A framebuffer is bound automatically. |
422 class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl | 428 class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl |
423 : public GLSurfaceOzoneSurfaceless { | 429 : public GLSurfaceOzoneSurfaceless { |
424 public: | 430 public: |
425 GLSurfaceOzoneSurfacelessSurfaceImpl( | 431 GLSurfaceOzoneSurfacelessSurfaceImpl( |
426 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 432 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
427 AcceleratedWidget widget); | 433 AcceleratedWidget widget); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 } | 720 } |
715 } | 721 } |
716 | 722 |
717 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 723 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
718 return ui::OzonePlatform::GetInstance() | 724 return ui::OzonePlatform::GetInstance() |
719 ->GetSurfaceFactoryOzone() | 725 ->GetSurfaceFactoryOzone() |
720 ->GetNativeDisplay(); | 726 ->GetNativeDisplay(); |
721 } | 727 } |
722 | 728 |
723 } // namespace gfx | 729 } // namespace gfx |
OLD | NEW |