Index: gm/aaclip.cpp |
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp |
index ec29a4f896f324a87d3f8d7e9b825d6210b17885..537da07386d3b75818cb3951244976ebf0c9eed5 100644 |
--- a/gm/aaclip.cpp |
+++ b/gm/aaclip.cpp |
@@ -8,6 +8,7 @@ |
#include "gm.h" |
#include "SkCanvas.h" |
#include "SkPath.h" |
+#include "SkSurface.h" |
static void test_quadstroke(SkCanvas* canvas) { |
SkPath path; |
@@ -122,27 +123,28 @@ static void test_grad(SkCanvas* canvas) { |
canvas->drawPaint(p); |
} |
-static SkCanvas* MakeCanvas(const SkIRect& bounds) { |
- SkBitmap bm; |
- bm.allocN32Pixels(bounds.width(), bounds.height()); |
- bm.eraseColor(SK_ColorTRANSPARENT); |
- |
- SkCanvas* canvas = new SkCanvas(bm); |
- canvas->translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
- return canvas; |
+static SkSurface* MakeSurface(const SkIRect& bounds) { |
+ SkImageInfo info = SkImageInfo::MakeN32Premul(bounds.width(), |
+ bounds.height()); |
+ SkSurface* surface = SkSurface::NewRaster(info); |
+ surface->getCanvas()->clear(0); |
+ surface->getCanvas()->translate(-SkIntToScalar(bounds.fLeft), |
+ -SkIntToScalar(bounds.fTop)); |
+ return surface; |
} |
+static void compare(SkSurface* a, SkSurface* b) { |
#ifdef SK_DEBUG |
-static void GetBitmap(const SkCanvas* canvas, SkBitmap* bm) { |
- *bm = canvas->getDevice()->accessBitmap(false); |
-} |
-#endif |
+ SkImageInfo infoa, infob; |
+ size_t rowBytesa, rowBytesb; |
+ |
+ const void* pa = a->peekPixels(&infoa, &rowBytesa); |
+ const void* pb = b->peekPixels(&infob, &rowBytesb); |
+ SkASSERT(pa && pb); |
-static void compare_canvas(const SkCanvas* a, const SkCanvas* b) { |
-#ifdef SK_DEBUG |
SkBitmap bma, bmb; |
- GetBitmap(a, &bma); |
- GetBitmap(b, &bmb); |
+ bma.installPixels(infoa, const_cast<void*>(pa), rowBytesa, NULL, NULL); |
+ bmb.installPixels(infob, const_cast<void*>(pb), rowBytesb, NULL, NULL); |
SkASSERT(bma.width() == bmb.width()); |
SkASSERT(bma.height() == bmb.height()); |
@@ -175,13 +177,13 @@ static void test_maskFromPath(const SkPath& path) { |
SkPaint paint; |
paint.setAntiAlias(true); |
- SkAutoTUnref<SkCanvas> path_canvas(MakeCanvas(bounds)); |
- path_canvas->drawPath(path, paint); |
+ SkAutoTUnref<SkSurface> path_surface(MakeSurface(bounds)); |
+ path_surface->getCanvas()->drawPath(path, paint); |
- SkAutoTUnref<SkCanvas> rect_canvas(MakeCanvas(bounds)); |
- drawRectAsPath(rect_canvas, path.getBounds(), paint); |
+ SkAutoTUnref<SkSurface> rect_surface(MakeSurface(bounds)); |
+ drawRectAsPath(rect_surface->getCanvas(), path.getBounds(), paint); |
- compare_canvas(path_canvas, rect_canvas); |
+ compare(path_surface, rect_surface); |
} |
static void test_mask() { |
@@ -285,7 +287,7 @@ protected: |
if (false) { |
test_grad(canvas); return; |
} |
- if (false) { // avoid bit rot, suppress warning |
+ if (true) { // avoid bit rot, suppress warning |
test_mask(); |
} |