OLD | NEW |
| 1 |
1 /* | 2 /* |
2 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
3 * | 4 * |
4 * 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 |
5 * found in the LICENSE file. | 6 * found in the LICENSE file. |
6 */ | 7 */ |
7 | 8 |
| 9 |
8 #include "SkAtomics.h" | 10 #include "SkAtomics.h" |
9 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
11 #include "SkData.h" | 13 #include "SkDither.h" |
12 #include "SkFilterQuality.h" | 14 #include "SkFlattenable.h" |
| 15 #include "SkImagePriv.h" |
13 #include "SkMallocPixelRef.h" | 16 #include "SkMallocPixelRef.h" |
14 #include "SkMask.h" | 17 #include "SkMask.h" |
15 #include "SkMath.h" | 18 #include "SkPackBits.h" |
16 #include "SkPixelRef.h" | 19 #include "SkPixelRef.h" |
17 #include "SkReadBuffer.h" | 20 #include "SkReadBuffer.h" |
18 #include "SkRect.h" | |
19 #include "SkScalar.h" | |
20 #include "SkUnPreMultiply.h" | 21 #include "SkUnPreMultiply.h" |
| 22 #include "SkUtils.h" |
| 23 #include "SkValidationUtils.h" |
21 #include "SkWriteBuffer.h" | 24 #include "SkWriteBuffer.h" |
22 | 25 #include <new> |
23 #include <string.h> | |
24 | 26 |
25 static bool reset_return_false(SkBitmap* bm) { | 27 static bool reset_return_false(SkBitmap* bm) { |
26 bm->reset(); | 28 bm->reset(); |
27 return false; | 29 return false; |
28 } | 30 } |
29 | 31 |
30 SkBitmap::SkBitmap() { | 32 SkBitmap::SkBitmap() { |
31 sk_bzero(this, sizeof(*this)); | 33 sk_bzero(this, sizeof(*this)); |
32 } | 34 } |
33 | 35 |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 742 } |
741 SkDEBUGCODE(dst.validate();) | 743 SkDEBUGCODE(dst.validate();) |
742 | 744 |
743 // we know we're good, so commit to result | 745 // we know we're good, so commit to result |
744 result->swap(dst); | 746 result->swap(dst); |
745 return true; | 747 return true; |
746 } | 748 } |
747 | 749 |
748 /////////////////////////////////////////////////////////////////////////////// | 750 /////////////////////////////////////////////////////////////////////////////// |
749 | 751 |
| 752 #include "SkCanvas.h" |
| 753 #include "SkPaint.h" |
| 754 |
750 bool SkBitmap::canCopyTo(SkColorType dstColorType) const { | 755 bool SkBitmap::canCopyTo(SkColorType dstColorType) const { |
751 const SkColorType srcCT = this->colorType(); | 756 const SkColorType srcCT = this->colorType(); |
752 | 757 |
753 if (srcCT == kUnknown_SkColorType) { | 758 if (srcCT == kUnknown_SkColorType) { |
754 return false; | 759 return false; |
755 } | 760 } |
756 | 761 |
757 bool sameConfigs = (srcCT == dstColorType); | 762 bool sameConfigs = (srcCT == dstColorType); |
758 switch (dstColorType) { | 763 switch (dstColorType) { |
759 case kAlpha_8_SkColorType: | 764 case kAlpha_8_SkColorType: |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrig
in.fX); | 1214 SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrig
in.fX); |
1210 SkASSERT(fPixelRef->info().height() >= (int)this->height() + fPixelRefOr
igin.fY); | 1215 SkASSERT(fPixelRef->info().height() >= (int)this->height() + fPixelRefOr
igin.fY); |
1211 SkASSERT(fPixelRef->rowBytes() >= fInfo.minRowBytes()); | 1216 SkASSERT(fPixelRef->rowBytes() >= fInfo.minRowBytes()); |
1212 } else { | 1217 } else { |
1213 SkASSERT(NULL == fColorTable); | 1218 SkASSERT(NULL == fColorTable); |
1214 } | 1219 } |
1215 } | 1220 } |
1216 #endif | 1221 #endif |
1217 | 1222 |
1218 #ifndef SK_IGNORE_TO_STRING | 1223 #ifndef SK_IGNORE_TO_STRING |
1219 #include "SkString.h" | |
1220 void SkBitmap::toString(SkString* str) const { | 1224 void SkBitmap::toString(SkString* str) const { |
1221 | 1225 |
1222 static const char* gColorTypeNames[kLastEnum_SkColorType + 1] = { | 1226 static const char* gColorTypeNames[kLastEnum_SkColorType + 1] = { |
1223 "UNKNOWN", "A8", "565", "4444", "RGBA", "BGRA", "INDEX8", | 1227 "UNKNOWN", "A8", "565", "4444", "RGBA", "BGRA", "INDEX8", |
1224 }; | 1228 }; |
1225 | 1229 |
1226 str->appendf("bitmap: ((%d, %d) %s", this->width(), this->height(), | 1230 str->appendf("bitmap: ((%d, %d) %s", this->width(), this->height(), |
1227 gColorTypeNames[this->colorType()]); | 1231 gColorTypeNames[this->colorType()]); |
1228 | 1232 |
1229 str->append(" ("); | 1233 str->append(" ("); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 /////////////////////////////////////////////////////////////////////////////// | 1304 /////////////////////////////////////////////////////////////////////////////// |
1301 | 1305 |
1302 #ifdef SK_DEBUG | 1306 #ifdef SK_DEBUG |
1303 void SkImageInfo::validate() const { | 1307 void SkImageInfo::validate() const { |
1304 SkASSERT(fWidth >= 0); | 1308 SkASSERT(fWidth >= 0); |
1305 SkASSERT(fHeight >= 0); | 1309 SkASSERT(fHeight >= 0); |
1306 SkASSERT(SkColorTypeIsValid(fColorType)); | 1310 SkASSERT(SkColorTypeIsValid(fColorType)); |
1307 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1311 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1308 } | 1312 } |
1309 #endif | 1313 #endif |
OLD | NEW |