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

Side by Side Diff: cc/contents_scaling_layer.cc

Issue 11644035: cc: Invalidate the full tiled layer when contents scale changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 : last_update_contents_scale_x_(0.f)
16 , last_update_contents_scale_y_(0.f)
17 {
15 } 18 }
16 19
17 ContentsScalingLayer::~ContentsScalingLayer() { 20 ContentsScalingLayer::~ContentsScalingLayer() {
18 } 21 }
19 22
20 void ContentsScalingLayer::calculateContentsScale( 23 void ContentsScalingLayer::calculateContentsScale(
21 float ideal_contents_scale, 24 float ideal_contents_scale,
22 float* contents_scale_x, 25 float* contents_scale_x,
23 float* contents_scale_y, 26 float* contents_scale_y,
24 gfx::Size* content_bounds) { 27 gfx::Size* content_bounds) {
25 *contents_scale_x = ideal_contents_scale; 28 *contents_scale_x = ideal_contents_scale;
26 *contents_scale_y = ideal_contents_scale; 29 *contents_scale_y = ideal_contents_scale;
27 *content_bounds = computeContentBoundsForScale( 30 *content_bounds = computeContentBoundsForScale(
28 ideal_contents_scale, 31 ideal_contents_scale,
29 ideal_contents_scale); 32 ideal_contents_scale);
30 } 33 }
31 34
32 void ContentsScalingLayer::didUpdateBounds() { 35 void ContentsScalingLayer::didUpdateBounds() {
33 drawProperties().content_bounds = computeContentBoundsForScale( 36 drawProperties().content_bounds = computeContentBoundsForScale(
34 contentsScaleX(), 37 contentsScaleX(),
35 contentsScaleY()); 38 contentsScaleY());
36 } 39 }
37 40
41 void ContentsScalingLayer::update(
42 ResourceUpdateQueue& queue,
43 const OcclusionTracker* occlusion,
44 RenderingStats& stats) {
45 if (drawProperties().contents_scale_x == last_update_contents_scale_x_ &&
46 drawProperties().contents_scale_y == last_update_contents_scale_y_)
47 return;
48
49 last_update_contents_scale_x_ = drawProperties().contents_scale_x;
50 last_update_contents_scale_y_ = drawProperties().contents_scale_y;
51 // Invalidate the whole layer if scale changed.
52 setNeedsDisplayRect(gfx::Rect(bounds()));
53 }
54
38 } // namespace cc 55 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698