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

Unified Diff: src/image/SkSurface_Raster.cpp

Issue 108303003: Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refa… (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/image/SkImage_Raster.cpp ('k') | src/images/SkImageRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkSurface_Raster.cpp
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 61ade6f46c8ec6584c3a5a18995dff3a766cca2c..27db504df6f056e8d35d1ca68adc608bfa4164d7 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));
}
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | src/images/SkImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698