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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 293283002: move ashmem switching logic to SkDiscardableMemory::Create (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 7 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 | « src/ports/SkDiscardableMemory_ashmem.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 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // example of how Android will do this inside their BitmapFactory 484 // example of how Android will do this inside their BitmapFactory
485 static SkPixelRef* install_pixel_ref(SkBitmap* bitmap, 485 static SkPixelRef* install_pixel_ref(SkBitmap* bitmap,
486 SkStreamRewindable* stream, 486 SkStreamRewindable* stream,
487 int sampleSize, bool ditherImage) { 487 int sampleSize, bool ditherImage) {
488 SkASSERT(bitmap != NULL); 488 SkASSERT(bitmap != NULL);
489 SkASSERT(stream != NULL); 489 SkASSERT(stream != NULL);
490 SkASSERT(stream->rewind()); 490 SkASSERT(stream->rewind());
491 SkASSERT(stream->unique()); 491 SkASSERT(stream->unique());
492 SkColorType colorType = bitmap->colorType(); 492 SkColorType colorType = bitmap->colorType();
493 SkDecodingImageGenerator::Options opts(sampleSize, ditherImage, colorType); 493 SkDecodingImageGenerator::Options opts(sampleSize, ditherImage, colorType);
494 SkAutoTDelete<SkImageGenerator> gen( 494 if (SkInstallDiscardablePixelRef(
495 SkDecodingImageGenerator::Create(stream, opts)); 495 SkDecodingImageGenerator::Create(stream, opts), bitmap)) {
496 SkImageInfo info;
497 if ((NULL == gen.get()) || !gen->getInfo(&info)) {
498 return NULL;
499 }
500 SkDiscardableMemory::Factory* factory = NULL;
501 if (info.getSafeSize(info.minRowBytes()) < (32 * 1024)) {
502 // only use ashmem for large images, since mmaps come at a price
503 factory = SkGetGlobalDiscardableMemoryPool();
504 }
505 if (SkInstallDiscardablePixelRef(gen.detach(), bitmap, factory)) {
506 return bitmap->pixelRef(); 496 return bitmap->pixelRef();
507 } 497 }
508 return NULL; 498 return NULL;
509 } 499 }
510 /** 500 /**
511 * A test for the SkDecodingImageGenerator::Create and 501 * A test for the SkDecodingImageGenerator::Create and
512 * SkInstallDiscardablePixelRef functions. 502 * SkInstallDiscardablePixelRef functions.
513 */ 503 */
514 DEF_TEST(ImprovedBitmapFactory, reporter) { 504 DEF_TEST(ImprovedBitmapFactory, reporter) {
515 SkString resourcePath = skiatest::Test::GetResourcePath(); 505 SkString resourcePath = skiatest::Test::GetResourcePath();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 720 }
731 SkDecodingImageGenerator::Options options(scaleList[i], 721 SkDecodingImageGenerator::Options options(scaleList[i],
732 ditherList[j]); 722 ditherList[j]);
733 test_options(reporter, options, encodedStream, encodedData, 723 test_options(reporter, options, encodedStream, encodedData,
734 useDataList[m], path); 724 useDataList[m], path);
735 } 725 }
736 } 726 }
737 } 727 }
738 } 728 }
739 } 729 }
OLDNEW
« no previous file with comments | « src/ports/SkDiscardableMemory_ashmem.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698