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