| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/common/gpu/image_transport_surface_overlay_mac.h" | 5 #include "content/common/gpu/image_transport_surface_overlay_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <IOSurface/IOSurface.h> | 8 #include <IOSurface/IOSurface.h> |
| 9 #include <OpenGL/CGLRenderers.h> | 9 #include <OpenGL/CGLRenderers.h> |
| 10 #include <OpenGL/CGLTypes.h> | 10 #include <OpenGL/CGLTypes.h> |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // Sort the input planes by z-index, and remove any overlays from the | 355 // Sort the input planes by z-index, and remove any overlays from the |
| 356 // damage rect. | 356 // damage rect. |
| 357 gfx::RectF dip_damage_rect = ConvertRectToDIPF( | 357 gfx::RectF dip_damage_rect = ConvertRectToDIPF( |
| 358 swap->scale_factor, swap->pixel_damage_rect); | 358 swap->scale_factor, swap->pixel_damage_rect); |
| 359 std::sort(swap->overlay_planes.begin(), swap->overlay_planes.end(), | 359 std::sort(swap->overlay_planes.begin(), swap->overlay_planes.end(), |
| 360 OverlayPlane::Compare); | 360 OverlayPlane::Compare); |
| 361 for (auto& plane : swap->overlay_planes) | 361 for (auto& plane : swap->overlay_planes) |
| 362 dip_damage_rect.Subtract(plane->dip_frame_rect); | 362 dip_damage_rect.Subtract(plane->dip_frame_rect); |
| 363 | 363 |
| 364 ScopedCAActionDisabler disabler; | 364 ScopedCAActionDisabler disabler; |
| 365 if (swap->root_plane.get()) | 365 UpdateRootAndPartialDamagePlanes(swap->root_plane, dip_damage_rect); |
| 366 UpdateRootAndPartialDamagePlanes(swap->root_plane, dip_damage_rect); | |
| 367 UpdateOverlayPlanes(swap->overlay_planes); | 366 UpdateOverlayPlanes(swap->overlay_planes); |
| 368 UpdateCALayerTree(); | 367 UpdateCALayerTree(); |
| 369 swap->overlay_planes.clear(); | 368 swap->overlay_planes.clear(); |
| 370 } | 369 } |
| 371 | 370 |
| 372 // Send acknowledgement to the browser. | 371 // Send acknowledgement to the browser. |
| 373 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 372 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 374 params.surface_handle = | 373 params.surface_handle = |
| 375 ui::SurfaceHandleFromCAContextID([ca_context_ contextId]); | 374 ui::SurfaceHandleFromCAContextID([ca_context_ contextId]); |
| 376 params.size = swap->pixel_size; | 375 params.size = swap->pixel_size; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 403 old_plane->Destroy(); | 402 old_plane->Destroy(); |
| 404 } | 403 } |
| 405 | 404 |
| 406 void ImageTransportSurfaceOverlayMac::UpdateRootAndPartialDamagePlanes( | 405 void ImageTransportSurfaceOverlayMac::UpdateRootAndPartialDamagePlanes( |
| 407 const linked_ptr<OverlayPlane>& new_root_plane, | 406 const linked_ptr<OverlayPlane>& new_root_plane, |
| 408 const gfx::RectF& dip_damage_rect) { | 407 const gfx::RectF& dip_damage_rect) { |
| 409 std::list<linked_ptr<OverlayPlane>> old_partial_damage_planes; | 408 std::list<linked_ptr<OverlayPlane>> old_partial_damage_planes; |
| 410 old_partial_damage_planes.swap(current_partial_damage_planes_); | 409 old_partial_damage_planes.swap(current_partial_damage_planes_); |
| 411 linked_ptr<OverlayPlane> plane_for_swap; | 410 linked_ptr<OverlayPlane> plane_for_swap; |
| 412 | 411 |
| 412 // If there is no new root plane, destroy the old one. |
| 413 if (!new_root_plane.get()) { |
| 414 for (auto& old_plane : old_partial_damage_planes) |
| 415 old_plane->Destroy(); |
| 416 if (current_root_plane_.get()) |
| 417 current_root_plane_->Destroy(); |
| 418 current_root_plane_.reset(); |
| 419 return; |
| 420 } |
| 421 |
| 413 // If the frame's size changed, if we haven't updated the root layer, or if | 422 // If the frame's size changed, if we haven't updated the root layer, or if |
| 414 // we have full damage, then use the root layer directly. | 423 // we have full damage, then use the root layer directly. |
| 415 if (!current_root_plane_.get() || | 424 if (!current_root_plane_.get() || |
| 416 current_root_plane_->dip_frame_rect != new_root_plane->dip_frame_rect || | 425 current_root_plane_->dip_frame_rect != new_root_plane->dip_frame_rect || |
| 417 dip_damage_rect == new_root_plane->dip_frame_rect) { | 426 dip_damage_rect == new_root_plane->dip_frame_rect) { |
| 418 plane_for_swap = new_root_plane; | 427 plane_for_swap = new_root_plane; |
| 419 } | 428 } |
| 420 | 429 |
| 421 // Walk though the existing partial damage layers and see if there is one that | 430 // Walk though the existing partial damage layers and see if there is one that |
| 422 // is appropriate to re-use. | 431 // is appropriate to re-use. |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // Compute the previous vsync time. | 716 // Compute the previous vsync time. |
| 708 base::TimeTicks previous_vsync = | 717 base::TimeTicks previous_vsync = |
| 709 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + | 718 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + |
| 710 vsync_timebase_; | 719 vsync_timebase_; |
| 711 | 720 |
| 712 // Return |interval_fraction| through the next vsync. | 721 // Return |interval_fraction| through the next vsync. |
| 713 return previous_vsync + (1 + interval_fraction) * vsync_interval_; | 722 return previous_vsync + (1 + interval_fraction) * vsync_interval_; |
| 714 } | 723 } |
| 715 | 724 |
| 716 } // namespace content | 725 } // namespace content |
| OLD | NEW |