summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.cc4
-rw-r--r--chrome/browser/download/download_util.cc15
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc23
-rw-r--r--chrome/browser/renderer_host/render_widget_host_unittest.cc4
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc13
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc6
-rw-r--r--chrome/browser/views/browser_actions_container.cc4
-rw-r--r--chrome/browser/views/bubble_border.cc6
-rw-r--r--chrome/browser/views/create_application_shortcut_view.cc10
-rw-r--r--chrome/browser/views/detachable_toolbar_view.cc14
-rw-r--r--chrome/browser/views/download_item_view.cc24
-rw-r--r--chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc6
-rw-r--r--chrome/browser/views/extensions/extension_shelf.cc7
-rw-r--r--chrome/browser/views/frame/browser_view.cc6
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc14
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc12
-rw-r--r--chrome/browser/views/fullscreen_exit_bubble.cc4
-rw-r--r--chrome/browser/views/info_bubble.cc4
-rw-r--r--chrome/browser/views/infobars/translate_infobar_base.cc11
-rw-r--r--chrome/browser/views/infobars/translate_infobars.cc9
-rw-r--r--chrome/browser/views/list_background.h6
-rw-r--r--chrome/browser/views/location_bar/location_bar_view.cc5
-rw-r--r--chrome/browser/views/notifications/balloon_view.cc4
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc6
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc6
-rw-r--r--chrome/browser/views/sad_tab_view.cc5
-rw-r--r--chrome/browser/views/status_bubble_views.cc6
-rw-r--r--chrome/browser/views/tabs/base_tab.cc6
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc11
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc6
-rw-r--r--chrome/browser/views/tabs/native_view_photobooth_win.cc13
-rw-r--r--chrome/browser/views/tabs/side_tab.cc14
-rw-r--r--chrome/browser/views/tabs/tab.cc19
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc22
-rw-r--r--chrome/browser/views/theme_install_bubble_view.cc3
-rw-r--r--chrome/common/extensions/extension_action.cc23
-rw-r--r--gfx/canvas.h200
-rw-r--r--gfx/canvas_2.h201
-rw-r--r--gfx/canvas_skia.cc43
-rw-r--r--gfx/canvas_skia.h10
-rw-r--r--gfx/canvas_skia_linux.cc2
-rw-r--r--gfx/canvas_skia_mac.mm2
-rw-r--r--gfx/canvas_skia_paint.h4
-rw-r--r--gfx/canvas_skia_win.cc2
-rw-r--r--gfx/font_mac.mm5
-rw-r--r--gfx/font_skia.cc5
-rw-r--r--gfx/font_win.cc5
-rw-r--r--gfx/gfx.gyp1
-rw-r--r--views/background.cc4
-rw-r--r--views/controls/button/text_button.cc23
-rw-r--r--views/controls/label.cc6
-rw-r--r--views/controls/menu/menu_controller.cc4
-rw-r--r--views/controls/menu/menu_item_view_gtk.cc15
-rw-r--r--views/controls/menu/menu_item_view_win.cc14
-rw-r--r--views/controls/menu/menu_scroll_view_container.cc13
-rw-r--r--views/controls/menu/menu_separator_win.cc6
-rw-r--r--views/controls/progress_bar.cc6
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_win.cc6
-rw-r--r--views/controls/table/table_view.cc4
-rw-r--r--views/drag_utils.cc7
-rw-r--r--views/drag_utils_win.cc4
-rw-r--r--views/painter.cc10
-rw-r--r--views/view.cc14
-rw-r--r--views/view_text_utils.cc6
-rw-r--r--views/view_unittest.cc4
-rw-r--r--views/widget/root_view.cc8
-rw-r--r--views/widget/root_view_win.cc7
-rw-r--r--views/widget/widget_win.cc7
-rw-r--r--views/widget/widget_win.h4
-rw-r--r--views/window/dialog_client_view.cc6
70 files changed, 500 insertions, 509 deletions
diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc
index 09c84f3..f6213ec 100644
--- a/chrome/browser/chromeos/status/network_menu_button.cc
+++ b/chrome/browser/chromeos/status/network_menu_button.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/status/status_area_host.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/skbitmap_operations.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -387,7 +387,7 @@ SkBitmap NetworkMenuButton::IconForDisplay(SkBitmap icon, SkBitmap badge) {
static const int kBadgeX = 14;
static const int kBadgeY = 14;
- gfx::Canvas canvas(kIconWidth, kIconHeight, false);
+ gfx::CanvasSkia canvas(kIconWidth, kIconHeight, false);
canvas.DrawBitmapInt(icon, kIconX, kIconY);
if (!badge.empty())
canvas.DrawBitmapInt(badge, kBadgeX, kBadgeY);
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 0972ddc..0042b75 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -27,7 +27,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/time_format.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/rect.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -225,7 +225,7 @@ void PaintDownloadProgress(gfx::Canvas* canvas,
foreground_paint.setShader(shader);
foreground_paint.setAntiAlias(true);
shader->unref();
- canvas->drawPath(path, foreground_paint);
+ canvas->AsCanvasSkia()->drawPath(path, foreground_paint);
return;
}
@@ -271,12 +271,13 @@ void PaintDownloadComplete(gfx::Canvas* canvas,
SkIntToScalar(complete_bounds.y()),
SkIntToScalar(complete_bounds.x() + complete_bounds.width()),
SkIntToScalar(complete_bounds.y() + complete_bounds.height()));
- canvas->saveLayerAlpha(&bounds,
- static_cast<int>(255.0 * opacity),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ &bounds,
+ static_cast<int>(255.0 * opacity),
+ SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y());
- canvas->restore();
+ canvas->AsCanvasSkia()->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 7ab29e6..5bd5ec8 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -619,13 +619,13 @@ void TabRendererGtk::Paint(gfx::Canvas* canvas) {
}
SkBitmap TabRendererGtk::PaintBitmap() {
- gfx::Canvas canvas(width(), height(), false);
+ gfx::CanvasSkia canvas(width(), height(), false);
Paint(&canvas);
return canvas.ExtractBitmap();
}
cairo_surface_t* TabRendererGtk::PaintToSurface() {
- gfx::Canvas canvas(width(), height(), false);
+ gfx::CanvasSkia canvas(width(), height(), false);
Paint(&canvas);
return cairo_surface_reference(cairo_get_target(canvas.beginPlatformPaint()));
}
@@ -804,7 +804,7 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
if (loading_animation_.animation_state() != ANIMATION_NONE) {
PaintLoadingAnimation(canvas);
} else {
- canvas->save();
+ canvas->AsCanvasSkia()->save();
canvas->ClipRectInt(0, 0, width(), height() - kFavIconTitleSpacing);
if (should_display_crashed_favicon_) {
canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0,
@@ -818,8 +818,9 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
if (!data_.favicon.isNull()) {
if (data_.is_default_favicon && theme_provider_->UseGtkTheme()) {
GdkPixbuf* favicon = GtkThemeProvider::GetDefaultFavicon(true);
- canvas->DrawGdkPixbuf(favicon, favicon_bounds_.x(),
- favicon_bounds_.y() + fav_icon_hiding_offset_);
+ canvas->AsCanvasSkia()->DrawGdkPixbuf(
+ favicon, favicon_bounds_.x(),
+ favicon_bounds_.y() + fav_icon_hiding_offset_);
} else {
// TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
// to using that class to render the favicon).
@@ -833,7 +834,7 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
}
}
}
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
}
@@ -847,11 +848,13 @@ void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
if (throb_value > 0) {
SkRect bounds;
bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ &bounds, static_cast<int>(throb_value * 0xff),
+ SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
+ SkXfermode::kClear_Mode);
PaintActiveTabBackground(canvas);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
}
}
diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc
index b6e4326..4ea8193 100644
--- a/chrome/browser/renderer_host/render_widget_host_unittest.cc
+++ b/chrome/browser/renderer_host/render_widget_host_unittest.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/renderer_host/render_widget_host_painting_observer.h"
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/common/render_messages.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::TimeDelta;
@@ -406,7 +406,7 @@ TEST_F(RenderWidgetHostTest, Background) {
host_->set_view(view.get());
// Create a checkerboard background to test with.
- gfx::Canvas canvas(4, 4, true);
+ gfx::CanvasSkia canvas(4, 4, true);
canvas.FillRectInt(SK_ColorBLACK, 0, 0, 2, 2);
canvas.FillRectInt(SK_ColorWHITE, 2, 0, 2, 2);
canvas.FillRectInt(SK_ColorWHITE, 0, 2, 2, 2);
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index df9565c..17d243c 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/views/bubble_border.h"
#include "chrome/browser/views/location_bar/location_bar_view.h"
-#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/insets.h"
@@ -273,7 +272,7 @@ AutocompleteResultView::~AutocompleteResultView() {
void AutocompleteResultView::Paint(gfx::Canvas* canvas) {
const ResultViewState state = GetState();
if (state != NORMAL)
- canvas->drawColor(GetColor(state, BACKGROUND));
+ canvas->AsCanvasSkia()->drawColor(GetColor(state, BACKGROUND));
// Paint the icon.
canvas->DrawBitmapInt(*GetIcon(), MirroredLeftPointForRect(icon_bounds_),
@@ -765,8 +764,7 @@ void AutocompletePopupContentsView::Paint(gfx::Canvas* canvas) {
// Instead, we paint all our children into a second canvas and use that as a
// shader to fill a path representing the round-rect clipping region. This
// yields a nice anti-aliased edge.
- // TODO(beng): Convert to CanvasSkia
- gfx::Canvas contents_canvas(width(), height(), true);
+ gfx::CanvasSkia contents_canvas(width(), height(), true);
contents_canvas.drawColor(GetColor(NORMAL, BACKGROUND));
View::PaintChildren(&contents_canvas);
// We want the contents background to be slightly transparent so we can see
@@ -788,7 +786,7 @@ void AutocompletePopupContentsView::Paint(gfx::Canvas* canvas) {
gfx::Path path;
MakeContentsPath(&path, GetLocalBounds(false));
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
// Now we paint the border, so it will be alpha-blended atop the contents.
// This looks slightly better in the corners than drawing the contents atop
@@ -935,8 +933,9 @@ void AutocompletePopupContentsView::MakeCanvasTransparent(
// Allow the window blur effect to show through the popup background.
SkAlpha alpha = GetThemeProvider()->ShouldUseNativeFrame() ?
kGlassPopupAlpha : kOpaquePopupAlpha;
- canvas->drawColor(SkColorSetA(GetColor(NORMAL, BACKGROUND), alpha),
- SkXfermode::kDstIn_Mode);
+ canvas->AsCanvasSkia()->drawColor(
+ SkColorSetA(GetColor(NORMAL, BACKGROUND), alpha),
+ SkXfermode::kDstIn_Mode);
}
void AutocompletePopupContentsView::OpenIndex(
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 0b97017..e595529 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -37,7 +37,6 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/page_transition_types.h"
#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
@@ -243,7 +242,7 @@ class BookmarkFolderButton : public views::MenuButton {
return disposition != CURRENT_TAB;
}
- virtual void Paint(gfx::Canvas *canvas) {
+ virtual void Paint(gfx::Canvas* canvas) {
views::MenuButton::Paint(canvas, false);
}
@@ -1111,8 +1110,7 @@ void BookmarkBarView::WriteDragData(View* sender,
for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
if (sender == GetBookmarkButton(i)) {
views::TextButton* button = GetBookmarkButton(i);
- // TODO(beng): convert to CanvasSkia
- gfx::Canvas canvas(button->width(), button->height(), false);
+ gfx::CanvasSkia canvas(button->width(), button->height(), false);
button->Paint(&canvas, true);
drag_utils::SetDragImageOnDataObject(canvas, button->size(),
press_pt, data);
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index e472de6..78cf623 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -323,8 +323,8 @@ gfx::Canvas* BrowserActionView::GetIconWithBadge() {
if (icon.isNull())
icon = button_->default_icon();
- // TODO(beng): Convert to CanvasSkia
- gfx::Canvas* canvas = new gfx::Canvas(icon.width(), icon.height(), false);
+ gfx::Canvas* canvas =
+ new gfx::CanvasSkia(icon.width(), icon.height(), false);
canvas->DrawBitmapInt(icon, 0, 0);
if (tab_id >= 0) {
diff --git a/chrome/browser/views/bubble_border.cc b/chrome/browser/views/bubble_border.cc
index 49c53b6..e37f5fe 100644
--- a/chrome/browser/views/bubble_border.cc
+++ b/chrome/browser/views/bubble_border.cc
@@ -6,7 +6,7 @@
#include "app/resource_bundle.h"
#include "base/logging.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/path.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -418,7 +418,7 @@ void BubbleBorder::DrawArrowInterior(gfx::Canvas* canvas,
else
path.lineTo(SkIntToScalar(tip_x + shift_x), SkIntToScalar(tip_y - shift_y));
path.close();
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
}
/////////////////////////
@@ -439,5 +439,5 @@ void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom()));
SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
path.addRoundRect(rect, radius, radius);
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
}
diff --git a/chrome/browser/views/create_application_shortcut_view.cc b/chrome/browser/views/create_application_shortcut_view.cc
index 0d3f6e2..b0a66b3 100644
--- a/chrome/browser/views/create_application_shortcut_view.cc
+++ b/chrome/browser/views/create_application_shortcut_view.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/codec/png_codec.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -169,8 +169,8 @@ void AppInfoView::Paint(gfx::Canvas* canvas) {
border_paint.setAntiAlias(true);
border_paint.setARGB(0xFF, 0xC8, 0xC8, 0xC8);
- canvas->drawRoundRect(border_rect, SkIntToScalar(2), SkIntToScalar(2),
- border_paint);
+ canvas->AsCanvasSkia()->drawRoundRect(
+ border_rect, SkIntToScalar(2), SkIntToScalar(2), border_paint);
SkRect inner_rect = {
border_rect.fLeft + SkDoubleToScalar(0.5),
@@ -182,8 +182,8 @@ void AppInfoView::Paint(gfx::Canvas* canvas) {
SkPaint inner_paint;
inner_paint.setAntiAlias(true);
inner_paint.setARGB(0xFF, 0xF8, 0xF8, 0xF8);
- canvas->drawRoundRect(inner_rect, SkIntToScalar(1.5), SkIntToScalar(1.5),
- inner_paint);
+ canvas->AsCanvasSkia()->drawRoundRect(
+ inner_rect, SkIntToScalar(1.5), SkIntToScalar(1.5), inner_paint);
}
}; // namespace
diff --git a/chrome/browser/views/detachable_toolbar_view.cc b/chrome/browser/views/detachable_toolbar_view.cc
index 2e3e457..ba44f3d 100644
--- a/chrome/browser/views/detachable_toolbar_view.cc
+++ b/chrome/browser/views/detachable_toolbar_view.cc
@@ -6,7 +6,7 @@
#include "app/resource_bundle.h"
#include "chrome/browser/browser_theme_provider.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/skia_util.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -70,7 +70,7 @@ void DetachableToolbarView::PaintContentAreaBackground(
paint.setAntiAlias(true);
paint.setColor(theme_provider->GetColor(BrowserThemeProvider::COLOR_TOOLBAR));
- canvas->drawRoundRect(
+ canvas->AsCanvasSkia()->drawRoundRect(
rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint);
}
@@ -85,9 +85,9 @@ void DetachableToolbarView::PaintContentAreaBorder(
border_paint.setAlpha(96);
border_paint.setAntiAlias(true);
- canvas->drawRoundRect(rect,
- SkDoubleToScalar(roundness),
- SkDoubleToScalar(roundness), border_paint);
+ canvas->AsCanvasSkia()->drawRoundRect(
+ rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness),
+ border_paint);
}
// static
@@ -106,7 +106,7 @@ void DetachableToolbarView::PaintVerticalDivider(
SkIntToScalar(vertical_padding + 1),
SkIntToScalar(x + 1),
SkIntToScalar(height / 2) };
- canvas->drawRect(rc, paint);
+ canvas->AsCanvasSkia()->drawRect(rc, paint);
// Draw the lower half of the divider.
SkPaint paint_down;
@@ -118,5 +118,5 @@ void DetachableToolbarView::PaintVerticalDivider(
SkIntToScalar(height / 2),
SkIntToScalar(x + 1),
SkIntToScalar(height - vertical_padding) };
- canvas->drawRect(rc_down, paint_down);
+ canvas->AsCanvasSkia()->drawRect(rc_down, paint_down);
}
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index d519783..edab6a5 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -20,7 +20,7 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/views/download_shelf_view.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -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->save();
+ canvas->AsCanvasSkia()->save();
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
}
@@ -536,10 +536,10 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Overlay our body hot state.
if (body_hover_animation_->GetCurrentValue() > 0) {
- canvas->saveLayerAlpha(NULL,
+ canvas->AsCanvasSkia()->saveLayerAlpha(NULL,
static_cast<int>(body_hover_animation_->GetCurrentValue() * 255),
SkCanvas::kARGB_NoClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
int x = kLeftPadding;
PaintBitmaps(canvas,
@@ -557,10 +557,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->restore();
+ canvas->AsCanvasSkia()->restore();
if (rtl_ui) {
- canvas->restore();
- canvas->save();
+ canvas->AsCanvasSkia()->restore();
+ canvas->AsCanvasSkia()->save();
// Flip it for drawing drop-down images for RTL locales.
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
@@ -578,17 +578,19 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Overlay our drop-down hot state.
if (drop_hover_animation_->GetCurrentValue() > 0) {
- canvas->saveLayerAlpha(NULL,
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ NULL,
static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255),
SkCanvas::kARGB_NoClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
+ SkXfermode::kClear_Mode);
PaintBitmaps(canvas,
drop_down_image_set->top, drop_down_image_set->center,
drop_down_image_set->bottom,
x, box_y_, box_height_, drop_down_image_set->top->width());
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
}
@@ -596,7 +598,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->restore();
+ canvas->AsCanvasSkia()->restore();
}
// Print the text, left aligned and always print the file extension.
diff --git a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
index 0b66c13..aa072f6 100644
--- a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
+++ b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/views/extensions/browser_action_drag_data.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "views/controls/menu/menu_item_view.h"
#include "views/controls/menu/menu_2.h"
@@ -34,11 +34,11 @@ BrowserActionOverflowMenuController::BrowserActionOverflowMenuController(
size_t command_id = 1; // Menu id 0 is reserved, start with 1.
for (size_t i = start_index; i < views_->size(); ++i) {
BrowserActionView* view = (*views_)[i];
- scoped_ptr<gfx::CanvasSkia> canvas(view->GetIconWithBadge());
+ scoped_ptr<gfx::Canvas> canvas(view->GetIconWithBadge());
menu_->AppendMenuItemWithIcon(
command_id,
UTF8ToWide(view->button()->extension()->name()),
- canvas->ExtractBitmap());
+ canvas->AsCanvasSkia()->ExtractBitmap());
// Set the tooltip for this item.
std::wstring tooltip = UTF8ToWide(
diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc
index e06b494..7bb5391 100644
--- a/chrome/browser/views/extensions/extension_shelf.cc
+++ b/chrome/browser/views/extensions/extension_shelf.cc
@@ -24,6 +24,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
+#include "gfx/canvas_skia.h"
#include "views/controls/label.h"
#include "views/screen.h"
#include "views/widget/root_view.h"
@@ -942,13 +943,15 @@ void ExtensionShelf::InitBackground(gfx::Canvas* canvas) {
for (int i = 0; i < count; ++i) {
ExtensionView* view = ToolstripAtIndex(i)->view();
- const SkBitmap& background = canvas->getDevice()->accessBitmap(false);
+ const SkBitmap& background =
+ canvas->AsCanvasSkia()->getDevice()->accessBitmap(false);
SkRect mapped_subset = background_rect;
gfx::Rect view_bounds = view->bounds();
mapped_subset.offset(SkIntToScalar(view_bounds.x()),
SkIntToScalar(view_bounds.y()));
- bool result = canvas->getTotalMatrix().mapRect(&mapped_subset);
+ bool result =
+ canvas->AsCanvasSkia()->getTotalMatrix().mapRect(&mapped_subset);
DCHECK(result);
SkIRect isubset;
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 343519e..caca13a 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -49,7 +49,7 @@
#include "chrome/common/native_window_notification_source.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "grit/app_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -221,12 +221,12 @@ class ResizeCorner : public views::View {
if (rtl_dir) {
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
- canvas->save();
+ canvas->AsCanvasSkia()->save();
}
canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(),
height() - bitmap->height());
if (rtl_dir)
- canvas->restore();
+ canvas->AsCanvasSkia()->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 d65cbc3..b37552e 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/views/tabs/side_tab_strip.h"
#include "chrome/browser/views/tabs/tab.h"
#include "chrome/browser/views/tabs/tab_strip.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/icon_util.h"
#include "grit/app_resources.h"
#include "grit/theme_resources.h"
@@ -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->save();
+ canvas->AsCanvasSkia()->save();
canvas->ClipRectInt(x - kNonClientBorderThickness,
y - kNonClientBorderThickness,
kNonClientBorderThickness,
kNonClientBorderThickness);
canvas->DrawBitmapInt(*toolbar_left, x - kNonClientBorderThickness,
y - kNonClientBorderThickness);
- canvas->restore();
+ canvas->AsCanvasSkia()->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->save();
+ canvas->AsCanvasSkia()->save();
canvas->ClipRectInt(x + w - kNonClientBorderThickness,
y - kNonClientBorderThickness,
kNonClientBorderThickness,
kNonClientBorderThickness);
canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
x + w, y);
- canvas->restore();
+ canvas->AsCanvasSkia()->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->save();
+ canvas->AsCanvasSkia()->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->restore();
+ canvas->AsCanvasSkia()->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 d18375a..227205f 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
#include "chrome/browser/views/toolbar_view.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/font.h"
#include "gfx/path.h"
#include "grit/app_resources.h"
@@ -382,10 +382,10 @@ void OpaqueBrowserFrameView::PaintChildren(gfx::Canvas* canvas) {
continue;
}
if (child == otr_avatar_icon_) {
- canvas->save();
+ canvas->AsCanvasSkia()->save();
canvas->ClipRectInt(0, 2, width(), otr_avatar_icon_->height() - 10);
child->ProcessPaint(canvas);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
} else {
child->ProcessPaint(canvas);
}
@@ -785,8 +785,8 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
bounds.set(SkIntToScalar(x - kClientEdgeThickness), SkIntToScalar(y),
SkIntToScalar(x + w + kClientEdgeThickness * 2),
SkIntToScalar(y + h));
- canvas->saveLayerAlpha(&bounds, 255);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(&bounds, 255);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
SkColor theme_toolbar_color =
tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
@@ -836,7 +836,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->restore();
+ canvas->AsCanvasSkia()->restore();
canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
left_x, y,
diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc
index c12326a..e216bd2 100644
--- a/chrome/browser/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/views/fullscreen_exit_bubble.cc
@@ -8,7 +8,7 @@
#include "app/resource_bundle.h"
#include "base/keyboard_codes.h"
#include "chrome/app/chrome_dll_resource.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "grit/generated_resources.h"
#include "views/screen.h"
#include "views/widget/root_view.h"
@@ -92,7 +92,7 @@ void FullscreenExitBubble::FullscreenExitView::Paint(gfx::Canvas* canvas) {
paint.setStyle(SkPaint::kFill_Style);
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setColor(SK_ColorBLACK);
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
}
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 7f1b4f2..34645a0 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -7,7 +7,7 @@
#include "base/keyboard_codes.h"
#include "chrome/browser/window_sizer.h"
#include "chrome/common/notification_service.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/path.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -114,7 +114,7 @@ void BorderContents::Paint(gfx::Canvas* canvas) {
SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom()));
SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
path.addRoundRect(rect, radius, radius);
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
// Now we paint the border, so it will be alpha-blended atop the contents.
// This looks slightly better in the corners than drawing the contents atop
diff --git a/chrome/browser/views/infobars/translate_infobar_base.cc b/chrome/browser/views/infobars/translate_infobar_base.cc
index aa89609..d344b88 100644
--- a/chrome/browser/views/infobars/translate_infobar_base.cc
+++ b/chrome/browser/views/infobars/translate_infobar_base.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/views/infobars/before_translate_infobar.h"
#include "chrome/browser/views/infobars/translate_message_infobar.h"
#include "chrome/browser/views/infobars/infobar_button_border.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "grit/app_resources.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/image_view.h"
@@ -148,11 +148,12 @@ 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->saveLayerAlpha(NULL, static_cast<int>(animation_value * 255),
- SkCanvas::kARGB_NoClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ NULL, static_cast<int>(animation_value * 255),
+ SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
background.Paint(canvas, this);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
// TranslateInfoBarDelegate views specific method:
diff --git a/chrome/browser/views/infobars/translate_infobars.cc b/chrome/browser/views/infobars/translate_infobars.cc
index 08d4a0f..e395c39 100644
--- a/chrome/browser/views/infobars/translate_infobars.cc
+++ b/chrome/browser/views/infobars/translate_infobars.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/translate/page_translated_details.h"
#include "chrome/browser/views/infobars/infobar_button_border.h"
#include "chrome/browser/views/infobars/infobar_text_button.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -757,11 +757,12 @@ 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->saveLayerAlpha(NULL, static_cast<int>(animation_value * 255),
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ NULL, static_cast<int>(animation_value * 255),
SkCanvas::kARGB_NoClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
GetBackground(state)->Paint(canvas, this);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const {
diff --git a/chrome/browser/views/list_background.h b/chrome/browser/views/list_background.h
index ba8317a..fb10067 100644
--- a/chrome/browser/views/list_background.h
+++ b/chrome/browser/views/list_background.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_LIST_BACKGROUND_H_
#define CHROME_BROWSER_VIEWS_LIST_BACKGROUND_H_
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/native_theme_win.h"
#include "views/background.h"
@@ -22,10 +22,10 @@ class ListBackground : public views::Background {
virtual ~ListBackground() {}
virtual void Paint(gfx::Canvas* canvas, views::View* view) const {
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
RECT native_lb = view->GetLocalBounds(true).ToRECT();
gfx::NativeTheme::instance()->PaintListBackground(dc, true, &native_lb);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
}
private:
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc
index 77a459f..09c1007 100644
--- a/chrome/browser/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/views/location_bar/location_bar_view.cc
@@ -27,7 +27,7 @@
#include "chrome/browser/views/location_bar/page_action_with_badge_view.h"
#include "chrome/browser/views/location_bar/selected_keyword_view.h"
#include "chrome/browser/views/location_bar/star_view.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/skia_util.h"
#include "grit/generated_resources.h"
@@ -556,7 +556,8 @@ void LocationBarView::Paint(gfx::Canvas* canvas) {
// below, and all our other bubbles.
const SkScalar radius(SkIntToScalar(BubbleBorder::GetCornerRadius()));
bounds.Inset(kEdgeThickness, 0);
- canvas->drawRoundRect(gfx::RectToSkRect(bounds), radius, radius, paint);
+ canvas->AsCanvasSkia()->drawRoundRect(gfx::RectToSkRect(bounds), radius,
+ radius, paint);
} else {
canvas->FillRectInt(color, bounds.x(), bounds.y(), bounds.width(),
bounds.height());
diff --git a/chrome/browser/views/notifications/balloon_view.cc b/chrome/browser/views/notifications/balloon_view.cc
index 2c362d0..68c6570 100644
--- a/chrome/browser/views/notifications/balloon_view.cc
+++ b/chrome/browser/views/notifications/balloon_view.cc
@@ -22,7 +22,7 @@
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/insets.h"
#include "gfx/native_widget_types.h"
#include "grit/generated_resources.h"
@@ -466,7 +466,7 @@ void BalloonViewImpl::Paint(gfx::Canvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(kControlBarBackgroundColor);
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
// Draw a 1-pixel gray line between the content and the menu bar.
int line_width = GetTotalWidth() - kLeftMargin - kRightMargin;
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index b8b88cb..88dc660 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -40,7 +40,7 @@
#include "chrome/browser/views/options/fonts_languages_window_view.h"
#include "chrome/browser/views/restart_message_box.h"
#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/native_theme_win.h"
#include "grit/app_resources.h"
#include "grit/chromium_strings.h"
@@ -135,12 +135,12 @@ void FileDisplayArea::SetFile(const FilePath& file_path) {
}
void FileDisplayArea::Paint(gfx::Canvas* canvas) {
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
RECT rect = { 0, 0, width(), height() };
gfx::NativeTheme::instance()->PaintTextField(
dc, EP_EDITTEXT, ETS_READONLY, 0, &rect,
skia::SkColorToCOLORREF(text_field_background_color_), true, true);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
// Mirror left point for icon_bounds_ to draw icon in RTL locales correctly.
canvas->DrawBitmapInt(default_folder_icon_,
MirroredLeftPointForRect(icon_bounds_),
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index 4fd923e..df5b832 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -21,7 +21,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/font.h"
#include "gfx/native_theme_win.h"
#include "grit/generated_resources.h"
@@ -96,12 +96,12 @@ void FontDisplayView::SetFontType(const std::wstring& font_name,
}
void FontDisplayView::Paint(gfx::Canvas* canvas) {
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
RECT rect = { 0, 0, width(), height() };
gfx::NativeTheme::instance()->PaintTextField(
dc, EP_BACKGROUND, EBS_NORMAL, 0, &rect, ::GetSysColor(COLOR_3DFACE),
true, true);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
}
void FontDisplayView::Layout() {
diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc
index fbaa37d5..e02d975 100644
--- a/chrome/browser/views/sad_tab_view.cc
+++ b/chrome/browser/views/sad_tab_view.cc
@@ -57,9 +57,8 @@ void SadTabView::Paint(gfx::Canvas* canvas) {
kBackgroundColor,
kBackgroundEndColor))->safeUnref();
paint.setStyle(SkPaint::kFill_Style);
- canvas->drawRectCoords(0, 0,
- SkIntToScalar(width()), SkIntToScalar(height()),
- paint);
+ canvas->AsCanvasSkia()->drawRectCoords(
+ 0, 0, SkIntToScalar(width()), SkIntToScalar(height()), paint);
canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y());
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 5026c49..71be04d 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -14,7 +14,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/browser_theme_provider.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/point.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
@@ -414,7 +414,7 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
SkPaint shadow_paint;
shadow_paint.setFlags(SkPaint::kAntiAlias_Flag);
shadow_paint.setColor(kShadowColor);
- canvas->drawPath(shadow_path, shadow_paint);
+ canvas->AsCanvasSkia()->drawPath(shadow_path, shadow_paint);
// Draw the bubble.
rect.set(SkIntToScalar(kShadowThickness),
@@ -423,7 +423,7 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
SkIntToScalar(height - kShadowThickness));
SkPath path;
path.addRoundRect(rect, rad, SkPath::kCW_Direction);
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
// Draw highlight text and then the text body. In order to make sure the text
// is aligned to the right on RTL UIs, we mirror the text bounds if the
diff --git a/chrome/browser/views/tabs/base_tab.cc b/chrome/browser/views/tabs/base_tab.cc
index 04124ed..58e853f 100644
--- a/chrome/browser/views/tabs/base_tab.cc
+++ b/chrome/browser/views/tabs/base_tab.cc
@@ -17,7 +17,7 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/tabs/tab_controller.h"
#include "chrome/common/chrome_switches.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
#include "gfx/font.h"
#include "gfx/skbitmap_operations.h"
@@ -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->save();
+ canvas->AsCanvasSkia()->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->restore();
+ canvas->AsCanvasSkia()->restore();
}
}
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index bb97cd6..5778f0b 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -30,7 +30,7 @@
#include "chrome/browser/views/tabs/tab.h"
#include "chrome/browser/views/tabs/tab_strip.h"
#include "chrome/common/notification_service.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "views/event.h"
@@ -85,8 +85,9 @@ class DockView : public views::View {
SkPaint paint;
paint.setColor(SkColorSetRGB(108, 108, 108));
paint.setStyle(SkPaint::kFill_Style);
- canvas->drawRoundRect(outer_rect, SkIntToScalar(kRoundedRectRadius),
- SkIntToScalar(kRoundedRectRadius), paint);
+ canvas->AsCanvasSkia()->drawRoundRect(
+ outer_rect, SkIntToScalar(kRoundedRectRadius),
+ SkIntToScalar(kRoundedRectRadius), paint);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -96,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->save();
+ canvas->AsCanvasSkia()->save();
canvas->TranslateInt(width(), 0);
canvas->ScaleInt(-1, 1);
}
@@ -170,7 +171,7 @@ class DockView : public views::View {
break;
}
if (rtl_ui)
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
private:
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index e5c55a4..e0b13a1 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/views/tabs/dragged_tab_view.h"
#include "chrome/browser/views/tabs/native_view_photobooth.h"
-#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "third_party/skia/include/core/SkShader.h"
#include "views/widget/widget.h"
@@ -186,8 +185,7 @@ void DraggedTabView::PaintAttachedTab(gfx::Canvas* canvas) {
void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) {
gfx::Size ps = GetPreferredSize();
- // TODO(beng): Convert to CanvasSkia
- gfx::Canvas scale_canvas(ps.width(), ps.height(), false);
+ gfx::CanvasSkia scale_canvas(ps.width(), ps.height(), false);
SkBitmap& bitmap_device = const_cast<SkBitmap&>(
scale_canvas.getTopPlatformDevice().accessBitmap(true));
bitmap_device.eraseARGB(0, 0, 0, 0);
@@ -229,7 +227,7 @@ void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) {
rc.fTop = 0;
rc.fRight = SkIntToScalar(ps.width());
rc.fBottom = SkIntToScalar(ps.height());
- canvas->drawRect(rc, paint);
+ canvas->AsCanvasSkia()->drawRect(rc, paint);
}
void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) {
diff --git a/chrome/browser/views/tabs/native_view_photobooth_win.cc b/chrome/browser/views/tabs/native_view_photobooth_win.cc
index 8920a9b..1eb3125 100644
--- a/chrome/browser/views/tabs/native_view_photobooth_win.cc
+++ b/chrome/browser/views/tabs/native_view_photobooth_win.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/views/tabs/native_view_photobooth_win.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/point.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "views/widget/widget_win.h"
@@ -100,7 +100,7 @@ void NativeViewPhotoboothWin::PaintScreenshotIntoCanvas(
// Transfer the contents of the layered capture window to the screen-shot
// canvas' DIB.
- HDC target_dc = canvas->beginPlatformPaint();
+ HDC target_dc = canvas->AsCanvasSkia()->beginPlatformPaint();
HDC source_dc = GetDC(current_hwnd_);
RECT window_rect = {0};
GetWindowRect(current_hwnd_, &window_rect);
@@ -109,12 +109,11 @@ void NativeViewPhotoboothWin::PaintScreenshotIntoCanvas(
SRCCOPY);
// Windows screws up the alpha channel on all text it draws, and so we need
// to call makeOpaque _after_ the blit to correct for this.
- canvas->getTopPlatformDevice().makeOpaque(target_bounds.x(),
- target_bounds.y(),
- target_bounds.width(),
- target_bounds.height());
+ canvas->AsCanvasSkia()->getTopPlatformDevice().makeOpaque(
+ target_bounds.x(), target_bounds.y(), target_bounds.width(),
+ target_bounds.height());
ReleaseDC(current_hwnd_, source_dc);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/tabs/side_tab.cc b/chrome/browser/views/tabs/side_tab.cc
index c2448d2..05036d6 100644
--- a/chrome/browser/views/tabs/side_tab.cc
+++ b/chrome/browser/views/tabs/side_tab.cc
@@ -8,7 +8,7 @@
#include "app/theme_provider.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
#include "gfx/path.h"
#include "gfx/skia_util.h"
@@ -91,18 +91,20 @@ void SideTab::Paint(gfx::Canvas* canvas) {
paint.setAntiAlias(true);
SkRect border_rect = { SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(width()), SkIntToScalar(height()) };
- canvas->drawRoundRect(border_rect, SkIntToScalar(kRoundRectRadius),
- SkIntToScalar(kRoundRectRadius), paint);
+ canvas->AsCanvasSkia()->drawRoundRect(border_rect,
+ SkIntToScalar(kRoundRectRadius),
+ SkIntToScalar(kRoundRectRadius),
+ paint);
}
if (ShouldShowIcon()) {
if (data().phantom) {
SkRect bounds;
bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->saveLayerAlpha(&bounds, kPhantomTabIconAlpha,
- SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
- canvas->restore();
+ canvas->AsCanvasSkia()->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 afb7f6a..82ab751 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -13,7 +13,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/defaults.h"
-#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
#include "gfx/font.h"
@@ -382,18 +381,20 @@ void Tab::PaintTabBackground(gfx::Canvas* canvas) {
if (throb_value > 0) {
SkRect bounds;
bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ &bounds, static_cast<int>(throb_value * 0xff),
+ SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
+ SkXfermode::kClear_Mode);
PaintActiveTabBackground(canvas);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
}
}
void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) {
// Render the inactive tab background. We'll use this for clipping.
- gfx::Canvas background_canvas(width(), height(), false);
+ gfx::CanvasSkia background_canvas(width(), height(), false);
PaintInactiveTabBackground(&background_canvas);
SkBitmap background_image = background_canvas.ExtractBitmap();
@@ -437,10 +438,10 @@ void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) {
// And then the gradient on top of that.
if (mini_title_animation_->current_part_index() == 2) {
- canvas->saveLayerAlpha(NULL,
- mini_title_animation_->CurrentValueBetween(255, 0));
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ NULL, mini_title_animation_->CurrentValueBetween(255, 0));
canvas->DrawBitmapInt(hover_image, 0, 0);
- canvas->restore();
+ canvas->AsCanvasSkia()->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 b8aecf5..2d54f66 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -18,7 +18,7 @@
#include "chrome/browser/views/tabs/tab.h"
#include "chrome/browser/views/tabs/tab_strip_controller.h"
#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/path.h"
#include "gfx/size.h"
#include "grit/generated_resources.h"
@@ -294,31 +294,31 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
if (HasPhantomTabs()) {
SkRect bounds;
bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->saveLayerAlpha(&bounds, kPhantomTabAlpha,
- SkCanvas::kARGB_ClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ &bounds, kPhantomTabAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ 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->restore();
+ canvas->AsCanvasSkia()->restore();
- canvas->saveLayerAlpha(&bounds, kPhantomTabIconAlpha,
- SkCanvas::kARGB_ClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->saveLayerAlpha(
+ &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ 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->save();
+ canvas->AsCanvasSkia()->save();
canvas->ClipRectInt(tab->MirroredX(), tab->y(), tab->width(),
tab->height());
canvas->TranslateInt(tab->MirroredX(), tab->y());
tab->PaintIcon(canvas);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
}
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
Tab* selected_tab = NULL;
diff --git a/chrome/browser/views/theme_install_bubble_view.cc b/chrome/browser/views/theme_install_bubble_view.cc
index 43871b1..4e54812 100644
--- a/chrome/browser/views/theme_install_bubble_view.cc
+++ b/chrome/browser/views/theme_install_bubble_view.cc
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "gfx/canvas_skia.h"
#include "grit/generated_resources.h"
#include "views/widget/widget.h"
@@ -125,7 +126,7 @@ void ThemeInstallBubbleView::Paint(gfx::Canvas* canvas) {
SkIntToScalar(height()));
SkPath path;
path.addRoundRect(rect, rad, SkPath::kCW_Direction);
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
int text_width = views::Label::font().GetStringWidth(text_);
gfx::Rect body_bounds(kTextHorizPadding / 2, 0, text_width, height());
diff --git a/chrome/common/extensions/extension_action.cc b/chrome/common/extensions/extension_action.cc
index d86b1f9..9951ba6 100644
--- a/chrome/common/extensions/extension_action.cc
+++ b/chrome/common/extensions/extension_action.cc
@@ -9,7 +9,7 @@
#include "app/resource_bundle.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/font.h"
#include "gfx/rect.h"
#include "grit/app_resources.h"
@@ -118,7 +118,7 @@ void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
if (SkColorGetA(background_color) == 0x00)
background_color = SkColorSetARGB(255, 218, 0, 24); // Default badge color.
- canvas->save();
+ canvas->AsCanvasSkia()->save();
SkPaint* text_paint = GetTextPaint();
text_paint->setColor(text_color);
@@ -158,7 +158,8 @@ void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
rect_paint.setStyle(SkPaint::kFill_Style);
rect_paint.setAntiAlias(true);
rect_paint.setColor(background_color);
- canvas->drawRoundRect(rect, SkIntToScalar(2), SkIntToScalar(2), rect_paint);
+ canvas->AsCanvasSkia()->drawRoundRect(rect, SkIntToScalar(2), SkIntToScalar(2),
+ rect_paint);
// Overlay the gradient. It is stretchy, so we do this in three parts.
ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance();
@@ -169,24 +170,24 @@ void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
SkBitmap* gradient_center = resource_bundle.GetBitmapNamed(
IDR_BROWSER_ACTION_BADGE_CENTER);
- canvas->drawBitmap(*gradient_left, rect.fLeft, rect.fTop);
+ canvas->AsCanvasSkia()->drawBitmap(*gradient_left, rect.fLeft, rect.fTop);
canvas->TileImageInt(*gradient_center,
SkScalarFloor(rect.fLeft) + gradient_left->width(),
SkScalarFloor(rect.fTop),
SkScalarFloor(rect.width()) - gradient_left->width() -
gradient_right->width(),
SkScalarFloor(rect.height()));
- canvas->drawBitmap(*gradient_right,
+ canvas->AsCanvasSkia()->drawBitmap(*gradient_right,
rect.fRight - SkIntToScalar(gradient_right->width()), rect.fTop);
// Finally, draw the text centered within the badge. We set a clip in case the
// text was too large.
rect.fLeft += kPadding;
rect.fRight -= kPadding;
- canvas->clipRect(rect);
- canvas->drawText(text.c_str(), text.size(),
- rect.fLeft + (rect.width() - text_width) / 2,
- rect.fTop + kTextSize + kTopTextPadding,
- *text_paint);
- canvas->restore();
+ canvas->AsCanvasSkia()->clipRect(rect);
+ canvas->AsCanvasSkia()->drawText(text.c_str(), text.size(),
+ rect.fLeft + (rect.width() - text_width) / 2,
+ rect.fTop + kTextSize + kTopTextPadding,
+ *text_paint);
+ canvas->AsCanvasSkia()->restore();
}
diff --git a/gfx/canvas.h b/gfx/canvas.h
index 589d77d..d66db03 100644
--- a/gfx/canvas.h
+++ b/gfx/canvas.h
@@ -5,27 +5,195 @@
#ifndef GFX_CANVAS_H_
#define GFX_CANVAS_H_
-#include "gfx/canvas_skia.h"
+#include <string>
+
+#include "gfx/native_widget_types.h"
+// TODO(beng): remove this include when we no longer depend on SkTypes.
+#include "skia/ext/platform_canvas.h"
namespace gfx {
-// Temporary compatibility shim, remove once Canvas2->Canvas.
-class Canvas : public CanvasSkia {
+class CanvasSkia;
+class Font;
+class Rect;
+
+// TODO(beng): documentation.
+class Canvas {
public:
- Canvas(int width, int height, bool is_opaque)
- : CanvasSkia(width, height, is_opaque) {
- }
- Canvas() : CanvasSkia() {}
-
- // Overridden from Canvas2:
- Canvas* AsCanvas() {
- return this;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Canvas);
+ // Specifies the alignment for text rendered with the DrawStringInt method.
+ enum {
+ TEXT_ALIGN_LEFT = 1,
+ TEXT_ALIGN_CENTER = 2,
+ TEXT_ALIGN_RIGHT = 4,
+ TEXT_VALIGN_TOP = 8,
+ TEXT_VALIGN_MIDDLE = 16,
+ TEXT_VALIGN_BOTTOM = 32,
+
+ // Specifies the text consists of multiple lines.
+ MULTI_LINE = 64,
+
+ // By default DrawStringInt does not process the prefix ('&') character
+ // specially. That is, the string "&foo" is rendered as "&foo". When
+ // rendering text from a resource that uses the prefix character for
+ // mnemonics, the prefix should be processed and can be rendered as an
+ // underline (SHOW_PREFIX), or not rendered at all (HIDE_PREFIX).
+ SHOW_PREFIX = 128,
+ HIDE_PREFIX = 256,
+
+ // Prevent ellipsizing
+ NO_ELLIPSIS = 512,
+
+ // Specifies if words can be split by new lines.
+ // This only works with MULTI_LINE.
+ CHARACTER_BREAK = 1024,
+
+ // Instructs DrawStringInt() to render the text using RTL directionality.
+ // In most cases, passing this flag is not necessary because information
+ // about the text directionality is going to be embedded within the string
+ // in the form of special Unicode characters. However, we don't insert
+ // directionality characters into strings if the locale is LTR because some
+ // platforms (for example, an English Windows XP with no RTL fonts
+ // installed) don't support these characters. Thus, this flag should be
+ // used to render text using RTL directionality when the locale is LTR.
+ FORCE_RTL_DIRECTIONALITY = 2048,
+ };
+
+ virtual ~Canvas() {}
+
+ // Creates an empty canvas. Must be initialized before it can be used.
+ static Canvas* CreateCanvas();
+
+ // Creates a canvas with the specified size.
+ static Canvas* CreateCanvas(int width, int height, bool is_opaque);
+
+ // 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;
+
+ // Wrapper function that takes integer arguments.
+ // Returns true if the clip is non-empty.
+ // See clipRect for specifics.
+ virtual bool ClipRectInt(int x, int y, int w, int h) = 0;
+
+ // Test whether the provided rectangle intersects the current clip rect.
+ virtual bool IntersectsClipRectInt(int x, int y, int w, int h) = 0;
+
+ // Wrapper function that takes integer arguments.
+ // See translate() for specifics.
+ virtual void TranslateInt(int x, int y) = 0;
+
+ // Wrapper function that takes integer arguments.
+ // See scale() for specifics.
+ virtual void ScaleInt(int x, int y) = 0;
+
+ // Fills the given rectangle with the given paint's parameters.
+ virtual void FillRectInt(int x, int y, int w, int h,
+ const SkPaint& paint) = 0;
+
+ // Fills the specified region with the specified color using a transfer
+ // mode of SkXfermode::kSrcOver_Mode.
+ virtual void FillRectInt(const SkColor& color, int x, int y, int w,
+ int h) = 0;
+
+ // Draws a single pixel rect in the specified region with the specified
+ // color, using a transfer mode of SkXfermode::kSrcOver_Mode.
+ //
+ // NOTE: if you need a single pixel line, use DraLineInt.
+ virtual void DrawRectInt(const SkColor& color, int x, int y, int w,
+ int h) = 0;
+
+ // Draws a single pixel rect in the specified region with the specified
+ // color and transfer mode.
+ //
+ // NOTE: if you need a single pixel line, use DraLineInt.
+ virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h,
+ SkXfermode::Mode mode) = 0;
+
+ // Draws a single pixel line with the specified color.
+ virtual void DrawLineInt(const SkColor& color, int x1, int y1, int x2,
+ int y2) = 0;
+
+ // Draws a bitmap with the origin at the specified location. The upper left
+ // corner of the bitmap is rendered at the specified location.
+ virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y) = 0;
+
+ // Draws a bitmap with the origin at the specified location, using the
+ // specified paint. The upper left corner of the bitmap is rendered at the
+ // specified location.
+ virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y,
+ const SkPaint& paint) = 0;
+
+ // Draws a portion of a bitmap in the specified location. The src parameters
+ // correspond to the region of the bitmap to draw in the region defined
+ // by the dest coordinates.
+ //
+ // If the width or height of the source differs from that of the destination,
+ // the bitmap will be scaled. When scaling down, it is highly recommended
+ // that you call buildMipMap(false) on your bitmap to ensure that it has
+ // a mipmap, which will result in much higher-quality output. Set |filter|
+ // to use filtering for bitmaps, otherwise the nearest-neighbor algorithm
+ // is used for resampling.
+ //
+ // An optional custom SkPaint can be provided.
+ virtual void DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y,
+ int src_w, int src_h, int dest_x, int dest_y,
+ int dest_w, int dest_h, bool filter) = 0;
+ virtual void DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y,
+ int src_w, int src_h, int dest_x, int dest_y,
+ int dest_w, int dest_h, bool filter,
+ const SkPaint& paint) = 0;
+
+ // Draws text with the specified color, font and location. The text is
+ // aligned to the left, vertically centered, clipped to the region. If the
+ // text is too big, it is truncated and '...' is added to the end.
+ virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
+ const SkColor& color, int x, int y, int w,
+ int h) = 0;
+ virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
+ const SkColor& color,
+ const gfx::Rect& display_rect) = 0;
+
+ // Draws text with the specified color, font and location. The last argument
+ // specifies flags for how the text should be rendered. It can be one of
+ // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
+ virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
+ const SkColor& color, int x, int y, int w, int h,
+ int flags) = 0;
+
+ // Draws a dotted gray rectangle used for focus purposes.
+ virtual void DrawFocusRect(int x, int y, int width, int height) = 0;
+
+ // Tiles the image in the specified region.
+ virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w,
+ int h) = 0;
+ virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
+ int dest_x, int dest_y, int w, int h) = 0;
+
+ // TODO(beng): remove this once we don't need to use any skia-specific methods
+ // through this interface.
+ // A quick and dirty way to obtain the underlying SkCanvas.
+ virtual CanvasSkia* AsCanvasSkia() { return NULL; }
+ virtual const CanvasSkia* AsCanvasSkia() const { return NULL; }
+};
+
+class CanvasPaint {
+ public:
+ virtual ~CanvasPaint() {}
+
+ // Creates a canvas that paints to |view| when it is destroyed. The canvas is
+ // sized to the client area of |view|.
+ static CanvasPaint* CreateCanvasPaint(gfx::NativeView view);
+
+ // Returns true if the canvas has an invalid rect that needs to be repainted.
+ virtual bool IsValid() const = 0;
+
+ // Returns the rectangle that is invalid.
+ virtual gfx::Rect GetInvalidRect() const = 0;
+
+ // Returns the underlying Canvas.
+ virtual Canvas* AsCanvas() = 0;
};
-}
+} // namespace gfx;
#endif // GFX_CANVAS_H_
diff --git a/gfx/canvas_2.h b/gfx/canvas_2.h
deleted file mode 100644
index bf7e244..0000000
--- a/gfx/canvas_2.h
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GFX_CANVAS_2_H_
-#define GFX_CANVAS_2_H_
-
-#include <string>
-
-#include "gfx/native_widget_types.h"
-// TODO(beng): remove this include when we no longer depend on SkTypes.
-#include "skia/ext/platform_canvas.h"
-
-namespace gfx {
-
-class Canvas;
-class Font;
-class Rect;
-
-// TODO(beng): documentation.
-class Canvas2 {
- public:
- // Specifies the alignment for text rendered with the DrawStringInt method.
- enum {
- TEXT_ALIGN_LEFT = 1,
- TEXT_ALIGN_CENTER = 2,
- TEXT_ALIGN_RIGHT = 4,
- TEXT_VALIGN_TOP = 8,
- TEXT_VALIGN_MIDDLE = 16,
- TEXT_VALIGN_BOTTOM = 32,
-
- // Specifies the text consists of multiple lines.
- MULTI_LINE = 64,
-
- // By default DrawStringInt does not process the prefix ('&') character
- // specially. That is, the string "&foo" is rendered as "&foo". When
- // rendering text from a resource that uses the prefix character for
- // mnemonics, the prefix should be processed and can be rendered as an
- // underline (SHOW_PREFIX), or not rendered at all (HIDE_PREFIX).
- SHOW_PREFIX = 128,
- HIDE_PREFIX = 256,
-
- // Prevent ellipsizing
- NO_ELLIPSIS = 512,
-
- // Specifies if words can be split by new lines.
- // This only works with MULTI_LINE.
- CHARACTER_BREAK = 1024,
-
- // Instructs DrawStringInt() to render the text using RTL directionality.
- // In most cases, passing this flag is not necessary because information
- // about the text directionality is going to be embedded within the string
- // in the form of special Unicode characters. However, we don't insert
- // directionality characters into strings if the locale is LTR because some
- // platforms (for example, an English Windows XP with no RTL fonts
- // installed) don't support these characters. Thus, this flag should be
- // used to render text using RTL directionality when the locale is LTR.
- FORCE_RTL_DIRECTIONALITY = 2048,
- };
-
- virtual ~Canvas2() {}
-
- // Creates an empty canvas. Must be initialized before it can be used.
- static Canvas2* CreateCanvas();
-
- // Creates a canvas with the specified size.
- static Canvas2* CreateCanvas(int width, int height, bool is_opaque);
-
- // 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;
-
- // Wrapper function that takes integer arguments.
- // Returns true if the clip is non-empty.
- // See clipRect for specifics.
- virtual bool ClipRectInt(int x, int y, int w, int h) = 0;
-
- // Test whether the provided rectangle intersects the current clip rect.
- virtual bool IntersectsClipRectInt(int x, int y, int w, int h) = 0;
-
- // Wrapper function that takes integer arguments.
- // See translate() for specifics.
- virtual void TranslateInt(int x, int y) = 0;
-
- // Wrapper function that takes integer arguments.
- // See scale() for specifics.
- virtual void ScaleInt(int x, int y) = 0;
-
- // Fills the given rectangle with the given paint's parameters.
- virtual void FillRectInt(int x, int y, int w, int h,
- const SkPaint& paint) = 0;
-
- // Fills the specified region with the specified color using a transfer
- // mode of SkXfermode::kSrcOver_Mode.
- virtual void FillRectInt(const SkColor& color, int x, int y, int w,
- int h) = 0;
-
- // Draws a single pixel rect in the specified region with the specified
- // color, using a transfer mode of SkXfermode::kSrcOver_Mode.
- //
- // NOTE: if you need a single pixel line, use DraLineInt.
- virtual void DrawRectInt(const SkColor& color, int x, int y, int w,
- int h) = 0;
-
- // Draws a single pixel rect in the specified region with the specified
- // color and transfer mode.
- //
- // NOTE: if you need a single pixel line, use DraLineInt.
- virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h,
- SkXfermode::Mode mode) = 0;
-
- // Draws a single pixel line with the specified color.
- virtual void DrawLineInt(const SkColor& color, int x1, int y1, int x2,
- int y2) = 0;
-
- // Draws a bitmap with the origin at the specified location. The upper left
- // corner of the bitmap is rendered at the specified location.
- virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y) = 0;
-
- // Draws a bitmap with the origin at the specified location, using the
- // specified paint. The upper left corner of the bitmap is rendered at the
- // specified location.
- virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y,
- const SkPaint& paint) = 0;
-
- // Draws a portion of a bitmap in the specified location. The src parameters
- // correspond to the region of the bitmap to draw in the region defined
- // by the dest coordinates.
- //
- // If the width or height of the source differs from that of the destination,
- // the bitmap will be scaled. When scaling down, it is highly recommended
- // that you call buildMipMap(false) on your bitmap to ensure that it has
- // a mipmap, which will result in much higher-quality output. Set |filter|
- // to use filtering for bitmaps, otherwise the nearest-neighbor algorithm
- // is used for resampling.
- //
- // An optional custom SkPaint can be provided.
- virtual void DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y,
- int src_w, int src_h, int dest_x, int dest_y,
- int dest_w, int dest_h, bool filter) = 0;
- virtual void DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y,
- int src_w, int src_h, int dest_x, int dest_y,
- int dest_w, int dest_h, bool filter,
- const SkPaint& paint) = 0;
-
- // Draws text with the specified color, font and location. The text is
- // aligned to the left, vertically centered, clipped to the region. If the
- // text is too big, it is truncated and '...' is added to the end.
- virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
- const SkColor& color, int x, int y, int w,
- int h) = 0;
- virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
- const SkColor& color,
- const gfx::Rect& display_rect) = 0;
-
- // Draws text with the specified color, font and location. The last argument
- // specifies flags for how the text should be rendered. It can be one of
- // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
- virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
- const SkColor& color, int x, int y, int w, int h,
- int flags) = 0;
-
- // Draws a dotted gray rectangle used for focus purposes.
- virtual void DrawFocusRect(int x, int y, int width, int height) = 0;
-
- // Tiles the image in the specified region.
- virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w,
- int h) = 0;
- virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
- int dest_x, int dest_y, int w, int h) = 0;
-
- // Extracts a bitmap from the contents of this canvas.
- virtual SkBitmap ExtractBitmap() const = 0;
-
- // TODO(beng): remove this once we don't need to use any skia-specific methods
- // through this interface.
- // A quick and dirty way to obtain the underlying SkCanvas.
- virtual Canvas* AsCanvas() { return NULL; }
-};
-
-class CanvasPaint2 {
- public:
- virtual ~CanvasPaint2() {}
-
- // Creates a canvas that paints to |view| when it is destroyed. The canvas is
- // sized to the client area of |view|.
- static CanvasPaint2* CreateCanvasPaint(gfx::NativeView view);
-
- // Returns true if the canvas has an invalid rect that needs to be repainted.
- virtual bool IsValid() const = 0;
-
- // Returns the rectangle that is invalid.
- virtual gfx::Rect GetInvalidRect() const = 0;
-
- // Returns the underlying Canvas2.
- virtual Canvas2* AsCanvas2() = 0;
-};
-
-} // namespace gfx;
-
-#endif // GFX_CANVAS_2_H_
diff --git a/gfx/canvas_skia.cc b/gfx/canvas_skia.cc
index 8fa763a..8fb752de 100644
--- a/gfx/canvas_skia.cc
+++ b/gfx/canvas_skia.cc
@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include <limits>
#include "base/i18n/rtl.h"
#include "base/logging.h"
-#include "gfx/canvas.h"
#include "gfx/font.h"
#include "gfx/rect.h"
#include "third_party/skia/include/core/SkShader.h"
@@ -19,6 +18,17 @@
namespace gfx {
+SkBitmap CanvasSkia::ExtractBitmap() const {
+ const SkBitmap& device_bitmap = getDevice()->accessBitmap(false);
+
+ // Make a bitmap to return, and a canvas to draw into it. We don't just want
+ // to call extractSubset or the copy constructor, since we want an actual copy
+ // of the bitmap.
+ SkBitmap result;
+ device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
+ return result;
+}
+
bool CanvasSkia::GetClipRect(gfx::Rect* r) {
SkRect clip;
if (!getClipBounds(&clip)) {
@@ -263,15 +273,12 @@ void CanvasSkia::TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
restore();
}
-SkBitmap CanvasSkia::ExtractBitmap() const {
- const SkBitmap& device_bitmap = getDevice()->accessBitmap(false);
+CanvasSkia* CanvasSkia::AsCanvasSkia() {
+ return this;
+}
- // Make a bitmap to return, and a canvas to draw into it. We don't just want
- // to call extractSubset or the copy constuctor, since we want an actual copy
- // of the bitmap.
- SkBitmap result;
- device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
- return result;
+const CanvasSkia* CanvasSkia::AsCanvasSkia() const {
+ return this;
}
// static
@@ -282,19 +289,19 @@ int CanvasSkia::DefaultCanvasTextAlignment() {
}
////////////////////////////////////////////////////////////////////////////////
-// Canvas2, public:
+// Canvas, public:
-Canvas2* Canvas2::CreateCanvas() {
- return new Canvas;
+Canvas* Canvas::CreateCanvas() {
+ return new CanvasSkia;
}
-Canvas2* Canvas2::CreateCanvas(int width, int height, bool is_opaque) {
- return new Canvas(width, height, is_opaque);
+Canvas* Canvas::CreateCanvas(int width, int height, bool is_opaque) {
+ return new CanvasSkia(width, height, is_opaque);
}
#if defined(OS_WIN)
// TODO(beng): move to canvas_win.cc, etc.
-class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint2 {
+class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint {
public:
CanvasPaintWin(gfx::NativeView view) : CanvasSkiaPaint(view) {}
@@ -307,13 +314,13 @@ class CanvasPaintWin : public CanvasSkiaPaint, public CanvasPaint2 {
return gfx::Rect(paintStruct().rcPaint);
}
- virtual Canvas2* AsCanvas2() {
+ virtual Canvas* AsCanvas() {
return this;
}
};
#endif
-CanvasPaint2* CanvasPaint2::CreateCanvasPaint(gfx::NativeView view) {
+CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) {
#if defined(OS_WIN)
return new CanvasPaintWin(view);
#else
diff --git a/gfx/canvas_skia.h b/gfx/canvas_skia.h
index 9a976fd..cae4ac1 100644
--- a/gfx/canvas_skia.h
+++ b/gfx/canvas_skia.h
@@ -6,7 +6,7 @@
#define GFX_CANVAS_SKIA_H_
#include "base/basictypes.h"
-#include "gfx/canvas_2.h"
+#include "gfx/canvas.h"
#include "skia/ext/platform_canvas.h"
#if defined(OS_POSIX) && !defined(OS_MACOSX)
@@ -33,7 +33,7 @@ class Canvas;
// the variant that does not take a SkXfermode::Mode uses a transfer mode
// of kSrcOver_Mode.
class CanvasSkia : public skia::PlatformCanvas,
- public Canvas2 {
+ public Canvas {
public:
// Creates an empty Canvas. Callers must use initialize before using the
// canvas.
@@ -76,6 +76,9 @@ class CanvasSkia : public skia::PlatformCanvas,
int x, int y, int w, int h, int flags);
#endif
+ // Extracts a bitmap from the contents of this canvas.
+ SkBitmap ExtractBitmap() const;
+
// Overridden from Canvas2:
virtual bool GetClipRect(gfx::Rect* clip_rect);
virtual bool ClipRectInt(int x, int y, int w, int h);
@@ -115,7 +118,8 @@ class CanvasSkia : public skia::PlatformCanvas,
virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h);
virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
int dest_x, int dest_y, int w, int h);
- virtual SkBitmap ExtractBitmap() const;
+ virtual CanvasSkia* AsCanvasSkia();
+ virtual const CanvasSkia* AsCanvasSkia() const;
private:
#if defined(OS_WIN)
diff --git a/gfx/canvas_skia_linux.cc b/gfx/canvas_skia_linux.cc
index 59e0e29..680476f 100644
--- a/gfx/canvas_skia_linux.cc
+++ b/gfx/canvas_skia_linux.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include <cairo/cairo.h>
#include <gtk/gtk.h>
diff --git a/gfx/canvas_skia_mac.mm b/gfx/canvas_skia_mac.mm
index 29102fd..7836869 100644
--- a/gfx/canvas_skia_mac.mm
+++ b/gfx/canvas_skia_mac.mm
@@ -4,7 +4,7 @@
#import <Cocoa/Cocoa.h>
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "base/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
diff --git a/gfx/canvas_skia_paint.h b/gfx/canvas_skia_paint.h
index 4e6f768..ac11ff0 100644
--- a/gfx/canvas_skia_paint.h
+++ b/gfx/canvas_skia_paint.h
@@ -5,7 +5,7 @@
#ifndef GFX_CANVAS_SKIA_PAINT_H_
#define GFX_CANVAS_SKIA_PAINT_H_
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "skia/ext/canvas_paint.h"
// Define a gfx::CanvasSkiaPaint type that wraps our gfx::Canvas like the
@@ -13,7 +13,7 @@
namespace gfx {
-typedef skia::CanvasPaintT<Canvas> CanvasSkiaPaint;
+typedef skia::CanvasPaintT<CanvasSkia> CanvasSkiaPaint;
} // namespace gfx
diff --git a/gfx/canvas_skia_win.cc b/gfx/canvas_skia_win.cc
index 4177ef5..f3c5f8f 100644
--- a/gfx/canvas_skia_win.cc
+++ b/gfx/canvas_skia_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include <limits>
diff --git a/gfx/font_mac.mm b/gfx/font_mac.mm
index f964d94..e569a35 100644
--- a/gfx/font_mac.mm
+++ b/gfx/font_mac.mm
@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/scoped_nsobject.h"
#include "base/sys_string_conversions.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
namespace gfx {
@@ -60,7 +60,8 @@ int Font::ave_char_width() const {
int Font::GetStringWidth(const std::wstring& text) const {
int width = 0, height = 0;
- Canvas::SizeStringInt(text, *this, &width, &height, gfx::Canvas::NO_ELLIPSIS);
+ CanvasSkia::SizeStringInt(text, *this, &width, &height,
+ gfx::Canvas::NO_ELLIPSIS);
return width;
}
diff --git a/gfx/font_skia.cc b/gfx/font_skia.cc
index 97a3c85..0289cdb 100644
--- a/gfx/font_skia.cc
+++ b/gfx/font_skia.cc
@@ -11,7 +11,7 @@
#include "base/logging.h"
#include "base/string_piece.h"
#include "base/sys_string_conversions.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -177,7 +177,8 @@ void Font::PaintSetup(SkPaint* paint) const {
int Font::GetStringWidth(const std::wstring& text) const {
int width = 0, height = 0;
- Canvas::SizeStringInt(text, *this, &width, &height, gfx::Canvas::NO_ELLIPSIS);
+ CanvasSkia::SizeStringInt(text, *this, &width, &height,
+ gfx::Canvas::NO_ELLIPSIS);
return width;
}
diff --git a/gfx/font_win.cc b/gfx/font_win.cc
index 4d4d28e..f9b7243 100644
--- a/gfx/font_win.cc
+++ b/gfx/font_win.cc
@@ -12,7 +12,7 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "base/win_util.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
namespace gfx {
@@ -171,7 +171,8 @@ Font Font::DeriveFont(int size_delta, int style) const {
int Font::GetStringWidth(const std::wstring& text) const {
int width = 0, height = 0;
- Canvas::SizeStringInt(text, *this, &width, &height, gfx::Canvas::NO_ELLIPSIS);
+ CanvasSkia::SizeStringInt(text, *this, &width, &height,
+ gfx::Canvas::NO_ELLIPSIS);
return width;
}
diff --git a/gfx/gfx.gyp b/gfx/gfx.gyp
index c0d4000..592901c 100644
--- a/gfx/gfx.gyp
+++ b/gfx/gfx.gyp
@@ -63,7 +63,6 @@
'blit.cc',
'blit.h',
'canvas.h',
- 'canvas_2.h',
'canvas_skia.h',
'canvas_skia.cc',
'canvas_skia_linux.cc',
diff --git a/views/background.cc b/views/background.cc
index a791f7f..f135138 100644
--- a/views/background.cc
+++ b/views/background.cc
@@ -5,7 +5,7 @@
#include "views/background.h"
#include "base/logging.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "skia/ext/skia_utils_win.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -25,7 +25,7 @@ class SolidBackground : public Background {
void Paint(gfx::Canvas* canvas, View* view) const {
// Fill the background. Note that we don't constrain to the bounds as
// canvas is already clipped for us.
- canvas->drawColor(get_color());
+ canvas->AsCanvasSkia()->drawColor(get_color());
}
private:
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index 98c69fe..f2b7613 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -8,7 +8,7 @@
#include "app/throb_animation.h"
#include "app/resource_bundle.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "views/controls/button/button.h"
#include "views/event.h"
#include "grit/app_resources.h"
@@ -256,12 +256,13 @@ 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->saveLayerAlpha(NULL,
+ canvas->AsCanvasSkia()->saveLayerAlpha(NULL,
static_cast<int>(hover_animation_->GetCurrentValue() * 255),
SkCanvas::kARGB_NoClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
+ SkXfermode::kClear_Mode);
PaintBorder(canvas);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
} else if ((show_highlighted_ &&
(state_ == BS_HOT || state_ == BS_PUSHED)) ||
(state_ == BS_NORMAL && normal_has_border_)) {
@@ -330,19 +331,17 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
else
text_color = color_;
- int draw_string_flags = gfx::Canvas::DefaultCanvasTextAlignment() |
+ int draw_string_flags = gfx::CanvasSkia::DefaultCanvasTextAlignment() |
PrefixTypeToCanvasType(prefix_type_);
if (for_drag) {
#if defined(OS_WIN)
// TODO(erg): Either port DrawStringWithHalo to linux or find an
// alternative here.
- canvas->DrawStringWithHalo(text_, font_, text_color, color_highlight_,
- text_bounds.x(),
- text_bounds.y(),
- text_bounds.width(),
- text_bounds.height(),
- draw_string_flags);
+ canvas->AsCanvasSkia()->DrawStringWithHalo(
+ text_, font_, text_color, color_highlight_, text_bounds.x(),
+ text_bounds.y(), text_bounds.width(), text_bounds.height(),
+ draw_string_flags);
#else
canvas->DrawStringInt(text_,
font_,
@@ -381,7 +380,7 @@ void TextButton::UpdateColor() {
void TextButton::UpdateTextSize() {
int width = 0, height = 0;
- gfx::Canvas::SizeStringInt(
+ gfx::CanvasSkia::SizeStringInt(
text_, font_, &width, &height,
gfx::Canvas::NO_ELLIPSIS | PrefixTypeToCanvasType(prefix_type_));
text_size_.SetSize(width, font_.height());
diff --git a/views/controls/label.cc b/views/controls/label.cc
index 88a755d..d30a62b 100644
--- a/views/controls/label.cc
+++ b/views/controls/label.cc
@@ -13,7 +13,7 @@
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/font.h"
#include "gfx/insets.h"
@@ -67,7 +67,7 @@ int Label::GetHeightForWidth(int w) {
w = std::max(0, w - GetInsets().width());
int h = font_.height();
- gfx::Canvas::SizeStringInt(text_, font_, &w, &h, ComputeMultiLineFlags());
+ gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h, ComputeMultiLineFlags());
return h + GetInsets().height();
}
@@ -388,7 +388,7 @@ gfx::Size Label::GetTextSize() const {
int flags = ComputeMultiLineFlags();
if (!is_multi_line_)
flags |= gfx::Canvas::NO_ELLIPSIS;
- gfx::Canvas::SizeStringInt(text_, font_, &w, &h, flags);
+ gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h, flags);
text_size_.SetSize(w, h);
text_size_valid_ = true;
}
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index de31f02..955451a 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -9,7 +9,7 @@
#include "base/i18n/rtl.h"
#include "base/keyboard_codes.h"
#include "base/time.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/menu/menu_scroll_view_container.h"
#include "views/controls/menu/submenu_view.h"
@@ -470,7 +470,7 @@ void MenuController::OnMouseDragged(SubmenuView* source,
View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc);
View::ConvertPointToView(NULL, item, &press_loc);
// TODO(beng): Convert to CanvasSkia
- gfx::Canvas canvas(item->width(), item->height(), false);
+ gfx::CanvasSkia canvas(item->width(), item->height(), false);
item->Paint(&canvas, true);
OSExchangeData data;
diff --git a/views/controls/menu/menu_item_view_gtk.cc b/views/controls/menu/menu_item_view_gtk.cc
index f3e7556..db21e01 100644
--- a/views/controls/menu/menu_item_view_gtk.cc
+++ b/views/controls/menu/menu_item_view_gtk.cc
@@ -5,7 +5,7 @@
#include "views/controls/menu/menu_item_view.h"
#include "app/resource_bundle.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
#include "grit/app_resources.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -70,7 +70,8 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) {
// only need the background when we want it to look different, as when we're
// selected.
if (render_selection)
- canvas->drawColor(kSelectedBackgroundColor, SkXfermode::kSrc_Mode);
+ canvas->AsCanvasSkia()->drawColor(kSelectedBackgroundColor,
+ SkXfermode::kSrc_Mode);
// Render the check.
if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) {
@@ -103,13 +104,13 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) {
paint.setShader(shader);
shader->unref();
int radius = kIndicatorSize / 2;
- canvas->drawCircle(radius, radius, radius, paint);
+ canvas->AsCanvasSkia()->drawCircle(radius, radius, radius, paint);
paint.setStrokeWidth(SkIntToScalar(0));
paint.setShader(NULL);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(kBaseStroke);
- canvas->drawCircle(radius, radius, radius, paint);
+ canvas->AsCanvasSkia()->drawCircle(radius, radius, radius, paint);
if (GetDelegate()->IsItemChecked(GetCommand())) {
SkPoint selected_gradient_points[2];
@@ -125,13 +126,15 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) {
paint.setShader(shader);
shader->unref();
paint.setStyle(SkPaint::kFill_Style);
- canvas->drawCircle(radius, radius, kSelectedIndicatorSize / 2, paint);
+ canvas->AsCanvasSkia()->drawCircle(radius, radius,
+ kSelectedIndicatorSize / 2, paint);
paint.setStrokeWidth(SkIntToScalar(0));
paint.setShader(NULL);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(kIndicatorStroke);
- canvas->drawCircle(radius, radius, kSelectedIndicatorSize / 2, paint);
+ canvas->AsCanvasSkia()->drawCircle(radius, radius,
+ kSelectedIndicatorSize / 2, paint);
}
canvas->TranslateInt(
diff --git a/views/controls/menu/menu_item_view_win.cc b/views/controls/menu/menu_item_view_win.cc
index 2ac0921..b491092 100644
--- a/views/controls/menu/menu_item_view_win.cc
+++ b/views/controls/menu/menu_item_view_win.cc
@@ -8,7 +8,7 @@
#include <Vssym32.h>
#include "app/l10n_util.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/native_theme_win.h"
#include "grit/app_strings.h"
#include "views/controls/menu/menu_config.h"
@@ -34,7 +34,7 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) {
GetChildViewCount() == 0);
int state = render_selection ? MPI_HOT :
(IsEnabled() ? MPI_NORMAL : MPI_DISABLED);
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
// The gutter is rendered before the background.
if (config.render_gutter && !for_drag) {
@@ -87,10 +87,10 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) {
// foreground and background colors are for the text to draw the correct
// halo. Instead, just draw black on white, which will look good in most
// cases.
- canvas->DrawStringWithHalo(GetTitle(), font, 0x00000000, 0xFFFFFFFF,
- text_bounds.x(), text_bounds.y(),
- text_bounds.width(), text_bounds.height(),
- GetRootMenuItem()->GetDrawStringFlags());
+ canvas->AsCanvasSkia()->DrawStringWithHalo(
+ GetTitle(), font, 0x00000000, 0xFFFFFFFF, text_bounds.x(),
+ text_bounds.y(), text_bounds.width(), text_bounds.height(),
+ GetRootMenuItem()->GetDrawStringFlags());
} else {
canvas->DrawStringInt(GetTitle(), font, fg_color,
text_bounds.x(), text_bounds.y(), text_bounds.width(),
@@ -131,7 +131,7 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) {
NativeTheme::MENU, dc, MENU_POPUPSUBMENU, state_id, &arrow_rect,
arrow_direction, render_selection);
}
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
}
void MenuItemView::PaintCheck(HDC dc,
int state_id,
diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc
index b538f5b..d3a7ae8 100644
--- a/views/controls/menu/menu_scroll_view_container.cc
+++ b/views/controls/menu/menu_scroll_view_container.cc
@@ -10,7 +10,7 @@
#include <Vssym32.h>
#endif
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "views/border.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -83,14 +83,14 @@ class MenuScrollButton : public View {
const MenuConfig& config = MenuConfig::instance();
#if defined(OS_WIN)
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
// The background.
RECT item_bounds = { 0, 0, width(), height() };
NativeTheme::instance()->PaintMenuItemBackground(
NativeTheme::MENU, dc, MENU_POPUPITEM, MPI_NORMAL, false,
&item_bounds);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT);
#else
@@ -185,11 +185,11 @@ void MenuScrollViewContainer::PaintBackground(gfx::Canvas* canvas) {
}
#if defined(OS_WIN)
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
RECT bounds = {0, 0, width(), height()};
NativeTheme::instance()->PaintMenuBackground(
NativeTheme::MENU, dc, MENU_POPUPBACKGROUND, 0, &bounds);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
#elif defined(OS_CHROMEOS)
static const SkColor kGradientColors[2] = {
SK_ColorWHITE,
@@ -220,7 +220,8 @@ void MenuScrollViewContainer::PaintBackground(gfx::Canvas* canvas) {
canvas->FillRectInt(0, 0, width(), height(), paint);
#else
// This is the same as COLOR_TOOLBAR.
- canvas->drawColor(SkColorSetRGB(210, 225, 246), SkXfermode::kSrc_Mode);
+ canvas->AsCanvasSkia()->drawColor(SkColorSetRGB(210, 225, 246),
+ SkXfermode::kSrc_Mode);
#endif
}
diff --git a/views/controls/menu/menu_separator_win.cc b/views/controls/menu/menu_separator_win.cc
index 58e2bb4..ed3f34f 100644
--- a/views/controls/menu/menu_separator_win.cc
+++ b/views/controls/menu/menu_separator_win.cc
@@ -8,7 +8,7 @@
#include <uxtheme.h>
#include <Vssym32.h>
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/native_theme_win.h"
#include "views/controls/menu/menu_config.h"
#include "views/controls/menu/menu_item_view.h"
@@ -20,7 +20,7 @@ void MenuSeparator::Paint(gfx::Canvas* canvas) {
// The gutter is rendered before the background.
int start_x = 0;
int start_y = height() / 3;
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
if (config.render_gutter) {
// If render_gutter is true, we're on Vista and need to render the
// gutter, then indent the separator from the gutter.
@@ -36,7 +36,7 @@ void MenuSeparator::Paint(gfx::Canvas* canvas) {
RECT separator_bounds = { start_x, start_y, width(), height() };
gfx::NativeTheme::instance()->PaintMenuSeparator(
dc, MENU_POPUPSEPARATOR, MPI_NORMAL, &separator_bounds);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
}
gfx::Size MenuSeparator::GetPreferredSize() {
diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc
index 19f10c5..1006acd 100644
--- a/views/controls/progress_bar.cc
+++ b/views/controls/progress_bar.cc
@@ -10,7 +10,7 @@
#include "app/resource_bundle.h"
#include "base/logging.h"
#include "base/string_util.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/font.h"
#include "gfx/insets.h"
@@ -75,7 +75,7 @@ static void FillRoundRect(gfx::Canvas* canvas,
} else {
paint.setColor(gradient_start_color);
}
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
}
static void StrokeRoundRect(gfx::Canvas* canvas,
@@ -92,7 +92,7 @@ static void StrokeRoundRect(gfx::Canvas* canvas,
paint.setStyle(SkPaint::kStroke_Style);
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setStrokeWidth(SkIntToScalar(stroke_width));
- canvas->drawPath(path, paint);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
}
} // anonymous namespace
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
index 87f2ebb..832d4a2 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
@@ -10,7 +10,7 @@
#include "app/resource_bundle.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/font.h"
#include "gfx/native_theme_win.h"
#include "views/controls/tabbed_pane/tabbed_pane.h"
@@ -36,10 +36,10 @@ class TabBackground : public Background {
virtual ~TabBackground() {}
virtual void Paint(gfx::Canvas* canvas, View* view) const {
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
RECT r = {0, 0, view->width(), view->height()};
gfx::NativeTheme::instance()->PaintTabPanelBackground(dc, &r);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
}
private:
diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc
index 75425c2..8b86a6e 100644
--- a/views/controls/table/table_view.cc
+++ b/views/controls/table/table_view.cc
@@ -16,7 +16,7 @@
#include "base/i18n/rtl.h"
#include "base/string_util.h"
#include "base/win_util.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
#include "gfx/font.h"
#include "gfx/icon_util.h"
@@ -1157,7 +1157,7 @@ void TableView::PaintAltText() {
// Pad by 1 for halo.
canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1,
1, bounds.width() - 2, bounds.height() - 2,
- gfx::Canvas::DefaultCanvasTextAlignment());
+ gfx::CanvasSkia::DefaultCanvasTextAlignment());
canvas.getTopPlatformDevice().drawToHDC(dc, bounds.x(), bounds.y(), NULL);
ReleaseDC(GetNativeControlHWND(), dc);
}
diff --git a/views/drag_utils.cc b/views/drag_utils.cc
index 8fbd79a..0b5ffa0 100644
--- a/views/drag_utils.cc
+++ b/views/drag_utils.cc
@@ -10,7 +10,6 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
-#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "gfx/font.h"
#include "googleurl/src/gurl.h"
@@ -49,8 +48,7 @@ void SetURLAndDragImage(const GURL& url,
button.SetBounds(0, 0, prefsize.width(), prefsize.height());
// Render the image.
- // TODO(beng): Convert to CanvasSkia
- gfx::Canvas canvas(prefsize.width(), prefsize.height(), false);
+ gfx::CanvasSkia canvas(prefsize.width(), prefsize.height(), false);
button.Paint(&canvas, true);
SetDragImageOnDataObject(canvas, prefsize,
gfx::Point(prefsize.width() / 2, prefsize.height() / 2), data);
@@ -70,8 +68,7 @@ void CreateDragImageForFile(const FilePath::StringType& file_name,
// Add +2 here to allow room for the halo.
const int height = font.height() + icon->height() +
kLinkDragImageVPadding + 2;
- // TODO(beng): Convert to CanvasSkia
- gfx::Canvas canvas(width, height, false /* translucent */);
+ gfx::CanvasSkia canvas(width, height, false /* translucent */);
// Paint the icon.
canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0);
diff --git a/views/drag_utils_win.cc b/views/drag_utils_win.cc
index 74663a6..3c951ed 100644
--- a/views/drag_utils_win.cc
+++ b/views/drag_utils_win.cc
@@ -10,7 +10,7 @@
#include "app/os_exchange_data.h"
#include "app/os_exchange_data_provider_win.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/gdi_util.h"
namespace drag_utils {
@@ -47,7 +47,7 @@ static HBITMAP CreateBitmapFromCanvas(const gfx::Canvas& canvas,
HDC compatible_dc = CreateCompatibleDC(screen_dc);
HGDIOBJ old_object = SelectObject(compatible_dc, bitmap);
BitBlt(compatible_dc, 0, 0, width, height,
- canvas.getTopPlatformDevice().getBitmapDC(),
+ canvas.AsCanvasSkia()->getTopPlatformDevice().getBitmapDC(),
0, 0, SRCCOPY);
SelectObject(compatible_dc, old_object);
ReleaseDC(NULL, compatible_dc);
diff --git a/views/painter.cc b/views/painter.cc
index 1c354da..c368a0a 100644
--- a/views/painter.cc
+++ b/views/painter.cc
@@ -7,6 +7,7 @@
#include "app/resource_bundle.h"
#include "base/logging.h"
#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/insets.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -43,8 +44,9 @@ class GradientPainter : public Painter {
// Need to unref shader, otherwise never deleted.
s->unref();
- canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0),
- SkIntToScalar(w), SkIntToScalar(h), paint);
+ canvas->AsCanvasSkia()->drawRectCoords(
+ SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(w), SkIntToScalar(h),
+ paint);
}
private:
@@ -146,10 +148,10 @@ void Painter::PaintPainterAt(int x, int y, int w, int h,
DCHECK(canvas && painter);
if (w < 0 || h < 0)
return;
- canvas->save();
+ canvas->AsCanvasSkia()->save();
canvas->TranslateInt(x, y);
painter->Paint(w, h, canvas);
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
// static
diff --git a/views/view.cc b/views/view.cc
index d8ba4c3..e2d4e43 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -14,7 +14,7 @@
#include "base/message_loop.h"
#include "base/scoped_handle.h"
#include "base/utf_string_conversions.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/path.h"
#include "third_party/skia/include/core/SkShader.h"
#include "views/background.h"
@@ -378,7 +378,7 @@ void View::ProcessPaint(gfx::Canvas* canvas) {
return;
// We're going to modify the canvas, save it's state first.
- canvas->save();
+ canvas->AsCanvasSkia()->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->save();
+ canvas->AsCanvasSkia()->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->save();
+ canvas->AsCanvasSkia()->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->restore();
+ canvas->AsCanvasSkia()->restore();
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
PaintChildren(canvas);
}
// Restore the canvas's original transform.
- canvas->restore();
+ canvas->AsCanvasSkia()->restore();
}
void View::PaintNow() {
diff --git a/views/view_text_utils.cc b/views/view_text_utils.cc
index 1fb39d3..ea1bba7 100644
--- a/views/view_text_utils.cc
+++ b/views/view_text_utils.cc
@@ -9,7 +9,7 @@
#include "base/i18n/word_iterator.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/size.h"
#include "views/controls/label.h"
@@ -118,7 +118,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas,
word = text; // Draw the whole text at once.
int w = font.GetStringWidth(word), h = font.height();
- canvas->SizeStringInt(word, font, &w, &h, flags);
+ gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags);
// If we exceed the boundaries, we need to wrap.
WrapIfWordDoesntFit(w, font.height(), position, bounds);
@@ -132,7 +132,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas,
// left of the LTR string.
if (ltr_within_rtl && word[word.size() - 1] == L' ') {
int space_w = font.GetStringWidth(L" "), space_h = font.height();
- canvas->SizeStringInt(L" ", font, &space_w, &space_h, flags);
+ gfx::CanvasSkia::SizeStringInt(L" ", font, &space_w, &space_h, flags);
x += space_w;
}
}
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index b5e1091..8d6ad8e 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -8,7 +8,7 @@
#include "base/keyboard_codes.h"
#include "base/message_loop.h"
#include "base/string_util.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/path.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "views/background.h"
@@ -81,7 +81,7 @@ void PaintRootView(views::RootView* root, bool empty_paint) {
// User isn't logged in, so that PaintNow will generate an empty rectangle.
// Invoke paint directly.
gfx::Rect paint_rect = root->GetScheduledPaintRect();
- gfx::Canvas canvas(paint_rect.width(), paint_rect.height(), true);
+ gfx::CanvasSkia canvas(paint_rect.width(), paint_rect.height(), true);
canvas.TranslateInt(-paint_rect.x(), -paint_rect.y());
canvas.ClipRectInt(0, 0, paint_rect.width(), paint_rect.height());
root->ProcessPaint(&canvas);
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index ff08d29..d67f5e3 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -10,7 +10,7 @@
#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/message_loop.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "views/fill_layout.h"
#include "views/focus/view_storage.h"
#include "views/widget/widget.h"
@@ -173,10 +173,10 @@ void RootView::ProcessPaint(gfx::Canvas* canvas) {
return;
// Clear the background.
- canvas->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
+ canvas->AsCanvasSkia()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
// Save the current transforms.
- canvas->save();
+ canvas->AsCanvasSkia()->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->restore();
+ canvas->AsCanvasSkia()->restore();
ClearPaintRect();
}
diff --git a/views/widget/root_view_win.cc b/views/widget/root_view_win.cc
index 3c9706d..ab885d0 100644
--- a/views/widget/root_view_win.cc
+++ b/views/widget/root_view_win.cc
@@ -9,7 +9,6 @@
#include "app/os_exchange_data_provider_win.h"
#include "base/base_drag_source.h"
#include "base/logging.h"
-#include "gfx/canvas_2.h"
#include "gfx/canvas_skia.h"
namespace views {
@@ -25,12 +24,12 @@ void RootView::OnPaint(HWND hwnd) {
RECT win_version = original_dirty_region.ToRECT();
InvalidateRect(hwnd, &win_version, FALSE);
}
- scoped_ptr<gfx::CanvasPaint2> canvas(
- gfx::CanvasPaint2::CreateCanvasPaint(hwnd));
+ scoped_ptr<gfx::CanvasPaint> canvas(
+ gfx::CanvasPaint::CreateCanvasPaint(hwnd));
if (!canvas->IsValid()) {
SchedulePaint(canvas->GetInvalidRect(), false);
if (NeedsPainting(false))
- ProcessPaint(canvas->AsCanvas2()->AsCanvas());
+ ProcessPaint(canvas->AsCanvas());
}
}
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 7705784..5948bfd 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -9,7 +9,6 @@
#include "app/win_util.h"
#include "base/string_util.h"
#include "base/win_util.h"
-#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "gfx/native_theme_win.h"
#include "gfx/path.h"
@@ -1122,9 +1121,9 @@ Window* WidgetWin::GetWindowImpl(HWND hwnd) {
}
void WidgetWin::SizeContents(const gfx::Size& window_size) {
- contents_.reset(new gfx::Canvas(window_size.width(),
- window_size.height(),
- false));
+ contents_.reset(new gfx::CanvasSkia(window_size.width(),
+ window_size.height(),
+ false));
}
void WidgetWin::PaintLayeredWindow() {
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 98da389..866cc70 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -20,7 +20,7 @@
#include "views/widget/widget.h"
namespace gfx {
-class Canvas;
+class CanvasSkia;
class Rect;
}
@@ -533,7 +533,7 @@ class WidgetWin : public app::WindowImpl,
// A canvas that contains the window contents in the case of a layered
// window.
- scoped_ptr<gfx::Canvas> contents_;
+ scoped_ptr<gfx::CanvasSkia> contents_;
// Whether or not the window should delete itself when it is destroyed.
// Set this to false via its setter for stack allocated instances.
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 8b32d63..4f40987 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -17,7 +17,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/keyboard_codes.h"
-#include "gfx/canvas.h"
+#include "gfx/canvas_skia.h"
#include "gfx/font.h"
#include "grit/app_strings.h"
#include "views/controls/button/native_button.h"
@@ -418,7 +418,7 @@ void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) {
if (window()->GetDelegate()->CanResize() ||
window()->GetDelegate()->CanMaximize()) {
#if defined(OS_WIN)
- HDC dc = canvas->beginPlatformPaint();
+ HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint();
SIZE gripper_size = { 0, 0 };
gfx::NativeTheme::instance()->GetThemePartSize(
gfx::NativeTheme::STATUS, dc, SP_GRIPPER, 1, NULL, TS_TRUE,
@@ -434,7 +434,7 @@ void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) {
RECT native_bounds = size_box_bounds_.ToRECT();
gfx::NativeTheme::instance()->PaintStatusGripper(
dc, SP_PANE, 1, 0, &native_bounds);
- canvas->endPlatformPaint();
+ canvas->AsCanvasSkia()->endPlatformPaint();
#else
NOTIMPLEMENTED();
// TODO(port): paint size box