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

Unified Diff: ash/desktop_background/desktop_background_view.cc

Issue 10205013: Reland "Fix wallpaper fade animation flashing problem" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix issue Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/shell_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/desktop_background/desktop_background_view.cc
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 64c8785243826d9056dda3b84686107b50e70219..a4179654c8af184fed919c24fe6bf3dbb77b5eac 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -9,17 +9,48 @@
#include "ash/ash_export.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/window_animations.h"
+#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "grit/ui_resources.h"
#include "ui/aura/root_window.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/compositor/layer_animation_observer.h"
+#include "ui/gfx/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/image/image.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace internal {
+namespace {
+
+class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
+ public:
+ explicit ShowWallpaperAnimationObserver(views::Widget* desktop_widget)
+ : desktop_widget_(desktop_widget) {
+ }
+
+ virtual ~ShowWallpaperAnimationObserver() {
+ }
+
+ private:
+ // Overridden from ui::ImplicitAnimationObserver:
+ virtual void OnImplicitAnimationsCompleted() OVERRIDE {
+ internal::RootWindowLayoutManager* root_window_layout =
+ Shell::GetInstance()->root_window_layout();
+ root_window_layout->SetBackgroundWidget(desktop_widget_);
+ MessageLoop::current()->DeleteSoon(FROM_HERE, this);
+ }
+
+ views::Widget* desktop_widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
+};
+
+} // namespace
// For our scaling ratios we need to round positive numbers.
static int RoundPositive(double x) {
@@ -96,8 +127,7 @@ void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) {
Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), event.location());
}
-views::Widget* CreateDesktopBackground(const SkBitmap& wallpaper,
- ImageLayout layout) {
+void CreateDesktopBackground(const SkBitmap& wallpaper, ImageLayout layout) {
views::Widget* desktop_widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
@@ -111,10 +141,16 @@ views::Widget* CreateDesktopBackground(const SkBitmap& wallpaper,
ash::SetWindowVisibilityAnimationType(
desktop_widget->GetNativeView(),
ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
+ ash::SetWindowVisibilityAnimationTransition(
+ desktop_widget->GetNativeView(),
+ ash::ANIMATE_SHOW);
desktop_widget->SetBounds(params.parent->bounds());
+ ui::ScopedLayerAnimationSettings settings(desktop_widget->GetNativeView()->
+ layer()->GetAnimator());
+ settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
+ settings.AddObserver(new ShowWallpaperAnimationObserver(desktop_widget));
desktop_widget->Show();
desktop_widget->GetNativeView()->SetName("DesktopBackgroundView");
- return desktop_widget;
}
} // namespace internal
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/shell_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698