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
3 // found in the LICENSE file.
5 #include "cc/contents_scaling_layer.h"
6 #include "ui/gfx/size_conversions.h"
10 gfx::Size
ContentsScalingLayer::computeContentBoundsForScale(float scaleX
, float scaleY
) const {
11 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX
, scaleY
));
14 ContentsScalingLayer::ContentsScalingLayer()
15 : last_update_contents_scale_x_(0.f
)
16 , last_update_contents_scale_y_(0.f
)
20 ContentsScalingLayer::~ContentsScalingLayer() {
23 void ContentsScalingLayer::calculateContentsScale(
24 float ideal_contents_scale
,
25 bool animating_transform_to_screen
,
26 float* contents_scale_x
,
27 float* contents_scale_y
,
28 gfx::Size
* content_bounds
) {
29 *contents_scale_x
= ideal_contents_scale
;
30 *contents_scale_y
= ideal_contents_scale
;
31 *content_bounds
= computeContentBoundsForScale(
33 ideal_contents_scale
);
36 void ContentsScalingLayer::didUpdateBounds() {
37 drawProperties().content_bounds
= computeContentBoundsForScale(
42 void ContentsScalingLayer::update(
43 ResourceUpdateQueue
& queue
,
44 const OcclusionTracker
* occlusion
,
45 RenderingStats
* stats
) {
46 if (drawProperties().contents_scale_x
== last_update_contents_scale_x_
&&
47 drawProperties().contents_scale_y
== last_update_contents_scale_y_
)
50 last_update_contents_scale_x_
= drawProperties().contents_scale_x
;
51 last_update_contents_scale_y_
= drawProperties().contents_scale_y
;
52 // Invalidate the whole layer if scale changed.
53 setNeedsDisplayRect(gfx::Rect(bounds()));