| 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); | 693 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); |
| 694 | 694 |
| 695 // Compute |vsync_timebase_| to be the first vsync after time zero. | 695 // Compute |vsync_timebase_| to be the first vsync after time zero. |
| 696 if (vsync_parameters_valid_) { | 696 if (vsync_parameters_valid_) { |
| 697 vsync_timebase_ -= | 697 vsync_timebase_ -= |
| 698 vsync_interval_ * | 698 vsync_interval_ * |
| 699 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); | 699 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| 703 void ImageTransportSurfaceOverlayMac::OnResize(gfx::Size pixel_size, | 703 bool ImageTransportSurfaceOverlayMac::Resize(const gfx::Size& pixel_size, |
| 704 float scale_factor) { | 704 float scale_factor) { |
| 705 // Flush through any pending frames. | 705 // Flush through any pending frames. |
| 706 DisplayAndClearAllPendingSwaps(); | 706 DisplayAndClearAllPendingSwaps(); |
| 707 pixel_size_ = pixel_size; | 707 pixel_size_ = pixel_size; |
| 708 scale_factor_ = scale_factor; | 708 scale_factor_ = scale_factor; |
| 709 return true; |
| 709 } | 710 } |
| 710 | 711 |
| 711 void ImageTransportSurfaceOverlayMac::SetLatencyInfo( | 712 void ImageTransportSurfaceOverlayMac::SetLatencyInfo( |
| 712 const std::vector<ui::LatencyInfo>& latency_info) { | 713 const std::vector<ui::LatencyInfo>& latency_info) { |
| 713 latency_info_.insert( | 714 latency_info_.insert( |
| 714 latency_info_.end(), latency_info.begin(), latency_info.end()); | 715 latency_info_.end(), latency_info.begin(), latency_info.end()); |
| 715 } | 716 } |
| 716 | 717 |
| 717 void ImageTransportSurfaceOverlayMac::OnGpuSwitched() { | 718 void ImageTransportSurfaceOverlayMac::OnGpuSwitched() { |
| 718 // Create a new context, and use the GL renderer ID that the new context gets. | 719 // Create a new context, and use the GL renderer ID that the new context gets. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 744 // Compute the previous vsync time. | 745 // Compute the previous vsync time. |
| 745 base::TimeTicks previous_vsync = | 746 base::TimeTicks previous_vsync = |
| 746 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + | 747 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + |
| 747 vsync_timebase_; | 748 vsync_timebase_; |
| 748 | 749 |
| 749 // Return |interval_fraction| through the next vsync. | 750 // Return |interval_fraction| through the next vsync. |
| 750 return previous_vsync + (1 + interval_fraction) * vsync_interval_; | 751 return previous_vsync + (1 + interval_fraction) * vsync_interval_; |
| 751 } | 752 } |
| 752 | 753 |
| 753 } // namespace content | 754 } // namespace content |
| OLD | NEW |