OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The Android Open Source Project | 2 * Copyright 2015 The Android Open Source Project |
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 "SkData.h" | 8 #include "SkData.h" |
9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 protected: | 45 protected: |
46 SkData* onRefEncodedData() SK_OVERRIDE { | 46 SkData* onRefEncodedData() SK_OVERRIDE { |
47 return SkRef(fData.get()); | 47 return SkRef(fData.get()); |
48 } | 48 } |
49 | 49 |
50 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 50 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { |
51 *info = fInfo; | 51 *info = fInfo; |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 virtual Result onGetPixelsEnum(const SkImageInfo& info, void* pixels, size_t
rowBytes, | 55 virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, |
56 SkPMColor ctableEntries[], int* ctableCount) SK_O
VERRIDE { | 56 SkPMColor ctableEntries[], int* ctableCount) SK_O
VERRIDE { |
57 SkMemoryStream stream(fData->data(), fData->size(), false); | 57 SkMemoryStream stream(fData->data(), fData->size(), false); |
58 SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocat
or, | 58 SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocat
or, |
59 (info, pixels, ro
wBytes))); | 59 (info, pixels, ro
wBytes))); |
60 fDecoder->setAllocator(allocator); | 60 fDecoder->setAllocator(allocator); |
61 fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.
alphaType()); | 61 fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.
alphaType()); |
62 | 62 |
63 SkBitmap bm; | 63 SkBitmap bm; |
64 const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, inf
o.colorType(), | 64 const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, inf
o.colorType(), |
65 SkImageDecoder::k
DecodePixels_Mode); | 65 SkImageDecoder::k
DecodePixels_Mode); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 SkBitmap bm; | 108 SkBitmap bm; |
109 stream.rewind(); | 109 stream.rewind(); |
110 if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDe
codeBounds_Mode)) { | 110 if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDe
codeBounds_Mode)) { |
111 SkDELETE(decoder); | 111 SkDELETE(decoder); |
112 return NULL; | 112 return NULL; |
113 } | 113 } |
114 | 114 |
115 return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data)); | 115 return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data)); |
116 } | 116 } |
OLD | NEW |