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

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: Created 7 years, 2 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 | 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 parent_(NULL), 49 parent_(NULL),
50 visible_(true), 50 visible_(true),
51 force_render_surface_(false), 51 force_render_surface_(false),
52 fills_bounds_opaquely_(true), 52 fills_bounds_opaquely_(true),
53 layer_updated_externally_(false), 53 layer_updated_externally_(false),
54 background_blur_radius_(0), 54 background_blur_radius_(0),
55 layer_saturation_(0.0f), 55 layer_saturation_(0.0f),
56 layer_brightness_(0.0f), 56 layer_brightness_(0.0f),
57 layer_grayscale_(0.0f), 57 layer_grayscale_(0.0f),
58 layer_inverted_(false), 58 layer_inverted_(false),
59 layer_mask_(NULL),
60 layer_mask_back_link_(NULL), 59 layer_mask_back_link_(NULL),
61 zoom_(1), 60 zoom_(1),
62 zoom_inset_(0), 61 zoom_inset_(0),
63 delegate_(NULL), 62 delegate_(NULL),
64 cc_layer_(NULL), 63 cc_layer_(NULL),
65 scale_content_(true), 64 scale_content_(true),
66 device_scale_factor_(1.0f) { 65 device_scale_factor_(1.0f) {
66 layer_mask_.reset(NULL);
Jun Mukai 2013/10/04 01:39:36 nit: just reset(), NULL is not necessary
piman 2013/10/04 03:44:39 Just remove. The default scoped_ptr constructor do
michaelpg 2013/10/04 05:56:41 Done.
67 CreateWebLayer(); 67 CreateWebLayer();
68 } 68 }
69 69
70 Layer::Layer(LayerType type) 70 Layer::Layer(LayerType type)
71 : type_(type), 71 : type_(type),
72 compositor_(NULL), 72 compositor_(NULL),
73 parent_(NULL), 73 parent_(NULL),
74 visible_(true), 74 visible_(true),
75 force_render_surface_(false), 75 force_render_surface_(false),
76 fills_bounds_opaquely_(true), 76 fills_bounds_opaquely_(true),
77 layer_updated_externally_(false), 77 layer_updated_externally_(false),
78 background_blur_radius_(0), 78 background_blur_radius_(0),
79 layer_saturation_(0.0f), 79 layer_saturation_(0.0f),
80 layer_brightness_(0.0f), 80 layer_brightness_(0.0f),
81 layer_grayscale_(0.0f), 81 layer_grayscale_(0.0f),
82 layer_inverted_(false), 82 layer_inverted_(false),
83 layer_mask_(NULL),
84 layer_mask_back_link_(NULL), 83 layer_mask_back_link_(NULL),
85 zoom_(1), 84 zoom_(1),
86 zoom_inset_(0), 85 zoom_inset_(0),
87 delegate_(NULL), 86 delegate_(NULL),
88 cc_layer_(NULL), 87 cc_layer_(NULL),
89 scale_content_(true), 88 scale_content_(true),
90 device_scale_factor_(1.0f) { 89 device_scale_factor_(1.0f) {
90 layer_mask_.reset(NULL);
Jun Mukai 2013/10/04 01:39:36 ditto
michaelpg 2013/10/04 05:56:41 Removed
91 CreateWebLayer(); 91 CreateWebLayer();
92 } 92 }
93 93
94 Layer::~Layer() { 94 Layer::~Layer() {
95 // Destroying the animator may cause observers to use the layer (and 95 // Destroying the animator may cause observers to use the layer (and
96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer 96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer
97 // is still around. 97 // is still around.
98 if (animator_.get()) 98 if (animator_.get())
99 animator_->SetDelegate(NULL); 99 animator_->SetDelegate(NULL);
100 animator_ = NULL; 100 animator_ = NULL;
101 if (compositor_) 101 if (compositor_)
102 compositor_->SetRootLayer(NULL); 102 compositor_->SetRootLayer(NULL);
103 if (parent_) 103 if (parent_)
104 parent_->Remove(this); 104 parent_->Remove(this);
105 if (layer_mask_) 105 if (layer_mask_.get())
106 SetMaskLayer(NULL); 106 SetMaskLayer(NULL);
107 if (layer_mask_back_link_) 107 if (layer_mask_back_link_)
Jun Mukai 2013/10/04 01:39:36 this is weird, if the layer_mask_ is owned by the
piman 2013/10/04 03:44:39 Agreed. Please remove.
michaelpg 2013/10/04 05:56:41 Done.
108 layer_mask_back_link_->SetMaskLayer(NULL); 108 layer_mask_back_link_->SetMaskLayer(NULL);
109 for (size_t i = 0; i < children_.size(); ++i) 109 for (size_t i = 0; i < children_.size(); ++i)
110 children_[i]->parent_ = NULL; 110 children_[i]->parent_ = NULL;
111 cc_layer_->RemoveLayerAnimationEventObserver(this); 111 cc_layer_->RemoveLayerAnimationEventObserver(this);
112 cc_layer_->RemoveFromParent(); 112 cc_layer_->RemoveFromParent();
113 } 113 }
114 114
115 Compositor* Layer::GetCompositor() { 115 Compositor* Layer::GetCompositor() {
116 return GetRoot(this)->compositor_; 116 return GetRoot(this)->compositor_;
117 } 117 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 void Layer::SetLayerInverted(bool inverted) { 278 void Layer::SetLayerInverted(bool inverted) {
279 layer_inverted_ = inverted; 279 layer_inverted_ = inverted;
280 SetLayerFilters(); 280 SetLayerFilters();
281 } 281 }
282 282
283 void Layer::SetMaskLayer(Layer* layer_mask) { 283 void Layer::SetMaskLayer(Layer* layer_mask) {
284 // The provided mask should not have a layer mask itself. 284 // The provided mask should not have a layer mask itself.
285 DCHECK(!layer_mask || 285 DCHECK(!layer_mask ||
286 (!layer_mask->layer_mask_layer() && 286 (!layer_mask->layer_mask_layer() &&
287 layer_mask->children().empty() && 287 layer_mask->children().empty() &&
288 !layer_mask->layer_mask_back_link_)); 288 !layer_mask->layer_mask_back_link_));
michaelpg 2013/10/04 05:56:41 Removing this debug check (because we remove the m
289 DCHECK(!layer_mask_back_link_); 289 DCHECK(!layer_mask_back_link_);
290 if (layer_mask_ == layer_mask) 290 if (layer_mask_ == layer_mask)
291 return; 291 return;
292 // We need to de-reference the currently linked object so that no problem 292 // We need to de-reference the currently linked object so that no problem
293 // arises if the mask layer gets deleted before this object. 293 // arises if the mask layer gets deleted before this object.
294 if (layer_mask_) 294 if (layer_mask_.get())
295 layer_mask_->layer_mask_back_link_ = NULL; 295 layer_mask_->layer_mask_back_link_ = NULL;
296 layer_mask_ = layer_mask; 296 layer_mask_.reset(layer_mask);
297 cc_layer_->SetMaskLayer( 297 cc_layer_->SetMaskLayer(
298 layer_mask ? layer_mask->cc_layer() : NULL); 298 layer_mask ? layer_mask->cc_layer() : NULL);
299 // We need to reference the linked object so that it can properly break the 299 // We need to reference the linked object so that it can properly break the
300 // link to us when it gets deleted. 300 // link to us when it gets deleted.
301 if (layer_mask) { 301 if (layer_mask) {
302 layer_mask->layer_mask_back_link_ = this; 302 layer_mask->layer_mask_back_link_ = this;
303 layer_mask->OnDeviceScaleFactorChanged(device_scale_factor_); 303 layer_mask->OnDeviceScaleFactorChanged(device_scale_factor_);
304 } 304 }
305 } 305 }
306 306
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 gfx::Transform transform = this->transform(); 616 gfx::Transform transform = this->transform();
617 device_scale_factor_ = device_scale_factor; 617 device_scale_factor_ = device_scale_factor;
618 RecomputeCCTransformFromTransform(transform); 618 RecomputeCCTransformFromTransform(transform);
619 RecomputeDrawsContentAndUVRect(); 619 RecomputeDrawsContentAndUVRect();
620 RecomputePosition(); 620 RecomputePosition();
621 SchedulePaint(gfx::Rect(bounds_.size())); 621 SchedulePaint(gfx::Rect(bounds_.size()));
622 if (delegate_) 622 if (delegate_)
623 delegate_->OnDeviceScaleFactorChanged(device_scale_factor); 623 delegate_->OnDeviceScaleFactorChanged(device_scale_factor);
624 for (size_t i = 0; i < children_.size(); ++i) 624 for (size_t i = 0; i < children_.size(); ++i)
625 children_[i]->OnDeviceScaleFactorChanged(device_scale_factor); 625 children_[i]->OnDeviceScaleFactorChanged(device_scale_factor);
626 if (layer_mask_) 626 if (layer_mask_.get())
627 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); 627 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor);
628 } 628 }
629 629
630 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { 630 void Layer::RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) {
631 cc_layer_->RequestCopyOfOutput(request.Pass()); 631 cc_layer_->RequestCopyOfOutput(request.Pass());
632 } 632 }
633 633
634 void Layer::PaintContents(SkCanvas* sk_canvas, 634 void Layer::PaintContents(SkCanvas* sk_canvas,
635 gfx::Rect clip, 635 gfx::Rect clip,
636 gfx::RectF* opaque) { 636 gfx::RectF* opaque) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); 972 cc_layer_->SetBounds(ConvertSizeToPixel(this, size));
973 } 973 }
974 974
975 void Layer::RecomputePosition() { 975 void Layer::RecomputePosition() {
976 cc_layer_->SetPosition(gfx::ScalePoint( 976 cc_layer_->SetPosition(gfx::ScalePoint(
977 gfx::PointF(bounds_.x(), bounds_.y()), 977 gfx::PointF(bounds_.x(), bounds_.y()),
978 device_scale_factor_)); 978 device_scale_factor_));
979 } 979 }
980 980
981 } // namespace ui 981 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698