Enable automatic rescaling in bench_pictures

bench_pictures with "--device gpu" is failing because we're trying to allocate
too much GPU memory.  Move the recently-added scaling code into picture_utils
and share it between render_pictures and bench_pictures.
Review URL: https://codereview.appspot.com/6495125

git-svn-id: http://skia.googlecode.com/svn/trunk@5543 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/picture_utils.h b/tools/picture_utils.h
index cca9431..db996ca 100644
--- a/tools/picture_utils.h
+++ b/tools/picture_utils.h
@@ -7,12 +7,15 @@
 
 #ifndef picture_utils_DEFINED
 #define picture_utils_DEFINED
-#include "SkTypes.h"
 
+#include "SkTypes.h"
+#include "SkSize.h"
+
+template <typename T> class SkAutoTUnref;
 class SkBitmap;
 class SkFILEStream;
-class SkString;
 class SkPicture;
+class SkString;
 
 namespace sk_tools {
     // since PNG insists on unpremultiplying our alpha, we take no precision
@@ -41,6 +44,14 @@
     // Specifically, it configures the bitmap, allocates pixels and then
     // erases the pixels to transparent black.
     void setup_bitmap(SkBitmap* bitmap, int width, int height);
+
+    // Determines whether the given dimensions are too large and suggests a new
+    // size.
+    bool area_too_big(int w, int h, SkISize* newSize);
+
+    // Determines whether the given SkPicture is too large and, if so, replaces
+    // it with a new, scaled-down SkPicture.
+    void resize_if_needed(SkAutoTUnref<SkPicture>* aur);
 }
 
 #endif  // picture_utils_DEFINED