diff options
-rw-r--r-- | chrome/browser/ui/gtk/gtk_theme_service.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc | 12 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/tab.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/tab_strip.cc | 5 | ||||
-rw-r--r-- | ui/gfx/canvas.h | 12 | ||||
-rw-r--r-- | ui/gfx/canvas_skia.cc | 31 | ||||
-rw-r--r-- | ui/gfx/canvas_skia.h | 12 | ||||
-rw-r--r-- | ui/gfx/canvas_skia_win.cc | 8 | ||||
-rw-r--r-- | ui/gfx/render_text.cc | 4 | ||||
-rw-r--r-- | ui/gfx/render_text_linux.cc | 7 | ||||
-rw-r--r-- | ui/gfx/render_text_win.cc | 6 | ||||
-rw-r--r-- | ui/gfx/skia_util.cc | 5 | ||||
-rw-r--r-- | ui/gfx/skia_util.h | 1 | ||||
-rw-r--r-- | ui/views/touchui/touch_selection_controller_impl.cc | 2 | ||||
-rw-r--r-- | ui/views/window/custom_frame_view.cc | 7 |
16 files changed, 71 insertions, 65 deletions
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index 144a104..567e48f 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service.cc @@ -1072,10 +1072,11 @@ SkBitmap* GtkThemeService::GenerateFrameImage( paint.setShader(shader); shader->unref(); - canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); + canvas.DrawRectInt(0, 0, kToolbarImageWidth, gradient_size, paint); } - canvas.FillRect(base, gfx::Rect(0, gradient_size, kToolbarImageWidth, + canvas.FillRect(base, gfx::Rect(0, gradient_size, + kToolbarImageWidth, kToolbarImageHeight - gradient_size)); return new SkBitmap(canvas.ExtractBitmap()); } 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 d1e3dbb..c13f68f 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc @@ -173,12 +173,14 @@ class AutocompletePopupContentsView::InstantOptInView } virtual void OnPaint(gfx::Canvas* canvas) { - gfx::Rect paint_rect(GetLocalBounds()); - paint_rect.Inset(kOptInBackgroundHInset, kOptInBackgroundVInset); canvas->Save(); - canvas->Translate(paint_rect.origin()); - bg_painter_->Paint(paint_rect.width(), paint_rect.height(), canvas); - canvas->DrawRect(paint_rect, ResourceBundle::toolbar_separator_color); + canvas->Translate(gfx::Point(kOptInBackgroundHInset, + kOptInBackgroundVInset)); + bg_painter_->Paint(width() - kOptInBackgroundHInset * 2, + height() - kOptInBackgroundVInset * 2, canvas); + canvas->DrawRectInt(ResourceBundle::toolbar_separator_color, 0, 0, + width() - kOptInBackgroundHInset * 2, + height() - kOptInBackgroundVInset * 2); canvas->Restore(); } 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 74a6219..68757de 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 @@ -450,11 +450,11 @@ void AppPanelBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { client_area_top, left->width(), client_area_height); // Draw the toolbar color to fill in the edges. - canvas->DrawRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, - client_area_top - kClientEdgeThickness, - client_area_bounds.width() + kClientEdgeThickness, - client_area_bottom - client_area_top + kClientEdgeThickness), - ui::ResourceBundle::toolbar_color); + canvas->DrawRectInt(ResourceBundle::toolbar_color, + client_area_bounds.x() - kClientEdgeThickness, + client_area_top - kClientEdgeThickness, + client_area_bounds.width() + kClientEdgeThickness, + client_area_bottom - client_area_top + kClientEdgeThickness); } void AppPanelBrowserFrameView::LayoutWindowControls() { diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index ae088ac..f5f244c 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -397,8 +397,7 @@ void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { SkShader::kClamp_TileMode); paint.setShader(shader); shader->unref(); - hover_canvas.DrawRect(gfx::Rect(x - radius, -radius, radius * 2, radius * 2), - paint); + hover_canvas.DrawRectInt(x - radius, -radius, radius * 2, radius * 2, paint); // Draw the radial gradient clipped to the background into hover_image. SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap( @@ -578,9 +577,9 @@ SkBitmap Tab::DrawHoverGlowBitmap(int width_input, int height_input) { if (shader) { paint.setShader(shader); shader->unref(); - gfx::Rect paint_rect(hover_point_, gfx::Size()); - paint_rect.Inset(-radius, -radius); - hover_canvas.DrawRect(paint_rect, paint); + hover_canvas.DrawRectInt(hover_point_.x() - radius, + hover_point_.y() - radius, + radius * 2, radius * 2, paint); } return hover_canvas.ExtractBitmap(); } diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 1ec7fbf..457e892 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -334,8 +334,9 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) { multiple_tabs_selected ? 150 : 200, 255, 255, 255)); paint.setXfermodeMode(SkXfermode::kDstIn_Mode); paint.setStyle(SkPaint::kFill_Style); - // The tabstrip area overlaps the toolbar area by 2 px. - canvas->DrawRect(gfx::Rect(0, 0, width(), height() - 2), paint); + canvas->DrawRectInt(0, 0, width(), + height() - 2, // Visible region that overlaps the toolbar. + paint); } // Now selected but not active. We don't want these dimmed if using native diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h index 7942a93..9615957 100644 --- a/ui/gfx/canvas.h +++ b/ui/gfx/canvas.h @@ -122,18 +122,20 @@ class UI_EXPORT Canvas { // color, using a transfer mode of SkXfermode::kSrcOver_Mode. // // NOTE: if you need a single pixel line, use DrawLineInt. - virtual void DrawRect(const gfx::Rect& rect, const SkColor& color) = 0; + virtual void DrawRectInt(const SkColor& color, + int x, int y, int w, int h) = 0; // Draws a single pixel rect in the specified region with the specified // color and transfer mode. // // NOTE: if you need a single pixel line, use DrawLineInt. - virtual void DrawRect(const gfx::Rect& rect, - const SkColor& color, - SkXfermode::Mode mode) = 0; + virtual void DrawRectInt(const SkColor& color, + int x, int y, int w, int h, + SkXfermode::Mode mode) = 0; // Draws the given rectangle with the given paint's parameters. - virtual void DrawRect(const gfx::Rect& rect, const SkPaint& paint) = 0; + virtual void DrawRectInt(int x, int y, int w, int h, + const SkPaint& paint) = 0; // Draws a single pixel line with the specified color. virtual void DrawLineInt(const SkColor& color, diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc index d7c0c0a..4a7c7fc 100644 --- a/ui/gfx/canvas_skia.cc +++ b/ui/gfx/canvas_skia.cc @@ -133,7 +133,7 @@ void CanvasSkia::FillRect(const SkColor& color, paint.setColor(color); paint.setStyle(SkPaint::kFill_Style); paint.setXfermodeMode(mode); - DrawRect(rect, paint); + DrawRectInt(rect.x(), rect.y(), rect.width(), rect.height(), paint); } void CanvasSkia::FillRect(const gfx::Brush* brush, const gfx::Rect& rect) { @@ -141,16 +141,16 @@ void CanvasSkia::FillRect(const gfx::Brush* brush, const gfx::Rect& rect) { SkPaint paint; paint.setShader(shader->shader()); // TODO(beng): set shader transform to match canvas transform. - DrawRect(rect, paint); + DrawRectInt(rect.x(), rect.y(), rect.width(), rect.height(), paint); } -void CanvasSkia::DrawRect(const gfx::Rect& rect, const SkColor& color) { - DrawRect(rect, color, SkXfermode::kSrcOver_Mode); +void CanvasSkia::DrawRectInt(const SkColor& color, int x, int y, int w, int h) { + DrawRectInt(color, x, y, w, h, SkXfermode::kSrcOver_Mode); } -void CanvasSkia::DrawRect(const gfx::Rect& rect, - const SkColor& color, - SkXfermode::Mode mode) { +void CanvasSkia::DrawRectInt(const SkColor& color, + int x, int y, int w, int h, + SkXfermode::Mode mode) { SkPaint paint; paint.setColor(color); paint.setStyle(SkPaint::kStroke_Style); @@ -160,11 +160,12 @@ void CanvasSkia::DrawRect(const gfx::Rect& rect, paint.setStrokeWidth(SkIntToScalar(0)); paint.setXfermodeMode(mode); - DrawRect(rect, paint); + DrawRectInt(x, y, w, h, paint); } -void CanvasSkia::DrawRect(const gfx::Rect& rect, const SkPaint& paint) { - canvas_->drawIRect(RectToSkIRect(rect), paint); +void CanvasSkia::DrawRectInt(int x, int y, int w, int h, const SkPaint& paint) { + SkIRect rc = { x, y, x + w, y + h }; + canvas_->drawIRect(rc, paint); } void CanvasSkia::DrawLineInt(const SkColor& color, @@ -213,12 +214,10 @@ void CanvasSkia::DrawFocusRect(const gfx::Rect& rect) { paint.setShader(shader); shader->unref(); - DrawRect(gfx::Rect(rect.x(), rect.y(), rect.width(), 1), paint); - DrawRect(gfx::Rect(rect.x(), rect.y() + rect.height() - 1, rect.width(), 1), - paint); - DrawRect(gfx::Rect(rect.x(), rect.y(), 1, rect.height()), paint); - DrawRect(gfx::Rect(rect.x() + rect.width() - 1, rect.y(), 1, rect.height()), - paint); + DrawRectInt(rect.x(), rect.y(), rect.width(), 1, paint); + DrawRectInt(rect.x(), rect.y() + rect.height() - 1, rect.width(), 1, paint); + DrawRectInt(rect.x(), rect.y(), 1, rect.height(), paint); + DrawRectInt(rect.x() + rect.width() - 1, rect.y(), 1, rect.height(), paint); } void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap, int x, int y) { diff --git a/ui/gfx/canvas_skia.h b/ui/gfx/canvas_skia.h index ac49010..05d4824 100644 --- a/ui/gfx/canvas_skia.h +++ b/ui/gfx/canvas_skia.h @@ -109,11 +109,13 @@ class UI_EXPORT CanvasSkia : public Canvas { SkXfermode::Mode mode) OVERRIDE; virtual void FillRect(const gfx::Brush* brush, const gfx::Rect& rect) OVERRIDE; - virtual void DrawRect(const gfx::Rect& rect, const SkColor& color) OVERRIDE; - virtual void DrawRect(const gfx::Rect& rect, - const SkColor& color, - SkXfermode::Mode mode) OVERRIDE; - virtual void DrawRect(const gfx::Rect& rect, const SkPaint& paint) OVERRIDE; + virtual void DrawRectInt(const SkColor& color, + int x, int y, int w, int h) OVERRIDE; + virtual void DrawRectInt(const SkColor& color, + int x, int y, int w, int h, + SkXfermode::Mode mode) OVERRIDE; + virtual void DrawRectInt(int x, int y, int w, int h, + const SkPaint& paint) OVERRIDE; virtual void DrawLineInt(const SkColor& color, int x1, int y1, int x2, int y2) OVERRIDE; diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc index 119a593..1c45368 100644 --- a/ui/gfx/canvas_skia_win.cc +++ b/ui/gfx/canvas_skia_win.cc @@ -415,11 +415,10 @@ void CanvasSkia::DrawStringWithHalo(const string16& text, // Create a temporary buffer filled with the halo color. It must leave room // for the 1-pixel border around the text. - gfx::Rect rect(gfx::Point(), gfx::Size(w + 2, h + 2)); - CanvasSkia text_canvas(rect.width(), rect.height(), true); + CanvasSkia text_canvas(w + 2, h + 2, true); SkPaint bkgnd_paint; bkgnd_paint.setColor(halo_color); - text_canvas.DrawRect(rect, bkgnd_paint); + text_canvas.DrawRectInt(0, 0, w + 2, h + 2, bkgnd_paint); // Draw the text into the temporary buffer. This will have correct // ClearType since the background color is the same as the halo color. @@ -429,8 +428,7 @@ void CanvasSkia::DrawStringWithHalo(const string16& text, // opaque. We have to do this first since pixelShouldGetHalo will check for // 0 to see if a pixel has been modified to transparent, and black text that // Windows draw will look transparent to it! - skia::MakeOpaque(text_canvas.sk_canvas(), rect.x(), rect.y(), rect.width(), - rect.height()); + skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, w + 2, h + 2); uint32_t halo_premul = SkPreMultiplyColor(halo_color); SkBitmap& text_bitmap = const_cast<SkBitmap&>( diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index 73ff1c1..c3d9b6f 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -391,8 +391,10 @@ void RenderText::Draw(Canvas* canvas) { } // Paint cursor. Replace cursor is drawn as rectangle for now. + Rect cursor(GetUpdatedCursorBounds()); if (cursor_visible() && focused()) - canvas->DrawRect(GetUpdatedCursorBounds(), kCursorColor); + canvas->DrawRectInt(kCursorColor, cursor.x(), cursor.y(), + cursor.width(), cursor.height()); } SelectionModel RenderText::FindCursorPosition(const Point& point) { diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc index 85f8ea1..ab6e725 100644 --- a/ui/gfx/render_text_linux.cc +++ b/ui/gfx/render_text_linux.cc @@ -89,8 +89,13 @@ void RenderTextLinux::Draw(Canvas* canvas) { cairo_restore(cr); // Paint cursor. + bounds = GetUpdatedCursorBounds(); if (cursor_visible() && focused()) - canvas->DrawRect(GetUpdatedCursorBounds(), kCursorColor); + canvas->DrawRectInt(kCursorColor, + bounds.x(), + bounds.y(), + bounds.width(), + bounds.height()); } SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc index 7486835..b2b1b16 100644 --- a/ui/gfx/render_text_win.cc +++ b/ui/gfx/render_text_win.cc @@ -730,8 +730,10 @@ void RenderTextWin::DrawVisualText(Canvas* canvas) { void RenderTextWin::DrawCursor(Canvas* canvas) { // Paint cursor. Replace cursor is drawn as rectangle for now. // TODO(msw): Draw a better cursor with a better indication of association. - if (cursor_visible() && focused()) - canvas->DrawRect(GetUpdatedCursorBounds(), kCursorColor); + if (cursor_visible() && focused()) { + Rect r(GetUpdatedCursorBounds()); + canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); + } } RenderText* RenderText::CreateRenderText() { diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc index 320fd6b..b0f3bd1 100644 --- a/ui/gfx/skia_util.cc +++ b/ui/gfx/skia_util.cc @@ -20,11 +20,6 @@ SkRect RectToSkRect(const gfx::Rect& rect) { return r; } -SkIRect RectToSkIRect(const gfx::Rect& rect) { - SkIRect r = { rect.x(), rect.y(), rect.right(), rect.bottom() }; - return r; -} - gfx::Rect SkRectToRect(const SkRect& rect) { return gfx::Rect(static_cast<int>(rect.fLeft), static_cast<int>(rect.fTop), diff --git a/ui/gfx/skia_util.h b/ui/gfx/skia_util.h index de7b8f4..a9312ef 100644 --- a/ui/gfx/skia_util.h +++ b/ui/gfx/skia_util.h @@ -22,7 +22,6 @@ class Rect; // Convert between Skia and gfx rect types. UI_EXPORT SkRect RectToSkRect(const gfx::Rect& rect); -UI_EXPORT SkIRect RectToSkIRect(const gfx::Rect& rect); UI_EXPORT gfx::Rect SkRectToRect(const SkRect& rect); // Creates a vertical gradient shader. The caller owns the shader. diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc index b18a9d8..d297fa7 100644 --- a/ui/views/touchui/touch_selection_controller_impl.cc +++ b/ui/views/touchui/touch_selection_controller_impl.cc @@ -276,7 +276,7 @@ class TouchSelectionControllerImpl::TouchContextMenuView paint.setStyle(SkPaint::kFill_Style); paint.setXfermodeMode(SkXfermode::kSrc_Mode); - canvas->DrawRect(GetLocalBounds(), paint); + canvas->DrawRectInt(0, 0, width(), height(), paint); #else // This is the same as COLOR_TOOLBAR. canvas->GetSkCanvas()->drawColor(SkColorSetRGB(210, 225, 246), diff --git a/ui/views/window/custom_frame_view.cc b/ui/views/window/custom_frame_view.cc index 6c56db1..fae0d2f 100644 --- a/ui/views/window/custom_frame_view.cc +++ b/ui/views/window/custom_frame_view.cc @@ -484,10 +484,9 @@ void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { client_area_top, left->width(), client_area_height); // Draw the toolbar color to fill in the edges. - canvas->DrawRect(gfx::Rect(client_area_bounds.x() - 1, client_area_top - 1, - client_area_bounds.width() + 1, - client_area_bottom - client_area_top + 1), - ui::ResourceBundle::toolbar_color); + canvas->DrawRectInt(ResourceBundle::toolbar_color, + client_area_bounds.x() - 1, client_area_top - 1, + client_area_bounds.width() + 1, client_area_bottom - client_area_top + 1); } void CustomFrameView::LayoutWindowControls() { |