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

Unified Diff: src/core/SkMipMap.cpp

Issue 122283002: Revert of remove Sk64 from public API, and start to remove usage internally (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | src/core/SkRegion_path.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMipMap.cpp
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index ff62f4d59d53b154340d69a611621fec49edc1c7..4888b574e4a687c63e400374b99d4c973686535b 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -109,15 +109,21 @@
*dst->getAddr16(x >> 1, y >> 1) = (uint16_t)collaps4444(c >> 2);
}
+static bool isPos32Bits(const Sk64& value) {
+ return !value.isNeg() && value.is32();
+}
+
SkMipMap::Level* SkMipMap::AllocLevels(int levelCount, size_t pixelSize) {
if (levelCount < 0) {
return NULL;
}
- int64_t size = sk_64_mul(levelCount + 1, sizeof(Level)) + pixelSize;
- if (!sk_64_isS32(size)) {
- return NULL;
- }
- return (Level*)sk_malloc_throw(sk_64_asS32(size));
+ Sk64 size;
+ size.setMul(levelCount + 1, sizeof(Level));
+ size.add(SkToS32(pixelSize));
+ if (!isPos32Bits(size)) {
+ return NULL;
+ }
+ return (Level*)sk_malloc_throw(size.get32());
}
SkMipMap* SkMipMap::Build(const SkBitmap& src) {
« 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