| 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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 SK_MEMBER(format, BitmapFormat), | 49 SK_MEMBER(format, BitmapFormat), |
| 50 SK_MEMBER(height, Int), | 50 SK_MEMBER(height, Int), |
| 51 SK_MEMBER(rowBytes, Int), | 51 SK_MEMBER(rowBytes, Int), |
| 52 SK_MEMBER(width, Int), | 52 SK_MEMBER(width, Int), |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 DEFINE_GET_MEMBER(SkDrawBitmap); | 57 DEFINE_GET_MEMBER(SkDrawBitmap); |
| 58 | 58 |
| 59 SkDrawBitmap::SkDrawBitmap() : format((SkBitmap::Config) -1), height(-1), | 59 SkDrawBitmap::SkDrawBitmap() : format((SkColorType) -1), height(-1), |
| 60 rowBytes(0), width(-1), fColor(0), fColorSet(false) { | 60 rowBytes(0), width(-1), fColor(0), fColorSet(false) { |
| 61 } | 61 } |
| 62 | 62 |
| 63 SkDrawBitmap::~SkDrawBitmap() { | 63 SkDrawBitmap::~SkDrawBitmap() { |
| 64 } | 64 } |
| 65 | 65 |
| 66 #ifdef SK_DUMP_ENABLED | 66 #ifdef SK_DUMP_ENABLED |
| 67 void SkDrawBitmap::dump(SkAnimateMaker* maker) { | 67 void SkDrawBitmap::dump(SkAnimateMaker* maker) { |
| 68 dumpBase(maker); | 68 dumpBase(maker); |
| 69 dumpAttrs(maker); | 69 dumpAttrs(maker); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 81 case 4: formatName = "RGB32"; break; | 81 case 4: formatName = "RGB32"; break; |
| 82 } | 82 } |
| 83 SkDebugf("format=\"%s\" />\n", formatName); | 83 SkDebugf("format=\"%s\" />\n", formatName); |
| 84 } | 84 } |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 void SkDrawBitmap::onEndElement(SkAnimateMaker&) { | 87 void SkDrawBitmap::onEndElement(SkAnimateMaker&) { |
| 88 SkASSERT(width != -1); | 88 SkASSERT(width != -1); |
| 89 SkASSERT(height != -1); | 89 SkASSERT(height != -1); |
| 90 SkASSERT(rowBytes >= 0); | 90 SkASSERT(rowBytes >= 0); |
| 91 SkColorType colorType = SkBitmapConfigToColorType((SkBitmap::Config)format); | 91 SkColorType colorType = SkColorType(format); |
| 92 fBitmap.setInfo(SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaT
ype), rowBytes); | 92 fBitmap.setInfo(SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaT
ype), rowBytes); |
| 93 fBitmap.allocPixels(); | 93 fBitmap.allocPixels(); |
| 94 if (fColorSet) | 94 if (fColorSet) |
| 95 fBitmap.eraseColor(fColor); | 95 fBitmap.eraseColor(fColor); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool SkDrawBitmap::setProperty(int index, SkScriptValue& value) | 98 bool SkDrawBitmap::setProperty(int index, SkScriptValue& value) |
| 99 { | 99 { |
| 100 switch (index) { | 100 switch (index) { |
| 101 case SK_PROPERTY(erase): | 101 case SK_PROPERTY(erase): |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 fLast.set(src); | 188 fLast.set(src); |
| 189 fBitmap.reset(); | 189 fBitmap.reset(); |
| 190 | 190 |
| 191 //SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str()); | 191 //SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str()); |
| 192 SkAutoTUnref<SkStreamAsset> stream(SkStream::NewFromFile(src.c_str())); | 192 SkAutoTUnref<SkStreamAsset> stream(SkStream::NewFromFile(src.c_str())); |
| 193 if (stream.get()) { | 193 if (stream.get()) { |
| 194 SkImageDecoder::DecodeStream(stream, &fBitmap); | 194 SkImageDecoder::DecodeStream(stream, &fBitmap); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 } | 197 } |
| OLD | NEW |