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

Side by Side Diff: cc/layers/contents_scaling_layer.cc

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 months 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
« no previous file with comments | « cc/base/tiling_data.cc ('k') | cc/layers/delegated_renderer_layer_impl.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/layers/contents_scaling_layer.h" 5 #include "cc/layers/contents_scaling_layer.h"
6 #include "cc/trees/layer_tree_host.h"
6 #include "ui/gfx/geometry/size_conversions.h" 7 #include "ui/gfx/geometry/size_conversions.h"
7 8
8 namespace cc { 9 namespace cc {
9 10
10 gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale( 11 gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale(
11 float scale_x, 12 float scale_x,
12 float scale_y) const { 13 float scale_y) const {
13 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y)); 14 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y));
14 } 15 }
15 16
16 ContentsScalingLayer::ContentsScalingLayer() 17 ContentsScalingLayer::ContentsScalingLayer()
17 : last_update_contents_scale_x_(0.f), 18 : last_update_contents_scale_x_(0.f),
18 last_update_contents_scale_y_(0.f) {} 19 last_update_contents_scale_y_(0.f) {}
19 20
20 ContentsScalingLayer::~ContentsScalingLayer() { 21 ContentsScalingLayer::~ContentsScalingLayer() {
21 } 22 }
22 23
23 void ContentsScalingLayer::CalculateContentsScale( 24 void ContentsScalingLayer::CalculateContentsScale(
24 float ideal_contents_scale, 25 float ideal_contents_scale,
25 float* contents_scale_x, 26 float* contents_scale_x,
26 float* contents_scale_y, 27 float* contents_scale_y,
27 gfx::Size* content_bounds) { 28 gfx::Size* content_bounds) {
29 float old_contents_scale_x = *contents_scale_x;
30 float old_contents_scale_y = *contents_scale_y;
31 gfx::Size old_content_bounds = *content_bounds;
28 *contents_scale_x = ideal_contents_scale; 32 *contents_scale_x = ideal_contents_scale;
29 *contents_scale_y = ideal_contents_scale; 33 *contents_scale_y = ideal_contents_scale;
30 *content_bounds = ComputeContentBoundsForScale( 34 *content_bounds = ComputeContentBoundsForScale(
31 ideal_contents_scale, 35 ideal_contents_scale,
32 ideal_contents_scale); 36 ideal_contents_scale);
37
38 if (!layer_tree_host())
39 return;
40
41 if (old_contents_scale_x != *contents_scale_x ||
42 old_contents_scale_y != *contents_scale_y ||
43 old_content_bounds != *content_bounds) {
44 layer_tree_host()->property_trees()->needs_rebuild = true;
45 }
33 } 46 }
34 47
35 bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue, 48 bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue,
36 const OcclusionTracker<Layer>* occlusion) { 49 const OcclusionTracker<Layer>* occlusion) {
37 bool updated = Layer::Update(queue, occlusion); 50 bool updated = Layer::Update(queue, occlusion);
38 51
39 if (draw_properties().contents_scale_x == last_update_contents_scale_x_ && 52 if (draw_properties().contents_scale_x == last_update_contents_scale_x_ &&
40 draw_properties().contents_scale_y == last_update_contents_scale_y_) 53 draw_properties().contents_scale_y == last_update_contents_scale_y_)
41 return updated; 54 return updated;
42 55
43 last_update_contents_scale_x_ = draw_properties().contents_scale_x; 56 last_update_contents_scale_x_ = draw_properties().contents_scale_x;
44 last_update_contents_scale_y_ = draw_properties().contents_scale_y; 57 last_update_contents_scale_y_ = draw_properties().contents_scale_y;
45 // Invalidate the whole layer if scale changed. 58 // Invalidate the whole layer if scale changed.
46 SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds)); 59 SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds));
47 return updated; 60 return updated;
48 } 61 }
49 62
50 } // namespace cc 63 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/tiling_data.cc ('k') | cc/layers/delegated_renderer_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698