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

Side by Side Diff: tests/CodexTest.cpp

Issue 1395183003: Add scaled subset API to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@split0
Patch Set: Created 5 years, 2 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/SkWebpCodec.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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return; 232 return;
233 } 233 }
234 234
235 SkRandom rand; 235 SkRandom rand;
236 SkIRect subset; 236 SkIRect subset;
237 SkCodec::Options opts; 237 SkCodec::Options opts;
238 opts.fSubset = ⊂ 238 opts.fSubset = ⊂
239 for (int i = 0; i < 5; i++) { 239 for (int i = 0; i < 5; i++) {
240 subset = generate_random_subset(&rand, size.width(), size.height()); 240 subset = generate_random_subset(&rand, size.width(), size.height());
241 SkASSERT(!subset.isEmpty()); 241 SkASSERT(!subset.isEmpty());
242 const bool supported = codec->getValidSubset(&subset); 242 const bool supported = codec->getScaledSubsetDimensions(1.0f, opts);
243 REPORTER_ASSERT(r, supported == supportsSubsetDecoding); 243 REPORTER_ASSERT(r, supported == supportsSubsetDecoding);
244 244
245 SkImageInfo subsetInfo = info.makeWH(subset.width(), subset.height()); 245 SkImageInfo subsetInfo = info.makeWH(subset.width(), subset.height());
246 SkBitmap bm; 246 SkBitmap bm;
247 bm.allocPixels(subsetInfo); 247 bm.allocPixels(subsetInfo);
248 const SkCodec::Result result = codec->getPixels(bm.info(), bm.getPixels( ), bm.rowBytes(), 248 const SkCodec::Result result = codec->getPixels(bm.info(), bm.getPixels( ), bm.rowBytes(),
249 &opts, nullptr, nullptr) ; 249 &opts, nullptr, nullptr) ;
250 250
251 if (supportsSubsetDecoding) { 251 if (supportsSubsetDecoding) {
252 REPORTER_ASSERT(r, result == expectedResult); 252 REPORTER_ASSERT(r, result == expectedResult);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); 589 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
590 result = decoder->startScanlineDecode( 590 result = decoder->startScanlineDecode(
591 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); 591 decoder->getInfo().makeColorType(kIndex_8_SkColorType));
592 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); 592 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
593 } 593 }
594 594
595 DEF_TEST(Codec_Params, r) { 595 DEF_TEST(Codec_Params, r) {
596 test_invalid_parameters(r, "index8.png"); 596 test_invalid_parameters(r, "index8.png");
597 test_invalid_parameters(r, "mandrill.wbmp"); 597 test_invalid_parameters(r, "mandrill.wbmp");
598 } 598 }
OLDNEW
« src/codec/SkWebpCodec.cpp ('K') | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698