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

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

Issue 93703004: Change SkDecodingImageGenerator API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 1 Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 Sk64 size; 215 Sk64 size;
216 size.setMul(SkToS32(SkBitmap::ComputeRowBytes(c, width)), height); 216 size.setMul(SkToS32(SkBitmap::ComputeRowBytes(c, width)), height);
217 return size; 217 return size;
218 } 218 }
219 219
220 size_t SkBitmap::ComputeSize(Config c, int width, int height) { 220 size_t SkBitmap::ComputeSize(Config c, int width, int height) {
221 Sk64 size = SkBitmap::ComputeSize64(c, width, height); 221 Sk64 size = SkBitmap::ComputeSize64(c, width, height);
222 return isPos32Bits(size) ? size.get32() : 0; 222 return isPos32Bits(size) ? size.get32() : 0;
223 } 223 }
224 224
225 Sk64 SkBitmap::ComputeSize64(const SkImageInfo& info) {
226 return SkBitmap::ComputeSize64(SkImageInfoToBitmapConfig(info),
227 info.fWidth, info.fHeight);
228 }
229
230 size_t SkBitmap::ComputeSize(const SkImageInfo& info) {
231 return SkBitmap::ComputeSize(SkImageInfoToBitmapConfig(info),
232 info.fWidth, info.fHeight);
233 }
234
225 Sk64 SkBitmap::ComputeSafeSize64(Config config, 235 Sk64 SkBitmap::ComputeSafeSize64(Config config,
226 uint32_t width, 236 uint32_t width,
227 uint32_t height, 237 uint32_t height,
228 size_t rowBytes) { 238 size_t rowBytes) {
229 Sk64 safeSize; 239 Sk64 safeSize;
230 safeSize.setZero(); 240 safeSize.setZero();
231 if (height > 0) { 241 if (height > 0) {
232 // TODO: Handle the case where the return value from 242 // TODO: Handle the case where the return value from
233 // ComputeRowBytes is more than 31 bits. 243 // ComputeRowBytes is more than 31 bits.
234 safeSize.set(SkToS32(ComputeRowBytes(config, width))); 244 safeSize.set(SkToS32(ComputeRowBytes(config, width)));
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 /** We explicitly use the same allocator for our pixels that SkMask does, 539 /** We explicitly use the same allocator for our pixels that SkMask does,
530 so that we can freely assign memory allocated by one class to the other. 540 so that we can freely assign memory allocated by one class to the other.
531 */ 541 */
532 bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst, 542 bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst,
533 SkColorTable* ctable) { 543 SkColorTable* ctable) {
534 SkImageInfo info; 544 SkImageInfo info;
535 if (!dst->asImageInfo(&info)) { 545 if (!dst->asImageInfo(&info)) {
536 // SkDebugf("unsupported config for info %d\n", dst->config()); 546 // SkDebugf("unsupported config for info %d\n", dst->config());
537 return false; 547 return false;
538 } 548 }
539 549
540 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, dst->rowBytes(), 550 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, dst->rowBytes(),
541 ctable); 551 ctable);
542 if (NULL == pr) { 552 if (NULL == pr) {
543 return false; 553 return false;
544 } 554 }
545 555
546 dst->setPixelRef(pr, 0)->unref(); 556 dst->setPixelRef(pr, 0)->unref();
547 // since we're already allocated, we lockPixels right away 557 // since we're already allocated, we lockPixels right away
548 dst->lockPixels(); 558 dst->lockPixels();
549 return true; 559 return true;
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 if (NULL != uri) { 1721 if (NULL != uri) {
1712 str->appendf(" uri:\"%s\"", uri); 1722 str->appendf(" uri:\"%s\"", uri);
1713 } else { 1723 } else {
1714 str->appendf(" pixelref:%p", pr); 1724 str->appendf(" pixelref:%p", pr);
1715 } 1725 }
1716 } 1726 }
1717 1727
1718 str->append(")"); 1728 str->append(")");
1719 } 1729 }
1720 #endif 1730 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698