Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / layers / contents_scaling_layer.cc
blobc50575bedb12fe9559b374a0fbeeb51207050732
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/layers/contents_scaling_layer.h"
6 #include "cc/trees/layer_tree_host.h"
7 #include "ui/gfx/geometry/size_conversions.h"
9 namespace cc {
11 gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale(
12 float scale_x,
13 float scale_y) const {
14 return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y));
17 ContentsScalingLayer::ContentsScalingLayer(const LayerSettings& settings)
18 : Layer(settings),
19 last_update_contents_scale_x_(0.f),
20 last_update_contents_scale_y_(0.f) {
23 ContentsScalingLayer::~ContentsScalingLayer() {
26 void ContentsScalingLayer::CalculateContentsScale(
27 float ideal_contents_scale,
28 float* contents_scale_x,
29 float* contents_scale_y,
30 gfx::Size* content_bounds) {
31 float old_contents_scale_x = *contents_scale_x;
32 float old_contents_scale_y = *contents_scale_y;
33 gfx::Size old_content_bounds = *content_bounds;
34 *contents_scale_x = ideal_contents_scale;
35 *contents_scale_y = ideal_contents_scale;
36 *content_bounds = ComputeContentBoundsForScale(
37 ideal_contents_scale,
38 ideal_contents_scale);
40 if (!layer_tree_host())
41 return;
43 if (old_contents_scale_x != *contents_scale_x ||
44 old_contents_scale_y != *contents_scale_y ||
45 old_content_bounds != *content_bounds) {
46 layer_tree_host()->property_trees()->needs_rebuild = true;
50 bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue,
51 const OcclusionTracker<Layer>* occlusion) {
52 bool updated = Layer::Update(queue, occlusion);
54 if (draw_properties().contents_scale_x == last_update_contents_scale_x_ &&
55 draw_properties().contents_scale_y == last_update_contents_scale_y_)
56 return updated;
58 last_update_contents_scale_x_ = draw_properties().contents_scale_x;
59 last_update_contents_scale_y_ = draw_properties().contents_scale_y;
60 // Invalidate the whole layer if scale changed.
61 SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds));
62 return updated;
65 } // namespace cc