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 29 matching lines...) Expand all Loading... |
40 public: | 40 public: |
41 SkImageDecoderGenerator(const SkImageInfo& info, SkImageDecoder* decoder, Sk
Data* data) | 41 SkImageDecoderGenerator(const SkImageInfo& info, SkImageDecoder* decoder, Sk
Data* data) |
42 : INHERITED(info), fInfo(info), fDecoder(decoder), fData(SkRef(data)) | 42 : INHERITED(info), fInfo(info), fDecoder(decoder), fData(SkRef(data)) |
43 {} | 43 {} |
44 | 44 |
45 protected: | 45 protected: |
46 SkData* onRefEncodedData() override { | 46 SkData* onRefEncodedData() override { |
47 return SkRef(fData.get()); | 47 return SkRef(fData.get()); |
48 } | 48 } |
49 | 49 |
50 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO | |
51 virtual bool onGetInfo(SkImageInfo* info) override { | |
52 *info = fInfo; | |
53 return true; | |
54 } | |
55 #endif | |
56 | |
57 virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, | 50 virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t row
Bytes, |
58 const Options&, | 51 const Options&, |
59 SkPMColor ctableEntries[], int* ctableCount) over
ride { | 52 SkPMColor ctableEntries[], int* ctableCount) over
ride { |
60 SkMemoryStream stream(fData->data(), fData->size(), false); | 53 SkMemoryStream stream(fData->data(), fData->size(), false); |
61 SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocat
or, | 54 SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocat
or, |
62 (info, pixels, ro
wBytes))); | 55 (info, pixels, ro
wBytes))); |
63 fDecoder->setAllocator(allocator); | 56 fDecoder->setAllocator(allocator); |
64 fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.
alphaType()); | 57 fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.
alphaType()); |
65 | 58 |
66 SkBitmap bm; | 59 SkBitmap bm; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 105 |
113 SkBitmap bm; | 106 SkBitmap bm; |
114 stream.rewind(); | 107 stream.rewind(); |
115 if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDe
codeBounds_Mode)) { | 108 if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDe
codeBounds_Mode)) { |
116 SkDELETE(decoder); | 109 SkDELETE(decoder); |
117 return NULL; | 110 return NULL; |
118 } | 111 } |
119 | 112 |
120 return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data)); | 113 return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data)); |
121 } | 114 } |
OLD | NEW |