OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDrawBitmap.h" | 10 #include "SkDrawBitmap.h" |
11 #include "SkAnimateMaker.h" | 11 #include "SkAnimateMaker.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkImageDecoder.h" | 13 #include "SkData.h" |
| 14 #include "SkImage.h" |
14 #include "SkPaint.h" | 15 #include "SkPaint.h" |
15 #include "SkStream.h" | 16 #include "SkStream.h" |
16 | 17 |
17 #if SK_USE_CONDENSED_INFO == 0 | 18 #if SK_USE_CONDENSED_INFO == 0 |
18 | 19 |
19 const SkMemberInfo SkBaseBitmap::fInfo[] = { | 20 const SkMemberInfo SkBaseBitmap::fInfo[] = { |
20 SK_MEMBER(x, Float), | 21 SK_MEMBER(x, Float), |
21 SK_MEMBER(y, Float) | 22 SK_MEMBER(y, Float) |
22 }; | 23 }; |
23 | 24 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 175 } |
175 | 176 |
176 void SkImageBaseBitmap::onEndElement(SkAnimateMaker& maker) { | 177 void SkImageBaseBitmap::onEndElement(SkAnimateMaker& maker) { |
177 fUriBase = maker.fPrefix.c_str(); | 178 fUriBase = maker.fPrefix.c_str(); |
178 } | 179 } |
179 | 180 |
180 void SkImageBaseBitmap::resolve() { | 181 void SkImageBaseBitmap::resolve() { |
181 fDirty = false; | 182 fDirty = false; |
182 if (base64.fData) { | 183 if (base64.fData) { |
183 fBitmap.reset(); | 184 fBitmap.reset(); |
184 SkImageDecoder::DecodeMemory(base64.fData, base64.fLength, &fBitmap); | 185 sk_sp<SkData> data = SkData::MakeWithoutCopy(base64.fData, base64.fLengt
h); |
| 186 sk_sp<SkImage> image = SkImage::MakeFromEncoded(data); |
| 187 image->asLegacyBitmap(&fBitmap, SkImage::kRO_LegacyBitmapMode); |
185 } else if (src.size()) { | 188 } else if (src.size()) { |
186 if (fLast.equals(src)) | 189 if (fLast.equals(src)) |
187 return; | 190 return; |
188 fLast.set(src); | 191 fLast.set(src); |
189 fBitmap.reset(); | 192 fBitmap.reset(); |
190 | 193 |
191 //SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str()); | 194 //SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str()); |
192 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(src.c_str())); | 195 sk_sp<SkData> data = SkData::MakeFromFileName(src.c_str()); |
193 if (stream.get()) { | 196 if (data) { |
194 SkImageDecoder::DecodeStream(stream, &fBitmap); | 197 sk_sp<SkImage> image = SkImage::MakeFromEncoded(data); |
| 198 image->asLegacyBitmap(&fBitmap, SkImage::kRO_LegacyBitmapMode); |
195 } | 199 } |
196 } | 200 } |
197 } | 201 } |
OLD | NEW |