| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkData.h" | 11 #include "SkData.h" |
| 12 #include "SkFilterQuality.h" | 12 #include "SkFilterQuality.h" |
| 13 #include "SkMallocPixelRef.h" | 13 #include "SkMallocPixelRef.h" |
| 14 #include "SkMask.h" | 14 #include "SkMask.h" |
| 15 #include "SkMath.h" | 15 #include "SkMath.h" |
| 16 #include "SkPixelRef.h" | 16 #include "SkPixelRef.h" |
| 17 #include "SkReadBuffer.h" | 17 #include "SkReadBuffer.h" |
| 18 #include "SkRect.h" | 18 #include "SkRect.h" |
| 19 #include "SkScalar.h" | 19 #include "SkScalar.h" |
| 20 #include "SkTemplates.h" |
| 20 #include "SkUnPreMultiply.h" | 21 #include "SkUnPreMultiply.h" |
| 21 #include "SkWriteBuffer.h" | 22 #include "SkWriteBuffer.h" |
| 22 | 23 |
| 23 #include <string.h> | 24 #include <string.h> |
| 24 | 25 |
| 25 static bool reset_return_false(SkBitmap* bm) { | 26 static bool reset_return_false(SkBitmap* bm) { |
| 26 bm->reset(); | 27 bm->reset(); |
| 27 return false; | 28 return false; |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 static void write_raw_pixels(SkWriteBuffer* buffer, const SkPixmap& pmap) { | 1076 static void write_raw_pixels(SkWriteBuffer* buffer, const SkPixmap& pmap) { |
| 1076 const SkImageInfo& info = pmap.info(); | 1077 const SkImageInfo& info = pmap.info(); |
| 1077 const size_t snugRB = info.width() * info.bytesPerPixel(); | 1078 const size_t snugRB = info.width() * info.bytesPerPixel(); |
| 1078 const char* src = (const char*)pmap.addr(); | 1079 const char* src = (const char*)pmap.addr(); |
| 1079 const size_t ramRB = pmap.rowBytes(); | 1080 const size_t ramRB = pmap.rowBytes(); |
| 1080 | 1081 |
| 1081 buffer->write32(SkToU32(snugRB)); | 1082 buffer->write32(SkToU32(snugRB)); |
| 1082 info.flatten(*buffer); | 1083 info.flatten(*buffer); |
| 1083 | 1084 |
| 1084 const size_t size = snugRB * info.height(); | 1085 const size_t size = snugRB * info.height(); |
| 1085 SkAutoMalloc storage(size); | 1086 SkAutoTMalloc<char> storage(size); |
| 1086 char* dst = (char*)storage.get(); | 1087 char* dst = storage.get(); |
| 1087 for (int y = 0; y < info.height(); ++y) { | 1088 for (int y = 0; y < info.height(); ++y) { |
| 1088 memcpy(dst, src, snugRB); | 1089 memcpy(dst, src, snugRB); |
| 1089 dst += snugRB; | 1090 dst += snugRB; |
| 1090 src += ramRB; | 1091 src += ramRB; |
| 1091 } | 1092 } |
| 1092 buffer->writeByteArray(storage.get(), size); | 1093 buffer->writeByteArray(storage.get(), size); |
| 1093 | 1094 |
| 1094 const SkColorTable* ct = pmap.ctable(); | 1095 const SkColorTable* ct = pmap.ctable(); |
| 1095 if (kIndex_8_SkColorType == info.colorType() && ct) { | 1096 if (kIndex_8_SkColorType == info.colorType() && ct) { |
| 1096 buffer->writeBool(true); | 1097 buffer->writeBool(true); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 /////////////////////////////////////////////////////////////////////////////// | 1328 /////////////////////////////////////////////////////////////////////////////// |
| 1328 | 1329 |
| 1329 #ifdef SK_DEBUG | 1330 #ifdef SK_DEBUG |
| 1330 void SkImageInfo::validate() const { | 1331 void SkImageInfo::validate() const { |
| 1331 SkASSERT(fWidth >= 0); | 1332 SkASSERT(fWidth >= 0); |
| 1332 SkASSERT(fHeight >= 0); | 1333 SkASSERT(fHeight >= 0); |
| 1333 SkASSERT(SkColorTypeIsValid(fColorType)); | 1334 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1334 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1335 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1335 } | 1336 } |
| 1336 #endif | 1337 #endif |
| OLD | NEW |