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

Side by Side Diff: tests/CodexTest.cpp

Issue 1277213002: Support more swizzles to 565 in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update new 565 swizzling functions for scaling Created 5 years, 4 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 unified diff | Download patch
« src/codec/SkSwizzler.cpp ('K') | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 rect.fBottom = rand->nextRangeU(0, h); 71 rect.fBottom = rand->nextRangeU(0, h);
72 rect.sort(); 72 rect.sort();
73 } while (rect.isEmpty()); 73 } while (rect.isEmpty());
74 return rect; 74 return rect;
75 } 75 }
76 76
77 static void check(skiatest::Reporter* r, 77 static void check(skiatest::Reporter* r,
78 const char path[], 78 const char path[],
79 SkISize size, 79 SkISize size,
80 bool supportsScanlineDecoding, 80 bool supportsScanlineDecoding,
81 bool supportsSubsetDecoding) { 81 bool supportsSubsetDecoding,
82 bool supports565 = true) {
82 SkAutoTDelete<SkStream> stream(resource(path)); 83 SkAutoTDelete<SkStream> stream(resource(path));
83 if (!stream) { 84 if (!stream) {
84 SkDebugf("Missing resource '%s'\n", path); 85 SkDebugf("Missing resource '%s'\n", path);
85 return; 86 return;
86 } 87 }
87 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); 88 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
88 if (!codec) { 89 if (!codec) {
89 ERRORF(r, "Unable to decode '%s'", path); 90 ERRORF(r, "Unable to decode '%s'", path);
90 return; 91 return;
91 } 92 }
92 93
93 // This test is used primarily to verify rewinding works properly. Using kN 32 allows 94 // This test is used primarily to verify rewinding works properly. Using kN 32 allows
94 // us to test this without the added overhead of creating different bitmaps depending 95 // us to test this without the added overhead of creating different bitmaps depending
95 // on the color type (ex: building a color table for kIndex8). DM is where we test 96 // on the color type (ex: building a color table for kIndex8). DM is where we test
96 // decodes to all possible destination color types. 97 // decodes to all possible destination color types.
97 SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType); 98 SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType);
98 REPORTER_ASSERT(r, info.dimensions() == size); 99 REPORTER_ASSERT(r, info.dimensions() == size);
100
101 {
102 // Test decoding to 565
103 SkImageInfo info565 = info.makeColorType(kRGB_565_SkColorType);
104 SkCodec::Result expected = (supports565 && info.alphaType() == kOpaque_S kAlphaType) ?
105 SkCodec::kSuccess : SkCodec::kInvalidConversion;
106 test_info(r, codec, info565, expected, NULL);
107 }
108
99 SkBitmap bm; 109 SkBitmap bm;
100 bm.allocPixels(info); 110 bm.allocPixels(info);
101 SkAutoLockPixels autoLockPixels(bm); 111 SkAutoLockPixels autoLockPixels(bm);
102 SkCodec::Result result = 112 SkCodec::Result result =
103 codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL); 113 codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL);
104 REPORTER_ASSERT(r, result == SkCodec::kSuccess); 114 REPORTER_ASSERT(r, result == SkCodec::kSuccess);
105 115
106 SkMD5::Digest digest; 116 SkMD5::Digest digest;
107 md5(bm, &digest); 117 md5(bm, &digest);
108 118
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 check(r, "color_wheel.ico", SkISize::Make(128, 128), false, false); 216 check(r, "color_wheel.ico", SkISize::Make(128, 128), false, false);
207 // Decodes an embedded PNG image 217 // Decodes an embedded PNG image
208 check(r, "google_chrome.ico", SkISize::Make(256, 256), false, false); 218 check(r, "google_chrome.ico", SkISize::Make(256, 256), false, false);
209 219
210 // GIF 220 // GIF
211 check(r, "box.gif", SkISize::Make(200, 55), false, false); 221 check(r, "box.gif", SkISize::Make(200, 55), false, false);
212 check(r, "color_wheel.gif", SkISize::Make(128, 128), false, false); 222 check(r, "color_wheel.gif", SkISize::Make(128, 128), false, false);
213 check(r, "randPixels.gif", SkISize::Make(8, 8), false, false); 223 check(r, "randPixels.gif", SkISize::Make(8, 8), false, false);
214 224
215 // JPG 225 // JPG
216 check(r, "CMYK.jpg", SkISize::Make(642, 516), true, false); 226 check(r, "CMYK.jpg", SkISize::Make(642, 516), true, false, false);
217 check(r, "color_wheel.jpg", SkISize::Make(128, 128), true, false); 227 check(r, "color_wheel.jpg", SkISize::Make(128, 128), true, false);
218 check(r, "grayscale.jpg", SkISize::Make(128, 128), true, false); 228 check(r, "grayscale.jpg", SkISize::Make(128, 128), true, false);
219 check(r, "mandrill_512_q075.jpg", SkISize::Make(512, 512), true, false); 229 check(r, "mandrill_512_q075.jpg", SkISize::Make(512, 512), true, false);
220 check(r, "randPixels.jpg", SkISize::Make(8, 8), true, false); 230 check(r, "randPixels.jpg", SkISize::Make(8, 8), true, false);
221 231
222 // PNG 232 // PNG
223 check(r, "arrow.png", SkISize::Make(187, 312), true, false); 233 check(r, "arrow.png", SkISize::Make(187, 312), true, false);
224 check(r, "baby_tux.png", SkISize::Make(240, 246), true, false); 234 check(r, "baby_tux.png", SkISize::Make(240, 246), true, false);
225 check(r, "color_wheel.png", SkISize::Make(128, 128), true, false); 235 check(r, "color_wheel.png", SkISize::Make(128, 128), true, false);
226 check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), true, fals e); 236 check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), true, fals e);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); 367 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
358 result = decoder->start( 368 result = decoder->start(
359 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); 369 decoder->getInfo().makeColorType(kIndex_8_SkColorType));
360 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); 370 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
361 } 371 }
362 372
363 DEF_TEST(Codec_Params, r) { 373 DEF_TEST(Codec_Params, r) {
364 test_invalid_parameters(r, "index8.png"); 374 test_invalid_parameters(r, "index8.png");
365 test_invalid_parameters(r, "mandrill.wbmp"); 375 test_invalid_parameters(r, "mandrill.wbmp");
366 } 376 }
OLDNEW
« src/codec/SkSwizzler.cpp ('K') | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698