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

Unified Diff: tests/ImageTest.cpp

Issue 1222683004: add colortable param to newrastercopy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test Created 5 years, 6 months 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/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageTest.cpp
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index b196ca8f349bbd23149c97afe28f06a095bd1c83..eb8f7615a9c47380efef87a1c4134df048abcfe1 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -103,3 +103,30 @@ DEF_GPUTEST(Image_Encode_Gpu, reporter, factory) {
test_encode(reporter, ctx);
}
#endif
+
+DEF_TEST(Image_NewRasterCopy, reporter) {
+ const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0);
+ const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0);
+ const SkPMColor blue = SkPackARGB32(0xFF, 0, 0, 0xFF);
+ SkPMColor colors[] = { red, green, blue, 0 };
+ SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colors, SK_ARRAY_COUNT(colors))));
+ // The colortable made a copy, so we can trash the original colors
+ memset(colors, 0xFF, sizeof(colors));
+
+ const SkImageInfo srcInfo = SkImageInfo::Make(2, 2, kIndex_8_SkColorType, kPremul_SkAlphaType);
+ const size_t srcRowBytes = 2 * sizeof(uint8_t);
+ uint8_t indices[] = { 0, 1, 2, 3 };
+ SkAutoTUnref<SkImage> image(SkImage::NewRasterCopy(srcInfo, indices, srcRowBytes, ctable));
+ // The image made a copy, so we can trash the original indices
+ memset(indices, 0xFF, sizeof(indices));
+
+ const SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(2, 2);
+ const size_t dstRowBytes = 2 * sizeof(SkPMColor);
+ SkPMColor pixels[4];
+ memset(pixels, 0xFF, sizeof(pixels)); // init with values we don't expect
+ image->readPixels(dstInfo, pixels, dstRowBytes, 0, 0);
+ REPORTER_ASSERT(reporter, red == pixels[0]);
+ REPORTER_ASSERT(reporter, green == pixels[1]);
+ REPORTER_ASSERT(reporter, blue == pixels[2]);
+ REPORTER_ASSERT(reporter, 0 == pixels[3]);
+}
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698