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

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

Issue 113823003: remove Sk64 from public API, and start to remove usage internally (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | src/core/SkRegion_path.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 2013 Google Inc. 2 * Copyright 2013 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 "SkMipMap.h" 8 #include "SkMipMap.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 c += expand4444(*p); 103 c += expand4444(*p);
104 if (x < src.width() - 1) { 104 if (x < src.width() - 1) {
105 p += 1; 105 p += 1;
106 } 106 }
107 c += expand4444(*p); 107 c += expand4444(*p);
108 108
109 *dst->getAddr16(x >> 1, y >> 1) = (uint16_t)collaps4444(c >> 2); 109 *dst->getAddr16(x >> 1, y >> 1) = (uint16_t)collaps4444(c >> 2);
110 } 110 }
111 111
112 static bool isPos32Bits(const Sk64& value) {
113 return !value.isNeg() && value.is32();
114 }
115
116 SkMipMap::Level* SkMipMap::AllocLevels(int levelCount, size_t pixelSize) { 112 SkMipMap::Level* SkMipMap::AllocLevels(int levelCount, size_t pixelSize) {
117 if (levelCount < 0) { 113 if (levelCount < 0) {
118 return NULL; 114 return NULL;
119 } 115 }
120 Sk64 size; 116 int64_t size = sk_64_mul(levelCount + 1, sizeof(Level)) + pixelSize;
121 size.setMul(levelCount + 1, sizeof(Level)); 117 if (!sk_64_isS32(size)) {
122 size.add(SkToS32(pixelSize));
123 if (!isPos32Bits(size)) {
124 return NULL; 118 return NULL;
125 } 119 }
126 return (Level*)sk_malloc_throw(size.get32()); 120 return (Level*)sk_malloc_throw(sk_64_asS32(size));
127 } 121 }
128 122
129 SkMipMap* SkMipMap::Build(const SkBitmap& src) { 123 SkMipMap* SkMipMap::Build(const SkBitmap& src) {
130 void (*proc)(SkBitmap* dst, int x, int y, const SkBitmap& src); 124 void (*proc)(SkBitmap* dst, int x, int y, const SkBitmap& src);
131 125
132 const SkBitmap::Config config = src.config(); 126 const SkBitmap::Config config = src.config();
133 switch (config) { 127 switch (config) {
134 case SkBitmap::kARGB_8888_Config: 128 case SkBitmap::kARGB_8888_Config:
135 proc = downsampleby2_proc32; 129 proc = downsampleby2_proc32;
136 break; 130 break;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 247 }
254 248
255 if (level > fCount) { 249 if (level > fCount) {
256 level = fCount; 250 level = fCount;
257 } 251 }
258 if (levelPtr) { 252 if (levelPtr) {
259 *levelPtr = fLevels[level - 1]; 253 *levelPtr = fLevels[level - 1];
260 } 254 }
261 return true; 255 return true;
262 } 256 }
OLDNEW
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | src/core/SkRegion_path.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698