OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 } | 1204 } |
1205 | 1205 |
1206 const size_t ramRB = info.minRowBytes(); | 1206 const size_t ramRB = info.minRowBytes(); |
1207 const int height = info.height(); | 1207 const int height = info.height(); |
1208 const size_t snugSize = snugRB * height; | 1208 const size_t snugSize = snugRB * height; |
1209 const size_t ramSize = ramRB * height; | 1209 const size_t ramSize = ramRB * height; |
1210 if (!buffer->validate(snugSize <= ramSize)) { | 1210 if (!buffer->validate(snugSize <= ramSize)) { |
1211 return false; | 1211 return false; |
1212 } | 1212 } |
1213 | 1213 |
1214 char* dst = (char*)sk_malloc_throw(ramSize); | 1214 SkAutoDataUnref data(SkData::NewUninitialized(ramSize)); |
| 1215 char* dst = (char*)data->writable_data(); |
1215 buffer->readByteArray(dst, snugSize); | 1216 buffer->readByteArray(dst, snugSize); |
1216 SkAutoDataUnref data(SkData::NewFromMalloc(dst, ramSize)); | |
1217 | 1217 |
1218 if (snugSize != ramSize) { | 1218 if (snugSize != ramSize) { |
1219 const char* srcRow = dst + snugRB * (height - 1); | 1219 const char* srcRow = dst + snugRB * (height - 1); |
1220 char* dstRow = dst + ramRB * (height - 1); | 1220 char* dstRow = dst + ramRB * (height - 1); |
1221 for (int y = height - 1; y >= 1; --y) { | 1221 for (int y = height - 1; y >= 1; --y) { |
1222 memmove(dstRow, srcRow, snugRB); | 1222 memmove(dstRow, srcRow, snugRB); |
1223 srcRow -= snugRB; | 1223 srcRow -= snugRB; |
1224 dstRow -= ramRB; | 1224 dstRow -= ramRB; |
1225 } | 1225 } |
1226 SkASSERT(srcRow == dstRow); // first row does not need to be moved | 1226 SkASSERT(srcRow == dstRow); // first row does not need to be moved |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 /////////////////////////////////////////////////////////////////////////////// | 1380 /////////////////////////////////////////////////////////////////////////////// |
1381 | 1381 |
1382 #ifdef SK_DEBUG | 1382 #ifdef SK_DEBUG |
1383 void SkImageInfo::validate() const { | 1383 void SkImageInfo::validate() const { |
1384 SkASSERT(fWidth >= 0); | 1384 SkASSERT(fWidth >= 0); |
1385 SkASSERT(fHeight >= 0); | 1385 SkASSERT(fHeight >= 0); |
1386 SkASSERT(SkColorTypeIsValid(fColorType)); | 1386 SkASSERT(SkColorTypeIsValid(fColorType)); |
1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1388 } | 1388 } |
1389 #endif | 1389 #endif |
OLD | NEW |