OLD | NEW |
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 //////////////////////////////////////////////////////////////////////////////// | 326 //////////////////////////////////////////////////////////////////////////////// |
327 | 327 |
328 // example of how Android will do this inside their BitmapFactory | 328 // example of how Android will do this inside their BitmapFactory |
329 static SkPixelRef* install_pixel_ref(SkBitmap* bitmap, | 329 static SkPixelRef* install_pixel_ref(SkBitmap* bitmap, |
330 SkStreamRewindable* stream, | 330 SkStreamRewindable* stream, |
331 int sampleSize, bool ditherImage) { | 331 int sampleSize, bool ditherImage) { |
332 SkASSERT(bitmap != NULL); | 332 SkASSERT(bitmap != NULL); |
333 SkASSERT(stream != NULL); | 333 SkASSERT(stream != NULL); |
334 SkASSERT(stream->rewind()); | 334 SkASSERT(stream->rewind()); |
335 SkASSERT(stream->unique()); | 335 SkASSERT(stream->unique()); |
336 SkColorType colorType; | 336 SkColorType colorType = bitmap->colorType(); |
337 if (!SkBitmapConfigToColorType(bitmap->config(), &colorType)) { | |
338 return NULL; | |
339 } | |
340 SkDecodingImageGenerator::Options opts(sampleSize, ditherImage, colorType); | 337 SkDecodingImageGenerator::Options opts(sampleSize, ditherImage, colorType); |
341 SkAutoTDelete<SkImageGenerator> gen( | 338 SkAutoTDelete<SkImageGenerator> gen( |
342 SkDecodingImageGenerator::Create(stream, opts)); | 339 SkDecodingImageGenerator::Create(stream, opts)); |
343 SkImageInfo info; | 340 SkImageInfo info; |
344 if ((NULL == gen.get()) || !gen->getInfo(&info)) { | 341 if ((NULL == gen.get()) || !gen->getInfo(&info)) { |
345 return NULL; | 342 return NULL; |
346 } | 343 } |
347 SkDiscardableMemory::Factory* factory = NULL; | 344 SkDiscardableMemory::Factory* factory = NULL; |
348 if (info.getSafeSize(info.minRowBytes()) < (32 * 1024)) { | 345 if (info.getSafeSize(info.minRowBytes()) < (32 * 1024)) { |
349 // only use ashmem for large images, since mmaps come at a price | 346 // only use ashmem for large images, since mmaps come at a price |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 } | 569 } |
573 SkDecodingImageGenerator::Options options(scaleList[i], | 570 SkDecodingImageGenerator::Options options(scaleList[i], |
574 ditherList[j]); | 571 ditherList[j]); |
575 test_options(reporter, options, encodedStream, encodedData, | 572 test_options(reporter, options, encodedStream, encodedData, |
576 useDataList[m], path); | 573 useDataList[m], path); |
577 } | 574 } |
578 } | 575 } |
579 } | 576 } |
580 } | 577 } |
581 } | 578 } |
OLD | NEW |