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

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

Issue 1212373006: Swizzling, except for premultiplying, done using libpng transforms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixing size of row allocation, member variable initialization, and synax issues Created 5 years, 5 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
« src/codec/SkCodec_libpng.cpp ('K') | « src/codec/SkCodec_libpng.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkMallocPixelRef.h" 8 #include "SkMallocPixelRef.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 return SkNEW_ARGS(SkMallocPixelRef, 47 return SkNEW_ARGS(SkMallocPixelRef,
48 (info, addr, rowBytes, ctable, NULL, NULL)); 48 (info, addr, rowBytes, ctable, NULL, NULL));
49 } 49 }
50 50
51 51
52 SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info, 52 SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info,
53 size_t requestedRowBytes, 53 size_t requestedRowBytes,
54 SkColorTable* ctable) { 54 SkColorTable* ctable) {
55 if (!is_valid(info, ctable)) { 55 if (!is_valid(info, ctable)) {
56 SkDebugf("failing 1\n");
scroggo 2015/06/30 20:50:04 I think you didn't mean to include the changes to
56 return NULL; 57 return NULL;
57 } 58 }
58 59
59 // only want to permit 31bits of rowBytes 60 // only want to permit 31bits of rowBytes
60 int64_t minRB = (int64_t)info.minRowBytes64(); 61 int64_t minRB = (int64_t)info.minRowBytes64();
61 if (minRB < 0 || !sk_64_isS32(minRB)) { 62 if (minRB < 0 || !sk_64_isS32(minRB)) {
63 SkDebugf("failing 2\n");
62 return NULL; // allocation will be too large 64 return NULL; // allocation will be too large
63 } 65 }
64 if (requestedRowBytes > 0 && (int32_t)requestedRowBytes < minRB) { 66 if (requestedRowBytes > 0 && (int32_t)requestedRowBytes < minRB) {
67 SkDebugf("failing 3\n");
65 return NULL; // cannot meet requested rowbytes 68 return NULL; // cannot meet requested rowbytes
66 } 69 }
67 70
68 int32_t rowBytes; 71 int32_t rowBytes;
69 if (requestedRowBytes) { 72 if (requestedRowBytes) {
70 rowBytes = SkToS32(requestedRowBytes); 73 rowBytes = SkToS32(requestedRowBytes);
71 } else { 74 } else {
72 rowBytes = minRB; 75 rowBytes = minRB;
73 } 76 }
74 77
75 int64_t bigSize = (int64_t)info.height() * rowBytes; 78 int64_t bigSize = (int64_t)info.height() * rowBytes;
76 if (!sk_64_isS32(bigSize)) { 79 if (!sk_64_isS32(bigSize)) {
80 SkDebugf("failing 4\n");
77 return NULL; 81 return NULL;
78 } 82 }
79 83
80 size_t size = sk_64_asS32(bigSize); 84 size_t size = sk_64_asS32(bigSize);
81 SkASSERT(size >= info.getSafeSize(rowBytes)); 85 SkASSERT(size >= info.getSafeSize(rowBytes));
82 void* addr = sk_malloc_flags(size, 0); 86 void* addr = sk_malloc_flags(size, 0);
83 if (NULL == addr) { 87 if (NULL == addr) {
88 SkDebugf("failing 5\n");
84 return NULL; 89 return NULL;
85 } 90 }
86 91
87 return SkNEW_ARGS(SkMallocPixelRef, 92 return SkNEW_ARGS(SkMallocPixelRef,
88 (info, addr, rowBytes, ctable, 93 (info, addr, rowBytes, ctable,
89 sk_free_releaseproc, NULL)); 94 sk_free_releaseproc, NULL));
90 } 95 }
91 96
92 SkMallocPixelRef* SkMallocPixelRef::NewWithProc(const SkImageInfo& info, 97 SkMallocPixelRef* SkMallocPixelRef::NewWithProc(const SkImageInfo& info,
93 size_t rowBytes, 98 size_t rowBytes,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { 204 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const {
200 return this->info().getSafeSize(fRB); 205 return this->info().getSafeSize(fRB);
201 } 206 }
202 207
203 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
204 209
205 SkPixelRef* SkMallocPixelRef::PRFactory::create(const SkImageInfo& info, size_t rowBytes, 210 SkPixelRef* SkMallocPixelRef::PRFactory::create(const SkImageInfo& info, size_t rowBytes,
206 SkColorTable* ctable) { 211 SkColorTable* ctable) {
207 return SkMallocPixelRef::NewAllocate(info, rowBytes, ctable); 212 return SkMallocPixelRef::NewAllocate(info, rowBytes, ctable);
208 } 213 }
OLDNEW
« src/codec/SkCodec_libpng.cpp ('K') | « src/codec/SkCodec_libpng.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698