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

Unified Diff: tests/CodexTest.cpp

Issue 1006583005: SkCodec: add wbmp class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-03-26 (Thursday) 15:46:11 EDT Created 5 years, 9 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
« src/codec/SkCodec.cpp ('K') | « src/codec/SkCodec_wbmp.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodexTest.cpp
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..37354f9c7bdea8ad46ad10f87a0e459a36b6f46d
--- /dev/null
+++ b/tests/CodexTest.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Resources.h"
+#include "SkBitmap.h"
+#include "SkCodec.h"
+#include "Test.h"
+
+static SkStreamAsset* resource(const char path[]) {
+ SkString fullPath = GetResourcePath(path);
+ return SkStream::NewFromFile(fullPath.c_str());
+}
+
+static void check(skiatest::Reporter* r,
+ const char path[],
+ SkISize size,
+ bool canRewind) {
+ SkAutoTDelete<SkStream> stream(resource(path));
+ if (!stream) {
+ SkDebugf("Missing resource '%s'\n", path);
+ return;
+ }
+ SkAutoTDelete<SkImageGenerator> gen(
+ SkCodec::NewFromStream(stream.detach()));
+ if (!gen) {
+ ERRORF(r, "Unable to decode '%s'", path);
+ return;
+ }
+ SkImageInfo info = gen->getInfo();
+ if (!size.isZero()) {
scroggo 2015/03/26 20:29:45 is size ever zero? Why? (It doesn't look like it f
hal.canary 2015/03/26 21:46:09 I didn't know the dimensions of all the files when
+ REPORTER_ASSERT(r, info.dimensions() == size);
+ }
+ SkBitmap bm;
+ bm.allocPixels(info);
+ SkAutoLockPixels autoLockPixels(bm);
+ SkImageGenerator::Result result =
+ gen->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL);
+ REPORTER_ASSERT(r, result == SkImageGenerator::kSuccess);
+
+ result =
+ gen->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL);
+
+ // All ImageGenerators should support re-decoding the pixels. It
+ // is a know bug that some can not.
scroggo 2015/03/26 20:29:45 known*
hal.canary 2015/03/26 21:46:09 Done.
+ if (canRewind) {
+ REPORTER_ASSERT(r, result == SkImageGenerator::kSuccess);
+ }
+}
+
+DEF_TEST(Codec, r) {
+ // WBMP
scroggo 2015/03/26 20:29:44 ICO, too?
hal.canary 2015/03/26 21:46:09 Done.
+ check(r, "mandrill.wbmp", SkISize::Make(512, 512), true);
+
+ // BMP
scroggo 2015/03/26 20:29:44 FIXME (msarett): SkBmpCodec should be able to rewi
hal.canary 2015/03/26 21:46:09 Done.
+ check(r, "randPixels.bmp", SkISize::Make(8, 8), false);
+
+ // PNG
scroggo 2015/03/26 20:29:44 FIXME (scroggo): SkPngCodec should be able to rewi
hal.canary 2015/03/26 21:46:09 Done.
+ check(r, "arrow.png", SkISize::Make(187, 312), false);
+ check(r, "baby_tux.png", SkISize::Make(240, 246), false);
+ check(r, "color_wheel.png", SkISize::Make(128, 128), false);
+ check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), false);
+ check(r, "mandrill_128.png", SkISize::Make(128, 128), false);
+ check(r, "mandrill_16.png", SkISize::Make(16, 16), false);
+ check(r, "mandrill_256.png", SkISize::Make(256, 256), false);
+ check(r, "mandrill_32.png", SkISize::Make(32, 32), false);
+ check(r, "mandrill_512.png", SkISize::Make(512, 512), false);
+ check(r, "mandrill_64.png", SkISize::Make(64, 64), false);
+ check(r, "plane.png", SkISize::Make(250, 126), false);
+ check(r, "randPixels.png", SkISize::Make(8, 8), false);
+ check(r, "yellow_rose.png", SkISize::Make(400, 301), false);
+}
« src/codec/SkCodec.cpp ('K') | « src/codec/SkCodec_wbmp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698