Commit e72feebc authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Revert 129220 - M20 Ash: Animate window header transition from active to inactive

BUG=116583
TEST=Manual

Review URL: http://codereview.chromium.org/9720043

TBR=pkotwicz@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9791025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129227 0039d316-1c4b-4281-b951-d872f2087c98
parent 6df627bf
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "third_party/skia/include/core/SkShader.h" #include "third_party/skia/include/core/SkShader.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/theme_provider.h" #include "ui/base/theme_provider.h"
...@@ -69,14 +68,11 @@ const int kCloseButtonOffsetY = 0; ...@@ -69,14 +68,11 @@ const int kCloseButtonOffsetY = 0;
// inset to preserve alignment with the NTP image, or else we'll break a bunch // inset to preserve alignment with the NTP image, or else we'll break a bunch
// of existing themes. We do something similar on OS X for the same reason. // of existing themes. We do something similar on OS X for the same reason.
const int kThemeFrameBitmapOffsetX = 5; const int kThemeFrameBitmapOffsetX = 5;
// Duration of crossfade animation for activating and deactivating frame.
const int kActivationCrossfadeDurationMs = 200;
// Tiles an image into an area, rounding the top corners. Samples the |bitmap| // Tiles an image into an area, rounding the top corners. Samples the |bitmap|
// starting |bitmap_offset_x| pixels from the left of the image. // starting |bitmap_offset_x| pixels from the left of the image.
void TileRoundRect(gfx::Canvas* canvas, void TileRoundRect(gfx::Canvas* canvas,
int x, int y, int w, int h, int x, int y, int w, int h,
SkPaint* paint,
const SkBitmap& bitmap, const SkBitmap& bitmap,
int corner_radius, int corner_radius,
int bitmap_offset_x) { int bitmap_offset_x) {
...@@ -94,17 +90,19 @@ void TileRoundRect(gfx::Canvas* canvas, ...@@ -94,17 +90,19 @@ void TileRoundRect(gfx::Canvas* canvas,
SkPath path; SkPath path;
path.addRoundRect(rect, radii, SkPath::kCW_Direction); path.addRoundRect(rect, radii, SkPath::kCW_Direction);
SkPaint paint;
SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader* shader = SkShader::CreateBitmapShader(bitmap,
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode); SkShader::kRepeat_TileMode);
paint->setShader(shader); paint.setShader(shader);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
// CreateBitmapShader returns a Shader with a reference count of one, we // CreateBitmapShader returns a Shader with a reference count of one, we
// need to unref after paint takes ownership of the shader. // need to unref after paint takes ownership of the shader.
shader->unref(); shader->unref();
// Adjust canvas to compensate for image sampling offset, draw, then adjust // Adjust canvas to compensate for image sampling offset, draw, then adjust
// back. This is cheaper than pushing/popping the entire canvas state. // back. This is cheaper than pushing/popping the entire canvas state.
canvas->sk_canvas()->translate(SkIntToScalar(-bitmap_offset_x), 0); canvas->sk_canvas()->translate(SkIntToScalar(-bitmap_offset_x), 0);
canvas->sk_canvas()->drawPath(path, *paint); canvas->sk_canvas()->drawPath(path, paint);
canvas->sk_canvas()->translate(SkIntToScalar(bitmap_offset_x), 0); canvas->sk_canvas()->translate(SkIntToScalar(bitmap_offset_x), 0);
} }
...@@ -126,10 +124,7 @@ FramePainter::FramePainter() ...@@ -126,10 +124,7 @@ FramePainter::FramePainter()
top_edge_(NULL), top_edge_(NULL),
top_right_corner_(NULL), top_right_corner_(NULL),
header_left_edge_(NULL), header_left_edge_(NULL),
header_right_edge_(NULL), header_right_edge_(NULL) {
previous_theme_frame_(NULL),
crossfade_theme_frame_(NULL),
crossfade_animation_(NULL) {
} }
FramePainter::~FramePainter() { FramePainter::~FramePainter() {
...@@ -266,43 +261,14 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view, ...@@ -266,43 +261,14 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view,
const SkBitmap* theme_frame, const SkBitmap* theme_frame,
const SkBitmap* theme_frame_overlay) { const SkBitmap* theme_frame_overlay) {
if (previous_theme_frame_ && previous_theme_frame_ != theme_frame) {
crossfade_animation_.reset(new ui::SlideAnimation(this));
crossfade_theme_frame_ = previous_theme_frame_;
crossfade_animation_->SetSlideDuration(kActivationCrossfadeDurationMs);
crossfade_animation_->Show();
}
header_frame_bounds_ = gfx::Rect(0, 0, view->width(), theme_frame->height());
const int kCornerRadius = 2;
SkPaint paint;
if (crossfade_animation_.get() && crossfade_animation_->is_animating()) {
uint8 theme_alpha = crossfade_animation_->GetCurrentValue() * 255;
// Draw the old header background, clipping the corners to be rounded.
paint.setAlpha(255 - theme_alpha);
paint.setXfermodeMode(SkXfermode::kPlus_Mode);
TileRoundRect(canvas,
0, 0, view->width(), theme_frame->height(),
&paint,
*crossfade_theme_frame_,
kCornerRadius,
kThemeFrameBitmapOffsetX);
paint.setAlpha(theme_alpha);
}
// Draw the header background, clipping the corners to be rounded. // Draw the header background, clipping the corners to be rounded.
const int kCornerRadius = 2;
TileRoundRect(canvas, TileRoundRect(canvas,
0, 0, view->width(), theme_frame->height(), 0, 0, view->width(), theme_frame->height(),
&paint,
*theme_frame, *theme_frame,
kCornerRadius, kCornerRadius,
kThemeFrameBitmapOffsetX); kThemeFrameBitmapOffsetX);
previous_theme_frame_ = theme_frame;
// Draw the theme frame overlay, if available. // Draw the theme frame overlay, if available.
if (theme_frame_overlay) if (theme_frame_overlay)
canvas->DrawBitmapInt(*theme_frame_overlay, 0, 0); canvas->DrawBitmapInt(*theme_frame_overlay, 0, 0);
...@@ -463,13 +429,6 @@ void FramePainter::OnWindowDestroying(aura::Window* window) { ...@@ -463,13 +429,6 @@ void FramePainter::OnWindowDestroying(aura::Window* window) {
window_ = NULL; window_ = NULL;
} }
///////////////////////////////////////////////////////////////////////////////
// ui::AnimationDelegate overrides:
void FramePainter::AnimationProgressed(const ui::Animation* animation) {
frame_->SchedulePaintInRect(gfx::Rect(header_frame_bounds_));
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// FramePainter, private: // FramePainter, private:
......
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h" // OVERRIDE #include "base/compiler_specific.h" // OVERRIDE
#include "base/memory/scoped_ptr.h"
#include "ui/base/animation/animation_delegate.h"
#include "ui/gfx/rect.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
class SkBitmap; class SkBitmap;
...@@ -21,12 +18,10 @@ class Window; ...@@ -21,12 +18,10 @@ class Window;
namespace gfx { namespace gfx {
class Canvas; class Canvas;
class Font; class Font;
class Rect;
class Point; class Point;
class Size; class Size;
} }
namespace ui {
class SlideAnimation;
}
namespace views { namespace views {
class ImageButton; class ImageButton;
class NonClientFrameView; class NonClientFrameView;
...@@ -39,8 +34,7 @@ namespace ash { ...@@ -39,8 +34,7 @@ namespace ash {
// Helper class for painting window frames. Exists to share code between // Helper class for painting window frames. Exists to share code between
// various implementations of views::NonClientFrameView. Canonical source of // various implementations of views::NonClientFrameView. Canonical source of
// layout constants for Ash window frames. // layout constants for Ash window frames.
class ASH_EXPORT FramePainter : public aura::WindowObserver, class ASH_EXPORT FramePainter : public aura::WindowObserver {
public ui::AnimationDelegate {
public: public:
FramePainter(); FramePainter();
virtual ~FramePainter(); virtual ~FramePainter();
...@@ -91,9 +85,6 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, ...@@ -91,9 +85,6 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver,
intptr_t old) OVERRIDE; intptr_t old) OVERRIDE;
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
// Overridden from ui::AnimationDelegate
void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
private: private:
// Sets the images for a button base on IDs from the |frame_| theme provider. // Sets the images for a button base on IDs from the |frame_| theme provider.
void SetButtonImages(views::ImageButton* button, void SetButtonImages(views::ImageButton* button,
...@@ -119,14 +110,6 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, ...@@ -119,14 +110,6 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver,
const SkBitmap* header_left_edge_; const SkBitmap* header_left_edge_;
const SkBitmap* header_right_edge_; const SkBitmap* header_right_edge_;
// The bitmap last used for painting header.
const SkBitmap* previous_theme_frame_;
// The bitmap we are crossfading from.
const SkBitmap* crossfade_theme_frame_;
gfx::Rect header_frame_bounds_;
scoped_ptr<ui::SlideAnimation> crossfade_animation_;
DISALLOW_COPY_AND_ASSIGN(FramePainter); DISALLOW_COPY_AND_ASSIGN(FramePainter);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment