summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/download/download_util.cc12
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc13
-rw-r--r--chrome/browser/views/download_item_view.cc23
-rw-r--r--chrome/browser/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc12
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc13
-rw-r--r--chrome/browser/views/infobars/translate_infobar_base.cc6
-rw-r--r--chrome/browser/views/infobars/translate_infobars.cc6
-rw-r--r--chrome/browser/views/tabs/base_tab.cc4
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/views/tabs/side_tab.cc8
-rw-r--r--chrome/browser/views/tabs/tab.cc14
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc17
-rw-r--r--chrome/common/extensions/extension_action.cc7
-rw-r--r--gfx/canvas.h15
-rw-r--r--gfx/canvas_skia.cc25
-rw-r--r--gfx/canvas_skia.h4
-rw-r--r--views/controls/button/text_button.cc7
-rw-r--r--views/painter.cc4
-rw-r--r--views/view.cc12
-rw-r--r--views/widget/root_view.cc4
21 files changed, 113 insertions, 101 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 0042b75..2da4c14 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -266,18 +266,10 @@ void PaintDownloadComplete(gfx::Canvas* canvas,
double opacity = sin(animation_progress * PI * kCompleteAnimationCycles +
PI/2) / 2 + 0.5;
- SkRect bounds;
- bounds.set(SkIntToScalar(complete_bounds.x()),
- SkIntToScalar(complete_bounds.y()),
- SkIntToScalar(complete_bounds.x() + complete_bounds.width()),
- SkIntToScalar(complete_bounds.y() + complete_bounds.height()));
- canvas->AsCanvasSkia()->saveLayerAlpha(
- &bounds,
- static_cast<int>(255.0 * opacity),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds);
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y());
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
// Load a language dependent height so that the dangerous download confirmation
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index 5bd5ec8..83f92e1 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -804,7 +804,7 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
if (loading_animation_.animation_state() != ANIMATION_NONE) {
PaintLoadingAnimation(canvas);
} else {
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(0, 0, width(), height() - kFavIconTitleSpacing);
if (should_display_crashed_favicon_) {
canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0,
@@ -834,7 +834,7 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
}
}
}
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
}
@@ -846,15 +846,12 @@ void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
double throb_value = GetThrobValue();
if (throb_value > 0) {
- SkRect bounds;
- bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->AsCanvasSkia()->saveLayerAlpha(
- &bounds, static_cast<int>(throb_value * 0xff),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff),
+ gfx::Rect(width(), height()));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
SkXfermode::kClear_Mode);
PaintActiveTabBackground(canvas);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
}
}
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index edab6a5..3800685 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -515,7 +515,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// (hot_)body_image_set->bottom_left, and drop_down_image_set,
// for RTL UI, we flip the canvas to draw those images mirrored.
// Consequently, we do not need to mirror the x-axis of those images.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
}
@@ -536,9 +536,8 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Overlay our body hot state.
if (body_hover_animation_->GetCurrentValue() > 0) {
- canvas->AsCanvasSkia()->saveLayerAlpha(NULL,
- static_cast<int>(body_hover_animation_->GetCurrentValue() * 255),
- SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(
+ static_cast<int>(body_hover_animation_->GetCurrentValue() * 255));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
int x = kLeftPadding;
@@ -557,10 +556,10 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
hot_body_image_set_.bottom_right,
x, box_y_, box_height_,
hot_body_image_set_.top_right->width());
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
if (rtl_ui) {
- canvas->AsCanvasSkia()->restore();
- canvas->AsCanvasSkia()->save();
+ canvas->Restore();
+ canvas->Save();
// Flip it for drawing drop-down images for RTL locales.
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
@@ -578,10 +577,8 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Overlay our drop-down hot state.
if (drop_hover_animation_->GetCurrentValue() > 0) {
- canvas->AsCanvasSkia()->saveLayerAlpha(
- NULL,
- static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255),
- SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(
+ static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
SkXfermode::kClear_Mode);
@@ -590,7 +587,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
drop_down_image_set->bottom,
x, box_y_, box_height_, drop_down_image_set->top->width());
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
}
@@ -598,7 +595,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Restore the canvas to avoid file name etc. text are drawn flipped.
// Consequently, the x-axis of following canvas->DrawXXX() method should be
// mirrored so the text and images are down in the right positions.
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
// Print the text, left aligned and always print the file extension.
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 2686a61..774eb73 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -220,12 +220,12 @@ class ResizeCorner : public views::View {
if (rtl_dir) {
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
}
canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(),
height() - bitmap->height());
if (rtl_dir)
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
static gfx::Size GetSize() {
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index b37552e..90e41b9 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -264,14 +264,14 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
// Draw left edge. We explicitly set a clip as the image is bigger than just
// the corner.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(x - kNonClientBorderThickness,
y - kNonClientBorderThickness,
kNonClientBorderThickness,
kNonClientBorderThickness);
canvas->DrawBitmapInt(*toolbar_left, x - kNonClientBorderThickness,
y - kNonClientBorderThickness);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
// Draw center edge. We need to draw a while line above the toolbar for the
// image to overlay nicely.
@@ -279,14 +279,14 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
canvas->TileImageInt(*toolbar_center, x, y - kNonClientBorderThickness, w,
toolbar_center->height());
// Right edge. Again, we have to clip because of image size.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(x + w - kNonClientBorderThickness,
y - kNonClientBorderThickness,
kNonClientBorderThickness,
kNonClientBorderThickness);
canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
x + w, y);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
} else {
// Draw the toolbar background, setting src_y of the paint to the tab
// strip height as the toolbar background begins at the top of the tabs.
@@ -356,11 +356,11 @@ void GlassBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
gfx::Point tabstrip_origin(browser_view_->tabstrip()->bounds().origin());
View::ConvertPointToView(frame_->GetWindow()->GetClientView(), this,
&tabstrip_origin);
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(dst_x, 2, w, tabstrip_origin.y() - 4);
canvas->DrawBitmapInt(otr_avatar_icon, src_x, src_y, w, h, dst_x, dst_y,
w, h, false);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
} else {
canvas->DrawBitmapInt(otr_avatar_icon, src_x, src_y, w, h, dst_x, dst_y,
w, h, false);
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 227205f..1709903 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -382,10 +382,10 @@ void OpaqueBrowserFrameView::PaintChildren(gfx::Canvas* canvas) {
continue;
}
if (child == otr_avatar_icon_) {
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(0, 2, width(), otr_avatar_icon_->height() - 10);
child->ProcessPaint(canvas);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
} else {
child->ProcessPaint(canvas);
}
@@ -781,11 +781,8 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
// Split our canvas out so we can mask out the corners of the toolbar
// without masking out the frame.
- SkRect bounds;
- bounds.set(SkIntToScalar(x - kClientEdgeThickness), SkIntToScalar(y),
- SkIntToScalar(x + w + kClientEdgeThickness * 2),
- SkIntToScalar(y + h));
- canvas->AsCanvasSkia()->saveLayerAlpha(&bounds, 255);
+ canvas->SaveLayerAlpha(
+ 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness, h));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
SkColor theme_toolbar_color =
@@ -836,7 +833,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
toolbar_right_mask->height() - bottom_edge_height,
toolbar_right_mask->width(), bottom_edge_height, right_x, bottom_y,
toolbar_right_mask->width(), bottom_edge_height, false, paint);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
left_x, y,
diff --git a/chrome/browser/views/infobars/translate_infobar_base.cc b/chrome/browser/views/infobars/translate_infobar_base.cc
index d344b88..b62a3ef 100644
--- a/chrome/browser/views/infobars/translate_infobar_base.cc
+++ b/chrome/browser/views/infobars/translate_infobar_base.cc
@@ -148,12 +148,10 @@ void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas,
const InfoBarBackground& background) {
// Draw the background into an offscreen buffer with alpha value per animation
// value, then blend it back into the current canvas.
- canvas->AsCanvasSkia()->saveLayerAlpha(
- NULL, static_cast<int>(animation_value * 255),
- SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
background.Paint(canvas, this);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
// TranslateInfoBarDelegate views specific method:
diff --git a/chrome/browser/views/infobars/translate_infobars.cc b/chrome/browser/views/infobars/translate_infobars.cc
index e395c39..c2a5e2e 100644
--- a/chrome/browser/views/infobars/translate_infobars.cc
+++ b/chrome/browser/views/infobars/translate_infobars.cc
@@ -757,12 +757,10 @@ void TranslateInfoBar::FadeBackground(gfx::Canvas* canvas,
double animation_value, TranslateInfoBarDelegate::TranslateState state) {
// Draw background into an offscreen buffer with alpha value per animation
// value, then blend it back into the current canvas.
- canvas->AsCanvasSkia()->saveLayerAlpha(
- NULL, static_cast<int>(animation_value * 255),
- SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
GetBackground(state)->Paint(canvas, this);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const {
diff --git a/chrome/browser/views/tabs/base_tab.cc b/chrome/browser/views/tabs/base_tab.cc
index 58e853f..9583233 100644
--- a/chrome/browser/views/tabs/base_tab.cc
+++ b/chrome/browser/views/tabs/base_tab.cc
@@ -437,7 +437,7 @@ void BaseTab::PaintIcon(gfx::Canvas* canvas, int x, int y) {
image_size, favicon_x, dst_y, image_size, image_size,
false);
} else {
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(0, 0, width(), height());
if (should_display_crashed_favicon_) {
canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0,
@@ -460,7 +460,7 @@ void BaseTab::PaintIcon(gfx::Canvas* canvas, int x, int y) {
true);
}
}
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
}
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index d0587bf..7f7f7a5 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -97,7 +97,7 @@ class DockView : public views::View {
bool rtl_ui = base::i18n::IsRTL();
if (rtl_ui) {
// Flip canvas to draw the mirrored tab images for RTL UI.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
}
@@ -171,7 +171,7 @@ class DockView : public views::View {
break;
}
if (rtl_ui)
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
private:
diff --git a/chrome/browser/views/tabs/side_tab.cc b/chrome/browser/views/tabs/side_tab.cc
index 05036d6..0169772 100644
--- a/chrome/browser/views/tabs/side_tab.cc
+++ b/chrome/browser/views/tabs/side_tab.cc
@@ -99,12 +99,10 @@ void SideTab::Paint(gfx::Canvas* canvas) {
if (ShouldShowIcon()) {
if (data().phantom) {
- SkRect bounds;
- bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->AsCanvasSkia()->saveLayerAlpha(
- &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(kPhantomTabIconAlpha,
+ gfx::Rect(width(), height()));
PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
} else {
PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
}
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index 82ab751..22e424a 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -379,15 +379,12 @@ void Tab::PaintTabBackground(gfx::Canvas* canvas) {
double throb_value = GetThrobValue();
if (throb_value > 0) {
- SkRect bounds;
- bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->AsCanvasSkia()->saveLayerAlpha(
- &bounds, static_cast<int>(throb_value * 0xff),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff),
+ gfx::Rect(width(), height()));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
SkXfermode::kClear_Mode);
PaintActiveTabBackground(canvas);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
}
}
@@ -438,10 +435,9 @@ void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) {
// And then the gradient on top of that.
if (mini_title_animation_->current_part_index() == 2) {
- canvas->AsCanvasSkia()->saveLayerAlpha(
- NULL, mini_title_animation_->CurrentValueBetween(255, 0));
+ canvas->SaveLayerAlpha(mini_title_animation_->CurrentValueBetween(255, 0));
canvas->DrawBitmapInt(hover_image, 0, 0);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
} else {
canvas->DrawBitmapInt(hover_image, 0, 0);
}
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 2d54f66..4b61bb5 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -292,33 +292,30 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
// Phantom tabs appear behind all other tabs and are rendered first. To make
// them slightly transparent we render them to a different layer.
if (HasPhantomTabs()) {
- SkRect bounds;
- bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->AsCanvasSkia()->saveLayerAlpha(
- &bounds, kPhantomTabAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ gfx::Rect local_bounds = GetLocalBounds(true);
+ canvas->SaveLayerAlpha(kPhantomTabAlpha, local_bounds);
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
for (int i = tab_count() - 1; i >= 0; --i) {
Tab* tab = GetTabAtTabDataIndex(i);
if (tab->data().phantom)
tab->ProcessPaint(canvas);
}
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
- canvas->AsCanvasSkia()->saveLayerAlpha(
- &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(kPhantomTabIconAlpha, local_bounds);
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
for (int i = tab_count() - 1; i >= 0; --i) {
Tab* tab = GetTabAtTabDataIndex(i);
if (tab->data().phantom) {
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->ClipRectInt(tab->MirroredX(), tab->y(), tab->width(),
tab->height());
canvas->TranslateInt(tab->MirroredX(), tab->y());
tab->PaintIcon(canvas);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
}
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
Tab* selected_tab = NULL;
diff --git a/chrome/common/extensions/extension_action.cc b/chrome/common/extensions/extension_action.cc
index dbdae7f..7e7503f 100644
--- a/chrome/common/extensions/extension_action.cc
+++ b/chrome/common/extensions/extension_action.cc
@@ -117,7 +117,7 @@ void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
if (SkColorGetA(background_color) == 0x00)
background_color = SkColorSetARGB(255, 218, 0, 24); // Default badge color.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
SkPaint* text_paint = GetTextPaint();
text_paint->setColor(text_color);
@@ -158,8 +158,7 @@ void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
rect_paint.setAntiAlias(true);
rect_paint.setColor(background_color);
canvas->AsCanvasSkia()->drawRoundRect(rect, SkIntToScalar(2),
- SkIntToScalar(2),
- rect_paint);
+ SkIntToScalar(2), rect_paint);
// Overlay the gradient. It is stretchy, so we do this in three parts.
ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance();
@@ -189,5 +188,5 @@ void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
rect.fLeft + (rect.width() - text_width) / 2,
rect.fTop + kTextSize + kTopTextPadding,
*text_paint);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
diff --git a/gfx/canvas.h b/gfx/canvas.h
index d66db03..90495cd 100644
--- a/gfx/canvas.h
+++ b/gfx/canvas.h
@@ -66,6 +66,21 @@ class Canvas {
// Creates a canvas with the specified size.
static Canvas* CreateCanvas(int width, int height, bool is_opaque);
+ // Saves a copy of the drawing state onto a stack, operating on this copy
+ // until a balanced call to Restore() is made.
+ virtual void Save() = 0;
+
+ // As with Save(), except draws to a layer that is blended with the canvas
+ // at the specified alpha once Restore() is called.
+ // |layer_bounds| are the bounds of the layer relative to the current
+ // transform.
+ virtual void SaveLayerAlpha(U8CPU alpha) = 0;
+ virtual void SaveLayerAlpha(U8CPU alpha, const gfx::Rect& layer_bounds) = 0;
+
+ // Restores the drawing state after a call to Save*(). It is an error to
+ // call Restore() more times than Save*().
+ virtual void Restore() = 0;
+
// Retrieves the clip rectangle and sets it in the specified rectangle if any.
// Returns true if the clip rect is non-empty.
virtual bool GetClipRect(gfx::Rect* clip_rect) = 0;
diff --git a/gfx/canvas_skia.cc b/gfx/canvas_skia.cc
index 8fb752de..28a3596 100644
--- a/gfx/canvas_skia.cc
+++ b/gfx/canvas_skia.cc
@@ -29,6 +29,31 @@ SkBitmap CanvasSkia::ExtractBitmap() const {
return result;
}
+////////////////////////////////////////////////////////////////////////////////
+// CanvasSkia, Canvas implementation:
+
+void CanvasSkia::Save() {
+ save();
+}
+
+void CanvasSkia::SaveLayerAlpha(U8CPU alpha) {
+ saveLayerAlpha(NULL, alpha);
+}
+
+
+void CanvasSkia::SaveLayerAlpha(U8CPU alpha, const gfx::Rect& layer_bounds) {
+ SkRect bounds;
+ bounds.set(SkIntToScalar(layer_bounds.x()),
+ SkIntToScalar(layer_bounds.y()),
+ SkIntToScalar(layer_bounds.right()),
+ SkIntToScalar(layer_bounds.bottom()));
+ saveLayerAlpha(&bounds, alpha);
+}
+
+void CanvasSkia::Restore() {
+ restore();
+}
+
bool CanvasSkia::GetClipRect(gfx::Rect* r) {
SkRect clip;
if (!getClipBounds(&clip)) {
diff --git a/gfx/canvas_skia.h b/gfx/canvas_skia.h
index cae4ac1..1648cbe 100644
--- a/gfx/canvas_skia.h
+++ b/gfx/canvas_skia.h
@@ -80,6 +80,10 @@ class CanvasSkia : public skia::PlatformCanvas,
SkBitmap ExtractBitmap() const;
// Overridden from Canvas2:
+ virtual void Save();
+ virtual void SaveLayerAlpha(U8CPU alpha);
+ virtual void SaveLayerAlpha(U8CPU alpha, const gfx::Rect& layer_bounds);
+ virtual void Restore();
virtual bool GetClipRect(gfx::Rect* clip_rect);
virtual bool ClipRectInt(int x, int y, int w, int h);
virtual bool IntersectsClipRectInt(int x, int y, int w, int h);
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index f2b7613..158314c 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -256,13 +256,12 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
if (show_highlighted_ && hover_animation_->is_animating()) {
// Draw the hover bitmap into an offscreen buffer, then blend it
// back into the current canvas.
- canvas->AsCanvasSkia()->saveLayerAlpha(NULL,
- static_cast<int>(hover_animation_->GetCurrentValue() * 255),
- SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas->SaveLayerAlpha(
+ static_cast<int>(hover_animation_->GetCurrentValue() * 255));
canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
SkXfermode::kClear_Mode);
PaintBorder(canvas);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
} else if ((show_highlighted_ &&
(state_ == BS_HOT || state_ == BS_PUSHED)) ||
(state_ == BS_NORMAL && normal_has_border_)) {
diff --git a/views/painter.cc b/views/painter.cc
index c368a0a..2dbcb4d 100644
--- a/views/painter.cc
+++ b/views/painter.cc
@@ -148,10 +148,10 @@ void Painter::PaintPainterAt(int x, int y, int w, int h,
DCHECK(canvas && painter);
if (w < 0 || h < 0)
return;
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
canvas->TranslateInt(x, y);
painter->Paint(w, h, canvas);
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
// static
diff --git a/views/view.cc b/views/view.cc
index e2d4e43..90fb2bc 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -378,7 +378,7 @@ void View::ProcessPaint(gfx::Canvas* canvas) {
return;
// We're going to modify the canvas, save it's state first.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
// Paint this View and its children, setting the clip rect to the bounds
// of this View and translating the origin to the local bounds' top left
@@ -393,7 +393,7 @@ void View::ProcessPaint(gfx::Canvas* canvas) {
canvas->TranslateInt(MirroredX(), y());
// Save the state again, so that any changes don't effect PaintChildren.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
// If the View we are about to paint requested the canvas to be flipped, we
// should change the transform appropriately.
@@ -401,7 +401,7 @@ void View::ProcessPaint(gfx::Canvas* canvas) {
if (flip_canvas) {
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
}
Paint(canvas);
@@ -410,14 +410,14 @@ void View::ProcessPaint(gfx::Canvas* canvas) {
// we don't pass the canvas with the mirrored transform to Views that
// didn't request the canvas to be flipped.
if (flip_canvas)
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
PaintChildren(canvas);
}
// Restore the canvas's original transform.
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
}
void View::PaintNow() {
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index d67f5e3..b9cf725 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -176,7 +176,7 @@ void RootView::ProcessPaint(gfx::Canvas* canvas) {
canvas->AsCanvasSkia()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
// Save the current transforms.
- canvas->AsCanvasSkia()->save();
+ canvas->Save();
// Set the clip rect according to the invalid rect.
int clip_x = invalid_rect_.x() + x();
@@ -188,7 +188,7 @@ void RootView::ProcessPaint(gfx::Canvas* canvas) {
View::ProcessPaint(canvas);
// Restore the previous transform
- canvas->AsCanvasSkia()->restore();
+ canvas->Restore();
ClearPaintRect();
}