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

Unified Diff: tests/ImageIsOpaqueTest.cpp

Issue 676883003: flag imageinfo as srgb (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix copy/paste error in loop limits Created 6 years, 1 month 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/ports/SkImageDecoder_CG.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageIsOpaqueTest.cpp
diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp
index 3fe5b3db0c725808ef8858433ac83d390d071f95..6fdbc8127abf4a4165c238393771af29f5cd78bd 100644
--- a/tests/ImageIsOpaqueTest.cpp
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -6,13 +6,47 @@
*/
#include "SkTypes.h"
+#include "Test.h"
+
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
#endif
#include "SkImage.h"
#include "SkSurface.h"
+#include "SkReadBuffer.h"
+#include "SkWriteBuffer.h"
-#include "Test.h"
+static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) {
+ // just need a safe amount of storage
+ char storage[sizeof(SkImageInfo)*2];
+ SkWriteBuffer wb(storage, sizeof(storage));
+ info.flatten(wb);
+ SkASSERT(wb.bytesWritten() < sizeof(storage));
+
+ SkReadBuffer rb(storage, wb.bytesWritten());
+ SkImageInfo info2;
+
+ // pick a noisy byte pattern, so we ensure that unflatten sets all of our fields
+ memset(&info2, 0xB8, sizeof(info2));
+
+ info2.unflatten(rb);
+ REPORTER_ASSERT(reporter, rb.offset() == wb.bytesWritten());
+ REPORTER_ASSERT(reporter, info == info2);
+}
+
+DEF_TEST(ImageInfo_flattening, reporter) {
+ for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) {
+ for (int at = 0; at <= kLastEnum_SkAlphaType; ++at) {
+ for (int pt = 0; pt <= kLastEnum_SkColorProfileType; ++pt) {
+ SkImageInfo info = SkImageInfo::Make(100, 200,
+ static_cast<SkColorType>(ct),
+ static_cast<SkAlphaType>(at),
+ static_cast<SkColorProfileType>(pt));
+ test_flatten(reporter, info);
+ }
+ }
+ }
+}
static void check_isopaque(skiatest::Reporter* reporter, SkSurface* surface, bool expectedOpaque) {
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
« no previous file with comments | « src/ports/SkImageDecoder_CG.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698