aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-12-09 13:55:20 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-09 13:55:20 -0800
commita8918a065075dece6e407cce0dfddf110e5d61a9 (patch)
treeefb420e47b1b7838e1381d5ee56724863f9d97dc /tests
parent2e3b3e369d79e78f7635d4c20e83a47ab571bdf2 (diff)
Revert of remove (dumb) canvas::NewRaster, and rename surface::NewRasterPMColor to N32Premul (patchset #3 id:40001 of https://codereview.chromium.org/790733003/)
Reason for revert: need to update chrome first Original issue's description: > remove (dumb) canvas::NewRaster, and rename surface::NewRasterPMColor to N32Premul > > patch from issue 781403002 at patchset 20001 (http://crrev.com/781403002#ps20001) > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/2c1605a1fbaa2e35a27399a34254fb1200ec2ae6 TBR=fmalita@google.com,fmalita@chromium.org NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/791763002
Diffstat (limited to 'tests')
-rw-r--r--tests/CanvasTest.cpp19
-rw-r--r--tests/DeferredCanvasTest.cpp16
-rw-r--r--tests/DrawBitmapRectTest.cpp2
-rw-r--r--tests/DrawPathTest.cpp48
-rw-r--r--tests/PathTest.cpp10
-rw-r--r--tests/RecordDrawTest.cpp2
-rw-r--r--tests/RecorderTest.cpp2
-rw-r--r--tests/SkResourceCacheTest.cpp5
8 files changed, 49 insertions, 55 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 1f8f2760b5..d5ddfe6fb0 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -73,7 +73,7 @@ static void createBitmap(SkBitmap* bm, SkColor color) {
}
static SkSurface* createSurface(SkColor color) {
- SkSurface* surface = SkSurface::NewRasterN32Premul(kWidth, kHeight);
+ SkSurface* surface = SkSurface::NewRasterPMColor(kWidth, kHeight);
surface->getCanvas()->clear(color);
return surface;
}
@@ -748,13 +748,7 @@ static void TestOverrideStateConsistency(skiatest::Reporter* reporter, const Tes
static void test_newraster(skiatest::Reporter* reporter) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
- const size_t minRowBytes = info.minRowBytes();
- const size_t size = info.getSafeSize(minRowBytes);
- SkAutoMalloc storage(size);
- SkPMColor* baseAddr = static_cast<SkPMColor*>(storage.get());
- sk_bzero(baseAddr, size);
-
- SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
+ SkCanvas* canvas = SkCanvas::NewRaster(info);
REPORTER_ASSERT(reporter, canvas);
SkImageInfo info2;
@@ -762,7 +756,6 @@ static void test_newraster(skiatest::Reporter* reporter) {
const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowBytes);
REPORTER_ASSERT(reporter, addr);
REPORTER_ASSERT(reporter, info == info2);
- REPORTER_ASSERT(reporter, minRowBytes == rowBytes);
for (int y = 0; y < info.height(); ++y) {
for (int x = 0; x < info.width(); ++x) {
REPORTER_ASSERT(reporter, 0 == addr[x]);
@@ -773,19 +766,19 @@ static void test_newraster(skiatest::Reporter* reporter) {
// now try a deliberately bad info
info = info.makeWH(-1, info.height());
- REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
+ REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info));
// too big
info = info.makeWH(1 << 30, 1 << 30);
- REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
+ REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info));
// not a valid pixel type
info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType());
- REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
+ REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info));
// We should succeed with a zero-sized valid info
info = SkImageInfo::MakeN32Premul(0, 0);
- canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
+ canvas = SkCanvas::NewRaster(info);
REPORTER_ASSERT(reporter, canvas);
SkDELETE(canvas);
}
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 1c1970a03f..043fe33557 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -32,7 +32,7 @@ static void create(SkBitmap* bm, SkColor color) {
}
static SkSurface* createSurface(SkColor color) {
- SkSurface* surface = SkSurface::NewRasterN32Premul(gWidth, gHeight);
+ SkSurface* surface = SkSurface::NewRasterPMColor(gWidth, gHeight);
surface->getCanvas()->clear(color);
return surface;
}
@@ -451,7 +451,7 @@ private:
// Verifies that the deferred canvas triggers a flush when its memory
// limit is exceeded
static void TestDeferredCanvasMemoryLimit(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
NotificationCounter notificationCounter;
@@ -486,7 +486,7 @@ static void TestDeferredCanvasSilentFlush(skiatest::Reporter* reporter) {
}
static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
NotificationCounter notificationCounter;
@@ -566,7 +566,7 @@ static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
}
static void TestDeferredCanvasSkip(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
NotificationCounter notificationCounter;
@@ -585,7 +585,7 @@ static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) {
// This test covers a code path that inserts bitmaps into the bitmap heap through the
// flattening of SkBitmapProcShaders. The refcount in the bitmap heap is maintained through
// the flattening and unflattening of the shader.
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
// test will fail if nbIterations is not in sync with
// BITMAPS_TO_KEEP in SkGPipeWrite.cpp
@@ -620,7 +620,7 @@ static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) {
}
static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
SkBitmap sourceImage;
// 100 by 100 image, takes 40,000 bytes in memory
@@ -811,7 +811,7 @@ static void TestDeferredCanvasSetSurface(skiatest::Reporter* reporter, GrContext
}
static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
NotificationCounter notificationCounter;
@@ -842,7 +842,7 @@ static void TestDeferredCanvasGetCanvasSize(skiatest::Reporter* reporter) {
SkAutoTUnref<SkSurface> surface(createSurface(0xFFFFFFFF));
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
- SkSurface* newSurface = SkSurface::NewRasterN32Premul(4, 4);
+ SkSurface* newSurface = SkSurface::NewRasterPMColor(4, 4);
SkAutoTUnref<SkSurface> aur(newSurface);
for (int i = 0; i < 2; ++i) {
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index c1e34a2612..71ad2cf733 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -43,7 +43,7 @@ static void test_faulty_pixelref(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, installSuccess);
// now our bitmap has a pixelref, but we know it will fail to lock
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200));
SkCanvas* canvas = surface->getCanvas();
const SkPaint::FilterLevel levels[] = {
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 67af75568a..2af4224c9c 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -17,7 +17,7 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) {
SkPMColor pixel[1];
output.installPixels(SkImageInfo::MakeN32Premul(1, 1), pixel, 4);
- SkSurface* surf = SkSurface::NewRasterN32Premul(300, 33300);
+ SkSurface* surf = SkSurface::NewRasterPMColor(300, 33300);
SkCanvas* canvas = surf->getCanvas();
SkRect r = { 0, 33000, 300, 33300 };
@@ -94,11 +94,11 @@ static void test_crbug131181() {
moveToH(&path, &data[0]);
cubicToH(&path, &data[2]);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterN32(640, 480));
SkPaint paint;
paint.setAntiAlias(true);
- surface->getCanvas()->drawPath(path, paint);
+ canvas->drawPath(path, paint);
}
// This used to assert in debug builds (and crash writing bad memory in release)
@@ -125,36 +125,38 @@ static void test_crbug_140803() {
static void test_inversepathwithclip() {
SkPath path;
- path.moveTo(0, 20);
- path.quadTo(10, 10, 20, 20);
+ path.moveTo(0, SkIntToScalar(20));
+ path.quadTo(SkIntToScalar(10), SkIntToScalar(10),
+ SkIntToScalar(20), SkIntToScalar(20));
path.toggleInverseFillType();
SkPaint paint;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
- SkCanvas* canvas = surface->getCanvas();
- canvas->save();
- canvas->clipRect(SkRect::MakeWH(19, 11));
+ SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterN32(640, 480));
+ canvas.get()->save();
+ canvas.get()->clipRect(SkRect::MakeWH(SkIntToScalar(19), SkIntToScalar(11)));
paint.setAntiAlias(false);
- canvas->drawPath(path, paint);
+ canvas.get()->drawPath(path, paint);
paint.setAntiAlias(true);
- canvas->drawPath(path, paint);
+ canvas.get()->drawPath(path, paint);
- canvas->restore();
+ canvas.get()->restore();
// Now do the test again, with the path flipped, so we only draw in the
// top half of our bounds, and have the clip intersect our bounds at the
// bottom.
path.reset(); // preserves our filltype
- path.moveTo(0, 10);
- path.quadTo(10, 20, 20, 10);
- canvas->clipRect(SkRect::MakeXYWH(0, 19, 19, 11));
+ path.moveTo(0, SkIntToScalar(10));
+ path.quadTo(SkIntToScalar(10), SkIntToScalar(20),
+ SkIntToScalar(20), SkIntToScalar(10));
+ canvas.get()->clipRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(19),
+ SkIntToScalar(19), SkIntToScalar(11)));
paint.setAntiAlias(false);
- canvas->drawPath(path, paint);
+ canvas.get()->drawPath(path, paint);
paint.setAntiAlias(true);
- canvas->drawPath(path, paint);
+ canvas.get()->drawPath(path, paint);
}
static void test_bug533() {
@@ -170,8 +172,8 @@ static void test_bug533() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
- surface->getCanvas()->drawPath(path, paint);
+ SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterN32(640, 480));
+ canvas.get()->drawPath(path, paint);
}
static void test_crbug_140642() {
@@ -212,8 +214,8 @@ static void test_bigcubic() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
- surface->getCanvas()->drawPath(path, paint);
+ SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterN32(640, 480));
+ canvas.get()->drawPath(path, paint);
}
// we used to assert if the bounds of the device (clip) was larger than 32K
@@ -222,13 +224,13 @@ static void test_bigcubic() {
static void test_giantaa() {
const int W = 400;
const int H = 400;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(33000, 10));
+ SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterN32(33000, 10));
SkPaint paint;
paint.setAntiAlias(true);
SkPath path;
path.addOval(SkRect::MakeXYWH(-10, -10, 20 + W, 20 + H));
- surface->getCanvas()->drawPath(path, paint);
+ canvas.get()->drawPath(path, paint);
}
// Extremely large path_length/dash_length ratios may cause infinite looping
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index d09f8a2b30..4588619080 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -54,7 +54,7 @@ static void make_path_crbug364224_simplified(SkPath* path) {
static void test_path_crbug364224() {
SkPath path;
SkPaint paint;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(84, 88));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(84, 88));
SkCanvas* canvas = surface->getCanvas();
make_path_crbug364224_simplified(&path);
@@ -299,7 +299,7 @@ static void test_bad_cubic_crbug234190() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(84, 88));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(84, 88));
surface->getCanvas()->drawPath(path, paint);
}
@@ -418,7 +418,7 @@ static void test_crbug_170666() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(1000, 1000));
build_path_simple_170666(path);
surface->getCanvas()->drawPath(path, paint);
@@ -497,7 +497,7 @@ static void build_big_path(SkPath* path, bool reducedCase) {
}
static void test_clipped_cubic() {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(640, 480));
// This path used to assert, because our cubic-chopping code incorrectly
// moved control points after the chop. This test should be run in SK_DEBUG
@@ -533,7 +533,7 @@ static void test_tricky_cubic() {
SkPaint paint;
paint.setAntiAlias(true);
- SkSurface* surface = SkSurface::NewRasterN32Premul(19, 130);
+ SkSurface* surface = SkSurface::NewRasterPMColor(19, 130);
surface->getCanvas()->drawPath(path, paint);
surface->unref();
}
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index 2d9e90d48b..30be24c28a 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -286,7 +286,7 @@ DEF_TEST(RecordDraw_drawImage, r){
bool fDrawImageRectCalled;
};
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(10, 10));
surface->getCanvas()->clear(SK_ColorGREEN);
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 7a2755699f..d81bf059ef 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -155,7 +155,7 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
SkAutoTUnref<SkImage> image;
{
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
surface->getCanvas()->clear(SK_ColorGREEN);
image.reset(surface->newImageSnapshot());
}
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index e1f8a65bbc..0e941758ee 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -11,7 +11,6 @@
#include "SkDiscardableMemoryPool.h"
#include "SkGraphics.h"
#include "SkResourceCache.h"
-#include "SkSurface.h"
static const int kCanvasSize = 1;
static const int kBitmapSize = 16;
@@ -28,8 +27,8 @@ static bool is_in_scaled_image_cache(const SkBitmap& orig,
// Draw a scaled bitmap, then return true iff it has been cached.
static bool test_scaled_image_cache_useage() {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kCanvasSize, kCanvasSize));
- SkCanvas* canvas = surface->getCanvas();
+ SkAutoTUnref<SkCanvas> canvas(
+ SkCanvas::NewRasterN32(kCanvasSize, kCanvasSize));
SkBitmap bitmap;
bitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
bitmap.eraseColor(0xFFFFFFFF);