Skip to content

Commit

Permalink
Convert FillRect(... SkPaint) to DrawRect() since it doesn't necessar…
Browse files Browse the repository at this point in the history
…ily fill, it just draws with the provided paint.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3165032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56589 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
pkasting@chromium.org committed Aug 18, 2010
1 parent 4fa172e commit 55a0ffd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/views/tabs/tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) {
SkShader::kClamp_TileMode);
paint.setShader(shader);
shader->unref();
hover_canvas.FillRectInt(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(
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/views/tabs/tab_strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
paint.setStyle(SkPaint::kFill_Style);
canvas->FillRectInt(
0, 0, width(),
canvas->DrawRectInt(0, 0, width(),
height() - 2, // Visible region that overlaps the toolbar.
paint);
}
Expand Down
8 changes: 4 additions & 4 deletions gfx/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ class Canvas {
// See scale() for specifics.
virtual void ScaleInt(int x, int y) = 0;

// Fills the given rectangle with the given paint's parameters.
virtual void FillRectInt(int x, int y, int w, int h,
const SkPaint& paint) = 0;

// Fills the specified region with the specified color using a transfer
// mode of SkXfermode::kSrcOver_Mode.
virtual void FillRectInt(const SkColor& color,
Expand All @@ -125,6 +121,10 @@ class Canvas {
int x, int y, int w, int h,
SkXfermode::Mode mode) = 0;

// Draws the given rectangle with the given paint's parameters.
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,
int x1, int y1,
Expand Down
10 changes: 5 additions & 5 deletions gfx/canvas_direct2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ void CanvasDirect2D::ScaleInt(int x, int y) {
rt_->SetTransform(transform);
}

void CanvasDirect2D::FillRectInt(int x, int y, int w, int h,
const SkPaint& paint) {
NOTIMPLEMENTED();
}

void CanvasDirect2D::FillRectInt(const SkColor& color,
int x, int y, int w, int h) {
ScopedComPtr<ID2D1SolidColorBrush> solid_brush;
Expand All @@ -233,6 +228,11 @@ void CanvasDirect2D::DrawRectInt(const SkColor& color,
NOTIMPLEMENTED();
}

void CanvasDirect2D::DrawRectInt(int x, int y, int w, int h,
const SkPaint& paint) {
NOTIMPLEMENTED();
}

void CanvasDirect2D::DrawLineInt(const SkColor& color,
int x1, int y1,
int x2, int y2) {
Expand Down
2 changes: 1 addition & 1 deletion gfx/canvas_direct2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class CanvasDirect2D : public Canvas {
virtual bool ClipRectInt(int x, int y, int w, int h);
virtual void TranslateInt(int x, int y);
virtual void ScaleInt(int x, int y);
virtual void FillRectInt(int x, int y, int w, int h, const SkPaint& paint);
virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h);
virtual void FillRectInt(const gfx::Brush* brush, int x, int y, int w, int h);
virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h);
virtual void DrawRectInt(const SkColor& color,
int x, int y, int w, int h,
SkXfermode::Mode mode);
virtual void DrawRectInt(int x, int y, int w, int h, const SkPaint& paint);
virtual void DrawLineInt(const SkColor& color,
int x1, int y1,
int x2, int y2);
Expand Down
24 changes: 12 additions & 12 deletions gfx/canvas_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void CanvasSkia::FillRectInt(const SkColor& color, int x, int y, int w, int h) {
paint.setColor(color);
paint.setStyle(SkPaint::kFill_Style);
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
FillRectInt(x, y, w, h, paint);
DrawRectInt(x, y, w, h, paint);
}

void CanvasSkia::FillRectInt(const gfx::Brush* brush,
Expand All @@ -118,12 +118,7 @@ void CanvasSkia::FillRectInt(const gfx::Brush* brush,
SkPaint paint;
paint.setShader(shader->shader());
// TODO(beng): set shader transform to match canvas transform.
FillRectInt(x, y, w, h, paint);
}

void CanvasSkia::FillRectInt(int x, int y, int w, int h, const SkPaint& paint) {
SkIRect rc = {x, y, x + w, y + h};
drawIRect(rc, paint);
DrawRectInt(x, y, w, h, paint);
}

void CanvasSkia::DrawRectInt(const SkColor& color, int x, int y, int w, int h) {
Expand All @@ -142,7 +137,12 @@ void CanvasSkia::DrawRectInt(const SkColor& color,
paint.setStrokeWidth(SkIntToScalar(0));
paint.setXfermodeMode(mode);

FillRectInt(x, y, w, h, paint);
DrawRectInt(x, y, w, h, paint);
}

void CanvasSkia::DrawRectInt(int x, int y, int w, int h, const SkPaint& paint) {
SkIRect rc = { x, y, x + w, y + h };
drawIRect(rc, paint);
}

void CanvasSkia::DrawLineInt(const SkColor& color,
Expand Down Expand Up @@ -193,10 +193,10 @@ void CanvasSkia::DrawFocusRect(int x, int y, int width, int height) {
paint.setShader(shader);
shader->unref();

FillRectInt(x, y, width, 1, paint);
FillRectInt(x, y + height - 1, width, 1, paint);
FillRectInt(x, y, 1, height, paint);
FillRectInt(x + width - 1, y, 1, height, paint);
DrawRectInt(x, y, width, 1, paint);
DrawRectInt(x, y + height - 1, width, 1, paint);
DrawRectInt(x, y, 1, height, paint);
DrawRectInt(x + width - 1, y, 1, height, paint);
}

void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap, int x, int y) {
Expand Down
2 changes: 1 addition & 1 deletion gfx/canvas_skia.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ class CanvasSkia : public skia::PlatformCanvas,
virtual bool ClipRectInt(int x, int y, int w, int h);
virtual void TranslateInt(int x, int y);
virtual void ScaleInt(int x, int y);
virtual void FillRectInt(int x, int y, int w, int h, const SkPaint& paint);
virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h);
virtual void FillRectInt(const gfx::Brush* brush, int x, int y, int w, int h);
virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h);
virtual void DrawRectInt(const SkColor& color,
int x, int y, int w, int h,
SkXfermode::Mode mode);
virtual void DrawRectInt(int x, int y, int w, int h, const SkPaint& paint);
virtual void DrawLineInt(const SkColor& color,
int x1, int y1,
int x2, int y2);
Expand Down
5 changes: 3 additions & 2 deletions gfx/canvas_skia_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ void CanvasSkia::DrawStringInt(const std::wstring& text,
// pixel against both the halo color and transparent since DrawStringWithHalo
// will modify the bitmap as it goes, and clears pixels shouldn't count as
// changed.
static bool pixelShouldGetHalo(const SkBitmap& bitmap, int x, int y,
static bool pixelShouldGetHalo(const SkBitmap& bitmap,
int x, int y,
SkColor halo_color) {
if (x > 0 &&
*bitmap.getAddr32(x - 1, y) != halo_color &&
Expand Down Expand Up @@ -263,7 +264,7 @@ void CanvasSkia::DrawStringWithHalo(const std::wstring& text,
CanvasSkia text_canvas(w + 2, h + 2, true);
SkPaint bkgnd_paint;
bkgnd_paint.setColor(halo_color);
text_canvas.FillRectInt(0, 0, w + 2, h + 2, 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.
Expand Down
2 changes: 1 addition & 1 deletion views/controls/menu/menu_scroll_view_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void MenuScrollViewContainer::PaintBackground(gfx::Canvas* canvas) {
paint.setStyle(SkPaint::kFill_Style);
paint.setXfermodeMode(SkXfermode::kSrc_Mode);

canvas->FillRectInt(0, 0, width(), height(), paint);
canvas->DrawRectInt(0, 0, width(), height(), paint);
#else
// This is the same as COLOR_TOOLBAR.
canvas->AsCanvasSkia()->drawColor(SkColorSetRGB(210, 225, 246),
Expand Down

0 comments on commit 55a0ffd

Please sign in to comment.