aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkSurface_Raster.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-06 21:43:05 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-06 21:43:05 +0000
commit2ebc10dd12a6fe55fda37a9bd5b1e0c1c1e08232 (patch)
treeaa813ad903bfbe78fc82c6e5d97d06111fecd119 /src/image/SkSurface_Raster.cpp
parent473f0aa2bb218e50fce5e19063f8c8fdaf57fad4 (diff)
Revert "Revert "Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refactor bitmap later to remove redundancy, and more interestingly, remove the chance for a disconnect between the actual (pixelref) rowbytes and config, and the one claimed by the bitmap."""
This reverts commit 5f035e90d6dea0139a4f204b634e7b7b3b4976d7. Reverting because it breaks chrome/blink due to new SkPixelRef constructor arg. BUG= Review URL: https://codereview.chromium.org/108993002 git-svn-id: http://skia.googlecode.com/svn/trunk@12551 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image/SkSurface_Raster.cpp')
-rw-r--r--src/image/SkSurface_Raster.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 61ade6f46c..27db504df6 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -155,9 +155,19 @@ SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
return NULL;
}
- SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
- if (NULL == pr.get()) {
+ static const size_t kMaxTotalSize = SK_MaxS32;
+ size_t rowBytes = SkImageMinRowBytes(info);
+ uint64_t size64 = (uint64_t)info.fHeight * rowBytes;
+ if (size64 > kMaxTotalSize) {
+ return NULL;
+ }
+
+ size_t size = (size_t)size64;
+ void* pixels = sk_malloc_throw(size);
+ if (NULL == pixels) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Raster, (info, pr, info.minRowBytes()));
+
+ SkAutoTUnref<SkPixelRef> pr(SkNEW_ARGS(SkMallocPixelRef, (pixels, size, NULL, true)));
+ return SkNEW_ARGS(SkSurface_Raster, (info, pr, rowBytes));
}