diff options
author | tomhudson <tomhudson@google.com> | 2016-01-28 06:14:22 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-28 14:15:18 +0000 |
commit | ed673bebe493d773cd858a00bcc609db9bc93079 (patch) | |
tree | d780e2e7bc035f68b65cd4001fd6869dc90a60fb /skia | |
parent | cd77a9c86c77724b967b611f9554c5a52d27ebf0 (diff) | |
download | chromium_src-ed673bebe493d773cd858a00bcc609db9bc93079.zip chromium_src-ed673bebe493d773cd858a00bcc609db9bc93079.tar.gz chromium_src-ed673bebe493d773cd858a00bcc609db9bc93079.tar.bz2 |
skia::PlatformCanvas is an alias for SkCanvas; this is unhelpful. It's quite common for functions to be declared as returning SkCanvas* but defined as returning skia::PlatformCanvas*, so it's also not future-proof.
R=fmalita@chromium.org,reed@chromium.org
TBR=danakj@chromium.org,piman@chromium.org,thestig@chromium.org
Review URL: https://codereview.chromium.org/1618703006
Cr-Commit-Position: refs/heads/master@{#372084}
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/platform_canvas.h | 8 | ||||
-rw-r--r-- | skia/ext/platform_canvas_unittest.cc | 23 |
2 files changed, 17 insertions, 14 deletions
diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h index 89b8c32..5b8849b 100644 --- a/skia/ext/platform_canvas.h +++ b/skia/ext/platform_canvas.h @@ -20,9 +20,11 @@ class SkBaseDevice; -namespace skia { +// A PlatformCanvas is a software-rasterized SkCanvas which is *also* +// addressable by the platform-specific drawing API (GDI, Core Graphics, +// Cairo...). -typedef SkCanvas PlatformCanvas; +namespace skia { // // Note about error handling. @@ -51,7 +53,7 @@ enum OnFailureType { OnFailureType failure_type); // Draws the top layer of the canvas into the specified HDC. Only works - // with a PlatformCanvas with a BitmapPlatformDevice. + // with a SkCanvas with a BitmapPlatformDevice. SK_API void DrawToNativeContext(SkCanvas* canvas, HDC hdc, int x, diff --git a/skia/ext/platform_canvas_unittest.cc b/skia/ext/platform_canvas_unittest.cc index 57b37f8..e0f8981 100644 --- a/skia/ext/platform_canvas_unittest.cc +++ b/skia/ext/platform_canvas_unittest.cc @@ -14,6 +14,7 @@ #include "skia/ext/platform_device.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkPixelRef.h" @@ -41,10 +42,10 @@ bool IsOfColor(const SkBitmap& bitmap, int x, int y, uint32_t color) { // rectangle filled to rect_color. This function ignores the alpha channel, // since Windows will sometimes clear the alpha channel when drawing, and we // will fix that up later in cases it's necessary. -bool VerifyRect(const PlatformCanvas& canvas, +bool VerifyRect(const SkCanvas& canvas, uint32_t canvas_color, uint32_t rect_color, int x, int y, int w, int h) { - const SkBitmap bitmap = skia::ReadPixels(const_cast<PlatformCanvas*>(&canvas)); + const SkBitmap bitmap = skia::ReadPixels(const_cast<SkCanvas*>(&canvas)); SkAutoLockPixels lock(bitmap); for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { @@ -68,7 +69,7 @@ bool VerifyRect(const PlatformCanvas& canvas, // Return true if canvas has something that passes for a rounded-corner // rectangle. Basically, we're just checking to make sure that the pixels in the // middle are of rect_color and pixels in the corners are of canvas_color. -bool VerifyRoundedRect(const PlatformCanvas& canvas, +bool VerifyRoundedRect(const SkCanvas& canvas, uint32_t canvas_color, uint32_t rect_color, int x, @@ -97,19 +98,19 @@ bool VerifyRoundedRect(const PlatformCanvas& canvas, // Checks whether there is a white canvas with a black square at the given // location in pixels (not in the canvas coordinate system). -bool VerifyBlackRect(const PlatformCanvas& canvas, int x, int y, int w, int h) { +bool VerifyBlackRect(const SkCanvas& canvas, int x, int y, int w, int h) { return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h); } #if !defined(USE_AURA) // http://crbug.com/154358 // Check that every pixel in the canvas is a single color. -bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) { +bool VerifyCanvasColor(const SkCanvas& canvas, uint32_t canvas_color) { return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0); } #endif // !defined(USE_AURA) #if defined(OS_WIN) -void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { +void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { skia::ScopedPlatformPaint scoped_platform_paint(&canvas); HDC dc = scoped_platform_paint.GetPlatformSurface(); @@ -121,7 +122,7 @@ void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); } #elif defined(OS_MACOSX) -void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { +void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { skia::ScopedPlatformPaint scoped_platform_paint(&canvas); CGContextRef context = scoped_platform_paint.GetPlatformSurface(); @@ -133,14 +134,14 @@ void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { CGContextFillRect(context, inner_rc); } #else -void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { +void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { NOTIMPLEMENTED(); } #endif // Clips the contents of the canvas to the given rectangle. This will be // intersected with any existing clip. -void AddClip(PlatformCanvas& canvas, int x, int y, int w, int h) { +void AddClip(SkCanvas& canvas, int x, int y, int w, int h) { SkRect rect; rect.set(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), SkIntToScalar(y + h)); @@ -149,7 +150,7 @@ void AddClip(PlatformCanvas& canvas, int x, int y, int w, int h) { class LayerSaver { public: - LayerSaver(PlatformCanvas& canvas, int x, int y, int w, int h) + LayerSaver(SkCanvas& canvas, int x, int y, int w, int h) : canvas_(canvas), x_(x), y_(y), @@ -176,7 +177,7 @@ class LayerSaver { int bottom() const { return y_ + h_; } private: - PlatformCanvas& canvas_; + SkCanvas& canvas_; int x_, y_, w_, h_; }; |