| 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); | 665 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); |
| 666 | 666 |
| 667 // Compute |vsync_timebase_| to be the first vsync after time zero. | 667 // Compute |vsync_timebase_| to be the first vsync after time zero. |
| 668 if (vsync_parameters_valid_) { | 668 if (vsync_parameters_valid_) { |
| 669 vsync_timebase_ -= | 669 vsync_timebase_ -= |
| 670 vsync_interval_ * | 670 vsync_interval_ * |
| 671 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); | 671 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 | 674 |
| 675 void ImageTransportSurfaceOverlayMac::OnResize(gfx::Size pixel_size, | 675 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, |
| 676 float scale_factor) { | 676 float scale_factor) { |
| 677 // Flush through any pending frames. | 677 // Flush through any pending frames. |
| 678 DisplayAndClearAllPendingSwaps(); | 678 DisplayAndClearAllPendingSwaps(); |
| 679 pixel_size_ = pixel_size; | 679 pixel_size_ = pixel_size; |
| 680 scale_factor_ = scale_factor; | 680 scale_factor_ = scale_factor; |
| 681 return true; |
| 681 } | 682 } |
| 682 | 683 |
| 683 void ImageTransportSurfaceOverlayMac::SetLatencyInfo( | 684 void ImageTransportSurfaceOverlayMac::SetLatencyInfo( |
| 684 const std::vector<ui::LatencyInfo>& latency_info) { | 685 const std::vector<ui::LatencyInfo>& latency_info) { |
| 685 latency_info_.insert( | 686 latency_info_.insert( |
| 686 latency_info_.end(), latency_info.begin(), latency_info.end()); | 687 latency_info_.end(), latency_info.begin(), latency_info.end()); |
| 687 } | 688 } |
| 688 | 689 |
| 689 void ImageTransportSurfaceOverlayMac::OnGpuSwitched() { | 690 void ImageTransportSurfaceOverlayMac::OnGpuSwitched() { |
| 690 // Create a new context, and use the GL renderer ID that the new context gets. | 691 // Create a new context, and use the GL renderer ID that the new context gets. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 716 // Compute the previous vsync time. | 717 // Compute the previous vsync time. |
| 717 base::TimeTicks previous_vsync = | 718 base::TimeTicks previous_vsync = |
| 718 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + | 719 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + |
| 719 vsync_timebase_; | 720 vsync_timebase_; |
| 720 | 721 |
| 721 // Return |interval_fraction| through the next vsync. | 722 // Return |interval_fraction| through the next vsync. |
| 722 return previous_vsync + (1 + interval_fraction) * vsync_interval_; | 723 return previous_vsync + (1 + interval_fraction) * vsync_interval_; |
| 723 } | 724 } |
| 724 | 725 |
| 725 } // namespace content | 726 } // namespace content |
| OLD | NEW |