Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: cc/contents_scaling_layer.cc

Issue 11503005: cc: Refactor content scale/bounds into draw properties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/contents_scaling_layer.h ('k') | cc/contents_scaling_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 : m_contentsScale(1.0) {
16 } 15 }
17 16
18 ContentsScalingLayer::~ContentsScalingLayer() { 17 ContentsScalingLayer::~ContentsScalingLayer() {
19 } 18 }
20 19
21 gfx::Size ContentsScalingLayer::contentBounds() const { 20 void ContentsScalingLayer::calculateContentsScale(
22 return computeContentBoundsForScale(contentsScaleX(), contentsScaleY()); 21 float ideal_contents_scale,
22 float* contents_scale_x,
23 float* contents_scale_y,
24 gfx::Size* content_bounds) {
25 *contents_scale_x = ideal_contents_scale;
26 *contents_scale_y = ideal_contents_scale;
27 *content_bounds = computeContentBoundsForScale(
28 ideal_contents_scale,
29 ideal_contents_scale);
23 } 30 }
24 31
25 float ContentsScalingLayer::contentsScaleX() const { 32 void ContentsScalingLayer::didUpdateBounds() {
26 return m_contentsScale; 33 drawProperties().content_bounds = computeContentBoundsForScale(
27 } 34 contentsScaleX(),
28 35 contentsScaleY());
29 float ContentsScalingLayer::contentsScaleY() const {
30 return m_contentsScale;
31 }
32
33 void ContentsScalingLayer::setContentsScale(float contentsScale) {
34 if (m_contentsScale == contentsScale)
35 return;
36 m_contentsScale = contentsScale;
37 setNeedsDisplay();
38 } 36 }
39 37
40 } // namespace cc 38 } // namespace cc
OLDNEW
« no previous file with comments | « cc/contents_scaling_layer.h ('k') | cc/contents_scaling_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698