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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 101 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
102 SkYUVColorSpace* colorSpace) override { | 102 SkYUVColorSpace* colorSpace) override { |
103 SkMemoryStream stream(fData->data(), fData->size(), false); | 103 SkMemoryStream stream(fData->data(), fData->size(), false); |
104 return fDecoder->decodeYUV8Planes(&stream, sizes, planes, rowBytes, colo
rSpace); | 104 return fDecoder->decodeYUV8Planes(&stream, sizes, planes, rowBytes, colo
rSpace); |
105 } | 105 } |
106 | 106 |
107 private: | 107 private: |
108 typedef SkImageGenerator INHERITED; | 108 typedef SkImageGenerator INHERITED; |
109 }; | 109 }; |
110 | 110 |
111 SkImageGenerator* SkImageGenerator::NewFromData(SkData* data) { | 111 SkImageGenerator* SkImageGenerator::NewFromEncodedImpl(SkData* data) { |
112 if (NULL == data) { | |
113 return NULL; | |
114 } | |
115 | |
116 SkMemoryStream stream(data->data(), data->size(), false); | 112 SkMemoryStream stream(data->data(), data->size(), false); |
117 SkImageDecoder* decoder = SkImageDecoder::Factory(&stream); | 113 SkImageDecoder* decoder = SkImageDecoder::Factory(&stream); |
118 if (NULL == decoder) { | 114 if (NULL == decoder) { |
119 return NULL; | 115 return NULL; |
120 } | 116 } |
121 | 117 |
122 SkBitmap bm; | 118 SkBitmap bm; |
123 stream.rewind(); | 119 stream.rewind(); |
124 if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDe
codeBounds_Mode)) { | 120 if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDe
codeBounds_Mode)) { |
125 SkDELETE(decoder); | 121 SkDELETE(decoder); |
126 return NULL; | 122 return NULL; |
127 } | 123 } |
128 | 124 |
129 return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data)); | 125 return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data)); |
130 } | 126 } |
OLD | NEW |