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

Side by Side Diff: bench/nanobench.cpp

Issue 1418093006: Refactor SkBitmapRegionDecoderInterface for Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "nanobench.h" 10 #include "nanobench.h"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoderInterface::Str ategy strategy, 596 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoderInterface::Str ategy strategy,
597 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int* width, 597 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int* width,
598 int* height) { 598 int* height) {
599 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd( 599 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(
600 SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, s trategy)); 600 SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, s trategy));
601 if (nullptr == brd.get()) { 601 if (nullptr == brd.get()) {
602 // This is indicates that subset decoding is not supported for a particu lar image format. 602 // This is indicates that subset decoding is not supported for a particu lar image format.
603 return false; 603 return false;
604 } 604 }
605 605
606 SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(0, 0, brd->width(), brd->he ight(), 1, 606 SkIRect subset = SkIRect::MakeXYWH(0, 0, brd->width(), brd->height());
607 colorType)); 607 SkImageInfo info;
608 if (nullptr == bitmap.get() || colorType != bitmap->colorType()) { 608 if (!brd->prepareRegion(subset, 1, colorType, false, &info)) {
609 // This indicates that conversion to the requested color type is not sup ported for the 609 // This indicates that conversion to the requested color type is not sup ported
610 // particular image. 610 // or another parameter is invalid.
611 return false; 611 return false;
612 } 612 }
613 if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy) {
614 SkBitmap bitmap;
615 if (!brd->decodeRegion(bitmap) || colorType != bitmap.colorType()) {
616 // This indicates that conversion to the requested color type is not
617 // supported for the particular image.
618 return false;
619 }
620 }
613 621
614 if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * min OutputSize > 622 if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * min OutputSize >
615 (uint32_t) brd->height()) { 623 (uint32_t) brd->height()) {
616 // This indicates that the image is not large enough to decode a 624 // This indicates that the image is not large enough to decode a
617 // minOutputSize x minOutputSize subset at the given sampleSize. 625 // minOutputSize x minOutputSize subset at the given sampleSize.
618 return false; 626 return false;
619 } 627 }
620 628
621 // Set the image width and height. The calling code will use this to choose subsets to decode. 629 // Set the image width and height. The calling code will use this to choose subsets to decode.
622 *width = brd->width(); 630 *width = brd->width();
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1372
1365 return 0; 1373 return 0;
1366 } 1374 }
1367 1375
1368 #if !defined SK_BUILD_FOR_IOS 1376 #if !defined SK_BUILD_FOR_IOS
1369 int main(int argc, char** argv) { 1377 int main(int argc, char** argv) {
1370 SkCommandLineFlags::Parse(argc, argv); 1378 SkCommandLineFlags::Parse(argc, argv);
1371 return nanobench_main(); 1379 return nanobench_main();
1372 } 1380 }
1373 #endif 1381 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698