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

Side by Side Diff: dm/DM.cpp

Issue 1288963002: Provides multiple implementations of Android's SkBitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 5 years, 3 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
« no previous file with comments | « no previous file | dm/DMSrcSink.h » ('j') | dm/DMSrcSink.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "CrashHandler.h" 8 #include "CrashHandler.h"
9 #include "DMJsonWriter.h" 9 #include "DMJsonWriter.h"
10 #include "DMSrcSink.h" 10 #include "DMSrcSink.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 285 }
286 286
287 for (CodecSrc::Mode mode : modes) { 287 for (CodecSrc::Mode mode : modes) {
288 for (CodecSrc::DstColorType colorType : colorTypes) { 288 for (CodecSrc::DstColorType colorType : colorTypes) {
289 push_codec_src(path, mode, colorType, scale); 289 push_codec_src(path, mode, colorType, scale);
290 } 290 }
291 } 291 }
292 } 292 }
293 } 293 }
294 294
295 static bool codec_supported(const char* ext) { 295 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy,
296 // FIXME: Once other versions of SkCodec are available, we can add them to t his 296 SkColorType colorType) {
297 // list (and eventually we can remove this check once they are all supported ). 297 switch (strategy) {
298 case SkBitmapRegionDecoder::kCanvas_Strategy:
299 switch (colorType) {
300 case kN32_SkColorType:
301 case kRGB_565_SkColorType:
302 return true;
303 default:
304 return false;
305 }
306 case SkBitmapRegionDecoder::kOriginal_Strategy:
307 switch (colorType) {
308 case kN32_SkColorType:
309 case kRGB_565_SkColorType:
310 case kIndex_8_SkColorType:
311 case kAlpha_8_SkColorType:
312 return true;
313 default:
314 return false;
315 }
316 default:
317 SkASSERT(false);
318 return false;
319 }
320 }
321
322 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, Sk ColorType colorType,
323 BRDSrc::Mode mode, uint32_t sampleSize) {
324 SkString folder;
325 switch (strategy) {
326 case SkBitmapRegionDecoder::kCanvas_Strategy:
327 folder.append("brd_canvas");
328 break;
329 case SkBitmapRegionDecoder::kOriginal_Strategy:
330 folder.append("brd_sample");
331 break;
332 default:
333 SkASSERT(false);
334 return;
335 }
336
337 switch (mode) {
338 case BRDSrc::kFullImage_Mode:
339 break;
340 case BRDSrc::kDivisor_Mode:
341 folder.append("_divisor");
342 break;
343 default:
344 SkASSERT(false);
345 return;
346 }
347
348 switch (colorType) {
349 case kN32_SkColorType:
350 folder.append("_kN32");
351 break;
352 case kRGB_565_SkColorType:
353 folder.append("_k565");
354 break;
355 case kIndex_8_SkColorType:
356 folder.append("_kIndex");
357 break;
358 case kAlpha_8_SkColorType:
359 folder.append("_kAlpha");
360 break;
361 default:
362 SkASSERT(false);
363 return;
364 }
365
366 if (1 != sampleSize) {
367 folder.appendf("_%.3f", BRDSrc::GetScale(sampleSize));
368 }
369
370 BRDSrc* src = new BRDSrc(path, strategy, mode, colorType, sampleSize);
371 push_src("image", folder, src);
372 }
373
374 static void push_brd_srcs(Path path) {
375
376 const SkBitmapRegionDecoder::Strategy strategies[] = {
377 SkBitmapRegionDecoder::kCanvas_Strategy,
378 SkBitmapRegionDecoder::kOriginal_Strategy
379 };
380
381 // We will only test to one backend (8888), but we will test all of the
382 // color types that we need to decode to on this backend.
383 const SkColorType colorTypes[] = {
384 kN32_SkColorType,
385 kRGB_565_SkColorType,
386 kAlpha_8_SkColorType,
387 kIndex_8_SkColorType
388 };
389
390 const BRDSrc::Mode modes[] = {
391 BRDSrc::kFullImage_Mode,
392 BRDSrc::kDivisor_Mode
393 };
394
395 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
396
397 for (SkBitmapRegionDecoder::Strategy strategy : strategies) {
398 for (SkColorType colorType : colorTypes) {
399 if (brd_color_type_supported(strategy, colorType)) {
400 for (BRDSrc::Mode mode : modes) {
401 for (uint32_t sampleSize : sampleSizes) {
402 push_brd_src(path, strategy, colorType, mode, sampleSize );
403 }
404 }
405 }
406 }
407 }
408 }
409
410 static bool brd_supported(const char* ext) {
298 static const char* const exts[] = { 411 static const char* const exts[] = {
299 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", 412 "jpg", "jpeg", "png", "webp",
300 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", 413 "JPG", "JPEG", "PNG", "WEBP",
301 }; 414 };
302 415
303 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { 416 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
304 if (0 == strcmp(exts[i], ext)) { 417 if (0 == strcmp(exts[i], ext)) {
305 return true; 418 return true;
306 } 419 }
307 } 420 }
308 return false; 421 return false;
309 } 422 }
310 423
(...skipping 18 matching lines...) Expand all
329 }; 442 };
330 for (int i = 0; i < FLAGS_images.count(); i++) { 443 for (int i = 0; i < FLAGS_images.count(); i++) {
331 const char* flag = FLAGS_images[i]; 444 const char* flag = FLAGS_images[i];
332 if (sk_isdir(flag)) { 445 if (sk_isdir(flag)) {
333 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { 446 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) {
334 SkOSFile::Iter it(flag, exts[j]); 447 SkOSFile::Iter it(flag, exts[j]);
335 for (SkString file; it.next(&file); ) { 448 for (SkString file; it.next(&file); ) {
336 SkString path = SkOSPath::Join(flag, file.c_str()); 449 SkString path = SkOSPath::Join(flag, file.c_str());
337 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image 450 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image
338 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets 451 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets
339 if (codec_supported(exts[j])) { 452 push_codec_srcs(path);
340 push_codec_srcs(path); 453 if (brd_supported(exts[j])) {
454 push_brd_srcs(path);
341 } 455 }
342 } 456 }
343 } 457 }
344 } else if (sk_exists(flag)) { 458 } else if (sk_exists(flag)) {
345 // assume that FLAGS_images[i] is a valid image if it is a file. 459 // assume that FLAGS_images[i] is a valid image if it is a file.
346 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. 460 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age.
347 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets 461 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets
348 push_codec_srcs(flag); 462 push_codec_srcs(flag);
463 push_brd_srcs(flag);
349 } 464 }
350 } 465 }
351 } 466 }
352 467
353 static GrGLStandard get_gpu_api() { 468 static GrGLStandard get_gpu_api() {
354 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } 469 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
355 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } 470 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
356 return kNone_GrGLStandard; 471 return kNone_GrGLStandard;
357 } 472 }
358 473
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 } 1039 }
925 return 0; 1040 return 0;
926 } 1041 }
927 1042
928 #if !defined(SK_BUILD_FOR_IOS) 1043 #if !defined(SK_BUILD_FOR_IOS)
929 int main(int argc, char** argv) { 1044 int main(int argc, char** argv) {
930 SkCommandLineFlags::Parse(argc, argv); 1045 SkCommandLineFlags::Parse(argc, argv);
931 return dm_main(); 1046 return dm_main();
932 } 1047 }
933 #endif 1048 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMSrcSink.h » ('j') | dm/DMSrcSink.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698