summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 15:20:57 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 15:20:57 +0000
commit6814fce80baccfca00f55555ae08402aadc2d6ed (patch)
treeef8702b284a63c92cd869209233c9a1f27baa986 /ash/wm
parenteb8447a068c929bc5c6fdd80b5d0df14ed6d9189 (diff)
downloadchromium_src-6814fce80baccfca00f55555ae08402aadc2d6ed.zip
chromium_src-6814fce80baccfca00f55555ae08402aadc2d6ed.tar.gz
chromium_src-6814fce80baccfca00f55555ae08402aadc2d6ed.tar.bz2
Fixes crash when switching from custom theme to default theme.
Changed ash/wm/frame_painter.cc to hold onto id of crossfade_theme_frame so that frame_painter can check the validity of crossfade_theme_frame before painting the bitmap. Steps to repro 1. Go to settings Get themes, change theme. 2. Click 'Reset to default theme' Bug=http://crosbug.com/28811 Test=Manual Review URL: http://codereview.chromium.org/9982008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130926 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/custom_frame_view_ash.cc8
-rw-r--r--ash/wm/frame_painter.cc60
-rw-r--r--ash/wm/frame_painter.h10
-rw-r--r--ash/wm/panel_frame_view.cc8
4 files changed, 46 insertions, 40 deletions
diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc
index 0d48a11..49cca635 100644
--- a/ash/wm/custom_frame_view_ash.cc
+++ b/ash/wm/custom_frame_view_ash.cc
@@ -120,16 +120,14 @@ void CustomFrameViewAsh::Layout() {
}
void CustomFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
bool paint_as_active = ShouldPaintAsActive();
- const SkBitmap* theme_bitmap = paint_as_active ?
- rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_BASE_ACTIVE).ToSkBitmap() :
- rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_BASE_INACTIVE).ToSkBitmap();
+ int theme_bitmap_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE :
+ IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
frame_painter_->PaintHeader(
this,
canvas,
paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE,
- theme_bitmap,
+ theme_bitmap_id,
NULL);
frame_painter_->PaintTitleBar(this, canvas, GetTitleFont());
frame_painter_->PaintHeaderContentSeparator(this, canvas);
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc
index 85badd8f..a73d70a 100644
--- a/ash/wm/frame_painter.cc
+++ b/ash/wm/frame_painter.cc
@@ -145,9 +145,9 @@ FramePainter::FramePainter()
top_right_corner_(NULL),
header_left_edge_(NULL),
header_right_edge_(NULL),
- previous_theme_frame_(NULL),
+ previous_theme_frame_id_(0),
previous_opacity_(0),
- crossfade_theme_frame_(NULL),
+ crossfade_theme_frame_id_(0),
crossfade_opacity_(0),
crossfade_animation_(NULL),
size_button_behavior_(SIZE_BUTTON_MAXIMIZES) {
@@ -291,41 +291,51 @@ gfx::Size FramePainter::GetMinimumSize(views::NonClientFrameView* view) {
void FramePainter::PaintHeader(views::NonClientFrameView* view,
gfx::Canvas* canvas,
HeaderMode header_mode,
- const SkBitmap* theme_frame,
+ int theme_frame_id,
const SkBitmap* theme_frame_overlay) {
- int opacity = UseSoloWindowHeader(NULL) ?
- kSoloWindowOpacity :
- (header_mode == ACTIVE ? kActiveWindowOpacity : kInactiveWindowOpacity);
-
- if (previous_theme_frame_ && previous_theme_frame_ != theme_frame) {
+ if (previous_theme_frame_id_ != 0 &&
+ previous_theme_frame_id_ != theme_frame_id) {
crossfade_animation_.reset(new ui::SlideAnimation(this));
- crossfade_theme_frame_ = previous_theme_frame_;
+ crossfade_theme_frame_id_ = previous_theme_frame_id_;
crossfade_opacity_ = previous_opacity_;
crossfade_animation_->SetSlideDuration(kActivationCrossfadeDurationMs);
crossfade_animation_->Show();
}
+ int opacity = UseSoloWindowHeader(NULL) ?
+ kSoloWindowOpacity :
+ (header_mode == ACTIVE ? kActiveWindowOpacity : kInactiveWindowOpacity);
+
+ ui::ThemeProvider* theme_provider = frame_->GetThemeProvider();
+ SkBitmap* theme_frame = theme_provider->GetBitmapNamed(theme_frame_id);
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()) {
- double current_value = crossfade_animation_->GetCurrentValue();
- int old_alpha = (1 - current_value) * crossfade_opacity_;
- int new_alpha = current_value * opacity;
-
- // Draw the old header background, clipping the corners to be rounded.
- paint.setAlpha(old_alpha);
- paint.setXfermodeMode(SkXfermode::kPlus_Mode);
- TileRoundRect(canvas,
- 0, 0, view->width(), theme_frame->height(),
- &paint,
- *crossfade_theme_frame_,
- kCornerRadius,
- kThemeFrameBitmapOffsetX);
-
- paint.setAlpha(new_alpha);
+ SkBitmap* crossfade_theme_frame =
+ theme_provider->GetBitmapNamed(crossfade_theme_frame_id_);
+ if (crossfade_theme_frame) {
+ double current_value = crossfade_animation_->GetCurrentValue();
+ int old_alpha = (1 - current_value) * crossfade_opacity_;
+ int new_alpha = current_value * opacity;
+
+ // Draw the old header background, clipping the corners to be rounded.
+ paint.setAlpha(old_alpha);
+ paint.setXfermodeMode(SkXfermode::kPlus_Mode);
+ TileRoundRect(canvas,
+ 0, 0, view->width(), theme_frame->height(),
+ &paint,
+ *crossfade_theme_frame,
+ kCornerRadius,
+ kThemeFrameBitmapOffsetX);
+
+ paint.setAlpha(new_alpha);
+ } else {
+ crossfade_animation_.reset();
+ paint.setAlpha(opacity);
+ }
} else {
paint.setAlpha(opacity);
}
@@ -338,7 +348,7 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view,
kCornerRadius,
kThemeFrameBitmapOffsetX);
- previous_theme_frame_ = theme_frame;
+ previous_theme_frame_id_ = theme_frame_id;
previous_opacity_ = opacity;
// Draw the theme frame overlay, if available.
diff --git a/ash/wm/frame_painter.h b/ash/wm/frame_painter.h
index ab22165..7187b2b 100644
--- a/ash/wm/frame_painter.h
+++ b/ash/wm/frame_painter.h
@@ -84,7 +84,7 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver,
void PaintHeader(views::NonClientFrameView* view,
gfx::Canvas* canvas,
HeaderMode header_mode,
- const SkBitmap* theme_frame,
+ int theme_frame_id,
const SkBitmap* theme_frame_overlay);
// Paints the header/content separator line. Exists as a separate function
@@ -147,12 +147,12 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver,
const SkBitmap* header_left_edge_;
const SkBitmap* header_right_edge_;
- // Bitmap and opacity last used for painting header.
- const SkBitmap* previous_theme_frame_;
+ // Bitmap id and opacity last used for painting header.
+ int previous_theme_frame_id_;
int previous_opacity_;
- // Bitmap and opacity we are crossfading from.
- const SkBitmap* crossfade_theme_frame_;
+ // Bitmap id and opacity we are crossfading from.
+ int crossfade_theme_frame_id_;
int crossfade_opacity_;
gfx::Rect header_frame_bounds_;
diff --git a/ash/wm/panel_frame_view.cc b/ash/wm/panel_frame_view.cc
index dfbce25..f0cdba9 100644
--- a/ash/wm/panel_frame_view.cc
+++ b/ash/wm/panel_frame_view.cc
@@ -62,16 +62,14 @@ int PanelFrameView::NonClientHitTest(const gfx::Point& point) {
}
void PanelFrameView::OnPaint(gfx::Canvas* canvas) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
bool paint_as_active = ShouldPaintAsActive();
- const SkBitmap* theme_bitmap = paint_as_active ?
- rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_BASE_ACTIVE).ToSkBitmap() :
- rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_BASE_INACTIVE).ToSkBitmap();
+ int theme_bitmap_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE :
+ IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
frame_painter_->PaintHeader(
this,
canvas,
paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE,
- theme_bitmap,
+ theme_bitmap_id,
NULL);
frame_painter_->PaintHeaderContentSeparator(this, canvas);
}