Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: src/core/SkBitmap.cpp

Issue 1779263003: Make sp variants for SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/c/sk_surface.cpp ('k') | src/core/SkData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 1156
1157 const size_t ramRB = info.minRowBytes(); 1157 const size_t ramRB = info.minRowBytes();
1158 const int height = SkMax32(info.height(), 0); 1158 const int height = SkMax32(info.height(), 0);
1159 const uint64_t snugSize = sk_64_mul(snugRB, height); 1159 const uint64_t snugSize = sk_64_mul(snugRB, height);
1160 const uint64_t ramSize = sk_64_mul(ramRB, height); 1160 const uint64_t ramSize = sk_64_mul(ramRB, height);
1161 static const uint64_t max_size_t = (size_t)(-1); 1161 static const uint64_t max_size_t = (size_t)(-1);
1162 if (!buffer->validate((snugSize <= ramSize) && (ramSize <= max_size_t))) { 1162 if (!buffer->validate((snugSize <= ramSize) && (ramSize <= max_size_t))) {
1163 return false; 1163 return false;
1164 } 1164 }
1165 1165
1166 SkAutoDataUnref data(SkData::NewUninitialized(SkToSizeT(ramSize))); 1166 sk_sp<SkData> data(SkData::MakeUninitialized(SkToSizeT(ramSize)));
1167 unsigned char* dst = (unsigned char*)data->writable_data(); 1167 unsigned char* dst = (unsigned char*)data->writable_data();
1168 buffer->readByteArray(dst, SkToSizeT(snugSize)); 1168 buffer->readByteArray(dst, SkToSizeT(snugSize));
1169 1169
1170 if (snugSize != ramSize) { 1170 if (snugSize != ramSize) {
1171 const unsigned char* srcRow = dst + snugRB * (height - 1); 1171 const unsigned char* srcRow = dst + snugRB * (height - 1);
1172 unsigned char* dstRow = dst + ramRB * (height - 1); 1172 unsigned char* dstRow = dst + ramRB * (height - 1);
1173 for (int y = height - 1; y >= 1; --y) { 1173 for (int y = height - 1; y >= 1; --y) {
1174 memmove(dstRow, srcRow, snugRB); 1174 memmove(dstRow, srcRow, snugRB);
1175 srcRow -= snugRB; 1175 srcRow -= snugRB;
1176 dstRow -= ramRB; 1176 dstRow -= ramRB;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 /////////////////////////////////////////////////////////////////////////////// 1351 ///////////////////////////////////////////////////////////////////////////////
1352 1352
1353 #ifdef SK_DEBUG 1353 #ifdef SK_DEBUG
1354 void SkImageInfo::validate() const { 1354 void SkImageInfo::validate() const {
1355 SkASSERT(fWidth >= 0); 1355 SkASSERT(fWidth >= 0);
1356 SkASSERT(fHeight >= 0); 1356 SkASSERT(fHeight >= 0);
1357 SkASSERT(SkColorTypeIsValid(fColorType)); 1357 SkASSERT(SkColorTypeIsValid(fColorType));
1358 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1358 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1359 } 1359 }
1360 #endif 1360 #endif
OLDNEW
« no previous file with comments | « src/c/sk_surface.cpp ('k') | src/core/SkData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698