| 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/contents_scaling_layer.h" | 5 #include "cc/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(float scaleX, float
scaleY) const { | 10 gfx::Size ContentsScalingLayer::computeContentBoundsForScale(float scaleX, float
scaleY) const { |
| 11 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX, scaleY)); | 11 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX, scaleY)); |
| 12 } | 12 } |
| 13 | 13 |
| 14 ContentsScalingLayer::ContentsScalingLayer() | 14 ContentsScalingLayer::ContentsScalingLayer() |
| 15 : last_update_contents_scale_x_(0.f) | 15 : last_update_contents_scale_x_(0.f) |
| 16 , last_update_contents_scale_y_(0.f) | 16 , last_update_contents_scale_y_(0.f) |
| 17 { | 17 { |
| 18 } | 18 } |
| 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 bool animating_transform_to_screen, | 25 bool animating_transform_to_screen, |
| 26 float* contents_scale_x, | 26 float* contents_scale_x, |
| 27 float* contents_scale_y, | 27 float* contents_scale_y, |
| 28 gfx::Size* content_bounds) { | 28 gfx::Size* content_bounds) { |
| 29 *contents_scale_x = ideal_contents_scale; | 29 *contents_scale_x = ideal_contents_scale; |
| 30 *contents_scale_y = ideal_contents_scale; | 30 *contents_scale_y = ideal_contents_scale; |
| 31 *content_bounds = computeContentBoundsForScale( | 31 *content_bounds = computeContentBoundsForScale( |
| 32 ideal_contents_scale, | 32 ideal_contents_scale, |
| 33 ideal_contents_scale); | 33 ideal_contents_scale); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void ContentsScalingLayer::update( | 36 void ContentsScalingLayer::Update( |
| 37 ResourceUpdateQueue& queue, | 37 ResourceUpdateQueue* queue, |
| 38 const OcclusionTracker* occlusion, | 38 const OcclusionTracker* occlusion, |
| 39 RenderingStats* stats) { | 39 RenderingStats* stats) { |
| 40 if (drawProperties().contents_scale_x == last_update_contents_scale_x_ && | 40 if (draw_properties().contents_scale_x == last_update_contents_scale_x_ && |
| 41 drawProperties().contents_scale_y == last_update_contents_scale_y_) | 41 draw_properties().contents_scale_y == last_update_contents_scale_y_) |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 last_update_contents_scale_x_ = drawProperties().contents_scale_x; | 44 last_update_contents_scale_x_ = draw_properties().contents_scale_x; |
| 45 last_update_contents_scale_y_ = drawProperties().contents_scale_y; | 45 last_update_contents_scale_y_ = draw_properties().contents_scale_y; |
| 46 // Invalidate the whole layer if scale changed. | 46 // Invalidate the whole layer if scale changed. |
| 47 setNeedsDisplayRect(gfx::Rect(bounds())); | 47 SetNeedsDisplayRect(gfx::Rect(bounds())); |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace cc | 50 } // namespace cc |
| OLD | NEW |