Index: src/core/SkBitmap.cpp |
=================================================================== |
--- src/core/SkBitmap.cpp (revision 12666) |
+++ src/core/SkBitmap.cpp (working copy) |
@@ -453,20 +453,10 @@ |
return; |
} |
- SkImageInfo info; |
- if (!this->asImageInfo(&info)) { |
- this->setPixelRef(NULL, 0); |
- return; |
- } |
+ Sk64 size = this->getSize64(); |
+ SkASSERT(!size.isNeg() && size.is32()); |
- SkPixelRef* pr = SkMallocPixelRef::NewDirect(info, p, fRowBytes, ctable); |
- if (NULL == pr) { |
- this->setPixelRef(NULL, 0); |
- return; |
- } |
- |
- this->setPixelRef(pr)->unref(); |
- |
+ this->setPixelRef(new SkMallocPixelRef(p, size.get32(), ctable, false))->unref(); |
// since we're already allocated, we lockPixels right away |
this->lockPixels(); |
SkDEBUGCODE(this->validate();) |
@@ -531,19 +521,17 @@ |
*/ |
bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst, |
SkColorTable* ctable) { |
- SkImageInfo info; |
- if (!dst->asImageInfo(&info)) { |
-// SkDebugf("unsupported config for info %d\n", dst->config()); |
+ Sk64 size = dst->getSize64(); |
+ if (size.isNeg() || !size.is32()) { |
return false; |
} |
- |
- SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, dst->rowBytes(), |
- ctable); |
- if (NULL == pr) { |
+ |
+ void* addr = sk_malloc_flags(size.get32(), 0); // returns NULL on failure |
+ if (NULL == addr) { |
return false; |
} |
- dst->setPixelRef(pr, 0)->unref(); |
+ dst->setPixelRef(new SkMallocPixelRef(addr, size.get32(), ctable))->unref(); |
// since we're already allocated, we lockPixels right away |
dst->lockPixels(); |
return true; |