diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-31 00:11:05 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-31 00:11:05 +0000 |
commit | e728d1dbb22389af68d1adad7b18b985cde3bba1 (patch) | |
tree | b760162eea5504ac6fe637e2cc6d9a0f62b07432 | |
parent | 6b1ac06375f8f41be58938a5e94bcf5af0086ee2 (diff) | |
download | chromium_src-e728d1dbb22389af68d1adad7b18b985cde3bba1.zip chromium_src-e728d1dbb22389af68d1adad7b18b985cde3bba1.tar.gz chromium_src-e728d1dbb22389af68d1adad7b18b985cde3bba1.tar.bz2 |
ui/gfx: Convert Canvas::FillRectInt() to use gfx::Rect.
BUG=100898
R=pkasting@chromium.org
Review URL: http://codereview.chromium.org/8405002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107907 0039d316-1c4b-4281-b951-d872f2087c98
56 files changed, 342 insertions, 315 deletions
diff --git a/chrome/browser/chromeos/panels/panel_scroller_header.cc b/chrome/browser/chromeos/panels/panel_scroller_header.cc index 12de46e..93f8a04 100644 --- a/chrome/browser/chromeos/panels/panel_scroller_header.cc +++ b/chrome/browser/chromeos/panels/panel_scroller_header.cc @@ -40,11 +40,11 @@ gfx::Size PanelScrollerHeader::GetPreferredSize() { void PanelScrollerHeader::OnPaint(gfx::Canvas* canvas) { // TODO(brettw) fill this out with real styling. - canvas->FillRectInt(0xFFFFFFFF, 0, 0, size().width(), size().height()); + canvas->FillRect(0xFFFFFFFF, GetLocalBounds()); canvas->DrawLineInt(0xFFE6E6E6, 0, size().height() - 1, size().width(), size().height() - 1); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); gfx::Font font = rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); int font_top = 1; diff --git a/chrome/browser/chromeos/status/status_area_button.cc b/chrome/browser/chromeos/status/status_area_button.cc index 7987d59f3..e4b4103 100644 --- a/chrome/browser/chromeos/status/status_area_button.cc +++ b/chrome/browser/chromeos/status/status_area_button.cc @@ -65,8 +65,7 @@ StatusAreaButton::StatusAreaButton(StatusAreaHost* host, void StatusAreaButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { if (state() == BS_PUSHED) { // Apply 10% white when pushed down. - canvas->FillRectInt(SkColorSetARGB(0x19, 0xFF, 0xFF, 0xFF), - 0, 0, width(), height()); + canvas->FillRect(SkColorSetARGB(0x19, 0xFF, 0xFF, 0xFF), GetLocalBounds()); } if (use_menu_button_paint_) { diff --git a/chrome/browser/ntp_background_util.cc b/chrome/browser/ntp_background_util.cc index 5dc0d6f..96496f5 100644 --- a/chrome/browser/ntp_background_util.cc +++ b/chrome/browser/ntp_background_util.cc @@ -56,17 +56,16 @@ void PaintThemeBackground( } // namespace // static -void NtpBackgroundUtil::PaintBackgroundDetachedMode( - ui::ThemeProvider* tp, gfx::Canvas* canvas, const gfx::Rect& area, - int tab_contents_height) { +void NtpBackgroundUtil::PaintBackgroundDetachedMode(ui::ThemeProvider* tp, + gfx::Canvas* canvas, + const gfx::Rect& area, + int tab_contents_height) { // Draw the background to match the new tab page. - canvas->FillRectInt(tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND), - area.x(), area.y(), area.width(), area.height()); + canvas->FillRect(tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND), area); if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { int tiling = ThemeService::NO_REPEAT; - tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, - &tiling); + tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling); int alignment; if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment)) { diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc index b509943..b7d0bb6 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc @@ -827,11 +827,8 @@ void RenderWidgetHostViewViews::OnPaint(gfx::Canvas* canvas) { // paint a "hole" in the canvas so that the render of the web page is on // top of whatever else has already been painted in the views hierarchy. // Later views might still get to paint on top. - if (!get_use_acceleration_when_possible()) { - canvas->FillRectInt(SK_ColorBLACK, 0, 0, - bounds().width(), bounds().height(), - SkXfermode::kClear_Mode); - } + if (!get_use_acceleration_when_possible()) + canvas->FillRect(SK_ColorBLACK, GetLocalBounds(), SkXfermode::kClear_Mode); DCHECK(!about_to_validate_and_paint_); @@ -896,8 +893,7 @@ void RenderWidgetHostViewViews::OnPaint(gfx::Canvas* canvas) { whiteout_start_time_ = base::TimeTicks::Now(); if (get_use_acceleration_when_possible()) - canvas->FillRectInt(SK_ColorWHITE, 0, 0, - bounds().width(), bounds().height()); + canvas->FillRect(SK_ColorWHITE, GetLocalBounds()); } } diff --git a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc index b96333d..47a0fe9 100644 --- a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc +++ b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc @@ -13,8 +13,8 @@ #include "content/browser/renderer_host/mock_render_process_host.h" #include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/tab_contents/render_view_host_manager.h" -#include "content/public/browser/notification_service.h" #include "content/common/view_messages.h" +#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "skia/ext/platform_canvas.h" #include "testing/gtest/include/gtest/gtest.h" @@ -220,7 +220,7 @@ TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_SingleColor) { const gfx::Size kSize(20, 10); gfx::CanvasSkia canvas(kSize.width(), kSize.height(), true); // Fill all pixesl in black. - canvas.FillRectInt(kBlack, 0, 0, kSize.width(), kSize.height()); + canvas.FillRect(kBlack, gfx::Rect(gfx::Point(), kSize)); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); @@ -235,9 +235,9 @@ TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_TwoColors) { gfx::CanvasSkia canvas(kSize.width(), kSize.height(), true); // Fill all pixesl in black. - canvas.FillRectInt(kBlack, 0, 0, kSize.width(), kSize.height()); + canvas.FillRect(kBlack, gfx::Rect(gfx::Point(), kSize)); // Fill the left half pixels in white. - canvas.FillRectInt(kWhite, 0, 0, kSize.width() / 2, kSize.height()); + canvas.FillRect(kWhite, gfx::Rect(0, 0, kSize.width() / 2, kSize.height())); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index 1e48900..795b618 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service.cc @@ -27,8 +27,8 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "content/browser/user_metrics.h" -#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_details.h" +#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" @@ -1077,9 +1077,9 @@ SkBitmap* GtkThemeService::GenerateFrameImage( canvas.DrawRectInt(0, 0, kToolbarImageWidth, gradient_size, paint); } - canvas.FillRectInt(base, 0, gradient_size, - kToolbarImageWidth, - kToolbarImageHeight - gradient_size); + canvas.FillRect(base, gfx::Rect(0, gradient_size, + kToolbarImageWidth, + kToolbarImageHeight - gradient_size)); return new SkBitmap(canvas.ExtractBitmap()); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index b7f1818..ec950a4 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -654,9 +654,7 @@ void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) { indicator_bounds.set_x(GetMirroredXForRect(indicator_bounds)); // TODO(sky/glen): make me pretty! - canvas->FillRectInt(kDropIndicatorColor, indicator_bounds.x(), - indicator_bounds.y(), indicator_bounds.width(), - indicator_bounds.height()); + canvas->FillRect(kDropIndicatorColor, indicator_bounds); } } diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index 67b47bc..4557c0a 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -845,9 +845,7 @@ void BrowserActionsContainer::OnPaint(gfx::Canvas* canvas) { // Color of the drop indicator. static const SkColor kDropIndicatorColor = SK_ColorBLACK; - canvas->FillRectInt(kDropIndicatorColor, indicator_bounds.x(), - indicator_bounds.y(), indicator_bounds.width(), - indicator_bounds.height()); + canvas->FillRect(kDropIndicatorColor, indicator_bounds); } } diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc index d48427c..b9f5af5 100644 --- a/chrome/browser/ui/views/constrained_window_views.cc +++ b/chrome/browser/ui/views/constrained_window_views.cc @@ -450,18 +450,28 @@ void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) { // Fill with the frame color first so we have a constant background for // areas not covered by the theme image. - canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height()); - // Now fill down the sides. - canvas->FillRectInt(frame_color, 0, theme_frame->height(), left_edge->width(), - height() - theme_frame->height()); - canvas->FillRectInt(frame_color, width() - right_edge->width(), - theme_frame->height(), right_edge->width(), - height() - theme_frame->height()); - // Now fill the bottom area. - canvas->FillRectInt(frame_color, - left_edge->width(), height() - bottom_edge->height(), - width() - left_edge->width() - right_edge->width(), - bottom_edge->height()); + canvas->FillRect(frame_color, + gfx::Rect(0, 0, width(), theme_frame->height())); + + int remaining_height = height() - theme_frame->height(); + if (remaining_height > 0) { + // Now fill down the sides. + canvas->FillRect(frame_color, gfx::Rect(0, theme_frame->height(), + left_edge->width(), + remaining_height)); + canvas->FillRect(frame_color, gfx::Rect(width() - right_edge->width(), + theme_frame->height(), + right_edge->width(), + remaining_height)); + int center_width = width() - left_edge->width() - right_edge->width(); + if (center_width > 0) { + // Now fill the bottom area. + canvas->FillRect(frame_color, + gfx::Rect(left_edge->width(), + height() - bottom_edge->height(), + center_width, bottom_edge->height())); + } + } // Draw the theme frame. canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); @@ -508,13 +518,8 @@ void ConstrainedWindowFrameView::PaintClientEdge(gfx::Canvas* canvas) { gfx::Rect frame_shadow_bounds(client_edge_bounds); frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); - canvas->FillRectInt(kContentsBorderShadow, frame_shadow_bounds.x(), - frame_shadow_bounds.y(), frame_shadow_bounds.width(), - frame_shadow_bounds.height()); - - canvas->FillRectInt(ResourceBundle::toolbar_color, client_edge_bounds.x(), - client_edge_bounds.y(), client_edge_bounds.width(), - client_edge_bounds.height()); + canvas->FillRect(kContentsBorderShadow, frame_shadow_bounds); + canvas->FillRect(ResourceBundle::toolbar_color, client_edge_bounds); } void ConstrainedWindowFrameView::LayoutWindowControls() { diff --git a/chrome/browser/ui/views/default_search_view.cc b/chrome/browser/ui/views/default_search_view.cc index 568df1c..c2187a6 100644 --- a/chrome/browser/ui/views/default_search_view.cc +++ b/chrome/browser/ui/views/default_search_view.cc @@ -9,9 +9,9 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" +#include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" -#include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/views/constrained_window_views.h" @@ -19,8 +19,8 @@ #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" -#include "ui/base/message_box_flags.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/message_box_flags.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "views/controls/button/text_button.h" @@ -28,8 +28,8 @@ #include "views/controls/label.h" #include "views/layout/grid_layout.h" #include "views/layout/layout_constants.h" -#include "views/window/dialog_client_view.h" #include "views/widget/widget.h" +#include "views/window/dialog_client_view.h" namespace { @@ -134,12 +134,13 @@ DefaultSearchView::~DefaultSearchView() { void DefaultSearchView::OnPaint(gfx::Canvas* canvas) { // Fill in behind the background image with the standard gray toolbar color. - canvas->FillRectInt(GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR), - 0, 0, width(), background_image_->height()); + canvas->FillRect(GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR), + gfx::Rect(0, 0, width(), background_image_->height())); // The rest of the dialog background should be white. DCHECK(height() > background_image_->height()); - canvas->FillRectInt(SK_ColorWHITE, 0, background_image_->height(), width(), - height() - background_image_->height()); + canvas->FillRect(SK_ColorWHITE, + gfx::Rect(0, background_image_->height(), width(), + height() - background_image_->height())); } void DefaultSearchView::ButtonPressed(views::Button* sender, diff --git a/chrome/browser/ui/views/detachable_toolbar_view.cc b/chrome/browser/ui/views/detachable_toolbar_view.cc index 60c09e0..b7b31cc 100644 --- a/chrome/browser/ui/views/detachable_toolbar_view.cc +++ b/chrome/browser/ui/views/detachable_toolbar_view.cc @@ -28,10 +28,8 @@ void DetachableToolbarView::PaintBackgroundAttachedMode( views::View* view, const gfx::Point& background_origin) { ui::ThemeProvider* tp = view->GetThemeProvider(); - SkColor theme_toolbar_color = - tp->GetColor(ThemeService::COLOR_TOOLBAR); - canvas->FillRectInt(theme_toolbar_color, 0, 0, - view->width(), view->height()); + SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); + canvas->FillRect(theme_toolbar_color, view->GetLocalBounds()); canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), background_origin.x(), background_origin.y(), 0, 0, view->width(), view->height()); @@ -58,14 +56,16 @@ void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas, // the view (bar/shelf) is attached or detached. int thickness = views::NonClientFrameView::kClientEdgeThickness; int y = view->IsDetached() ? 0 : (view->height() - thickness); - canvas->FillRectInt(ResourceBundle::toolbar_separator_color, - 0, y, view->width(), thickness); + canvas->FillRect(ResourceBundle::toolbar_separator_color, + gfx::Rect(0, y, view->width(), thickness)); } // static void DetachableToolbarView::PaintContentAreaBackground( - gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, - const SkRect& rect, double roundness) { + gfx::Canvas* canvas, + ui::ThemeProvider* theme_provider, + const SkRect& rect, + double roundness) { SkPaint paint; paint.setAntiAlias(true); paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); diff --git a/chrome/browser/ui/views/download/download_shelf_view.cc b/chrome/browser/ui/views/download/download_shelf_view.cc index 8044192..2592e64 100644 --- a/chrome/browser/ui/views/download/download_shelf_view.cc +++ b/chrome/browser/ui/views/download/download_shelf_view.cc @@ -16,8 +16,8 @@ #include "chrome/browser/ui/views/download/download_item_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "content/browser/download/download_item.h" -#include "content/browser/download/download_stats.h" #include "content/browser/download/download_manager.h" +#include "content/browser/download/download_stats.h" #include "content/browser/tab_contents/navigation_entry.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -171,7 +171,7 @@ void DownloadShelfView::OnPaint(gfx::Canvas* canvas) { } void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { - canvas->FillRectInt(kBorderColor, 0, 0, width(), 1); + canvas->FillRect(kBorderColor, gfx::Rect(0, 0, width(), 1)); } void DownloadShelfView::OpenedDownload(DownloadItemView* view) { diff --git a/chrome/browser/ui/views/first_run_search_engine_view.cc b/chrome/browser/ui/views/first_run_search_engine_view.cc index 84af86f..a85e451 100644 --- a/chrome/browser/ui/views/first_run_search_engine_view.cc +++ b/chrome/browser/ui/views/first_run_search_engine_view.cc @@ -183,12 +183,13 @@ void FirstRunSearchEngineView::ButtonPressed(views::Button* sender, void FirstRunSearchEngineView::OnPaint(gfx::Canvas* canvas) { // Fill in behind the background image with the standard gray toolbar color. - canvas->FillRectInt(GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR), - 0, 0, width(), background_image_->height()); + canvas->FillRect(GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR), + gfx::Rect(0, 0, width(), background_image_->height())); // The rest of the dialog background should be white. DCHECK(height() > background_image_->height()); - canvas->FillRectInt(SK_ColorWHITE, 0, background_image_->height(), width(), - height() - background_image_->height()); + canvas->FillRect(SK_ColorWHITE, + gfx::Rect(0, background_image_->height(), width(), + height() - background_image_->height())); } void FirstRunSearchEngineView::OnTemplateURLServiceChanged() { diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc index d46e92d..668a157 100644 --- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc @@ -340,18 +340,28 @@ void AppPanelBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { // Fill with the frame color first so we have a constant background for // areas not covered by the theme image. - canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height()); - // Now fill down the sides. - canvas->FillRectInt(frame_color, 0, theme_frame->height(), left_edge->width(), - height() - theme_frame->height()); - canvas->FillRectInt(frame_color, width() - right_edge->width(), - theme_frame->height(), right_edge->width(), - height() - theme_frame->height()); - // Now fill the bottom area. - canvas->FillRectInt(frame_color, left_edge->width(), - height() - bottom_edge->height(), - width() - left_edge->width() - right_edge->width(), - bottom_edge->height()); + canvas->FillRect(frame_color, + gfx::Rect(0, 0, width(), theme_frame->height())); + + int remaining_height = height() - theme_frame->height(); + if (remaining_height > 0) { + // Now fill down the sides. + canvas->FillRect(frame_color, + gfx::Rect(0, theme_frame->height(), left_edge->width(), + remaining_height)); + canvas->FillRect(frame_color, + gfx::Rect(width() - right_edge->width(), + theme_frame->height(), right_edge->width(), + remaining_height)); + int center_width = width() - left_edge->width() - right_edge->width(); + if (center_width > 0) { + // Now fill the bottom area. + canvas->FillRect(frame_color, + gfx::Rect(left_edge->width(), + height() - bottom_edge->height(), + center_width, bottom_edge->height())); + } + } // Draw the theme frame. canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); diff --git a/chrome/browser/ui/views/frame/browser_frame_aura.cc b/chrome/browser/ui/views/frame/browser_frame_aura.cc index b4e0176..e49bcf1 100644 --- a/chrome/browser/ui/views/frame/browser_frame_aura.cc +++ b/chrome/browser/ui/views/frame/browser_frame_aura.cc @@ -74,9 +74,9 @@ void ToolbarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { h)); canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); - SkColor theme_toolbar_color = - tp->GetColor(ThemeService::COLOR_TOOLBAR); - canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); + SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); + canvas->FillRect(theme_toolbar_color, + gfx::Rect(x, bottom_y, w, bottom_edge_height)); // Tile the toolbar image starting at the frame edge on the left and where the // horizontal tabstrip is (or would be) on the top. @@ -141,12 +141,13 @@ void ToolbarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { bottom_edge_height, false); // Draw the content/toolbar separator. - canvas->FillRectInt( + canvas->FillRect( ResourceBundle::toolbar_separator_color, - x + views::NonClientFrameView::kClientEdgeThickness, - toolbar_bounds.bottom() - views::NonClientFrameView::kClientEdgeThickness, - w - (2 * views::NonClientFrameView::kClientEdgeThickness), - views::NonClientFrameView::kClientEdgeThickness); + gfx::Rect( + x + views::NonClientFrameView::kClientEdgeThickness, + toolbar_bounds.bottom() - views::NonClientFrameView::kClientEdgeThickness, + w - (2 * views::NonClientFrameView::kClientEdgeThickness), + views::NonClientFrameView::kClientEdgeThickness)); } } // namespace diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc index a543f7e..b77b80c 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc @@ -77,7 +77,7 @@ class WindowControlButton : public views::CustomButton { // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRectInt(GetBackgroundColor(), 0, 0, width(), height()); + canvas->FillRect(GetBackgroundColor(), GetLocalBounds()); canvas->DrawBitmapInt(icon_, 0, 0); } virtual gfx::Size GetPreferredSize() OVERRIDE { diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index 8187a6c..c92c7df 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -330,9 +330,11 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { right_x, y); // Draw the content/toolbar separator. - canvas->FillRectInt(ResourceBundle::toolbar_separator_color, - x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness, - w - (2 * kClientEdgeThickness), kClientEdgeThickness); + canvas->FillRect(ResourceBundle::toolbar_separator_color, + gfx::Rect(x + kClientEdgeThickness, + toolbar_bounds.bottom() - kClientEdgeThickness, + w - (2 * kClientEdgeThickness), + kClientEdgeThickness)); } void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { @@ -372,15 +374,16 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { // images because the images are meant to alpha-blend atop the frame whereas // these rects are meant to be fully opaque, without anything overlaid. SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); - canvas->FillRectInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, client_area_top, - kClientEdgeThickness, - client_area_bottom + kClientEdgeThickness - client_area_top); - canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, - client_area_bounds.width(), kClientEdgeThickness); - canvas->FillRectInt(toolbar_color, client_area_bounds.right(), - client_area_top, kClientEdgeThickness, - client_area_bottom + kClientEdgeThickness - client_area_top); + canvas->FillRect(toolbar_color, + gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, client_area_top, + kClientEdgeThickness, + client_area_bottom + kClientEdgeThickness - client_area_top)); + canvas->FillRect(toolbar_color, + gfx::Rect(client_area_bounds.x(), client_area_bottom, + client_area_bounds.width(), kClientEdgeThickness)); + canvas->FillRect(toolbar_color, gfx::Rect(client_area_bounds.right(), + client_area_top, kClientEdgeThickness, + client_area_bottom + kClientEdgeThickness - client_area_top)); } void GlassBrowserFrameView::LayoutAvatar() { diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index a306850..95ab6cd 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -610,19 +610,27 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); } SkColor frame_color = GetFrameColor(); - canvas->FillRectInt(frame_color, 0, 0, width(), top_area_height); - - // Now fill down the sides. - canvas->FillRectInt(frame_color, 0, top_area_height, left_edge->width(), - height() - top_area_height); - canvas->FillRectInt(frame_color, width() - right_edge->width(), - top_area_height, right_edge->width(), - height() - top_area_height); - // Now fill the bottom area. - canvas->FillRectInt(frame_color, left_edge->width(), - height() - bottom_edge->height(), - width() - left_edge->width() - right_edge->width(), - bottom_edge->height()); + canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height)); + + int remaining_height = height() - top_area_height; + if (remaining_height > 0) { + // Now fill down the sides. + canvas->FillRect(frame_color, + gfx::Rect(0, top_area_height, left_edge->width(), + remaining_height)); + canvas->FillRect(frame_color, + gfx::Rect(width() - right_edge->width(), + top_area_height, right_edge->width(), + remaining_height)); + int center_width = width() - left_edge->width() - right_edge->width(); + if (center_width > 0) { + // Now fill the bottom area. + canvas->FillRect(frame_color, + gfx::Rect(left_edge->width(), + height() - bottom_edge->height(), + center_width, bottom_edge->height())); + } + } // Draw the theme frame. canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); @@ -691,7 +699,7 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); if (top_area_height > theme_frame_bottom) { SkColor frame_color = GetFrameColor(); - canvas->FillRectInt(frame_color, 0, 0, width(), top_area_height); + canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height)); } // Draw the theme frame. It must be aligned with the tabstrip as if we were @@ -787,9 +795,9 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { h)); canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); - SkColor theme_toolbar_color = - tp->GetColor(ThemeService::COLOR_TOOLBAR); - canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); + SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); + canvas->FillRect(theme_toolbar_color, + gfx::Rect(x, bottom_y, w, bottom_edge_height)); // Tile the toolbar image starting at the frame edge on the left and where the // horizontal tabstrip is (or would be) on the top. @@ -854,9 +862,11 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { bottom_edge_height, false); // Draw the content/toolbar separator. - canvas->FillRectInt(ResourceBundle::toolbar_separator_color, - x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness, - w - (2 * kClientEdgeThickness), kClientEdgeThickness); + canvas->FillRect(ResourceBundle::toolbar_separator_color, + gfx::Rect(x + kClientEdgeThickness, + toolbar_bounds.bottom() - kClientEdgeThickness, + w - (2 * kClientEdgeThickness), + kClientEdgeThickness)); } void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { @@ -895,11 +905,12 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { top_right->width(), height, false); // Draw the toolbar color across the top edge. - canvas->FillRectInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, - client_area_top - kClientEdgeThickness, - client_area_bounds.width() + (2 * kClientEdgeThickness), - kClientEdgeThickness); + canvas->FillRect( + toolbar_color, + gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, + client_area_top - kClientEdgeThickness, + client_area_bounds.width() + (2 * kClientEdgeThickness), + kClientEdgeThickness)); } int client_area_bottom = @@ -930,15 +941,21 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { // where not covered by the toolbar image. NOTE: We do this after drawing the // images because the images are meant to alpha-blend atop the frame whereas // these rects are meant to be fully opaque, without anything overlaid. - canvas->FillRectInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, client_area_top, - kClientEdgeThickness, - client_area_bottom + kClientEdgeThickness - client_area_top); - canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, - client_area_bounds.width(), kClientEdgeThickness); - canvas->FillRectInt(toolbar_color, client_area_bounds.right(), - client_area_top, kClientEdgeThickness, - client_area_bottom + kClientEdgeThickness - client_area_top); + canvas->FillRect( + toolbar_color, + gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, + client_area_top, + kClientEdgeThickness, + client_area_bottom + kClientEdgeThickness - client_area_top)); + canvas->FillRect(toolbar_color, + gfx::Rect(client_area_bounds.x(), client_area_bottom, + client_area_bounds.width(), kClientEdgeThickness)); + canvas->FillRect( + toolbar_color, + gfx::Rect(client_area_bounds.right(), + client_area_top, + kClientEdgeThickness, + client_area_bottom + kClientEdgeThickness - client_area_top)); } SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { diff --git a/chrome/browser/ui/views/infobars/infobar_background.cc b/chrome/browser/ui/views/infobars/infobar_background.cc index 151c519..d345fa5 100644 --- a/chrome/browser/ui/views/infobars/infobar_background.cc +++ b/chrome/browser/ui/views/infobars/infobar_background.cc @@ -6,10 +6,10 @@ #include "chrome/browser/infobars/infobar.h" #include "chrome/browser/ui/views/infobars/infobar_view.h" +#include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia_paint.h" #include "ui/gfx/color_utils.h" -#include "third_party/skia/include/effects/SkGradientShader.h" #include "views/view.h" InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) @@ -57,7 +57,7 @@ void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { paint.setAntiAlias(false); // Now draw the separator at the bottom. - canvas->FillRectInt(separator_color_, 0, - view->height() - InfoBar::kSeparatorLineHeight, - view->width(), InfoBar::kSeparatorLineHeight); + canvas->FillRect(separator_color_, + gfx::Rect(0, view->height() - InfoBar::kSeparatorLineHeight, + view->width(), InfoBar::kSeparatorLineHeight)); } diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index e0c2d6b..30814ed 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -751,8 +751,7 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) { canvas->GetSkCanvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius, radius, paint); } else { - canvas->FillRectInt(color, bounds.x(), bounds.y(), bounds.width(), - bounds.height()); + canvas->FillRect(color, bounds); } if (show_focus_rect_ && HasFocus()) { diff --git a/chrome/browser/ui/views/location_bar/suggested_text_view.cc b/chrome/browser/ui/views/location_bar/suggested_text_view.cc index a122a99..1d69473 100644 --- a/chrome/browser/ui/views/location_bar/suggested_text_view.cc +++ b/chrome/browser/ui/views/location_bar/suggested_text_view.cc @@ -47,7 +47,7 @@ void SuggestedTextView::OnPaintBackground(gfx::Canvas* canvas) { return; // TODO(sky): these numbers need to come from the edit. - canvas->FillRectInt(bg_color_, 0, 2, width(), height() - 5); + canvas->FillRect(bg_color_, gfx::Rect(0, 2, width(), height() - 5)); } void SuggestedTextView::AnimationEnded(const ui::Animation* animation) { diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc index 15487e1..64ddc93 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.cc +++ b/chrome/browser/ui/views/notifications/balloon_view.cc @@ -491,8 +491,8 @@ void BalloonViewImpl::OnPaint(gfx::Canvas* canvas) { // Draw a 1-pixel gray line between the content and the menu bar. int line_width = GetTotalWidth() - kLeftMargin - kRightMargin; - canvas->FillRectInt(kControlBarSeparatorLineColor, - kLeftMargin, 1 + GetShelfHeight(), line_width, 1); + canvas->FillRect(kControlBarSeparatorLineColor, + gfx::Rect(kLeftMargin, 1 + GetShelfHeight(), line_width, 1)); View::OnPaint(canvas); OnPaintBorder(canvas); diff --git a/chrome/browser/ui/views/tabs/dragged_tab_view.cc b/chrome/browser/ui/views/tabs/dragged_tab_view.cc index ce196a5..70a1a6a 100644 --- a/chrome/browser/ui/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/ui/views/tabs/dragged_tab_view.cc @@ -141,17 +141,15 @@ void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { bitmap_device.eraseARGB(0, 0, 0, 0); int tab_height = renderer_bounds_.back().height(); - scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, - tab_height - kDragFrameBorderSize, - ps.width(), ps.height() - tab_height); - int image_x = kDragFrameBorderSize; - int image_y = tab_height; - int image_w = ps.width() - kTwiceDragFrameBorderSize; - int image_h = contents_size_.height(); - scale_canvas.FillRectInt(SK_ColorBLACK, image_x, image_y, image_w, image_h); - photobooth_->PaintScreenshotIntoCanvas( - &scale_canvas, - gfx::Rect(image_x, image_y, image_w, image_h)); + scale_canvas.FillRect(kDraggedTabBorderColor, + gfx::Rect(0, tab_height - kDragFrameBorderSize, + ps.width(), ps.height() - tab_height)); + gfx::Rect image_rect(kDragFrameBorderSize, + tab_height, + ps.width() - kTwiceDragFrameBorderSize, + contents_size_.height()); + scale_canvas.FillRect(SK_ColorBLACK, image_rect); + photobooth_->PaintScreenshotIntoCanvas(&scale_canvas, image_rect); for (size_t i = 0; i < renderers_.size(); ++i) renderers_[i]->Paint(&scale_canvas); diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index 74875d1..c792bb1f 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -594,7 +594,7 @@ void ToolbarView::OnPaint(gfx::Canvas* canvas) { // toolbar background below the location bar for us. // NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()! if (GetWidget()->ShouldUseNativeFrame()) - canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); + canvas->FillRect(SK_ColorBLACK, gfx::Rect(0, height() - 1, width(), 1)); } // Note this method is ignored on Windows, but needs to be implemented for diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc index ec77ab0..e3fbcfa 100644 --- a/chrome/browser/ui/views/wrench_menu.cc +++ b/chrome/browser/ui/views/wrench_menu.cc @@ -143,46 +143,49 @@ class MenuButtonBackground : public views::Background { int h = view->height(); switch (TypeAdjustedForRTL()) { case LEFT_BUTTON: - canvas->FillRectInt(background_color(state), 1, 1, w, h - 2); - canvas->FillRectInt(border_color(state), 2, 0, w, 1); - canvas->FillRectInt(border_color(state), 1, 1, 1, 1); - canvas->FillRectInt(border_color(state), 0, 2, 1, h - 4); - canvas->FillRectInt(border_color(state), 1, h - 2, 1, 1); - canvas->FillRectInt(border_color(state), 2, h - 1, w, 1); + canvas->FillRect(background_color(state), gfx::Rect(1, 1, w, h - 2)); + canvas->FillRect(border_color(state), gfx::Rect(2, 0, w, 1)); + canvas->FillRect(border_color(state), gfx::Rect(1, 1, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(0, 2, 1, h - 4)); + canvas->FillRect(border_color(state), gfx::Rect(1, h - 2, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(2, h - 1, w, 1)); break; case CENTER_BUTTON: { - canvas->FillRectInt(background_color(state), 1, 1, w - 2, h - 2); + canvas->FillRect(background_color(state), + gfx::Rect(1, 1, w - 2, h - 2)); SkColor left_color = state != CustomButton::BS_NORMAL ? border_color(state) : border_color(left_button_->state()); - canvas->FillRectInt(left_color, 0, 0, 1, h); - canvas->FillRectInt(border_color(state), 1, 0, w - 2, 1); - canvas->FillRectInt(border_color(state), 1, h - 1, w - 2, 1); + canvas->FillRect(left_color, gfx::Rect(0, 0, 1, h)); + canvas->FillRect(border_color(state), gfx::Rect(1, 0, w - 2, 1)); + canvas->FillRect(border_color(state), gfx::Rect(1, h - 1, w - 2, 1)); SkColor right_color = state != CustomButton::BS_NORMAL ? border_color(state) : border_color(right_button_->state()); - canvas->FillRectInt(right_color, w - 1, 0, 1, h); + canvas->FillRect(right_color, gfx::Rect(w - 1, 0, 1, h)); break; } case RIGHT_BUTTON: - canvas->FillRectInt(background_color(state), 0, 1, w - 1, h - 2); - canvas->FillRectInt(border_color(state), 0, 0, w - 2, 1); - canvas->FillRectInt(border_color(state), w - 2, 1, 1, 1); - canvas->FillRectInt(border_color(state), w - 1, 2, 1, h - 4); - canvas->FillRectInt(border_color(state), w - 2, h - 2, 1, 1); - canvas->FillRectInt(border_color(state), 0, h - 1, w - 2, 1); + canvas->FillRect(background_color(state), + gfx::Rect(0, 1, w - 1, h - 2)); + canvas->FillRect(border_color(state), gfx::Rect(0, 0, w - 2, 1)); + canvas->FillRect(border_color(state), gfx::Rect(w - 2, 1, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(w - 1, 2, 1, h - 4)); + canvas->FillRect(border_color(state), gfx::Rect(w - 2, h - 2, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(0, h - 1, w - 2, 1)); break; case SINGLE_BUTTON: - canvas->FillRectInt(background_color(state), 1, 1, w - 2, h - 2); - canvas->FillRectInt(border_color(state), 2, 0, w - 4, 1); - canvas->FillRectInt(border_color(state), 1, 1, 1, 1); - canvas->FillRectInt(border_color(state), 0, 2, 1, h - 4); - canvas->FillRectInt(border_color(state), 1, h - 2, 1, 1); - canvas->FillRectInt(border_color(state), 2, h - 1, w - 4, 1); - canvas->FillRectInt(border_color(state), w - 2, 1, 1, 1); - canvas->FillRectInt(border_color(state), w - 1, 2, 1, h - 4); - canvas->FillRectInt(border_color(state), w - 2, h - 2, 1, 1); + canvas->FillRect(background_color(state), + gfx::Rect(1, 1, w - 2, h - 2)); + canvas->FillRect(border_color(state), gfx::Rect(2, 0, w - 4, 1)); + canvas->FillRect(border_color(state), gfx::Rect(1, 1, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(0, 2, 1, h - 4)); + canvas->FillRect(border_color(state), gfx::Rect(1, h - 2, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(2, h - 1, w - 4, 1)); + canvas->FillRect(border_color(state), gfx::Rect(w - 2, 1, 1, 1)); + canvas->FillRect(border_color(state), gfx::Rect(w - 1, 2, 1, h - 4)); + canvas->FillRect(border_color(state), gfx::Rect(w - 2, h - 2, 1, 1)); break; default: diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index c5a5769..3fc1e00 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -428,10 +428,10 @@ TEST_F(RenderWidgetHostTest, Background) { // Create a checkerboard background to test with. 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); - canvas.FillRectInt(SK_ColorBLACK, 2, 2, 2, 2); + canvas.FillRect(SK_ColorBLACK, gfx::Rect(0, 0, 2, 2)); + canvas.FillRect(SK_ColorWHITE, gfx::Rect(2, 0, 2, 2)); + canvas.FillRect(SK_ColorWHITE, gfx::Rect(0, 2, 2, 2)); + canvas.FillRect(SK_ColorBLACK, gfx::Rect(2, 2, 2, 2)); const SkBitmap& background = canvas.sk_canvas()->getDevice()->accessBitmap(false); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 5feacd8..6601a54 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -6,8 +6,8 @@ #include "base/logging.h" #include "content/browser/renderer_host/backing_store_skia.h" -#include "content/browser/renderer_host/web_input_event_aura.h" #include "content/browser/renderer_host/render_widget_host.h" +#include "content/browser/renderer_host/web_input_event_aura.h" #include "content/public/browser/native_web_keyboard_event.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "ui/aura/aura_constants.h" @@ -437,8 +437,8 @@ void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect(gfx::Point(), canvas); } else { - canvas->FillRectInt(SK_ColorWHITE, 0, 0, window_->bounds().width(), - window_->bounds().height()); + canvas->FillRect(SK_ColorWHITE, + gfx::Rect(gfx::Point(), window_->bounds().size())); } } 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 0873015..fe78c3b 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -176,7 +176,7 @@ void DrawDeemphasized(const SkColor& color, paint_rect.y(), SRCCOPY); } - canvas.FillRectInt(color, 0, 0, paint_rect.width(), paint_rect.height()); + canvas.FillRect(color, gfx::Rect(gfx::Point(), paint_rect.size())); skia::DrawToNativeContext(canvas.sk_canvas(), paint_dc, paint_rect.x(), paint_rect.y(), NULL); } diff --git a/ui/aura_shell/examples/lock_view.cc b/ui/aura_shell/examples/lock_view.cc index cb0eae4..07f57e5 100644 --- a/ui/aura_shell/examples/lock_view.cc +++ b/ui/aura_shell/examples/lock_view.cc @@ -18,8 +18,7 @@ namespace examples { class LockView : public views::WidgetDelegateView { public: - LockView() { - } + LockView() {} virtual ~LockView() {} // Overridden from View: @@ -30,7 +29,7 @@ class LockView : public views::WidgetDelegateView { private: // Overridden from View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height()); + canvas->FillRect(SK_ColorYELLOW, GetLocalBounds()); string16 text = ASCIIToUTF16("LOCKED!"); int string_width = font_.GetStringWidth(text); canvas->DrawStringInt(text, font_, SK_ColorRED, (width() - string_width)/ 2, diff --git a/ui/aura_shell/examples/toplevel_window.cc b/ui/aura_shell/examples/toplevel_window.cc index ef48873..57dda48 100644 --- a/ui/aura_shell/examples/toplevel_window.cc +++ b/ui/aura_shell/examples/toplevel_window.cc @@ -34,7 +34,7 @@ ToplevelWindow::~ToplevelWindow() { } void ToplevelWindow::OnPaint(gfx::Canvas* canvas) { - canvas->FillRectInt(SK_ColorDKGRAY, 0, 0, width(), height()); + canvas->FillRect(SK_ColorDKGRAY, GetLocalBounds()); } string16 ToplevelWindow::GetWindowTitle() const { diff --git a/ui/aura_shell/examples/widgets.cc b/ui/aura_shell/examples/widgets.cc index faaf4a3..3aef092 100644 --- a/ui/aura_shell/examples/widgets.cc +++ b/ui/aura_shell/examples/widgets.cc @@ -93,7 +93,7 @@ WidgetsWindow::~WidgetsWindow() { } void WidgetsWindow::OnPaint(gfx::Canvas* canvas) { - canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height()); + canvas->FillRect(SK_ColorWHITE, GetLocalBounds()); } void WidgetsWindow::Layout() { diff --git a/ui/aura_shell/examples/window_type_launcher.cc b/ui/aura_shell/examples/window_type_launcher.cc index a58d975..2b9312a 100644 --- a/ui/aura_shell/examples/window_type_launcher.cc +++ b/ui/aura_shell/examples/window_type_launcher.cc @@ -58,7 +58,7 @@ WindowTypeLauncher::~WindowTypeLauncher() { } void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { - canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height()); + canvas->FillRect(SK_ColorWHITE, GetLocalBounds()); } void WindowTypeLauncher::Layout() { diff --git a/ui/aura_shell/toplevel_frame_view.cc b/ui/aura_shell/toplevel_frame_view.cc index 61f659c..d2cda68 100644 --- a/ui/aura_shell/toplevel_frame_view.cc +++ b/ui/aura_shell/toplevel_frame_view.cc @@ -46,7 +46,7 @@ class WindowControlButton : public views::CustomButton { // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRectInt(GetBackgroundColor(), 0, 0, width(), height()); + canvas->FillRect(GetBackgroundColor(), GetLocalBounds()); canvas->DrawBitmapInt(icon_, 0, 0); } virtual gfx::Size GetPreferredSize() OVERRIDE { @@ -116,11 +116,11 @@ class FrameComponent : public views::View, // Fill with current opacity value. int opacity = animation_->CurrentValueBetween(kFrameBorderHiddenOpacity, kFrameBorderVisibleOpacity); - canvas->FillRectInt(SkColorSetARGB(opacity, - SkColorGetR(kFrameColor), - SkColorGetG(kFrameColor), - SkColorGetB(kFrameColor)), - 0, 0, width(), height()); + canvas->FillRect(SkColorSetARGB(opacity, + SkColorGetR(kFrameColor), + SkColorGetG(kFrameColor), + SkColorGetB(kFrameColor)), + GetLocalBounds()); } // Overridden from ui::AnimationDelegate: diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h index 2887b30..5da0bce 100644 --- a/ui/gfx/canvas.h +++ b/ui/gfx/canvas.h @@ -107,17 +107,15 @@ class UI_EXPORT Canvas { // 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; + virtual void FillRect(const SkColor& color, const gfx::Rect& rect) = 0; - // Fills the specified region with the specified color and mode - virtual void FillRectInt(const SkColor& color, - int x, int y, int w, int h, - SkXfermode::Mode mode) = 0; + // Fills the specified region with the specified color and mode. + virtual void FillRect(const SkColor& color, + const gfx::Rect& rect, + SkXfermode::Mode mode) = 0; // Fills the specified region with the specified brush. - virtual void FillRectInt(const gfx::Brush* brush, - int x, int y, int w, int h) = 0; + virtual void FillRect(const gfx::Brush* brush, const gfx::Rect& rect) = 0; // Draws a single pixel rect in the specified region with the specified // color, using a transfer mode of SkXfermode::kSrcOver_Mode. diff --git a/ui/gfx/canvas_direct2d.cc b/ui/gfx/canvas_direct2d.cc index 08005f4..5a61ace 100644 --- a/ui/gfx/canvas_direct2d.cc +++ b/ui/gfx/canvas_direct2d.cc @@ -202,23 +202,21 @@ void CanvasDirect2D::Scale(int x_scale, int y_scale) { rt_->SetTransform(transform); } -void CanvasDirect2D::FillRectInt(const SkColor& color, - int x, int y, int w, int h) { +void CanvasDirect2D::FillRect(const SkColor& color, const gfx::Rect& rect) { base::win::ScopedComPtr<ID2D1SolidColorBrush> solid_brush; rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); - rt_->FillRectangle(RectToRectF(x, y, w, h), solid_brush); + rt_->FillRectangle(RectToRectF(rect), solid_brush); } -void CanvasDirect2D::FillRectInt(const SkColor& color, - int x, int y, int w, int h, - SkXfermode::Mode mode) { +void CanvasDirect2D::FillRect(const SkColor& color, + const gfx::Rect& rect, + SkXfermode::Mode mode) { NOTIMPLEMENTED(); } -void CanvasDirect2D::FillRectInt(const gfx::Brush* brush, - int x, int y, int w, int h) { +void CanvasDirect2D::FillRect(const gfx::Brush* brush, const gfx::Rect& rect) { const Direct2DBrush* d2d_brush = static_cast<const Direct2DBrush*>(brush); - rt_->FillRectangle(RectToRectF(x, y, w, h), d2d_brush->brush()); + rt_->FillRectangle(RectToRectF(rect), d2d_brush->brush()); } void CanvasDirect2D::DrawRectInt(const SkColor& color, diff --git a/ui/gfx/canvas_direct2d.h b/ui/gfx/canvas_direct2d.h index dc3cc8d..c5e6ad8 100644 --- a/ui/gfx/canvas_direct2d.h +++ b/ui/gfx/canvas_direct2d.h @@ -34,13 +34,12 @@ class UI_EXPORT CanvasDirect2D : public Canvas { virtual bool ClipRect(const gfx::Rect& rect) OVERRIDE; virtual void Translate(const gfx::Point& point) OVERRIDE; virtual void Scale(int x_scale, int y_scale) OVERRIDE; - virtual void FillRectInt(const SkColor& color, - int x, int y, int w, int h) OVERRIDE; - virtual void FillRectInt(const SkColor& color, - int x, int y, int w, int h, - SkXfermode::Mode mode) OVERRIDE; - virtual void FillRectInt(const gfx::Brush* brush, - int x, int y, int w, int h) OVERRIDE; + virtual void FillRect(const SkColor& color, const gfx::Rect& rect) OVERRIDE; + virtual void FillRect(const SkColor& color, + const gfx::Rect& rect, + SkXfermode::Mode mode) OVERRIDE; + virtual void FillRect(const gfx::Brush* brush, + const gfx::Rect& rect) OVERRIDE; virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h) OVERRIDE; virtual void DrawRectInt(const SkColor& color, diff --git a/ui/gfx/canvas_direct2d_unittest.cc b/ui/gfx/canvas_direct2d_unittest.cc index 8a6dcec..460599e 100644 --- a/ui/gfx/canvas_direct2d_unittest.cc +++ b/ui/gfx/canvas_direct2d_unittest.cc @@ -183,9 +183,9 @@ TEST(CanvasDirect2D, SaveLayerAlpha) { gfx::CanvasDirect2D canvas(window.rt()); canvas.Save(); - canvas.FillRectInt(SK_ColorBLUE, 20, 20, 100, 100); + canvas.FillRect(SK_ColorBLUE, gfx::Rect(20, 20, 100, 100)); canvas.SaveLayerAlpha(127); - canvas.FillRectInt(SK_ColorRED, 60, 60, 100, 100); + canvas.FillRect(SK_ColorRED, gfx::Rect(60, 60, 100, 100)); canvas.Restore(); canvas.Restore(); } @@ -197,9 +197,9 @@ TEST(CanvasDirect2D, SaveLayerAlphaWithBounds) { gfx::CanvasDirect2D canvas(window.rt()); canvas.Save(); - canvas.FillRectInt(SK_ColorBLUE, 20, 20, 100, 100); + canvas.FillRect(SK_ColorBLUE, gfx::Rect(20, 20, 100, 100)); canvas.SaveLayerAlpha(127, gfx::Rect(60, 60, 50, 50)); - canvas.FillRectInt(SK_ColorRED, 60, 60, 100, 100); + canvas.FillRect(SK_ColorRED, gfx::Rect(60, 60, 100, 100)); canvas.Restore(); canvas.Restore(); } @@ -210,7 +210,7 @@ TEST(CanvasDirect2D, FillRect) { TestWindow window; gfx::CanvasDirect2D canvas(window.rt()); - canvas.FillRectInt(SK_ColorRED, 20, 20, 100, 100); + canvas.FillRect(SK_ColorRED, gfx::Rect(20, 20, 100, 100)); } TEST(CanvasDirect2D, ClipRect) { @@ -219,9 +219,9 @@ TEST(CanvasDirect2D, ClipRect) { TestWindow window; gfx::CanvasDirect2D canvas(window.rt()); - canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); + canvas.FillRect(SK_ColorGREEN, gfx::Rect(0, 0, 500, 500)); canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); - canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); + canvas.FillRect(SK_ColorBLUE, gfx::Rect(0, 0, 500, 500)); } TEST(CanvasDirect2D, ClipRectWithTranslate) { @@ -232,16 +232,16 @@ TEST(CanvasDirect2D, ClipRectWithTranslate) { // Repeat the same rendering as in ClipRect... canvas.Save(); - canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); + canvas.FillRect(SK_ColorGREEN, gfx::Rect(0, 0, 500, 500)); canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); - canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); + canvas.FillRect(SK_ColorBLUE, gfx::Rect(0, 0, 500, 500)); canvas.Restore(); // ... then translate, clip and fill again relative to the new origin. canvas.Save(); canvas.Translate(gfx::Point(150, 150)); canvas.ClipRect(gfx::Rect(10, 10, 110, 110)); - canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); + canvas.FillRect(SK_ColorRED, gfx::Rect(0, 0, 500, 500)); canvas.Restore(); } @@ -253,9 +253,9 @@ TEST(CanvasDirect2D, ClipRectWithScale) { // Repeat the same rendering as in ClipRect... canvas.Save(); - canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); + canvas.FillRect(SK_ColorGREEN, gfx::Rect(0, 0, 500, 500)); canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); - canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); + canvas.FillRect(SK_ColorBLUE, gfx::Rect(0, 0, 500, 500)); canvas.Restore(); // ... then translate and scale, clip and fill again relative to the new @@ -264,7 +264,7 @@ TEST(CanvasDirect2D, ClipRectWithScale) { canvas.Translate(gfx::Point(150, 150)); canvas.Scale(2, 2); canvas.ClipRect(gfx::Rect(10, 10, 110, 110)); - canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); + canvas.FillRect(SK_ColorRED, gfx::Rect(0, 0, 500, 500)); canvas.Restore(); } diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc index 2f822e5..98e4776 100644 --- a/ui/gfx/canvas_skia.cc +++ b/ui/gfx/canvas_skia.cc @@ -122,27 +122,26 @@ void CanvasSkia::Scale(int x_scale, int y_scale) { canvas_->scale(SkIntToScalar(x_scale), SkIntToScalar(y_scale)); } -void CanvasSkia::FillRectInt(const SkColor& color, int x, int y, int w, int h) { - FillRectInt(color, x, y, w, h, SkXfermode::kSrcOver_Mode); +void CanvasSkia::FillRect(const SkColor& color, const gfx::Rect& rect) { + FillRect(color, rect, SkXfermode::kSrcOver_Mode); } -void CanvasSkia::FillRectInt(const SkColor& color, - int x, int y, int w, int h, - SkXfermode::Mode mode) { +void CanvasSkia::FillRect(const SkColor& color, + const gfx::Rect& rect, + SkXfermode::Mode mode) { SkPaint paint; paint.setColor(color); paint.setStyle(SkPaint::kFill_Style); paint.setXfermodeMode(mode); - DrawRectInt(x, y, w, h, paint); + DrawRectInt(rect.x(), rect.y(), rect.width(), rect.height(), paint); } -void CanvasSkia::FillRectInt(const gfx::Brush* brush, - int x, int y, int w, int h) { +void CanvasSkia::FillRect(const gfx::Brush* brush, const gfx::Rect& rect) { const SkiaShader* shader = static_cast<const SkiaShader*>(brush); SkPaint paint; paint.setShader(shader->shader()); // TODO(beng): set shader transform to match canvas transform. - DrawRectInt(x, y, w, h, paint); + DrawRectInt(rect.x(), rect.y(), rect.width(), rect.height(), paint); } void CanvasSkia::DrawRectInt(const SkColor& color, int x, int y, int w, int h) { diff --git a/ui/gfx/canvas_skia.h b/ui/gfx/canvas_skia.h index 045192f..05d4824 100644 --- a/ui/gfx/canvas_skia.h +++ b/ui/gfx/canvas_skia.h @@ -103,13 +103,12 @@ class UI_EXPORT CanvasSkia : public Canvas { virtual bool ClipRect(const gfx::Rect& rect) OVERRIDE; virtual void Translate(const gfx::Point& point) OVERRIDE; virtual void Scale(int x_scale, int y_scale) OVERRIDE; - virtual void FillRectInt(const SkColor& color, - int x, int y, int w, int h) OVERRIDE; - virtual void FillRectInt(const SkColor& color, - int x, int y, int w, int h, - SkXfermode::Mode mode) OVERRIDE; - virtual void FillRectInt(const gfx::Brush* brush, - int x, int y, int w, int h) OVERRIDE; + virtual void FillRect(const SkColor& color, const gfx::Rect& rect) OVERRIDE; + virtual void FillRect(const SkColor& color, + const gfx::Rect& rect, + SkXfermode::Mode mode) OVERRIDE; + virtual void FillRect(const gfx::Brush* brush, + const gfx::Rect& rect) OVERRIDE; virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h) OVERRIDE; virtual void DrawRectInt(const SkColor& color, diff --git a/ui/gfx/canvas_skia_linux.cc b/ui/gfx/canvas_skia_linux.cc index d5c5051..2d47ff2 100644 --- a/ui/gfx/canvas_skia_linux.cc +++ b/ui/gfx/canvas_skia_linux.cc @@ -118,8 +118,8 @@ void DrawStringContext::Draw(const SkColor& text_color) { void DrawStringContext::DrawWithHalo(const SkColor& text_color, const SkColor& halo_color) { gfx::CanvasSkia text_canvas(bounds_.width() + 2, bounds_.height() + 2, false); - text_canvas.FillRectInt(static_cast<SkColor>(0), - 0, 0, bounds_.width() + 2, bounds_.height() + 2); + text_canvas.FillRect(static_cast<SkColor>(0), + gfx::Rect(0, 0, bounds_.width() + 2, bounds_.height() + 2)); { skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas()); diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc index eb66d63..3f7d886 100644 --- a/ui/gfx/compositor/layer_unittest.cc +++ b/ui/gfx/compositor/layer_unittest.cc @@ -129,9 +129,8 @@ class TestLayerDelegate : public LayerDelegate { virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap(); paint_size_ = gfx::Size(contents.width(), contents.height()); - canvas->FillRectInt(colors_.at(color_index_), 0, 0, - contents.width(), - contents.height()); + canvas->FillRect(colors_[color_index_], + gfx::Rect(gfx::Point(), paint_size_)); color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); } virtual void OnLayerAnimationEnded( diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index 503fffc..b6fb359 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -351,7 +351,7 @@ void RenderText::Draw(Canvas* canvas) { for (std::vector<Rect>::const_iterator i = selection.begin(); i < selection.end(); ++i) { Rect r(*i); - canvas->FillRectInt(selection_color, r.x(), r.y(), r.width(), r.height()); + canvas->FillRect(selection_color, r); } // Create a temporary copy of the style ranges for composition and selection. diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc index 561bb6d..b3d3954 100644 --- a/ui/gfx/render_text_win.cc +++ b/ui/gfx/render_text_win.cc @@ -7,9 +7,9 @@ #include "base/logging.h" #include "base/stl_util.h" #include "base/string_util.h" +#include "third_party/skia/include/core/SkTypeface.h" #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia.h" -#include "third_party/skia/include/core/SkTypeface.h" namespace { @@ -577,7 +577,7 @@ void RenderTextWin::DrawSelection(Canvas* canvas) { GetSubstringBounds(GetSelectionStart(), GetCursorPosition())); SkColor color = focused() ? kFocusedSelectionColor : kUnfocusedSelectionColor; for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) - canvas->FillRectInt(color, i->x(), i->y(), i->width(), i->height()); + canvas->FillRect(color, *i); } void RenderTextWin::DrawVisualText(Canvas* canvas) { diff --git a/views/aura_desktop/aura_desktop_main.cc b/views/aura_desktop/aura_desktop_main.cc index d2a37b7..cb59e0b 100644 --- a/views/aura_desktop/aura_desktop_main.cc +++ b/views/aura_desktop/aura_desktop_main.cc @@ -82,7 +82,7 @@ class TestView : public views::View { private: // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) { - canvas->FillRectInt(color_, 0, 0, width(), height()); + canvas->FillRect(color_, GetLocalBounds()); } virtual bool OnMousePressed(const views::MouseEvent& event) { color_shifting_ = true; @@ -114,7 +114,7 @@ class TestWindowContents : public views::WidgetDelegateView { private: // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRectInt(SK_ColorGRAY, 0, 0, width(), height()); + canvas->FillRect(SK_ColorGRAY, GetLocalBounds()); } // Overridden from views::WidgetDelegateView: diff --git a/views/border.cc b/views/border.cc index a05d51c..3f90159 100644 --- a/views/border.cc +++ b/views/border.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -35,15 +35,15 @@ SolidBorder::SolidBorder(int thickness, SkColor color) void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const { // Top border. - canvas->FillRectInt(color_, 0, 0, view.width(), insets_.top()); + canvas->FillRect(color_, gfx::Rect(0, 0, view.width(), insets_.top())); // Left border. - canvas->FillRectInt(color_, 0, 0, insets_.left(), view.height()); + canvas->FillRect(color_, gfx::Rect(0, 0, insets_.left(), view.height())); // Bottom border. - canvas->FillRectInt(color_, 0, view.height() - insets_.bottom(), - view.width(), insets_.bottom()); + canvas->FillRect(color_, gfx::Rect(0, view.height() - insets_.bottom(), + view.width(), insets_.bottom())); // Right border. - canvas->FillRectInt(color_, view.width() - insets_.right(), 0, - insets_.right(), view.height()); + canvas->FillRect(color_, gfx::Rect(view.width() - insets_.right(), 0, + insets_.right(), view.height())); } void SolidBorder::GetInsets(gfx::Insets* insets) const { diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc index 6080167..49b4be5 100644 --- a/views/controls/menu/menu_scroll_view_container.cc +++ b/views/controls/menu/menu_scroll_view_container.cc @@ -99,7 +99,7 @@ class MenuScrollButton : public View { y += config.scroll_arrow_height; } for (int i = 0; i < config.scroll_arrow_height; ++i, --x, y += delta_y) - canvas->FillRectInt(arrow_color, x, y, (i * 2) + 1, 1); + canvas->FillRect(arrow_color, gfx::Rect(x, y, (i * 2) + 1, 1)); } private: diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index a68568d..50cb440 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -357,8 +357,7 @@ void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas, return; gfx::Rect bounds = CalculateDropIndicatorBounds(item, position); - canvas->FillRectInt(kDropIndicatorColor, bounds.x(), bounds.y(), - bounds.width(), bounds.height()); + canvas->FillRect(kDropIndicatorColor, bounds); } void SubmenuView::SchedulePaintForDropIndicator( diff --git a/views/controls/native/native_view_host.cc b/views/controls/native/native_view_host.cc index 728f70c..626b45d 100644 --- a/views/controls/native/native_view_host.cc +++ b/views/controls/native/native_view_host.cc @@ -141,7 +141,7 @@ void NativeViewHost::OnPaint(gfx::Canvas* canvas) { // It would be nice if this used some approximation of the page's // current background color. if (native_wrapper_->HasInstalledClip()) - canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height()); + canvas->FillRect(SK_ColorWHITE, GetLocalBounds()); } void NativeViewHost::VisibilityChanged(View* starting_from, bool is_visible) { diff --git a/views/controls/separator.cc b/views/controls/separator.cc index 8dd0312..7d3d99d 100644 --- a/views/controls/separator.cc +++ b/views/controls/separator.cc @@ -37,7 +37,7 @@ void Separator::GetAccessibleState(ui::AccessibleViewState* state) { } void Separator::Paint(gfx::Canvas* canvas) { - canvas->FillRectInt(kDefaultColor, x(), y(), width(), height()); + canvas->FillRect(kDefaultColor, bounds()); } std::string Separator::GetClassName() const { diff --git a/views/desktop/desktop_background.cc b/views/desktop/desktop_background.cc index 89399e1..e09abe5 100644 --- a/views/desktop/desktop_background.cc +++ b/views/desktop/desktop_background.cc @@ -19,7 +19,7 @@ DesktopBackground::~DesktopBackground() { void DesktopBackground::Paint(gfx::Canvas* canvas, View* view) const { // Paint the sky. - canvas->FillRectInt(SK_ColorCYAN, 0, 0, view->width(), view->width()); + canvas->FillRect(SK_ColorCYAN, view->GetLocalBounds()); SkPaint paint; paint.setAntiAlias(true); diff --git a/views/desktop/desktop_window_view.cc b/views/desktop/desktop_window_view.cc index 65d4801..94fda7d 100644 --- a/views/desktop/desktop_window_view.cc +++ b/views/desktop/desktop_window_view.cc @@ -73,7 +73,7 @@ class TestWindowContentView : public WidgetDelegateView { private: // Overridden from View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRectInt(color_, 0, 0, width(), height()); + canvas->FillRect(color_, GetLocalBounds()); } // Overridden from WindowDelegate: diff --git a/views/examples/native_theme_button_example.cc b/views/examples/native_theme_button_example.cc index f9b8a48..33b5b7d 100644 --- a/views/examples/native_theme_button_example.cc +++ b/views/examples/native_theme_button_example.cc @@ -12,8 +12,8 @@ #include "ui/base/animation/throb_animation.h" #include "ui/base/models/combobox_model.h" #include "ui/gfx/canvas.h" -#include "views/examples/example_combobox_model.h" #include "views/controls/label.h" +#include "views/examples/example_combobox_model.h" #include "views/layout/grid_layout.h" #include "views/native_theme_painter.h" @@ -191,7 +191,7 @@ gfx::Size ExampleNativeThemeButton::GetPreferredSize() { void ExampleNativeThemeButton::OnPaintBackground(gfx::Canvas* canvas) { // Fill the background with a known colour so that we know where the bounds // of the View are. - canvas->FillRectInt(SkColorSetRGB(255, 128, 128), 0, 0, width(), height()); + canvas->FillRect(SkColorSetRGB(255, 128, 128), GetLocalBounds()); CustomButton::OnPaintBackground(canvas); } diff --git a/views/examples/native_widget_views_example.cc b/views/examples/native_widget_views_example.cc index 9569645..11a2f2f 100644 --- a/views/examples/native_widget_views_example.cc +++ b/views/examples/native_widget_views_example.cc @@ -10,8 +10,8 @@ #include "views/examples/example_base.h" #include "views/test/test_views_delegate.h" #include "views/view.h" -#include "views/widget/widget.h" #include "views/widget/native_widget_views.h" +#include "views/widget/widget.h" namespace examples { @@ -33,7 +33,7 @@ class TestContentView : public views::View, // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { SkColor color = click_count_ % 2 == 0 ? SK_ColorGREEN : SK_ColorBLUE; - canvas->FillRectInt(color, 0, 0, width(), height()); + canvas->FillRect(color, GetLocalBounds()); } virtual void Layout() OVERRIDE { button_->SetBounds(10, 10, width() - 20, height() - 20); diff --git a/views/touchui/touch_selection_controller_impl.cc b/views/touchui/touch_selection_controller_impl.cc index 6ce527e..e590216 100644 --- a/views/touchui/touch_selection_controller_impl.cc +++ b/views/touchui/touch_selection_controller_impl.cc @@ -4,8 +4,8 @@ #include "views/touchui/touch_selection_controller_impl.h" -#include "base/utf_string_conversions.h" #include "base/time.h" +#include "base/utf_string_conversions.h" #include "grit/ui_strings.h" #include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/base/l10n/l10n_util.h" @@ -21,8 +21,8 @@ #include "views/controls/button/button.h" #include "views/controls/button/custom_button.h" #include "views/controls/button/text_button.h" -#include "views/controls/menu/menu_config.h" #include "views/controls/label.h" +#include "views/controls/menu/menu_config.h" #include "views/layout/box_layout.h" #include "views/widget/widget.h" @@ -191,15 +191,15 @@ class ContextMenuButtonBackground : public Background { } int w = view->width(); int h = view->height(); - canvas->FillRectInt(background_color, 1, 1, w - 2, h - 2); - canvas->FillRectInt(border_color, 2, 0, w - 4, 1); - canvas->FillRectInt(border_color, 1, 1, 1, 1); - canvas->FillRectInt(border_color, 0, 2, 1, h - 4); - canvas->FillRectInt(border_color, 1, h - 2, 1, 1); - canvas->FillRectInt(border_color, 2, h - 1, w - 4, 1); - canvas->FillRectInt(border_color, w - 2, 1, 1, 1); - canvas->FillRectInt(border_color, w - 1, 2, 1, h - 4); - canvas->FillRectInt(border_color, w - 2, h - 2, 1, 1); + canvas->FillRect(background_color, gfx::Rect(1, 1, w - 2, h - 2)); + canvas->FillRect(border_color, gfx::Rect(2, 0, w - 4, 1)); + canvas->FillRect(border_color, gfx::Rect(1, 1, 1, 1)); + canvas->FillRect(border_color, gfx::Rect(0, 2, 1, h - 4)); + canvas->FillRect(border_color, gfx::Rect(1, h - 2, 1, 1)); + canvas->FillRect(border_color, gfx::Rect(2, h - 1, w - 4, 1)); + canvas->FillRect(border_color, gfx::Rect(w - 2, 1, 1, 1)); + canvas->FillRect(border_color, gfx::Rect(w - 1, 2, 1, h - 4)); + canvas->FillRect(border_color, gfx::Rect(w - 2, h - 2, 1, 1)); } private: diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index 504a087..1b23eed 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -345,18 +345,28 @@ void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { // Fill with the frame color first so we have a constant background for // areas not covered by the theme image. - canvas->FillRectInt(frame_color, 0, 0, width(), frame_image->height()); - // Now fill down the sides. - canvas->FillRectInt(frame_color, 0, frame_image->height(), left_edge->width(), - height() - frame_image->height()); - canvas->FillRectInt(frame_color, width() - right_edge->width(), - frame_image->height(), right_edge->width(), - height() - frame_image->height()); - // Now fill the bottom area. - canvas->FillRectInt(frame_color, - left_edge->width(), height() - bottom_edge->height(), - width() - left_edge->width() - right_edge->width(), - bottom_edge->height()); + canvas->FillRect(frame_color, + gfx::Rect(0, 0, width(), frame_image->height())); + + int remaining_height = height() - frame_image->height(); + if (remaining_height > 0) { + // Now fill down the sides. + canvas->FillRect(frame_color, + gfx::Rect(0, frame_image->height(), left_edge->width(), + remaining_height)); + canvas->FillRect(frame_color, + gfx::Rect(width() - right_edge->width(), + frame_image->height(), right_edge->width(), + remaining_height)); + int center_width = width() - left_edge->width() - right_edge->width(); + if (center_width > 0) { + // Now fill the bottom area. + canvas->FillRect(frame_color, + gfx::Rect(left_edge->width(), + height() - bottom_edge->height(), + center_width, bottom_edge->height())); + } + } // Draw the theme frame. canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height()); diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index 9a75fe2..4320308 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -56,7 +56,7 @@ void UpdateButtonHelper(NativeTextButton* button_view, void FillViewWithSysColor(gfx::Canvas* canvas, View* view, COLORREF color) { SkColor sk_color = SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); - canvas->FillRectInt(sk_color, 0, 0, view->width(), view->height()); + canvas->FillRect(sk_color, view->GetLocalBounds()); } #endif @@ -317,14 +317,13 @@ void DialogClientView::OnPaint(gfx::Canvas* canvas) { FillViewWithSysColor(canvas, this, GetSysColor(COLOR_3DFACE)); #elif defined(USE_WAYLAND) || defined(USE_AURA) SkColor sk_color = SkColorSetARGB(200, 255, 255, 255); - canvas->FillRectInt(sk_color, 0, 0, width(), height()); + canvas->FillRect(sk_color, GetLocalBounds()); #else GtkWidget* widget = GetWidget()->GetNativeView(); if (GTK_IS_WINDOW(widget)) { GtkStyle* window_style = gtk_widget_get_style(widget); - canvas->FillRectInt(gfx::GdkColorToSkColor( - window_style->bg[GTK_STATE_NORMAL]), - 0, 0, width(), height()); + canvas->FillRect(gfx::GdkColorToSkColor(window_style->bg[GTK_STATE_NORMAL]), + GetLocalBounds()); } #endif } |