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

Unified Diff: skia/ext/bitmap_platform_device_mac.cc

Issue 1687933002: Move RasterDeviceTooBigToAllocate to caller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 | « skia/ext/bitmap_platform_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/bitmap_platform_device_mac.cc
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc
index e2b2c02a5f3664230aa02bf3bf1867d09e2486fe..d46efddf408d3585330b7a20a2dc5fa53318bf74 100644
--- a/skia/ext/bitmap_platform_device_mac.cc
+++ b/skia/ext/bitmap_platform_device_mac.cc
@@ -23,6 +23,19 @@ namespace skia {
namespace {
+// Returns true if it is unsafe to attempt to allocate an offscreen buffer
+// given these dimensions.
+bool RasterDeviceTooBigToAllocate(int width, int height) {
+
+#ifndef SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX
+#define SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX (2 * 256 * 1024 * 1024)
+#endif
+
+ int bytesPerPixel = 4;
+ int64_t bytes = (int64_t)width * height * bytesPerPixel;
+ return bytes > SKIA_EXT_RASTER_DEVICE_ALLOCATION_MAX;
+}
+
static CGContextRef CGContextForData(void* data, int width, int height) {
#define HAS_ARGB_SHIFTS(a, r, g, b) \
(SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
« no previous file with comments | « skia/ext/bitmap_platform_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698