diff options
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/canvas.h | 14 | ||||
-rw-r--r-- | ui/gfx/canvas_direct2d.cc | 16 | ||||
-rw-r--r-- | ui/gfx/canvas_direct2d.h | 13 | ||||
-rw-r--r-- | ui/gfx/canvas_direct2d_unittest.cc | 26 | ||||
-rw-r--r-- | ui/gfx/canvas_skia.cc | 17 | ||||
-rw-r--r-- | ui/gfx/canvas_skia.h | 13 | ||||
-rw-r--r-- | ui/gfx/canvas_skia_linux.cc | 4 | ||||
-rw-r--r-- | ui/gfx/compositor/layer_unittest.cc | 5 | ||||
-rw-r--r-- | ui/gfx/render_text.cc | 2 | ||||
-rw-r--r-- | ui/gfx/render_text_win.cc | 4 |
10 files changed, 53 insertions, 61 deletions
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) { |