summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 06:41:09 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 06:41:09 +0000
commit1219d90f11ee6196c9b9b94f140c86437dad8d88 (patch)
tree61b28fa48c50ef661dc369b785021506a0cf58a1 /ui
parentce528ee99aadb239b6cb44a72269e07bdc9fc2d0 (diff)
downloadchromium_src-1219d90f11ee6196c9b9b94f140c86437dad8d88.zip
chromium_src-1219d90f11ee6196c9b9b94f140c86437dad8d88.tar.gz
chromium_src-1219d90f11ee6196c9b9b94f140c86437dad8d88.tar.bz2
Revert 111288 - Possibly broke media_unittests on Mac
ui/gfx: Convert Canvas::DrawRectInt() to use gfx::Rect. BUG=100898 R=pkasting@chromium.org Review URL: http://codereview.chromium.org/8476019 TBR=tfarina@chromium.org Review URL: http://codereview.chromium.org/8681001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/canvas.h12
-rw-r--r--ui/gfx/canvas_skia.cc31
-rw-r--r--ui/gfx/canvas_skia.h12
-rw-r--r--ui/gfx/canvas_skia_win.cc8
-rw-r--r--ui/gfx/render_text.cc4
-rw-r--r--ui/gfx/render_text_linux.cc7
-rw-r--r--ui/gfx/render_text_win.cc6
-rw-r--r--ui/gfx/skia_util.cc5
-rw-r--r--ui/gfx/skia_util.h1
-rw-r--r--ui/views/touchui/touch_selection_controller_impl.cc2
-rw-r--r--ui/views/window/custom_frame_view.cc7
11 files changed, 49 insertions, 46 deletions
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() {