aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-09-02 12:50:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-02 12:50:45 -0700
commit848250415eddc54075f7eb8795e8db79e749c6ab (patch)
treeeb60aea6e61c9b3a9e195ab3cfb01d571351f78b
parent00f30bdc9e34b013da54b4406f36556c5be8d041 (diff)
make allocPixels throw on failure
BUG=skia: R=mtklein@google.com, fmalita@google.com, fmalita@chromium.org Author: reed@google.com Review URL: https://codereview.chromium.org/510423005
-rw-r--r--gyp/skia_for_chromium_defines.gypi1
-rw-r--r--include/core/SkBitmap.h68
-rw-r--r--samplecode/SampleApp.cpp2
-rw-r--r--samplecode/SampleFilterFuzz.cpp2
-rw-r--r--samplecode/SampleUnpremul.cpp6
-rw-r--r--src/core/SkBitmap.cpp14
-rw-r--r--src/core/SkBitmapDevice.cpp2
-rw-r--r--src/core/SkCanvas.cpp8
-rw-r--r--src/core/SkPictureShader.cpp2
-rw-r--r--src/core/SkScalerContext.cpp2
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp2
-rw-r--r--src/effects/SkBlurImageFilter.cpp4
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp2
-rw-r--r--src/effects/SkLightingImageFilter.cpp4
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp2
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp4
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp4
-rw-r--r--src/gpu/GrSWMaskHelper.cpp2
-rw-r--r--src/gpu/GrSurface.cpp3
-rw-r--r--src/gpu/SkGrPixelRef.cpp2
-rw-r--r--src/image/SkImage.cpp3
-rw-r--r--src/images/SkDecodingImageGenerator.cpp2
-rw-r--r--src/images/SkImageDecoder.cpp2
-rw-r--r--src/images/SkImageDecoder_libjpeg.cpp2
-rw-r--r--src/images/SkImageDecoder_libpng.cpp2
-rw-r--r--src/images/SkImageDecoder_libwebp.cpp2
-rw-r--r--src/images/SkMovie_gif.cpp4
-rw-r--r--src/lazy/SkCachingPixelRef.cpp2
-rw-r--r--src/lazy/SkDiscardablePixelRef.cpp2
-rw-r--r--src/pdf/SkPDFDevice.cpp2
-rw-r--r--src/pdf/SkPDFImage.cpp3
-rw-r--r--src/utils/SkPDFRasterizer.cpp2
-rw-r--r--src/utils/mac/SkCreateCGImageRef.cpp4
-rw-r--r--tests/ARGBImageEncoderTest.cpp5
-rw-r--r--tests/BitmapCopyTest.cpp14
-rw-r--r--tests/BitmapHasherTest.cpp3
-rw-r--r--tests/BitmapTest.cpp2
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp3
-rw-r--r--tests/DrawBitmapRectTest.cpp4
-rw-r--r--tests/ImageDecodingTest.cpp2
-rw-r--r--tests/KtxTest.cpp3
-rwxr-xr-xtests/PathOpsSkpClipTest.cpp3
-rw-r--r--tests/ReadPixelsTest.cpp4
-rw-r--r--tests/SerializationTest.cpp25
-rw-r--r--tests/SkResourceCacheTest.cpp2
-rw-r--r--tests/TextureCompressionTest.cpp12
-rw-r--r--tests/WritePixelsTest.cpp3
47 files changed, 137 insertions, 116 deletions
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index ac4a19f227..636fd87a8e 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -13,6 +13,7 @@
# If these become 'permanent', they should be moved into skia_common.gypi
#
'skia_for_chromium_defines': [
+ 'SK_SUPPORT_LEGACY_ALLOCPIXELS_BOOL',
'SK_IGNORE_PROPER_FRACTIONAL_SCALING',
'SK_SUPPORT_LEGACY_PICTURE_CLONE',
'SK_SUPPORT_LEGACY_GETDEVICE',
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 13a7e304c8..c58c78d764 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -14,6 +14,16 @@
#include "SkPoint.h"
#include "SkRefCnt.h"
+#ifdef SK_SUPPORT_LEGACY_ALLOCPIXELS_BOOL
+ #define SK_ALLOCPIXELS_RETURN_TYPE bool
+ #define SK_ALLOCPIXELS_RETURN_TRUE return true
+ #define SK_ALLOCPIXELS_RETURN_FAIL return false
+#else
+ #define SK_ALLOCPIXELS_RETURN_TYPE void
+ #define SK_ALLOCPIXELS_RETURN_TRUE return
+ #define SK_ALLOCPIXELS_RETURN_FAIL sk_throw()
+#endif
+
struct SkMask;
struct SkIRect;
struct SkRect;
@@ -218,7 +228,15 @@ public:
* a colortable, then ColorTable must be non-null, and will be ref'd.
* On failure, the bitmap will be set to empty and return false.
*/
- bool allocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*);
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo&, SkPixelRefFactory*, SkColorTable*);
+
+ SK_ALLOCPIXELS_RETURN_TYPE allocPixels(const SkImageInfo& info, SkPixelRefFactory* factory,
+ SkColorTable* ctable) {
+ if (!this->tryAllocPixels(info, factory, ctable)) {
+ SK_ALLOCPIXELS_RETURN_FAIL;
+ }
+ SK_ALLOCPIXELS_RETURN_TRUE;
+ }
/**
* Allocate the bitmap's pixels to match the requested image info and
@@ -228,26 +246,39 @@ public:
* the pixel size specified by info.colorType()) then false is returned
* and the bitmap is set to empty.
*/
- bool allocPixels(const SkImageInfo& info, size_t rowBytes);
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes);
- /**
- * Allocate a pixelref to match the specified image info, using the default
- * allocator.
- * On success, the bitmap's pixels will be "locked", and return true.
- * On failure, the bitmap will be set to empty and return false.
- */
- bool allocPixels(const SkImageInfo& info) {
+ SK_ALLOCPIXELS_RETURN_TYPE allocPixels(const SkImageInfo& info, size_t rowBytes) {
+ if (!this->tryAllocPixels(info, rowBytes)) {
+ SK_ALLOCPIXELS_RETURN_FAIL;
+ }
+ SK_ALLOCPIXELS_RETURN_TRUE;
+ }
+
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info) {
+ return this->tryAllocPixels(info, info.minRowBytes());
+ }
+
+ SK_ALLOCPIXELS_RETURN_TYPE allocPixels(const SkImageInfo& info) {
return this->allocPixels(info, info.minRowBytes());
}
- bool allocN32Pixels(int width, int height, bool isOpaque = false) {
+ bool SK_WARN_UNUSED_RESULT tryAllocN32Pixels(int width, int height, bool isOpaque = false) {
+ SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
+ if (isOpaque) {
+ info.fAlphaType = kOpaque_SkAlphaType;
+ }
+ return this->tryAllocPixels(info);
+ }
+
+ SK_ALLOCPIXELS_RETURN_TYPE allocN32Pixels(int width, int height, bool isOpaque = false) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
if (isOpaque) {
info.fAlphaType = kOpaque_SkAlphaType;
}
return this->allocPixels(info);
}
-
+
/**
* Install a pixelref that wraps the specified pixels and rowBytes, and
* optional ReleaseProc and context. When the pixels are no longer
@@ -320,7 +351,11 @@ public:
@return true if the allocation succeeds. If not the pixelref field of
the bitmap will be unchanged.
*/
- bool allocPixels(SkColorTable* ctable = NULL) {
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels(SkColorTable* ctable = NULL) {
+ return this->tryAllocPixels(NULL, ctable);
+ }
+
+ SK_ALLOCPIXELS_RETURN_TYPE allocPixels(SkColorTable* ctable = NULL) {
return this->allocPixels(NULL, ctable);
}
@@ -342,7 +377,14 @@ public:
@return true if the allocation succeeds. If not the pixelref field of
the bitmap will be unchanged.
*/
- bool allocPixels(Allocator* allocator, SkColorTable* ctable);
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator, SkColorTable* ctable);
+
+ SK_ALLOCPIXELS_RETURN_TYPE allocPixels(Allocator* allocator, SkColorTable* ctable) {
+ if (!this->tryAllocPixels(allocator, ctable)) {
+ SK_ALLOCPIXELS_RETURN_FAIL;
+ }
+ SK_ALLOCPIXELS_RETURN_TRUE;
+ }
/**
* Return the current pixelref object or NULL if there is none. This does
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 34d1b97360..e8d6d9911e 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -999,7 +999,7 @@ void SampleWindow::listTitles() {
static SkBitmap capture_bitmap(SkCanvas* canvas) {
SkBitmap bm;
- if (bm.allocPixels(canvas->imageInfo())) {
+ if (bm.tryAllocPixels(canvas->imageInfo())) {
canvas->readPixels(&bm, 0, 0);
}
return bm;
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 8aa48ed5c9..f4157cd6b5 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -153,7 +153,7 @@ static void rand_bitmap_for_canvas(SkBitmap* bitmap) {
do {
info = SkImageInfo::Make(kBitmapSize, kBitmapSize, rand_colortype(),
kPremul_SkAlphaType);
- } while (!valid_for_raster_canvas(info) || !bitmap->allocPixels(info));
+ } while (!valid_for_raster_canvas(info) || !bitmap->tryAllocPixels(info));
}
static void make_g_bitmap(SkBitmap& bitmap) {
diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp
index bfe69e0b50..992444d05d 100644
--- a/samplecode/SampleUnpremul.cpp
+++ b/samplecode/SampleUnpremul.cpp
@@ -128,11 +128,7 @@ protected:
// Copy it to a bitmap which can be drawn, converting
// to premultiplied:
SkBitmap bm;
- if (!bm.allocN32Pixels(fBitmap.width(), fBitmap.height())) {
- SkString errMsg("allocPixels failed");
- canvas->drawText(errMsg.c_str(), errMsg.size(), 0, height, paint);
- return;
- }
+ bm.allocN32Pixels(fBitmap.width(), fBitmap.height());
for (int i = 0; i < fBitmap.width(); ++i) {
for (int j = 0; j < fBitmap.height(); ++j) {
*bm.getAddr32(i, j) = premultiply_unpmcolor(*fBitmap.getAddr32(i, j));
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index d83199ddc4..928a4b74ed 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -268,7 +268,7 @@ void SkBitmap::setPixels(void* p, SkColorTable* ctable) {
SkDEBUGCODE(this->validate();)
}
-bool SkBitmap::allocPixels(Allocator* allocator, SkColorTable* ctable) {
+bool SkBitmap::tryAllocPixels(Allocator* allocator, SkColorTable* ctable) {
HeapAllocator stdalloc;
if (NULL == allocator) {
@@ -279,7 +279,7 @@ bool SkBitmap::allocPixels(Allocator* allocator, SkColorTable* ctable) {
///////////////////////////////////////////////////////////////////////////////
-bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) {
+bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) {
if (kIndex_8_SkColorType == requestedInfo.colorType()) {
return reset_return_false(this);
}
@@ -308,8 +308,8 @@ bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) {
return true;
}
-bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory* factory,
- SkColorTable* ctable) {
+bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory* factory,
+ SkColorTable* ctable) {
if (kIndex_8_SkColorType == requestedInfo.fColorType && NULL == ctable) {
return reset_return_false(this);
}
@@ -950,7 +950,7 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType, Allocator* alloc)
// TODO: can we just ref() the src colortable? Is it reentrant-safe?
ctable.reset(SkNEW_ARGS(SkColorTable, (*src->getColorTable())));
}
- if (!tmpDst.allocPixels(alloc, ctable)) {
+ if (!tmpDst.tryAllocPixels(alloc, ctable)) {
return false;
}
@@ -1122,7 +1122,7 @@ bool SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint,
} else {
NO_FILTER_CASE:
tmpBitmap.setInfo(SkImageInfo::MakeA8(this->width(), this->height()), srcM.fRowBytes);
- if (!tmpBitmap.allocPixels(allocator, NULL)) {
+ if (!tmpBitmap.tryAllocPixels(allocator, NULL)) {
// Allocation of pixels for alpha bitmap failed.
SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
tmpBitmap.width(), tmpBitmap.height());
@@ -1146,7 +1146,7 @@ bool SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint,
tmpBitmap.setInfo(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.height()),
dstM.fRowBytes);
- if (!tmpBitmap.allocPixels(allocator, NULL)) {
+ if (!tmpBitmap.tryAllocPixels(allocator, NULL)) {
// Allocation of pixels for alpha bitmap failed.
SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
tmpBitmap.width(), tmpBitmap.height());
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 5f205ce1e6..2287864bae 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -82,7 +82,7 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
return NULL;
}
} else {
- if (!bitmap.allocPixels(info)) {
+ if (!bitmap.tryAllocPixels(info)) {
return NULL;
}
if (!bitmap.info().isOpaque()) {
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 717878c82a..f071fc99fc 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -568,7 +568,7 @@ bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) {
bool weAllocated = false;
if (NULL == bitmap->pixelRef()) {
- if (!bitmap->allocPixels()) {
+ if (!bitmap->tryAllocPixels()) {
return false;
}
weAllocated = true;
@@ -594,7 +594,7 @@ bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
return false;
}
- if (!bitmap->allocN32Pixels(r.width(), r.height())) {
+ if (!bitmap->tryAllocN32Pixels(r.width(), r.height())) {
// bitmap will already be reset.
return false;
}
@@ -1006,7 +1006,7 @@ SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) {
fAddr = canvas->peekPixels(&fInfo, &fRowBytes);
if (NULL == fAddr) {
fInfo = canvas->imageInfo();
- if (kUnknown_SkColorType == fInfo.colorType() || !fBitmap.allocPixels(fInfo)) {
+ if (kUnknown_SkColorType == fInfo.colorType() || !fBitmap.tryAllocPixels(fInfo)) {
return; // failure, fAddr is NULL
}
if (!canvas->readPixels(&fBitmap, 0, 0)) {
@@ -2535,7 +2535,7 @@ SkCanvas* SkCanvas::NewRaster(const SkImageInfo& info) {
}
SkBitmap bitmap;
- if (!bitmap.allocPixels(info)) {
+ if (!bitmap.tryAllocPixels(info)) {
return NULL;
}
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 73ab170f11..a7b5412b5a 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -107,7 +107,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
if (!fCachedBitmapShader || tileScale != fCachedTileScale) {
SkBitmap bm;
- if (!bm.allocN32Pixels(tileSize.width(), tileSize.height())) {
+ if (!bm.tryAllocN32Pixels(tileSize.width(), tileSize.height())) {
return NULL;
}
bm.eraseColor(SK_ColorTRANSPARENT);
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index db3c0fb2f5..4d7f3629eb 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -437,7 +437,7 @@ static void generateMask(const SkMask& mask, const SkPath& path,
SkBitmap bm;
if (0 == dstRB) {
- if (!bm.allocPixels(info)) {
+ if (!bm.tryAllocPixels(info)) {
// can't allocate offscreen, so empty the mask and return
sk_bzero(mask.fImage, mask.computeImageSize());
return;
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index ce35ba2baa..261640f3e9 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -343,7 +343,7 @@ bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
return false;
}
- if (!dst->allocPixels(src.info())) {
+ if (!dst->tryAllocPixels(src.info())) {
return false;
}
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index d08209874b..8590400003 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -172,7 +172,7 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- if (!dst->allocPixels(src.info().makeWH(srcBounds.width(), srcBounds.height()))) {
+ if (!dst->tryAllocPixels(src.info().makeWH(srcBounds.width(), srcBounds.height()))) {
return false;
}
dst->getBounds(&dstBounds);
@@ -199,7 +199,7 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
}
SkBitmap temp;
- if (!temp.allocPixels(dst->info())) {
+ if (!temp.tryAllocPixels(dst->info())) {
return false;
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 5d15b4f8e8..bb71aa13e9 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -254,7 +254,7 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
return false;
}
- if (!dst->allocPixels(color.info().makeWH(bounds.width(), bounds.height()))) {
+ if (!dst->tryAllocPixels(color.info().makeWH(bounds.width(), bounds.height()))) {
return false;
}
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 69e27609f6..1eb2a3642e 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1016,7 +1016,7 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
+ if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
return false;
}
@@ -1134,7 +1134,7 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
+ if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
return false;
}
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 70e95f6e77..9293f7fc2a 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -321,7 +321,7 @@ bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
return false;
}
- if (!dst->allocPixels(src.info())) {
+ if (!dst->tryAllocPixels(src.info())) {
return false;
}
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index aa8b8049c9..c8959eecfb 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -265,7 +265,7 @@ static SkBitmap unpremultiplyBitmap(const SkBitmap& src)
return SkBitmap();
}
SkBitmap result;
- if (!result.allocPixels(src.info())) {
+ if (!result.tryAllocPixels(src.info())) {
return SkBitmap();
}
for (int y = 0; y < src.height(); ++y) {
@@ -307,7 +307,7 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- if (!result->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
+ if (!result->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
return false;
}
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 2b9c91eb53..c6c470c390 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -166,7 +166,7 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
return false;
}
- if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
+ if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))) {
return false;
}
@@ -191,7 +191,7 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
}
SkBitmap temp;
- if (!temp.allocPixels(dst->info())) {
+ if (!temp.tryAllocPixels(dst->info())) {
return false;
}
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index b7b2d1a7c6..b51bae4370 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -205,7 +205,7 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds,
// allocate the pixels for a bitmap
const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(cmpWidth, cmpHeight);
if (kBlitter_CompressionMode != fCompressionMode) {
- if (!fBM.allocPixels(bmImageInfo)) {
+ if (!fBM.tryAllocPixels(bmImageInfo)) {
return false;
}
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index a07fe67ae4..54497fe8c8 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -25,8 +25,7 @@ SkImageInfo GrSurface::info() const {
bool GrSurface::savePixels(const char* filename) {
SkBitmap bm;
- if (!bm.allocPixels(SkImageInfo::MakeN32Premul(this->width(),
- this->height()))) {
+ if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->height()))) {
return false;
}
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index d378032c06..2371ea72e3 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -170,7 +170,7 @@ bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
top = 0;
height = this->info().fHeight;
}
- if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
+ if (!dst->tryAllocN32Pixels(width, height)) {
SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\n");
return false;
}
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 795b8420e6..a6063846c7 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -117,9 +117,8 @@ bool SkImage_Base::onReadPixels(SkBitmap* bitmap, const SkIRect& subset) const {
return false;
}
} else {
- const SkImageInfo info = SkImageInfo::MakeN32Premul(subset.width(), subset.height());
SkBitmap tmp;
- if (!tmp.allocPixels(info)) {
+ if (!tmp.tryAllocN32Pixels(subset.width(), subset.height())) {
return false;
}
*bitmap = tmp;
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index dfa093becc..5c66c94a53 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -69,7 +69,7 @@ public:
virtual bool allocPixelRef(SkBitmap* bm, SkColorTable* ct) {
if (NULL == fTarget || !equal_modulo_alpha(fInfo, bm->info())) {
// Call default allocator.
- return bm->allocPixels(NULL, ct);
+ return bm->tryAllocPixels(NULL, ct);
}
// TODO(halcanary): verify that all callers of this function
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index ed2ad164a1..4a5e734628 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -133,7 +133,7 @@ bool SkImageDecoder::chooseFromOneChoice(SkColorType colorType, int width, int h
bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap,
SkColorTable* ctable) const {
- return bitmap->allocPixels(fAllocator, ctable);
+ return bitmap->tryAllocPixels(fAllocator, ctable);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 9b937162b3..99401e6b62 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -852,7 +852,7 @@ bool SkJPEGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
return return_false(*cinfo, bitmap, "allocPixelRef");
}
} else {
- if (!bitmap.allocPixels()) {
+ if (!bitmap.tryAllocPixels()) {
return return_false(*cinfo, bitmap, "allocPixels");
}
}
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 01b7c69c25..b69f87996c 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -823,7 +823,7 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
return false;
}
} else {
- if (!decodedBitmap.allocPixels(NULL, needColorTable ? colorTable : NULL)) {
+ if (!decodedBitmap.tryAllocPixels(NULL, needColorTable ? colorTable : NULL)) {
return false;
}
}
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
index f7cfa8b4cc..f32587ddcc 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -375,7 +375,7 @@ bool SkWEBPImageDecoder::onDecodeSubset(SkBitmap* decodedBitmap,
// alloc from native heap if it is a temp bitmap. (prevent GC)
bool allocResult = (bitmap == decodedBitmap)
? allocPixelRef(bitmap, NULL)
- : bitmap->allocPixels();
+ : bitmap->tryAllocPixels();
if (!allocResult) {
return return_false(*decodedBitmap, "allocPixelRef");
}
diff --git a/src/images/SkMovie_gif.cpp b/src/images/SkMovie_gif.cpp
index decefd5acc..3810db5662 100644
--- a/src/images/SkMovie_gif.cpp
+++ b/src/images/SkMovie_gif.cpp
@@ -364,11 +364,11 @@ bool SkGIFMovie::onGetBitmap(SkBitmap* bm)
startIndex = 0;
// create bitmap
- if (!bm->allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
+ if (!bm->tryAllocN32Pixels(width, height)) {
return false;
}
// create bitmap for backup
- if (!fBackup.allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
+ if (!fBackup.tryAllocN32Pixels(width, height)) {
return false;
}
} else if (startIndex > fCurrIndex) {
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
index 56431880c9..bd675324f1 100644
--- a/src/lazy/SkCachingPixelRef.cpp
+++ b/src/lazy/SkCachingPixelRef.cpp
@@ -46,7 +46,7 @@ bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
const SkImageInfo& info = this->info();
if (!SkBitmapCache::Find(this->getGenerationID(), info.fWidth, info.fHeight, &fLockedBitmap)) {
// Cache has been purged, must re-decode.
- if (!fLockedBitmap.allocPixels(info, fRowBytes)) {
+ if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) {
fErrorInDecoding = true;
return false;
}
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index a86c3deff4..ec8d5ea9af 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -110,7 +110,7 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst,
SkASSERT(info.colorType() != kUnknown_SkColorType);
if (dst->empty()) { // Use a normal pixelref.
- return dst->allocPixels();
+ return dst->tryAllocPixels();
}
SkAutoTUnref<SkDiscardablePixelRef> ref(
SkNEW_ARGS(SkDiscardablePixelRef,
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index ec07a8ff0e..f4ea694451 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -2120,7 +2120,7 @@ void SkPDFDevice::internalDrawBitmap(const SkMatrix& origMatrix,
const int w = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().width());
const int h = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().height());
- if (!perspectiveBitmap.allocPixels(SkImageInfo::MakeN32Premul(w, h))) {
+ if (!perspectiveBitmap.tryAllocN32Pixels(w, h)) {
return;
}
perspectiveBitmap.eraseColor(SK_ColorTRANSPARENT);
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index 49460510d9..0c9b7417a1 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -375,8 +375,7 @@ static uint16_t get_argb4444_neighbor_avg_color(const SkBitmap& bitmap,
static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap,
const SkIRect& srcRect) {
SkBitmap outBitmap;
- SkAssertResult(outBitmap.allocPixels(
- bitmap.info().makeWH(srcRect.width(), srcRect.height())));
+ outBitmap.allocPixels(bitmap.info().makeWH(srcRect.width(), srcRect.height()));
int dstRow = 0;
SkAutoLockPixels outBitmapPixelLock(outBitmap);
diff --git a/src/utils/SkPDFRasterizer.cpp b/src/utils/SkPDFRasterizer.cpp
index 66634804bc..1cb792fb81 100644
--- a/src/utils/SkPDFRasterizer.cpp
+++ b/src/utils/SkPDFRasterizer.cpp
@@ -50,7 +50,7 @@ bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) {
char *imgData = image.data();
SkBitmap bitmap;
- if (!bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
+ if (!bitmap.tryAllocN32Pixels(width, height)) {
return false;
}
bitmap.eraseColor(SK_ColorWHITE);
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp
index 01b774df09..14a24d8710 100644
--- a/src/utils/mac/SkCreateCGImageRef.cpp
+++ b/src/utils/mac/SkCreateCGImageRef.cpp
@@ -221,7 +221,7 @@ bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) {
int h = (int)CGRectGetHeight(bounds);
SkBitmap bitmap;
- if (!bitmap.allocPixels(SkImageInfo::MakeN32Premul(w, h))) {
+ if (!bitmap.tryAllocN32Pixels(w, h)) {
return false;
}
bitmap.eraseColor(SK_ColorWHITE);
@@ -287,7 +287,7 @@ bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef image, SkISize* scaleTo
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
SkBitmap tmp;
- if (!tmp.allocPixels(info)) {
+ if (!tmp.tryAllocPixels(info)) {
return false;
}
diff --git a/tests/ARGBImageEncoderTest.cpp b/tests/ARGBImageEncoderTest.cpp
index 18f315fca9..4d16f4cc6d 100644
--- a/tests/ARGBImageEncoderTest.cpp
+++ b/tests/ARGBImageEncoderTest.cpp
@@ -35,9 +35,8 @@ DEF_TEST(ARGBImageEncoder, reporter) {
// A bitmap that should generate the above bytes:
SkBitmap bitmap;
{
- bool success = bitmap.allocPixels(SkImageInfo::Make(kWidth, kHeight,
- gColorTypes[ctIndex], kOpaque_SkAlphaType));
- REPORTER_ASSERT(reporter, success);
+ bitmap.allocPixels(SkImageInfo::Make(kWidth, kHeight, gColorTypes[ctIndex],
+ kOpaque_SkAlphaType));
bitmap.eraseColor(SK_ColorBLUE);
// Change rows [0,1] from blue to [red,green].
SkCanvas canvas(bitmap);
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 4a49a6b487..6a20668cf6 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -387,14 +387,16 @@ DEF_TEST(BitmapCopy, reporter) {
ct = init_ctable(kPremul_SkAlphaType);
}
+ int localSubW;
if (isExtracted[copyCase]) { // A larger image to extract from.
- src.allocPixels(SkImageInfo::Make(2 * subW + 1, subH,
- gPairs[i].fColorType,
- kPremul_SkAlphaType));
+ localSubW = 2 * subW + 1;
} else { // Tests expect a 2x2 bitmap, so make smaller.
- src.allocPixels(SkImageInfo::Make(subW, subH,
- gPairs[i].fColorType,
- kPremul_SkAlphaType));
+ localSubW = subW;
+ }
+ // could fail if we pass kIndex_8 for the colortype
+ if (src.tryAllocPixels(SkImageInfo::Make(localSubW, subH, gPairs[i].fColorType,
+ kPremul_SkAlphaType))) {
+ // failure is fine, as we will notice later on
}
SkSafeUnref(ct);
diff --git a/tests/BitmapHasherTest.cpp b/tests/BitmapHasherTest.cpp
index e39439a11f..3b5170692d 100644
--- a/tests/BitmapHasherTest.cpp
+++ b/tests/BitmapHasherTest.cpp
@@ -17,8 +17,7 @@ typedef uint64_t checksum_result;
// Fill in bitmap with test data.
static void CreateTestBitmap(SkBitmap* bitmap, int width, int height,
SkColor color, skiatest::Reporter* reporter) {
- SkImageInfo info = SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType);
- REPORTER_ASSERT(reporter, bitmap->allocPixels(info));
+ bitmap->allocN32Pixels(width, height, kOpaque_SkAlphaType);
bitmap->eraseColor(color);
}
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index 42ed8841b4..4826b831fe 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -75,7 +75,7 @@ DEF_TEST(Bitmap, reporter) {
bool setConf = bm.setInfo(SkImageInfo::MakeN32Premul(width, height));
REPORTER_ASSERT(reporter, setConf);
if (setConf) {
- REPORTER_ASSERT(reporter, bm.allocPixels(NULL));
+ bm.allocPixels();
}
REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
}
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 65623d0e4f..7c63a0e925 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -348,8 +348,7 @@ DEF_TEST(Image_NewFromGenerator, r) {
REPORTER_ASSERT(r, TestImageGenerator::Height() == image->height());
SkBitmap bitmap;
- SkAssertResult(bitmap.allocN32Pixels(TestImageGenerator::Width(),
- TestImageGenerator::Height()));
+ bitmap.allocN32Pixels(TestImageGenerator::Width(), TestImageGenerator::Height());
SkCanvas canvas(bitmap);
const SkColor kDefaultColor = 0xffabcdef;
canvas.clear(kDefaultColor);
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index 6dca98b527..720155ca0c 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -190,7 +190,9 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter,
c.concat(matrix);
SkBitmap bm;
- bm.allocN32Pixels(width, height);
+ if (bm.tryAllocN32Pixels(width, height)) {
+ // allow this to fail silently, to test the code downstream
+ }
bm.eraseColor(SK_ColorRED);
matrix.setAll(0.0078740157f,
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index 8838e75566..4d26167370 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -770,7 +770,7 @@ public:
fSize = 0;
return true;
}
- return bm->allocPixels(NULL, ct);
+ return bm->tryAllocPixels(NULL, ct);
}
bool ready() { return fPixels != NULL; }
private:
diff --git a/tests/KtxTest.cpp b/tests/KtxTest.cpp
index bddd09abbf..32dacd5a0f 100644
--- a/tests/KtxTest.cpp
+++ b/tests/KtxTest.cpp
@@ -28,8 +28,7 @@ DEF_TEST(KtxReadWrite, reporter) {
SkRandom rand(0x1005cbad);
SkBitmap bm8888;
- bool pixelsAllocated = bm8888.allocN32Pixels(128, 128);
- REPORTER_ASSERT(reporter, pixelsAllocated);
+ bm8888.allocN32Pixels(128, 128);
uint8_t *pixels = reinterpret_cast<uint8_t*>(bm8888.getPixels());
REPORTER_ASSERT(reporter, NULL != pixels);
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index d413a08a66..cdc3c1fcd9 100755
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -482,8 +482,7 @@ void TestResult::testOne() {
do {
int dimX = SkScalarCeilToInt(width / fScale);
int dimY = SkScalarCeilToInt(height / fScale);
- if (oldBitmap.allocN32Pixels(dimX, dimY) &&
- opBitmap.allocN32Pixels(dimX, dimY)) {
+ if (oldBitmap.tryAllocN32Pixels(dimX, dimY) && opBitmap.tryAllocN32Pixels(dimX, dimY)) {
break;
}
SkDebugf("-%d-", fScale);
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index d0bf9031f0..77aac1fdd5 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -96,9 +96,7 @@ static SkPMColor convertToPMColor(SkColorType ct, SkAlphaType at, const uint32_t
static void fillCanvas(SkCanvas* canvas) {
static SkBitmap bmp;
if (bmp.isNull()) {
- SkDEBUGCODE(bool alloc =) bmp.allocN32Pixels(DEV_W, DEV_H);
- SkASSERT(alloc);
- SkAutoLockPixels alp(bmp);
+ bmp.allocN32Pixels(DEV_W, DEV_H);
intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
for (int y = 0; y < DEV_H; ++y) {
for (int x = 0; x < DEV_W; ++x) {
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 4e11f120db..450f94f47e 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -335,14 +335,12 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) {
compare_bitmaps(reporter, origBitmap, destBitmap);
}
-static bool setup_bitmap_for_canvas(SkBitmap* bitmap) {
- SkImageInfo info = SkImageInfo::Make(
- kBitmapSize, kBitmapSize, kN32_SkColorType, kPremul_SkAlphaType);
- return bitmap->allocPixels(info);
+static void setup_bitmap_for_canvas(SkBitmap* bitmap) {
+ bitmap->allocN32Pixels(kBitmapSize, kBitmapSize);
}
-static bool make_checkerboard_bitmap(SkBitmap& bitmap) {
- bool success = setup_bitmap_for_canvas(&bitmap);
+static void make_checkerboard_bitmap(SkBitmap& bitmap) {
+ setup_bitmap_for_canvas(&bitmap);
SkCanvas canvas(bitmap);
canvas.clear(0x00000000);
@@ -363,14 +361,12 @@ static bool make_checkerboard_bitmap(SkBitmap& bitmap) {
canvas.restore();
}
}
-
- return success;
}
-static bool draw_something(SkCanvas* canvas) {
+static void draw_something(SkCanvas* canvas) {
SkPaint paint;
SkBitmap bitmap;
- bool success = make_checkerboard_bitmap(bitmap);
+ make_checkerboard_bitmap(bitmap);
canvas->save();
canvas->scale(0.5f, 0.5f);
@@ -389,8 +385,6 @@ static bool draw_something(SkCanvas* canvas) {
paint.setColor(SK_ColorBLACK);
paint.setTextSize(SkIntToScalar(kBitmapSize/3));
canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint);
-
- return success;
}
DEF_TEST(Serialization, reporter) {
@@ -481,10 +475,9 @@ DEF_TEST(Serialization, reporter) {
// Test simple SkPicture serialization
{
SkPictureRecorder recorder;
- bool didDraw = draw_something(recorder.beginRecording(SkIntToScalar(kBitmapSize),
- SkIntToScalar(kBitmapSize),
- NULL, 0));
- REPORTER_ASSERT(reporter, didDraw);
+ draw_something(recorder.beginRecording(SkIntToScalar(kBitmapSize),
+ SkIntToScalar(kBitmapSize),
+ NULL, 0));
SkAutoTUnref<SkPicture> pict(recorder.endRecording());
// Serialize picture
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index b71c7443e5..454f8c2042 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -27,7 +27,7 @@ static bool test_scaled_image_cache_useage() {
SkAutoTUnref<SkCanvas> canvas(
SkCanvas::NewRasterN32(kCanvasSize, kCanvasSize));
SkBitmap bitmap;
- SkAssertResult(bitmap.allocN32Pixels(kBitmapSize, kBitmapSize));
+ bitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
bitmap.eraseColor(0xFFFFFFFF);
SkScalar scale = SkIntToScalar(kScale);
SkScalar scaledSize = SkIntToScalar(kBitmapSize) * scale;
diff --git a/tests/TextureCompressionTest.cpp b/tests/TextureCompressionTest.cpp
index da7a87bd41..b93cabb4e0 100644
--- a/tests/TextureCompressionTest.cpp
+++ b/tests/TextureCompressionTest.cpp
@@ -58,8 +58,7 @@ DEF_TEST(CompressAlphaFailDimensions, reporter) {
bool setInfoSuccess = bitmap.setInfo(info);
REPORTER_ASSERT(reporter, setInfoSuccess);
- bool allocPixelsSuccess = bitmap.allocPixels(info);
- REPORTER_ASSERT(reporter, allocPixelsSuccess);
+ bitmap.allocPixels(info);
bitmap.unlockPixels();
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) {
@@ -92,8 +91,7 @@ DEF_TEST(CompressAlphaFailColorType, reporter) {
bool setInfoSuccess = bitmap.setInfo(info);
REPORTER_ASSERT(reporter, setInfoSuccess);
- bool allocPixelsSuccess = bitmap.allocPixels(info);
- REPORTER_ASSERT(reporter, allocPixelsSuccess);
+ bitmap.allocPixels(info);
bitmap.unlockPixels();
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) {
@@ -128,8 +126,7 @@ DEF_TEST(CompressCheckerboard, reporter) {
bool setInfoSuccess = bitmap.setInfo(info);
REPORTER_ASSERT(reporter, setInfoSuccess);
- bool allocPixelsSuccess = bitmap.allocPixels(info);
- REPORTER_ASSERT(reporter, allocPixelsSuccess);
+ bitmap.allocPixels(info);
bitmap.unlockPixels();
// Populate bitmap
@@ -215,8 +212,7 @@ DEF_TEST(CompressLATC, reporter) {
bool setInfoSuccess = bitmap.setInfo(info);
REPORTER_ASSERT(reporter, setInfoSuccess);
- bool allocPixelsSuccess = bitmap.allocPixels(info);
- REPORTER_ASSERT(reporter, allocPixelsSuccess);
+ bitmap.allocPixels(info);
bitmap.unlockPixels();
int latcDimX, latcDimY;
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 2a8d0592bb..f47c67bd3b 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -115,8 +115,7 @@ static uint32_t getBitmapColor(int x, int y, int w, SkColorType ct, SkAlphaType
static void fillCanvas(SkCanvas* canvas) {
SkBitmap bmp;
if (bmp.isNull()) {
- SkDEBUGCODE(bool alloc = ) bmp.allocN32Pixels(DEV_W, DEV_H);
- SkASSERT(alloc);
+ bmp.allocN32Pixels(DEV_W, DEV_H);
for (int y = 0; y < DEV_H; ++y) {
for (int x = 0; x < DEV_W; ++x) {
*bmp.getAddr32(x, y) = getCanvasColor(x, y);