Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1914)

Unified Diff: tests/CanvasTest.cpp

Issue 784223007: Remove canvas::NewRaster, and rename surface::NewRasterPMColor to N32Premul (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CanvasTest.cpp
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index d5ddfe6fb05221c3b94848ccbe759ffef808a6b0..1f8f2760b5c150355920134af12f87063491965c 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::NewRasterPMColor(kWidth, kHeight);
+ SkSurface* surface = SkSurface::NewRasterN32Premul(kWidth, kHeight);
surface->getCanvas()->clear(color);
return surface;
}
@@ -748,7 +748,13 @@ static void TestOverrideStateConsistency(skiatest::Reporter* reporter, const Tes
static void test_newraster(skiatest::Reporter* reporter) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
- SkCanvas* canvas = SkCanvas::NewRaster(info);
+ 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);
REPORTER_ASSERT(reporter, canvas);
SkImageInfo info2;
@@ -756,6 +762,7 @@ 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]);
@@ -766,19 +773,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::NewRaster(info));
+ REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
// too big
info = info.makeWH(1 << 30, 1 << 30);
- REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info));
+ REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
// not a valid pixel type
info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType());
- REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info));
+ REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
// We should succeed with a zero-sized valid info
info = SkImageInfo::MakeN32Premul(0, 0);
- canvas = SkCanvas::NewRaster(info);
+ canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
REPORTER_ASSERT(reporter, canvas);
SkDELETE(canvas);
}
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698