summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 16:15:56 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 16:15:56 +0000
commita64691f2882ea7403dc2fcd39f026583e12429fe (patch)
treec63315d6994d84cf4a37ba45df02150cc07634a6 /chrome/common
parenta2c5a9894846449c6ab3180339557af293975b9a (diff)
downloadchromium_src-a64691f2882ea7403dc2fcd39f026583e12429fe.zip
chromium_src-a64691f2882ea7403dc2fcd39f026583e12429fe.tar.gz
chromium_src-a64691f2882ea7403dc2fcd39f026583e12429fe.tar.bz2
Fix a problem with DrawRectInt at the edges of a ChromeCanvas.
It seems there used to be an old bug in Skia, and we explicitly set a stroke width of 1 instead of 0 to work around it. Internally in Skia this goes down a more complex path, creating a path from the rect, and then filling the path. This was causing problems at the edges of the canvas, for example if you were to DrawRectInt(0, 0, width - 1, height - 1). Switch some SkRects to SkIRects. Internally Skia will still convert them to scalars, but it makes our code a bit cleaner. Review URL: http://codereview.chromium.org/62099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gfx/chrome_canvas.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/chrome/common/gfx/chrome_canvas.cc b/chrome/common/gfx/chrome_canvas.cc
index 647983e..ce9354f 100644
--- a/chrome/common/gfx/chrome_canvas.cc
+++ b/chrome/common/gfx/chrome_canvas.cc
@@ -58,9 +58,8 @@ void ChromeCanvas::FillRectInt(const SkColor& color,
void ChromeCanvas::FillRectInt(int x, int y, int w, int h,
const SkPaint& paint) {
- SkRect rc = {SkIntToScalar(x), SkIntToScalar(y),
- SkIntToScalar(x + w), SkIntToScalar(y + h) };
- drawRect(rc, paint);
+ SkIRect rc = {x, y, x + w, y + h};
+ drawIRect(rc, paint);
}
void ChromeCanvas::DrawRectInt(const SkColor& color,
@@ -68,18 +67,20 @@ void ChromeCanvas::DrawRectInt(const SkColor& color,
DrawRectInt(color, x, y, w, h, SkPorterDuff::kSrcOver_Mode);
}
-void ChromeCanvas::DrawRectInt(const SkColor& color, int x, int y, int w, int h,
+void ChromeCanvas::DrawRectInt(const SkColor& color,
+ int x, int y, int w, int h,
SkPorterDuff::Mode mode) {
SkPaint paint;
paint.setColor(color);
paint.setStyle(SkPaint::kStroke_Style);
- // Contrary to the docs, a width of 0 results in nothing.
- paint.setStrokeWidth(SkIntToScalar(1));
+ // Set a stroke width of 0, which will put us down the stroke rect path. If
+ // we set a stroke width of 1, for example, this will internally create a
+ // path and fill it, which causes problems near the edge of the canvas.
+ paint.setStrokeWidth(SkIntToScalar(0));
paint.setPorterDuffXfermode(mode);
- SkRect rc = {SkIntToScalar(x), SkIntToScalar(y),
- SkIntToScalar(x + w), SkIntToScalar(y + h) };
- drawRect(rc, paint);
+ SkIRect rc = {x, y, x + w, y + h};
+ drawIRect(rc, paint);
}
void ChromeCanvas::DrawFocusRect(int x, int y, int width, int height) {