| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/layers/contents_scaling_layer.h" | 5 #include "cc/layers/contents_scaling_layer.h" |
| 6 #include "ui/gfx/size_conversions.h" | 6 #include "ui/gfx/size_conversions.h" |
| 7 | 7 |
| 8 namespace cc { | 8 namespace cc { |
| 9 | 9 |
| 10 gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale( | 10 gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale( |
| 11 float scale_x, | 11 float scale_x, |
| 12 float scale_y) const { | 12 float scale_y) const { |
| 13 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y)); | 13 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y)); |
| 14 } | 14 } |
| 15 | 15 |
| 16 ContentsScalingLayer::ContentsScalingLayer() | 16 ContentsScalingLayer::ContentsScalingLayer() |
| 17 : last_update_contents_scale_x_(0.f), | 17 : last_update_contents_scale_x_(0.f), |
| 18 last_update_contents_scale_y_(0.f) {} | 18 last_update_contents_scale_y_(0.f) {} |
| 19 | 19 |
| 20 ContentsScalingLayer::~ContentsScalingLayer() { | 20 ContentsScalingLayer::~ContentsScalingLayer() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void ContentsScalingLayer::CalculateContentsScale( | 23 void ContentsScalingLayer::CalculateContentsScale( |
| 24 float ideal_contents_scale, | 24 float ideal_contents_scale, |
| 25 float device_scale_factor, | 25 float device_scale_factor, |
| 26 float page_scale_factor, | 26 float page_scale_factor, |
| 27 float maximum_animation_contents_scale, |
| 27 bool animating_transform_to_screen, | 28 bool animating_transform_to_screen, |
| 28 float* contents_scale_x, | 29 float* contents_scale_x, |
| 29 float* contents_scale_y, | 30 float* contents_scale_y, |
| 30 gfx::Size* content_bounds) { | 31 gfx::Size* content_bounds) { |
| 31 *contents_scale_x = ideal_contents_scale; | 32 *contents_scale_x = ideal_contents_scale; |
| 32 *contents_scale_y = ideal_contents_scale; | 33 *contents_scale_y = ideal_contents_scale; |
| 33 *content_bounds = ComputeContentBoundsForScale( | 34 *content_bounds = ComputeContentBoundsForScale( |
| 34 ideal_contents_scale, | 35 ideal_contents_scale, |
| 35 ideal_contents_scale); | 36 ideal_contents_scale); |
| 36 } | 37 } |
| 37 | 38 |
| 38 bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue, | 39 bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue, |
| 39 const OcclusionTracker<Layer>* occlusion) { | 40 const OcclusionTracker<Layer>* occlusion) { |
| 40 bool updated = Layer::Update(queue, occlusion); | 41 bool updated = Layer::Update(queue, occlusion); |
| 41 | 42 |
| 42 if (draw_properties().contents_scale_x == last_update_contents_scale_x_ && | 43 if (draw_properties().contents_scale_x == last_update_contents_scale_x_ && |
| 43 draw_properties().contents_scale_y == last_update_contents_scale_y_) | 44 draw_properties().contents_scale_y == last_update_contents_scale_y_) |
| 44 return updated; | 45 return updated; |
| 45 | 46 |
| 46 last_update_contents_scale_x_ = draw_properties().contents_scale_x; | 47 last_update_contents_scale_x_ = draw_properties().contents_scale_x; |
| 47 last_update_contents_scale_y_ = draw_properties().contents_scale_y; | 48 last_update_contents_scale_y_ = draw_properties().contents_scale_y; |
| 48 // Invalidate the whole layer if scale changed. | 49 // Invalidate the whole layer if scale changed. |
| 49 SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds)); | 50 SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds)); |
| 50 return updated; | 51 return updated; |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace cc | 54 } // namespace cc |
| OLD | NEW |