| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // TODO: the following should be replaced by a per surface flush as it gets | 276 // TODO: the following should be replaced by a per surface flush as it gets |
| 277 // implemented in GL drivers. | 277 // implemented in GL drivers. |
| 278 if (has_implicit_external_sync_) { | 278 if (has_implicit_external_sync_) { |
| 279 EGLSyncKHR fence = InsertFence(); | 279 EGLSyncKHR fence = InsertFence(); |
| 280 if (!fence) | 280 if (!fence) |
| 281 return SwapResult::SWAP_FAILED; | 281 return SwapResult::SWAP_FAILED; |
| 282 | 282 |
| 283 EGLDisplay display = GetDisplay(); | 283 EGLDisplay display = GetDisplay(); |
| 284 WaitForFence(display, fence); | 284 WaitForFence(display, fence); |
| 285 eglDestroySyncKHR(display, fence); | 285 eglDestroySyncKHR(display, fence); |
| 286 } else if (ozone_surface_->IsUniversalDisplayLinkDevice()) { | |
| 287 glFinish(); | |
| 288 } | 286 } |
| 289 | 287 |
| 290 unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_); | 288 unsubmitted_frames_.back()->ScheduleOverlayPlanes(widget_); |
| 291 unsubmitted_frames_.back()->overlays.clear(); | 289 unsubmitted_frames_.back()->overlays.clear(); |
| 292 | 290 |
| 291 if (ozone_surface_->IsUniversalDisplayLinkDevice()) |
| 292 glFinish(); |
| 293 |
| 293 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK | 294 return ozone_surface_->OnSwapBuffers() ? gfx::SwapResult::SWAP_ACK |
| 294 : gfx::SwapResult::SWAP_FAILED; | 295 : gfx::SwapResult::SWAP_FAILED; |
| 295 } | 296 } |
| 296 | 297 |
| 297 bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane(int z_order, | 298 bool GLSurfaceOzoneSurfaceless::ScheduleOverlayPlane(int z_order, |
| 298 OverlayTransform transform, | 299 OverlayTransform transform, |
| 299 GLImage* image, | 300 GLImage* image, |
| 300 const Rect& bounds_rect, | 301 const Rect& bounds_rect, |
| 301 const RectF& crop_rect) { | 302 const RectF& crop_rect) { |
| 302 unsubmitted_frames_.back()->overlays.push_back( | 303 unsubmitted_frames_.back()->overlays.push_back( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 base::Closure fence_wait_task = | 352 base::Closure fence_wait_task = |
| 352 base::Bind(&WaitForFence, GetDisplay(), fence); | 353 base::Bind(&WaitForFence, GetDisplay(), fence); |
| 353 | 354 |
| 354 base::Closure fence_retired_callback = | 355 base::Closure fence_retired_callback = |
| 355 base::Bind(&GLSurfaceOzoneSurfaceless::FenceRetired, | 356 base::Bind(&GLSurfaceOzoneSurfaceless::FenceRetired, |
| 356 weak_factory_.GetWeakPtr(), fence, frame); | 357 weak_factory_.GetWeakPtr(), fence, frame); |
| 357 | 358 |
| 358 base::WorkerPool::PostTaskAndReply(FROM_HERE, fence_wait_task, | 359 base::WorkerPool::PostTaskAndReply(FROM_HERE, fence_wait_task, |
| 359 fence_retired_callback, false); | 360 fence_retired_callback, false); |
| 360 return true; | 361 return true; |
| 361 } else if (ozone_surface_->IsUniversalDisplayLinkDevice()) { | |
| 362 glFinish(); | |
| 363 } | 362 } |
| 364 | 363 |
| 365 frame->ready = true; | 364 frame->ready = true; |
| 366 SubmitFrame(); | 365 SubmitFrame(); |
| 367 return last_swap_buffers_result_; | 366 return last_swap_buffers_result_; |
| 368 } | 367 } |
| 369 | 368 |
| 370 bool GLSurfaceOzoneSurfaceless::PostSubBufferAsync( | 369 bool GLSurfaceOzoneSurfaceless::PostSubBufferAsync( |
| 371 int x, | 370 int x, |
| 372 int y, | 371 int y, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 388 unsubmitted_frames_.weak_erase(unsubmitted_frames_.begin()); | 387 unsubmitted_frames_.weak_erase(unsubmitted_frames_.begin()); |
| 389 swap_buffers_pending_ = true; | 388 swap_buffers_pending_ = true; |
| 390 | 389 |
| 391 if (!frame->ScheduleOverlayPlanes(widget_)) { | 390 if (!frame->ScheduleOverlayPlanes(widget_)) { |
| 392 // |callback| is a wrapper for SwapCompleted(). Call it to properly | 391 // |callback| is a wrapper for SwapCompleted(). Call it to properly |
| 393 // propagate the failed state. | 392 // propagate the failed state. |
| 394 frame->callback.Run(gfx::SwapResult::SWAP_FAILED); | 393 frame->callback.Run(gfx::SwapResult::SWAP_FAILED); |
| 395 return; | 394 return; |
| 396 } | 395 } |
| 397 | 396 |
| 397 if (ozone_surface_->IsUniversalDisplayLinkDevice()) |
| 398 glFinish(); |
| 399 |
| 398 ozone_surface_->OnSwapBuffersAsync(frame->callback); | 400 ozone_surface_->OnSwapBuffersAsync(frame->callback); |
| 399 } | 401 } |
| 400 } | 402 } |
| 401 | 403 |
| 402 EGLSyncKHR GLSurfaceOzoneSurfaceless::InsertFence() { | 404 EGLSyncKHR GLSurfaceOzoneSurfaceless::InsertFence() { |
| 403 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, | 405 const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR, |
| 404 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, | 406 EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, |
| 405 EGL_NONE}; | 407 EGL_NONE}; |
| 406 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); | 408 return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list); |
| 407 } | 409 } |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 } | 725 } |
| 724 } | 726 } |
| 725 | 727 |
| 726 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 728 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
| 727 return ui::OzonePlatform::GetInstance() | 729 return ui::OzonePlatform::GetInstance() |
| 728 ->GetSurfaceFactoryOzone() | 730 ->GetSurfaceFactoryOzone() |
| 729 ->GetNativeDisplay(); | 731 ->GetNativeDisplay(); |
| 730 } | 732 } |
| 731 | 733 |
| 732 } // namespace gfx | 734 } // namespace gfx |
| OLD | NEW |