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

Side by Side Diff: ui/compositor/layer.cc

Issue 25961002: Retain tray bubble's rounded corners when the bubble animates out (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed layer ownership Created 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 parent_(NULL), 50 parent_(NULL),
51 visible_(true), 51 visible_(true),
52 force_render_surface_(false), 52 force_render_surface_(false),
53 fills_bounds_opaquely_(true), 53 fills_bounds_opaquely_(true),
54 layer_updated_externally_(false), 54 layer_updated_externally_(false),
55 background_blur_radius_(0), 55 background_blur_radius_(0),
56 layer_saturation_(0.0f), 56 layer_saturation_(0.0f),
57 layer_brightness_(0.0f), 57 layer_brightness_(0.0f),
58 layer_grayscale_(0.0f), 58 layer_grayscale_(0.0f),
59 layer_inverted_(false), 59 layer_inverted_(false),
60 layer_mask_(NULL),
61 layer_mask_back_link_(NULL),
62 zoom_(1), 60 zoom_(1),
63 zoom_inset_(0), 61 zoom_inset_(0),
64 delegate_(NULL), 62 delegate_(NULL),
65 cc_layer_(NULL), 63 cc_layer_(NULL),
66 scale_content_(true), 64 scale_content_(true),
67 device_scale_factor_(1.0f) { 65 device_scale_factor_(1.0f) {
68 CreateWebLayer(); 66 CreateWebLayer();
69 } 67 }
70 68
71 Layer::Layer(LayerType type) 69 Layer::Layer(LayerType type)
72 : type_(type), 70 : type_(type),
73 compositor_(NULL), 71 compositor_(NULL),
74 parent_(NULL), 72 parent_(NULL),
75 visible_(true), 73 visible_(true),
76 force_render_surface_(false), 74 force_render_surface_(false),
77 fills_bounds_opaquely_(true), 75 fills_bounds_opaquely_(true),
78 layer_updated_externally_(false), 76 layer_updated_externally_(false),
79 background_blur_radius_(0), 77 background_blur_radius_(0),
80 layer_saturation_(0.0f), 78 layer_saturation_(0.0f),
81 layer_brightness_(0.0f), 79 layer_brightness_(0.0f),
82 layer_grayscale_(0.0f), 80 layer_grayscale_(0.0f),
83 layer_inverted_(false), 81 layer_inverted_(false),
84 layer_mask_(NULL),
85 layer_mask_back_link_(NULL),
86 zoom_(1), 82 zoom_(1),
87 zoom_inset_(0), 83 zoom_inset_(0),
88 delegate_(NULL), 84 delegate_(NULL),
89 cc_layer_(NULL), 85 cc_layer_(NULL),
90 scale_content_(true), 86 scale_content_(true),
91 device_scale_factor_(1.0f) { 87 device_scale_factor_(1.0f) {
92 CreateWebLayer(); 88 CreateWebLayer();
93 } 89 }
94 90
95 Layer::~Layer() { 91 Layer::~Layer() {
96 // Destroying the animator may cause observers to use the layer (and 92 // Destroying the animator may cause observers to use the layer (and
97 // indirectly the WebLayer). Destroy the animator first so that the WebLayer 93 // indirectly the WebLayer). Destroy the animator first so that the WebLayer
98 // is still around. 94 // is still around.
99 if (animator_.get()) 95 if (animator_.get())
100 animator_->SetDelegate(NULL); 96 animator_->SetDelegate(NULL);
101 animator_ = NULL; 97 animator_ = NULL;
102 if (compositor_) 98 if (compositor_)
103 compositor_->SetRootLayer(NULL); 99 compositor_->SetRootLayer(NULL);
100 if (layer_mask_.get())
101 SetMaskLayer(scoped_ptr<Layer>());
104 if (parent_) 102 if (parent_)
105 parent_->Remove(this); 103 parent_->Remove(this);
106 if (layer_mask_)
107 SetMaskLayer(NULL);
108 if (layer_mask_back_link_)
109 layer_mask_back_link_->SetMaskLayer(NULL);
110 for (size_t i = 0; i < children_.size(); ++i) 104 for (size_t i = 0; i < children_.size(); ++i)
111 children_[i]->parent_ = NULL; 105 children_[i]->parent_ = NULL;
112 cc_layer_->RemoveLayerAnimationEventObserver(this); 106 cc_layer_->RemoveLayerAnimationEventObserver(this);
113 cc_layer_->RemoveFromParent(); 107 cc_layer_->RemoveFromParent();
114 } 108 }
115 109
116 Compositor* Layer::GetCompositor() { 110 Compositor* Layer::GetCompositor() {
117 return GetRoot(this)->compositor_; 111 return GetRoot(this)->compositor_;
118 } 112 }
119 113
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return animator_->GetTargetGrayscale(); 268 return animator_->GetTargetGrayscale();
275 } 269 }
276 return layer_grayscale(); 270 return layer_grayscale();
277 } 271 }
278 272
279 void Layer::SetLayerInverted(bool inverted) { 273 void Layer::SetLayerInverted(bool inverted) {
280 layer_inverted_ = inverted; 274 layer_inverted_ = inverted;
281 SetLayerFilters(); 275 SetLayerFilters();
282 } 276 }
283 277
284 void Layer::SetMaskLayer(Layer* layer_mask) { 278 void Layer::SetMaskLayer(scoped_ptr<Layer> layer_mask) {
285 // The provided mask should not have a layer mask itself. 279 // The provided mask should not have a layer mask itself.
286 DCHECK(!layer_mask || 280 DCHECK(!layer_mask.get() ||
287 (!layer_mask->layer_mask_layer() && 281 (!layer_mask->layer_mask_layer() &&
288 layer_mask->children().empty() && 282 layer_mask->children().empty()));
289 !layer_mask->layer_mask_back_link_)); 283 if (layer_mask_.get() == layer_mask.get())
290 DCHECK(!layer_mask_back_link_);
291 if (layer_mask_ == layer_mask)
292 return; 284 return;
293 // We need to de-reference the currently linked object so that no problem 285 layer_mask_ = layer_mask.Pass();
294 // arises if the mask layer gets deleted before this object.
295 if (layer_mask_)
296 layer_mask_->layer_mask_back_link_ = NULL;
297 layer_mask_ = layer_mask;
298 cc_layer_->SetMaskLayer( 286 cc_layer_->SetMaskLayer(
299 layer_mask ? layer_mask->cc_layer() : NULL); 287 layer_mask_.get() ? layer_mask_->cc_layer() : NULL);
300 // We need to reference the linked object so that it can properly break the 288 if (layer_mask_.get())
301 // link to us when it gets deleted. 289 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor_);
302 if (layer_mask) {
303 layer_mask->layer_mask_back_link_ = this;
304 layer_mask->OnDeviceScaleFactorChanged(device_scale_factor_);
305 }
306 } 290 }
307 291
308 void Layer::SetBackgroundZoom(float zoom, int inset) { 292 void Layer::SetBackgroundZoom(float zoom, int inset) {
309 zoom_ = zoom; 293 zoom_ = zoom;
310 zoom_inset_ = inset; 294 zoom_inset_ = inset;
311 295
312 SetLayerBackgroundFilters(); 296 SetLayerBackgroundFilters();
313 } 297 }
314 298
315 void Layer::SetLayerFilters() { 299 void Layer::SetLayerFilters() {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); 946 cc_layer_->SetBounds(ConvertSizeToPixel(this, size));
963 } 947 }
964 948
965 void Layer::RecomputePosition() { 949 void Layer::RecomputePosition() {
966 cc_layer_->SetPosition(gfx::ScalePoint( 950 cc_layer_->SetPosition(gfx::ScalePoint(
967 gfx::PointF(bounds_.x(), bounds_.y()), 951 gfx::PointF(bounds_.x(), bounds_.y()),
968 device_scale_factor_)); 952 device_scale_factor_));
969 } 953 }
970 954
971 } // namespace ui 955 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698