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 = bitmap->colorType(); | 336 SkColorType colorType; |
| 337 if (!SkBitmapConfigToColorType(bitmap->config(), &colorType)) { |
| 338 return NULL; |
| 339 } |
337 SkDecodingImageGenerator::Options opts(sampleSize, ditherImage, colorType); | 340 SkDecodingImageGenerator::Options opts(sampleSize, ditherImage, colorType); |
338 SkAutoTDelete<SkImageGenerator> gen( | 341 SkAutoTDelete<SkImageGenerator> gen( |
339 SkDecodingImageGenerator::Create(stream, opts)); | 342 SkDecodingImageGenerator::Create(stream, opts)); |
340 SkImageInfo info; | 343 SkImageInfo info; |
341 if ((NULL == gen.get()) || !gen->getInfo(&info)) { | 344 if ((NULL == gen.get()) || !gen->getInfo(&info)) { |
342 return NULL; | 345 return NULL; |
343 } | 346 } |
344 SkDiscardableMemory::Factory* factory = NULL; | 347 SkDiscardableMemory::Factory* factory = NULL; |
345 if (info.getSafeSize(info.minRowBytes()) < (32 * 1024)) { | 348 if (info.getSafeSize(info.minRowBytes()) < (32 * 1024)) { |
346 // only use ashmem for large images, since mmaps come at a price | 349 // 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... |
569 } | 572 } |
570 SkDecodingImageGenerator::Options options(scaleList[i], | 573 SkDecodingImageGenerator::Options options(scaleList[i], |
571 ditherList[j]); | 574 ditherList[j]); |
572 test_options(reporter, options, encodedStream, encodedData, | 575 test_options(reporter, options, encodedStream, encodedData, |
573 useDataList[m], path); | 576 useDataList[m], path); |
574 } | 577 } |
575 } | 578 } |
576 } | 579 } |
577 } | 580 } |
578 } | 581 } |
OLD | NEW |