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

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

Issue 10800020: Add brightness/grayscale animations and use them for OOBE boot transition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix hide animation Created 8 years, 5 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
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_animation_delegate.h » ('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 (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 compositor_(NULL), 49 compositor_(NULL),
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 opacity_(1.0f), 55 opacity_(1.0f),
56 background_blur_radius_(0), 56 background_blur_radius_(0),
57 layer_saturation_(0.0f), 57 layer_saturation_(0.0f),
58 layer_brightness_(0.0f), 58 layer_brightness_(0.0f),
59 layer_grayscale_(0.0f),
59 layer_inverted_(false), 60 layer_inverted_(false),
60 layer_mask_(NULL), 61 layer_mask_(NULL),
61 layer_mask_back_link_(NULL), 62 layer_mask_back_link_(NULL),
62 delegate_(NULL), 63 delegate_(NULL),
63 scale_content_(true), 64 scale_content_(true),
64 device_scale_factor_(1.0f) { 65 device_scale_factor_(1.0f) {
65 CreateWebLayer(); 66 CreateWebLayer();
66 } 67 }
67 68
68 Layer::Layer(LayerType type) 69 Layer::Layer(LayerType type)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 SetAnimator(LayerAnimator::CreateDefaultAnimator()); 178 SetAnimator(LayerAnimator::CreateDefaultAnimator());
178 return animator_.get(); 179 return animator_.get();
179 } 180 }
180 181
181 void Layer::SetTransform(const ui::Transform& transform) { 182 void Layer::SetTransform(const ui::Transform& transform) {
182 GetAnimator()->SetTransform(transform); 183 GetAnimator()->SetTransform(transform);
183 } 184 }
184 185
185 Transform Layer::GetTargetTransform() const { 186 Transform Layer::GetTargetTransform() const {
186 if (animator_.get() && animator_->IsAnimatingProperty( 187 if (animator_.get() && animator_->IsAnimatingProperty(
187 LayerAnimationElement::TRANSFORM)) 188 LayerAnimationElement::TRANSFORM)) {
188 return animator_->GetTargetTransform(); 189 return animator_->GetTargetTransform();
190 }
189 return transform_; 191 return transform_;
190 } 192 }
191 193
192 void Layer::SetBounds(const gfx::Rect& bounds) { 194 void Layer::SetBounds(const gfx::Rect& bounds) {
193 GetAnimator()->SetBounds(bounds); 195 GetAnimator()->SetBounds(bounds);
194 } 196 }
195 197
196 gfx::Rect Layer::GetTargetBounds() const { 198 gfx::Rect Layer::GetTargetBounds() const {
197 if (animator_.get() && animator_->IsAnimatingProperty( 199 if (animator_.get() && animator_->IsAnimatingProperty(
198 LayerAnimationElement::BOUNDS)) 200 LayerAnimationElement::BOUNDS)) {
199 return animator_->GetTargetBounds(); 201 return animator_->GetTargetBounds();
202 }
200 return bounds_; 203 return bounds_;
201 } 204 }
202 205
203 void Layer::SetMasksToBounds(bool masks_to_bounds) { 206 void Layer::SetMasksToBounds(bool masks_to_bounds) {
204 web_layer_.setMasksToBounds(masks_to_bounds); 207 web_layer_.setMasksToBounds(masks_to_bounds);
205 } 208 }
206 209
207 bool Layer::GetMasksToBounds() const { 210 bool Layer::GetMasksToBounds() const {
208 return web_layer_.masksToBounds(); 211 return web_layer_.masksToBounds();
209 } 212 }
(...skipping 12 matching lines...) Expand all
222 } 225 }
223 web_layer_.setBackgroundFilters(filters); 226 web_layer_.setBackgroundFilters(filters);
224 } 227 }
225 228
226 void Layer::SetLayerSaturation(float saturation) { 229 void Layer::SetLayerSaturation(float saturation) {
227 layer_saturation_ = saturation; 230 layer_saturation_ = saturation;
228 SetLayerFilters(); 231 SetLayerFilters();
229 } 232 }
230 233
231 void Layer::SetLayerBrightness(float brightness) { 234 void Layer::SetLayerBrightness(float brightness) {
232 layer_brightness_ = brightness; 235 GetAnimator()->SetBrightness(brightness);
233 SetLayerFilters(); 236 }
237
238 float Layer::GetTargetBrightness() const {
239 if (animator_.get() && animator_->IsAnimatingProperty(
240 LayerAnimationElement::BRIGHTNESS)) {
241 return animator_->GetTargetBrightness();
242 }
243 return layer_brightness();
244 }
245
246 void Layer::SetLayerGrayscale(float grayscale) {
247 GetAnimator()->SetGrayscale(grayscale);
248 }
249
250 float Layer::GetTargetGrayscale() const {
251 if (animator_.get() && animator_->IsAnimatingProperty(
252 LayerAnimationElement::GRAYSCALE)) {
253 return animator_->GetTargetGrayscale();
254 }
255 return layer_grayscale();
234 } 256 }
235 257
236 void Layer::SetLayerInverted(bool inverted) { 258 void Layer::SetLayerInverted(bool inverted) {
237 layer_inverted_ = inverted; 259 layer_inverted_ = inverted;
238 SetLayerFilters(); 260 SetLayerFilters();
239 } 261 }
240 262
241 void Layer::SetMaskLayer(Layer* layer_mask) { 263 void Layer::SetMaskLayer(Layer* layer_mask) {
242 // The provided mask should not have a layer mask itself. 264 // The provided mask should not have a layer mask itself.
243 DCHECK(!layer_mask || 265 DCHECK(!layer_mask ||
(...skipping 19 matching lines...) Expand all
263 void Layer::SetLayerFilters() { 285 void Layer::SetLayerFilters() {
264 WebKit::WebFilterOperations filters; 286 WebKit::WebFilterOperations filters;
265 if (layer_saturation_) { 287 if (layer_saturation_) {
266 filters.append(WebKit::WebFilterOperation::createSaturateFilter( 288 filters.append(WebKit::WebFilterOperation::createSaturateFilter(
267 layer_saturation_)); 289 layer_saturation_));
268 } 290 }
269 if (layer_brightness_) { 291 if (layer_brightness_) {
270 filters.append(WebKit::WebFilterOperation::createBrightnessFilter( 292 filters.append(WebKit::WebFilterOperation::createBrightnessFilter(
271 layer_brightness_)); 293 layer_brightness_));
272 } 294 }
295 if (layer_grayscale_) {
296 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter(
297 layer_grayscale_));
298 }
273 if (layer_inverted_) 299 if (layer_inverted_)
274 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0)); 300 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0));
275 301
276 web_layer_.setFilters(filters); 302 web_layer_.setFilters(filters);
277 } 303 }
278 304
279 float Layer::GetTargetOpacity() const { 305 float Layer::GetTargetOpacity() const {
280 if (animator_.get() && animator_->IsAnimatingProperty( 306 if (animator_.get() && animator_->IsAnimatingProperty(
281 LayerAnimationElement::OPACITY)) 307 LayerAnimationElement::OPACITY))
282 return animator_->GetTargetOpacity(); 308 return animator_->GetTargetOpacity();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 623
598 void Layer::SetVisibilityImmediately(bool visible) { 624 void Layer::SetVisibilityImmediately(bool visible) {
599 if (visible_ == visible) 625 if (visible_ == visible)
600 return; 626 return;
601 627
602 visible_ = visible; 628 visible_ = visible;
603 // TODO(piman): Expose a visibility flag on WebLayer. 629 // TODO(piman): Expose a visibility flag on WebLayer.
604 web_layer_.setOpacity(visible_ ? opacity_ : 0.f); 630 web_layer_.setOpacity(visible_ ? opacity_ : 0.f);
605 } 631 }
606 632
633 void Layer::SetBrightnessImmediately(float brightness) {
634 layer_brightness_ = brightness;
635 SetLayerFilters();
636 }
637
638 void Layer::SetGrayscaleImmediately(float grayscale) {
639 layer_grayscale_ = grayscale;
640 SetLayerFilters();
641 }
642
607 void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) { 643 void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) {
608 SetBoundsImmediately(bounds); 644 SetBoundsImmediately(bounds);
609 } 645 }
610 646
611 void Layer::SetTransformFromAnimation(const Transform& transform) { 647 void Layer::SetTransformFromAnimation(const Transform& transform) {
612 SetTransformImmediately(transform); 648 SetTransformImmediately(transform);
613 } 649 }
614 650
615 void Layer::SetOpacityFromAnimation(float opacity) { 651 void Layer::SetOpacityFromAnimation(float opacity) {
616 SetOpacityImmediately(opacity); 652 SetOpacityImmediately(opacity);
617 } 653 }
618 654
619 void Layer::SetVisibilityFromAnimation(bool visibility) { 655 void Layer::SetVisibilityFromAnimation(bool visibility) {
620 SetVisibilityImmediately(visibility); 656 SetVisibilityImmediately(visibility);
621 } 657 }
622 658
659 void Layer::SetBrightnessFromAnimation(float brightness) {
660 SetBrightnessImmediately(brightness);
661 }
662 void Layer::SetGrayscaleFromAnimation(float grayscale) {
663 SetGrayscaleImmediately(grayscale);
664 }
665
623 void Layer::ScheduleDrawForAnimation() { 666 void Layer::ScheduleDrawForAnimation() {
624 ScheduleDraw(); 667 ScheduleDraw();
625 } 668 }
626 669
627 const gfx::Rect& Layer::GetBoundsForAnimation() const { 670 const gfx::Rect& Layer::GetBoundsForAnimation() const {
628 return bounds(); 671 return bounds();
629 } 672 }
630 673
631 const Transform& Layer::GetTransformForAnimation() const { 674 const Transform& Layer::GetTransformForAnimation() const {
632 return transform(); 675 return transform();
633 } 676 }
634 677
635 float Layer::GetOpacityForAnimation() const { 678 float Layer::GetOpacityForAnimation() const {
636 return opacity(); 679 return opacity();
637 } 680 }
638 681
639 bool Layer::GetVisibilityForAnimation() const { 682 bool Layer::GetVisibilityForAnimation() const {
640 return visible(); 683 return visible();
641 } 684 }
642 685
686 float Layer::GetBrightnessForAnimation() const {
687 return layer_brightness();
688 }
689
690 float Layer::GetGrayscaleForAnimation() const {
691 return layer_grayscale();
692 }
693
643 void Layer::CreateWebLayer() { 694 void Layer::CreateWebLayer() {
644 if (type_ == LAYER_SOLID_COLOR) 695 if (type_ == LAYER_SOLID_COLOR)
645 web_layer_ = WebKit::WebSolidColorLayer::create(); 696 web_layer_ = WebKit::WebSolidColorLayer::create();
646 else 697 else
647 web_layer_ = WebKit::WebContentLayer::create(this); 698 web_layer_ = WebKit::WebContentLayer::create(this);
648 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 699 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
649 web_layer_.setOpaque(true); 700 web_layer_.setOpaque(true);
650 web_layer_is_accelerated_ = false; 701 web_layer_is_accelerated_ = false;
651 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch( 702 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch(
652 switches::kUIShowLayerBorders); 703 switches::kUIShowLayerBorders);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return; 757 return;
707 unsigned int color = 0xFF000000; 758 unsigned int color = 0xFF000000;
708 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 759 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
709 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 760 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
710 if (!opaque) 761 if (!opaque)
711 color |= 0xFF; 762 color |= 0xFF;
712 web_layer_.setDebugBorderColor(color); 763 web_layer_.setDebugBorderColor(color);
713 } 764 }
714 765
715 } // namespace ui 766 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698