diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 16:33:23 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 16:33:23 +0000 |
commit | 74db48eb22cd8bfe4d028418d99e7aee6c220930 (patch) | |
tree | 94b62cc97d669cb965d2073c5d9a72a4a3c3ee04 /views | |
parent | 2abd00dd89a5cbc9af4a88a59269fdf9f988cf12 (diff) | |
download | chromium_src-74db48eb22cd8bfe4d028418d99e7aee6c220930.zip chromium_src-74db48eb22cd8bfe4d028418d99e7aee6c220930.tar.gz chromium_src-74db48eb22cd8bfe4d028418d99e7aee6c220930.tar.bz2 |
Canvas refactoring part 3.
- Replace Canvas instance users with CanvasSkia users.
- Rename Canvas2 to Canvas.
- Delete Canvas subclass of CanvasSkia.
This has created some ugliness around the fact that people that used SkCanvas methods on Canvas now have to go through AsCanvasSkia first. This is temporary ugliness that will be eradicated as I incrementally build out the new Canvas API.
BUG=none
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/background.cc | 4 | ||||
-rw-r--r-- | views/controls/button/text_button.cc | 23 | ||||
-rw-r--r-- | views/controls/label.cc | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.cc | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_gtk.cc | 15 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_win.cc | 14 | ||||
-rw-r--r-- | views/controls/menu/menu_scroll_view_container.cc | 13 | ||||
-rw-r--r-- | views/controls/menu/menu_separator_win.cc | 6 | ||||
-rw-r--r-- | views/controls/progress_bar.cc | 6 | ||||
-rw-r--r-- | views/controls/tabbed_pane/native_tabbed_pane_win.cc | 6 | ||||
-rw-r--r-- | views/controls/table/table_view.cc | 4 | ||||
-rw-r--r-- | views/drag_utils.cc | 9 | ||||
-rw-r--r-- | views/painter.cc | 10 | ||||
-rw-r--r-- | views/view.cc | 14 | ||||
-rw-r--r-- | views/view_text_utils.cc | 6 | ||||
-rw-r--r-- | views/view_unittest.cc | 6 | ||||
-rw-r--r-- | views/widget/root_view.cc | 8 | ||||
-rw-r--r-- | views/widget/root_view_win.cc | 7 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 7 | ||||
-rw-r--r-- | views/widget/widget_win.h | 4 | ||||
-rw-r--r-- | views/window/dialog_client_view.cc | 6 |
21 files changed, 89 insertions, 89 deletions
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 f5b25ab..af43934 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 3b9f95b..07e9359 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); @@ -100,7 +97,7 @@ void SetDragImageOnDataObject(const gfx::Canvas& canvas, const gfx::Point& cursor_offset, OSExchangeData* data_object) { SetDragImageOnDataObject( - canvas.ExtractBitmap(), size, cursor_offset, data_object); + canvas.AsCanvasSkia()->ExtractBitmap(), size, cursor_offset, data_object); } } // namespace drag_utils 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..9c0a2b8 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); @@ -387,7 +387,7 @@ TEST_F(ViewTest, MouseEvent) { //////////////////////////////////////////////////////////////////////////////// void TestView::Paint(gfx::Canvas* canvas) { - canvas->getClipBounds(&last_clip_); + canvas->AsCanvasSkia()->getClipBounds(&last_clip_); } void CheckRect(const SkRect& check_rect, const SkRect& target_rect) { 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 |