OLD | NEW |
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 "ash/wm/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 return kThemeFrameImageInsetX; | 292 return kThemeFrameImageInsetX; |
293 } | 293 } |
294 | 294 |
295 void FramePainter::PaintHeader(views::NonClientFrameView* view, | 295 void FramePainter::PaintHeader(views::NonClientFrameView* view, |
296 gfx::Canvas* canvas, | 296 gfx::Canvas* canvas, |
297 HeaderMode header_mode, | 297 HeaderMode header_mode, |
298 int theme_frame_id, | 298 int theme_frame_id, |
299 const gfx::ImageSkia* theme_frame_overlay) { | 299 const gfx::ImageSkia* theme_frame_overlay) { |
300 if (previous_theme_frame_id_ != 0 && | 300 if (previous_theme_frame_id_ != 0 && |
301 previous_theme_frame_id_ != theme_frame_id) { | 301 previous_theme_frame_id_ != theme_frame_id) { |
302 crossfade_animation_.reset(new ui::SlideAnimation(this)); | 302 aura::Window* parent = frame_->GetNativeWindow()->parent(); |
303 crossfade_theme_frame_id_ = previous_theme_frame_id_; | 303 // Don't animate the header if the parent (a workspace) is already |
304 crossfade_opacity_ = previous_opacity_; | 304 // animating. Doing so results in continually painting during the animation |
305 crossfade_animation_->SetSlideDuration(kActivationCrossfadeDurationMs); | 305 // and gives a slower frame rate. |
306 crossfade_animation_->Show(); | 306 // TODO(sky): expose a better way to determine this rather than assuming |
| 307 // the parent is a workspace. |
| 308 bool parent_animating = parent && |
| 309 (parent->layer()->GetAnimator()->IsAnimatingProperty( |
| 310 ui::LayerAnimationElement::OPACITY) || |
| 311 parent->layer()->GetAnimator()->IsAnimatingProperty( |
| 312 ui::LayerAnimationElement::VISIBILITY)); |
| 313 if (!parent_animating) { |
| 314 crossfade_animation_.reset(new ui::SlideAnimation(this)); |
| 315 crossfade_theme_frame_id_ = previous_theme_frame_id_; |
| 316 crossfade_opacity_ = previous_opacity_; |
| 317 crossfade_animation_->SetSlideDuration(kActivationCrossfadeDurationMs); |
| 318 crossfade_animation_->Show(); |
| 319 } else { |
| 320 crossfade_animation_.reset(); |
| 321 } |
307 } | 322 } |
308 | 323 |
309 int opacity = | 324 int opacity = |
310 GetHeaderOpacity(header_mode, theme_frame_id, theme_frame_overlay); | 325 GetHeaderOpacity(header_mode, theme_frame_id, theme_frame_overlay); |
311 ui::ThemeProvider* theme_provider = frame_->GetThemeProvider(); | 326 ui::ThemeProvider* theme_provider = frame_->GetThemeProvider(); |
312 gfx::ImageSkia* theme_frame = theme_provider->GetImageSkiaNamed( | 327 gfx::ImageSkia* theme_frame = theme_provider->GetImageSkiaNamed( |
313 theme_frame_id); | 328 theme_frame_id); |
314 header_frame_bounds_ = gfx::Rect(0, 0, view->width(), theme_frame->height()); | 329 header_frame_bounds_ = gfx::Rect(0, 0, view->width(), theme_frame->height()); |
315 | 330 |
316 const int kCornerRadius = 2; | 331 const int kCornerRadius = 2; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); | 657 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); |
643 it != instances_->end(); | 658 it != instances_->end(); |
644 ++it) { | 659 ++it) { |
645 FramePainter* painter = *it; | 660 FramePainter* painter = *it; |
646 if (IsVisibleNormalWindow(painter->window_)) | 661 if (IsVisibleNormalWindow(painter->window_)) |
647 painter->frame_->non_client_view()->SchedulePaint(); | 662 painter->frame_->non_client_view()->SchedulePaint(); |
648 } | 663 } |
649 } | 664 } |
650 | 665 |
651 } // namespace ash | 666 } // namespace ash |
OLD | NEW |