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

Unified Diff: tests/ImageTest.cpp

Issue 2199813002: make an image from a mutable bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixx mmy spilling Created 4 years, 5 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 dd40f3608939c8d7b100908c2cd08e5d5742d433..72dc9432e39981df1fd394fd576a433cc0b75d6c 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -17,6 +17,7 @@
#include "SkImageEncoder.h"
#include "SkImageGenerator.h"
#include "SkImage_Base.h"
+#include "SkImagePriv.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkPixelSerializer.h"
@@ -194,6 +195,36 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) {
}
#endif
+DEF_TEST(Image_MakeFromRasterBitmap, reporter) {
+ const struct {
+ ForceCopyMode fMode;
+ bool fExpectSameAsMutable;
+ bool fExpectSameAsImmutable;
+ } recs[] = {
+ { kNo_ForceCopyMode, false, true },
+ { kYes_ForceCopyMode, false, false },
+ { kNever_ForceCopyMode, true, true },
+ };
+ for (auto rec : recs) {
+ SkPixmap pm;
+ SkBitmap bm;
+ bm.allocN32Pixels(100, 100);
+
+ auto img = SkMakeImageFromRasterBitmap(bm, rec.fMode);
+ REPORTER_ASSERT(reporter, img->peekPixels(&pm));
+ const bool sameMutable = pm.addr32(0, 0) == bm.getAddr32(0, 0);
+ REPORTER_ASSERT(reporter, rec.fExpectSameAsMutable == sameMutable);
+
+ bm.notifyPixelsChanged(); // force a new generation ID
+
+ bm.setImmutable();
+ img = SkMakeImageFromRasterBitmap(bm, rec.fMode);
+ REPORTER_ASSERT(reporter, img->peekPixels(&pm));
+ const bool sameImmutable = pm.addr32(0, 0) == bm.getAddr32(0, 0);
+ REPORTER_ASSERT(reporter, rec.fExpectSameAsImmutable == sameImmutable);
+ }
+}
+
namespace {
const char* kSerializedData = "serialized";
« 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