diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-27 00:16:05 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-27 00:16:05 +0000 |
commit | 7fe2839a49f64048d4530c22b3ca73efcc1d065c (patch) | |
tree | a55bd1e9f1f279e943a3acc27ccd284cd456fc3e | |
parent | cc07b048f1d76e73f0b0f2c1aac9baa574683af8 (diff) | |
download | chromium_src-7fe2839a49f64048d4530c22b3ca73efcc1d065c.zip chromium_src-7fe2839a49f64048d4530c22b3ca73efcc1d065c.tar.gz chromium_src-7fe2839a49f64048d4530c22b3ca73efcc1d065c.tar.bz2 |
ui/gfx: Convert Canvas::TranslateInt() to use gfx::Point.
BUG=100898
R=pkasting@chromium.org
Review URL: http://codereview.chromium.org/8390037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107483 0039d316-1c4b-4281-b951-d872f2087c98
28 files changed, 75 insertions, 85 deletions
diff --git a/chrome/browser/chromeos/views/copy_background.cc b/chrome/browser/chromeos/views/copy_background.cc index 64e329f..723103e 100644 --- a/chrome/browser/chromeos/views/copy_background.cc +++ b/chrome/browser/chromeos/views/copy_background.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -21,12 +21,10 @@ void CopyBackground::Paint(gfx::Canvas* canvas, views::View* view) const { const Background* background = background_owner_->background(); DCHECK(background); gfx::Point origin(0, 0); - views::View::ConvertPointToView(view, - background_owner_, - &origin); + views::View::ConvertPointToView(view, background_owner_, &origin); canvas->Save(); // Move the origin and paint as if it's paint onto the owner. - canvas->TranslateInt(-origin.x(), -origin.y()); + canvas->Translate(gfx::Point().Subtract(origin)); background->Paint(canvas, background_owner_); canvas->Restore(); } diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc index 26d957f..031e354 100644 --- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc @@ -391,7 +391,7 @@ void TabRendererGtk::PaintFaviconArea(GdkEventExpose* event) { // The actual paint methods expect 0, 0 to be the tab top left (see // PaintTab). - canvas.TranslateInt(x(), y()); + canvas.Translate(bounds_.origin()); // Paint the background behind the favicon. int theme_id; @@ -803,7 +803,7 @@ void TabRendererGtk::PaintTab(GdkEventExpose* event) { // The tab is rendered into a windowless widget whose offset is at the // coordinate event->area. Translate by these offsets so we can render at // (0,0) to match Windows' rendering metrics. - canvas.TranslateInt(event->area.x, event->area.y); + canvas.Translate(gfx::Rect(event->area).origin()); // Save the original x offset so we can position background images properly. background_offset_x_ = event->area.x; @@ -834,8 +834,7 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) { PaintLoadingAnimation(canvas); } else { canvas->Save(); - canvas->ClipRectInt( - gfx::Rect(0, 0, width(), height() - kFaviconTitleSpacing)); + canvas->ClipRect(gfx::Rect(0, 0, width(), height() - kFaviconTitleSpacing)); if (should_display_crashed_favicon_) { canvas->DrawBitmapInt(*crashed_favicon, 0, 0, crashed_favicon->width(), @@ -979,8 +978,8 @@ void TabRendererGtk::PaintLoadingAnimation(gfx::Canvas* canvas) { // NOTE: the clipping is a work around for 69528, it shouldn't be necessary. canvas->Save(); - canvas->ClipRectInt(gfx::Rect(favicon_bounds_.x(), favicon_bounds_.y(), - image_size, image_size)); + canvas->ClipRect(gfx::Rect(favicon_bounds_.x(), favicon_bounds_.y(), + image_size, image_size)); canvas->DrawBitmapInt(*frames, image_offset, 0, image_size, image_size, favicon_bounds_.x(), favicon_bounds_.y(), image_size, image_size, false); diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc index 10c36d1..0cca0d6 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc @@ -174,7 +174,8 @@ class AutocompletePopupContentsView::InstantOptInView virtual void OnPaint(gfx::Canvas* canvas) { canvas->Save(); - canvas->TranslateInt(kOptInBackgroundHInset, kOptInBackgroundVInset); + canvas->Translate(gfx::Point(kOptInBackgroundHInset, + kOptInBackgroundVInset)); bg_painter_->Paint(width() - kOptInBackgroundHInset * 2, height() - kOptInBackgroundVInset * 2, canvas); canvas->DrawRectInt(ResourceBundle::toolbar_separator_color, 0, 0, diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index 1899094..d54c0b4 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -743,7 +743,7 @@ void DownloadItemView::OnPaint(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->TranslateInt(width(), 0); + canvas->Translate(gfx::Point(width(), 0)); canvas->ScaleInt(-1, 1); } PaintBitmaps(canvas, diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc index a3c04a6..4d354bf 100644 --- a/chrome/browser/ui/views/find_bar_view.cc +++ b/chrome/browser/ui/views/find_bar_view.cc @@ -227,7 +227,7 @@ void FindBarView::OnPaint(gfx::Canvas* canvas) { // Now flip the canvas for the rest of the graphics if in RTL mode. canvas->Save(); if (base::i18n::IsRTL()) { - canvas->TranslateInt(width(), 0); + canvas->Translate(gfx::Point(width(), 0)); canvas->ScaleInt(-1, 1); } diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index 0358657..41aa6340 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -255,7 +255,7 @@ void InfoBarView::PaintChildren(gfx::Canvas* canvas) { // canvas_skia->clipPath(fill_path_); DCHECK_EQ(total_height(), height()) << "Infobar piecewise heights do not match overall height"; - canvas->ClipRectInt(gfx::Rect(0, arrow_height(), width(), bar_height())); + canvas->ClipRect(gfx::Rect(0, arrow_height(), width(), bar_height())); views::View::PaintChildren(canvas); canvas->Restore(); } diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc index 10e3fd8..82cec3e 100644 --- a/chrome/browser/ui/views/tabs/base_tab.cc +++ b/chrome/browser/ui/views/tabs/base_tab.cc @@ -88,7 +88,7 @@ void DrawIconCenter(gfx::Canvas* canvas, int dst_y = bounds.y() - (icon_height - bounds.height()) / 2; // NOTE: the clipping is a work around for 69528, it shouldn't be necessary. canvas->Save(); - canvas->ClipRectInt(gfx::Rect(dst_x, dst_y, icon_width, icon_height)); + canvas->ClipRect(gfx::Rect(dst_x, dst_y, icon_width, icon_height)); canvas->DrawBitmapInt(image, image_offset, 0, icon_width, icon_height, dst_x, dst_y, icon_width, icon_height, @@ -444,7 +444,7 @@ void BaseTab::PaintIcon(gfx::Canvas* canvas) { icon_size, icon_size, bounds, false); } else { canvas->Save(); - canvas->ClipRectInt(GetLocalBounds()); + canvas->ClipRect(GetLocalBounds()); if (should_display_crashed_favicon_) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); SkBitmap crashed_favicon(*rb.GetBitmapNamed(IDR_SAD_FAVICON)); diff --git a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc index d82aa9e..7938c41 100644 --- a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc @@ -93,7 +93,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->TranslateInt(width(), 0); + canvas->Translate(gfx::Point(width(), 0)); canvas->ScaleInt(-1, 1); } int x_of_active_tab = width() / 2 + kTabSpacing / 2; diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index f653cdf..491ce15 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -25,11 +25,11 @@ #include "content/browser/renderer_host/backing_store_win.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_widget_host.h" -#include "content/public/browser/notification_service.h" #include "content/common/plugin_messages.h" #include "content/common/view_messages.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/native_web_keyboard_event.h" +#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/common/content_switches.h" #include "skia/ext/skia_utils_win.h" @@ -1024,18 +1024,15 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { void RenderWidgetHostViewWin::DrawBackground(const RECT& dirty_rect, CPaintDC* dc) { if (!background_.empty()) { - gfx::CanvasSkia canvas(dirty_rect.right - dirty_rect.left, - dirty_rect.bottom - dirty_rect.top, - true); // opaque - canvas.TranslateInt(-dirty_rect.left, -dirty_rect.top); - - const RECT& dc_rect = dc->m_ps.rcPaint; - canvas.TileImageInt(background_, 0, 0, - dc_rect.right - dc_rect.left, - dc_rect.bottom - dc_rect.top); - - skia::DrawToNativeContext(canvas.sk_canvas(), *dc, dirty_rect.left, - dirty_rect.top, NULL); + gfx::Rect dirty_area(dirty_rect); + gfx::CanvasSkia canvas(dirty_area.width(), dirty_area.height(), true); + canvas.Translate(gfx::Point().Subtract(dirty_area.origin())); + + gfx::Rect dc_rect(dc->m_ps.rcPaint); + canvas.TileImageInt(background_, 0, 0, dc_rect.width(), dc_rect.height()); + + skia::DrawToNativeContext(canvas.sk_canvas(), *dc, dirty_area.x(), + dirty_area.y(), NULL); } else { HBRUSH white_brush = reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); dc->FillRect(&dirty_rect, white_brush); diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc index 2ac1718..619f93f 100644 --- a/ui/gfx/canvas.cc +++ b/ui/gfx/canvas.cc @@ -22,4 +22,4 @@ const SkCanvas* Canvas::GetSkCanvas() const { return NULL; } -} // namespace gfx; +} // namespace gfx diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h index 33b9f4e..189aeb4 100644 --- a/ui/gfx/canvas.h +++ b/ui/gfx/canvas.h @@ -19,7 +19,6 @@ class SkCanvas; namespace ui { class Transform; - typedef unsigned int TextureID; } @@ -99,17 +98,12 @@ class UI_EXPORT Canvas { // call Restore() more times than Save*(). virtual void Restore() = 0; - // Wrapper function that takes integer arguments. // Returns true if the clip is non-empty. - // See clipRect for specifics. - virtual bool ClipRectInt(const gfx::Rect& rect) = 0; + virtual bool ClipRect(const gfx::Rect& rect) = 0; - // Wrapper function that takes integer arguments. - // See translate() for specifics. - virtual void TranslateInt(int x, int y) = 0; + virtual void Translate(const gfx::Point& point) = 0; // Wrapper function that takes integer arguments. - // See scale() for specifics. virtual void ScaleInt(int x, int y) = 0; // Fills the specified region with the specified color using a transfer @@ -257,6 +251,6 @@ class UI_EXPORT CanvasPaint { virtual Canvas* AsCanvas() = 0; }; -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_CANVAS_H_ diff --git a/ui/gfx/canvas_direct2d.cc b/ui/gfx/canvas_direct2d.cc index f824b4d..a1b3a9f 100644 --- a/ui/gfx/canvas_direct2d.cc +++ b/ui/gfx/canvas_direct2d.cc @@ -173,7 +173,7 @@ void CanvasDirect2D::Restore() { rt_->RestoreDrawingState(drawing_state_block_); } -bool CanvasDirect2D::ClipRectInt(const gfx::Rect& rect) { +bool CanvasDirect2D::ClipRect(const gfx::Rect& rect) { rt_->PushAxisAlignedClip(RectToRectF(rect), D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); // Increment the clip count so the call to PushAxisAlignedClip() can be @@ -182,13 +182,13 @@ bool CanvasDirect2D::ClipRectInt(const gfx::Rect& rect) { return !rect.IsEmpty(); } -void CanvasDirect2D::TranslateInt(int x, int y) { +void CanvasDirect2D::Translate(const gfx::Point& point) { D2D1_MATRIX_3X2_F raw; rt_->GetTransform(&raw); D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, raw._32); - transform = D2D1::Matrix3x2F::Translation(static_cast<float>(x), - static_cast<float>(y)) * transform; + transform = D2D1::Matrix3x2F::Translation( + static_cast<float>(point.x()), static_cast<float>(point.y())) * transform; rt_->SetTransform(transform); } diff --git a/ui/gfx/canvas_direct2d.h b/ui/gfx/canvas_direct2d.h index e5a8aadf..75c424c 100644 --- a/ui/gfx/canvas_direct2d.h +++ b/ui/gfx/canvas_direct2d.h @@ -31,8 +31,8 @@ class UI_EXPORT CanvasDirect2D : public Canvas { virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds) OVERRIDE; virtual void Restore() OVERRIDE; - virtual bool ClipRectInt(const gfx::Rect& rect) OVERRIDE; - virtual void TranslateInt(int x, int y) OVERRIDE; + virtual bool ClipRect(const gfx::Rect& rect) OVERRIDE; + virtual void Translate(const gfx::Point& point) OVERRIDE; virtual void ScaleInt(int x, int y) OVERRIDE; virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h) OVERRIDE; @@ -117,6 +117,6 @@ class UI_EXPORT CanvasDirect2D : public Canvas { DISALLOW_COPY_AND_ASSIGN(CanvasDirect2D); }; -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_CANVAS_DIRECT2D_H_ diff --git a/ui/gfx/canvas_direct2d_unittest.cc b/ui/gfx/canvas_direct2d_unittest.cc index 61fc66b..db57990 100644 --- a/ui/gfx/canvas_direct2d_unittest.cc +++ b/ui/gfx/canvas_direct2d_unittest.cc @@ -220,7 +220,7 @@ TEST(CanvasDirect2D, ClipRect) { gfx::CanvasDirect2D canvas(window.rt()); canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); - canvas.ClipRectInt(gfx::Rect(20, 20, 120, 120)); + canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); } @@ -233,14 +233,14 @@ TEST(CanvasDirect2D, ClipRectWithTranslate) { // Repeat the same rendering as in ClipRect... canvas.Save(); canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); - canvas.ClipRectInt(gfx::Rect(20, 20, 120, 120)); + canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); canvas.Restore(); // ... then translate, clip and fill again relative to the new origin. canvas.Save(); - canvas.TranslateInt(150, 150); - canvas.ClipRectInt(gfx::Rect(10, 10, 110, 110)); + canvas.Translate(gfx::Point(150, 150)); + canvas.ClipRect(gfx::Rect(10, 10, 110, 110)); canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); canvas.Restore(); } @@ -254,16 +254,16 @@ TEST(CanvasDirect2D, ClipRectWithScale) { // Repeat the same rendering as in ClipRect... canvas.Save(); canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); - canvas.ClipRectInt(gfx::Rect(20, 20, 120, 120)); + canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); canvas.Restore(); // ... then translate and scale, clip and fill again relative to the new // origin. canvas.Save(); - canvas.TranslateInt(150, 150); + canvas.Translate(gfx::Point(150, 150)); canvas.ScaleInt(2, 2); - canvas.ClipRectInt(gfx::Rect(10, 10, 110, 110)); + canvas.ClipRect(gfx::Rect(10, 10, 110, 110)); canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); canvas.Restore(); } diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc index bf87434..6550073 100644 --- a/ui/gfx/canvas_skia.cc +++ b/ui/gfx/canvas_skia.cc @@ -110,12 +110,12 @@ void CanvasSkia::Restore() { canvas_->restore(); } -bool CanvasSkia::ClipRectInt(const gfx::Rect& rect) { +bool CanvasSkia::ClipRect(const gfx::Rect& rect) { return canvas_->clipRect(gfx::RectToSkRect(rect)); } -void CanvasSkia::TranslateInt(int x, int y) { - canvas_->translate(SkIntToScalar(x), SkIntToScalar(y)); +void CanvasSkia::Translate(const gfx::Point& point) { + canvas_->translate(SkIntToScalar(point.x()), SkIntToScalar(point.y())); } void CanvasSkia::ScaleInt(int x, int y) { @@ -334,7 +334,7 @@ void CanvasSkia::TileImageInt(const SkBitmap& bitmap, canvas_->save(); canvas_->translate(SkIntToScalar(dest_x - src_x), SkIntToScalar(dest_y - src_y)); - ClipRectInt(gfx::Rect(src_x, src_y, w, h)); + ClipRect(gfx::Rect(src_x, src_y, w, h)); canvas_->drawPaint(paint); canvas_->restore(); } diff --git a/ui/gfx/canvas_skia.h b/ui/gfx/canvas_skia.h index e3d44cd..5bf2318 100644 --- a/ui/gfx/canvas_skia.h +++ b/ui/gfx/canvas_skia.h @@ -100,8 +100,8 @@ class UI_EXPORT CanvasSkia : public Canvas { virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds) OVERRIDE; virtual void Restore() OVERRIDE; - virtual bool ClipRectInt(const gfx::Rect& rect) OVERRIDE; - virtual void TranslateInt(int x, int y) OVERRIDE; + virtual bool ClipRect(const gfx::Rect& rect) OVERRIDE; + virtual void Translate(const gfx::Point& point) OVERRIDE; virtual void ScaleInt(int x, int y) OVERRIDE; virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h) OVERRIDE; @@ -196,9 +196,10 @@ class UI_EXPORT CanvasSkia : public Canvas { scoped_ptr<skia::PlatformCanvas> owned_canvas_; SkCanvas* canvas_; + DISALLOW_COPY_AND_ASSIGN(CanvasSkia); }; -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_CANVAS_SKIA_H_ diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc index 68deb73..1c45368 100644 --- a/ui/gfx/canvas_skia_win.cc +++ b/ui/gfx/canvas_skia_win.cc @@ -532,7 +532,7 @@ void CanvasSkia::DrawFadeTruncatingString( // Move the origin to |display_rect.origin()|. This simplifies all the // drawing so that both the source and destination can be (0,0). canvas_->save(SkCanvas::kMatrix_SaveFlag); - TranslateInt(display_rect.x(), display_rect.y()); + Translate(display_rect.origin()); gfx::Rect solid_part(gfx::Point(), display_rect.size()); gfx::Rect head_part; @@ -569,7 +569,7 @@ void CanvasSkia::DrawFadeTruncatingString( // Draw the solid part. canvas_->save(SkCanvas::kClip_SaveFlag); - ClipRectInt(solid_part); + ClipRect(solid_part); DrawStringInt(text, font, color, text_rect.x(), text_rect.y(), text_rect.width(), text_rect.height(), diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc index b949cf9..2868f4d 100644 --- a/ui/gfx/compositor/layer.cc +++ b/ui/gfx/compositor/layer.cc @@ -8,8 +8,8 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebExternalTextureLayer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContentLayer.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebExternalTextureLayer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFloatRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" @@ -17,8 +17,8 @@ #if defined(USE_WEBKIT_COMPOSITOR) #include "ui/gfx/compositor/compositor_cc.h" #endif -#include "ui/gfx/compositor/layer_animation_manager.h" #include "ui/gfx/canvas_skia.h" +#include "ui/gfx/compositor/layer_animation_manager.h" #include "ui/gfx/interpolated_transform.h" #include "ui/gfx/point3.h" @@ -417,7 +417,7 @@ void Layer::UpdateLayerCanvas() { } scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvas( draw_rect.width(), draw_rect.height(), false)); - canvas->TranslateInt(-draw_rect.x(), -draw_rect.y()); + canvas->Translate(gfx::Point().Subtract(draw_rect.origin())); delegate_->OnPaintLayer(canvas.get()); SetCanvas(*canvas->GetSkCanvas(), draw_rect.origin()); #endif diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index ec2b24e..503fffc 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -341,7 +341,7 @@ int RenderText::GetStringWidth() { void RenderText::Draw(Canvas* canvas) { // Clip the canvas to the text display area. - canvas->ClipRectInt(display_rect_); + canvas->ClipRect(display_rect_); // Draw the selection. std::vector<Rect> selection(GetSubstringBounds(GetSelectionStart(), diff --git a/ui/gfx/render_text_linux.h b/ui/gfx/render_text_linux.h index 497a47c..217b43a 100644 --- a/ui/gfx/render_text_linux.h +++ b/ui/gfx/render_text_linux.h @@ -118,6 +118,6 @@ class RenderTextLinux : public RenderText { DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); }; -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_RENDER_TEXT_LINUX_H_ diff --git a/ui/gfx/render_text_win.h b/ui/gfx/render_text_win.h index b3673664..2491b62 100644 --- a/ui/gfx/render_text_win.h +++ b/ui/gfx/render_text_win.h @@ -123,6 +123,6 @@ class RenderTextWin : public RenderText { DISALLOW_COPY_AND_ASSIGN(RenderTextWin); }; -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_RENDER_TEXT_WIN_H_ diff --git a/ui/gfx/skia_util.h b/ui/gfx/skia_util.h index 0b43a4c..a9312ef 100644 --- a/ui/gfx/skia_util.h +++ b/ui/gfx/skia_util.h @@ -46,9 +46,9 @@ UI_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1, // there was none. UI_EXPORT string16 RemoveAcceleratorChar(const string16& s, char16 accelerator_char, - int *accelerated_char_pos, - int *accelerated_char_span); + int* accelerated_char_pos, + int* accelerated_char_span); -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_SKIA_UTIL_H_ diff --git a/ui/gfx/win_util.h b/ui/gfx/win_util.h index 67074d0..619097f 100644 --- a/ui/gfx/win_util.h +++ b/ui/gfx/win_util.h @@ -16,7 +16,6 @@ UI_EXPORT bool Direct2dIsAvailable(); // Returns true if DirectWrite is available, false otherwise. bool DirectWriteIsAvailable(); -} // namespace gfx; +} // namespace gfx #endif // UI_GFX_WIN_UTIL_H_ - diff --git a/views/controls/combobox/native_combobox_views.cc b/views/controls/combobox/native_combobox_views.cc index 5a1176e..724da9e 100644 --- a/views/controls/combobox/native_combobox_views.cc +++ b/views/controls/combobox/native_combobox_views.cc @@ -302,7 +302,7 @@ void NativeComboboxViews::PaintText(gfx::Canvas* canvas) { gfx::Insets insets = GetInsets(); canvas->Save(); - canvas->ClipRectInt(GetContentsBounds()); + canvas->ClipRect(GetContentsBounds()); int x = insets.left(); int y = insets.top(); diff --git a/views/controls/menu/menu_image_util.cc b/views/controls/menu/menu_image_util.cc index e9b4b81..883ced58 100644 --- a/views/controls/menu/menu_image_util.cc +++ b/views/controls/menu/menu_image_util.cc @@ -9,6 +9,7 @@ #include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas_skia.h" +#include "ui/gfx/point.h" namespace { @@ -29,7 +30,7 @@ const SkColor kIndicatorStroke = SkColorSetRGB(0, 0, 0); SkBitmap* CreateRadioButtonImage(bool selected) { // + 2 (1px on each side) to cover rounding error. gfx::CanvasSkia canvas(kIndicatorSize + 2, kIndicatorSize + 2, false); - canvas.TranslateInt(1, 1); + canvas.Translate(gfx::Point(1, 1)); SkPoint gradient_points[3]; gradient_points[0].set(SkIntToScalar(0), SkIntToScalar(0)); diff --git a/views/painter.cc b/views/painter.cc index f39317d..5b2fc12 100644 --- a/views/painter.cc +++ b/views/painter.cc @@ -11,6 +11,7 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/insets.h" +#include "ui/gfx/point.h" namespace views { @@ -149,7 +150,7 @@ void Painter::PaintPainterAt(int x, int y, int w, int h, if (w < 0 || h < 0) return; canvas->Save(); - canvas->TranslateInt(x, y); + canvas->Translate(gfx::Point(x, y)); painter->Paint(w, h, canvas); canvas->Restore(); } diff --git a/views/view.cc b/views/view.cc index 4f04208..0a6fdd1 100644 --- a/views/view.cc +++ b/views/view.cc @@ -677,15 +677,14 @@ void View::Paint(gfx::Canvas* canvas) { // Note that the X (or left) position we pass to ClipRectInt takes into // consideration whether or not the view uses a right-to-left layout so that // we paint our view in its mirrored position if need be. - if (!canvas->ClipRectInt(gfx::Rect(GetMirroredX(), y(), - width() - static_cast<int>(clip_x_), - height() - static_cast<int>(clip_y_)))) { + if (!canvas->ClipRect(gfx::Rect(GetMirroredX(), y(), + width() - static_cast<int>(clip_x_), + height() - static_cast<int>(clip_y_)))) { return; } // Non-empty clip, translate the graphics such that 0,0 corresponds to // where this view is located (related to its parent). - canvas->TranslateInt(GetMirroredX(), y()); - + canvas->Translate(GetMirroredPosition()); canvas->Transform(GetTransform()); PaintCommon(canvas); @@ -1464,7 +1463,7 @@ void View::PaintCommon(gfx::Canvas* canvas) { // request the canvas to be flipped. ScopedCanvas scoped(canvas); if (FlipCanvasOnPaintForRTLUI()) { - canvas->TranslateInt(width(), 0); + canvas->Translate(gfx::Point(width(), 0)); canvas->ScaleInt(-1, 1); } diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 554d0e62..aa4e8501 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -2320,7 +2320,7 @@ void NativeWidgetWin::RedrawLayeredWindowContents() { // We need to clip to the dirty rect ourselves. layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag); - layered_window_contents_->ClipRectInt(invalid_rect_); + layered_window_contents_->ClipRect(invalid_rect_); GetWidget()->GetRootView()->Paint(layered_window_contents_.get()); layered_window_contents_->sk_canvas()->restore(); |