aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar borenet@google.com <borenet@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-20 18:54:04 +0000
committerGravatar borenet@google.com <borenet@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-20 18:54:04 +0000
commit2d2b9a0d8c78c62565e8eedeca3c337827d795c1 (patch)
tree01375a842fa069c9088497b453b272f58d5dd31a
parentdc12b62bb97f07d9b47b1d4d1674c550d80831c4 (diff)
Remove automatic resizing in *_pictures
Review URL: https://codereview.appspot.com/6554045 git-svn-id: http://skia.googlecode.com/svn/trunk@5614 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--tools/bench_pictures_main.cpp12
-rw-r--r--tools/picture_utils.cpp45
-rw-r--r--tools/picture_utils.h10
-rw-r--r--tools/render_pictures_main.cpp10
4 files changed, 7 insertions, 70 deletions
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 6cbb991e73..359240ea7a 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -109,8 +109,7 @@ static bool run_single_benchmark(const SkString& inputPath,
}
bool success = false;
- SkPicture* picture = SkNEW_ARGS(SkPicture, (&inputStream, &success));
- SkAutoTUnref<SkPicture> aur(picture);
+ SkPicture picture(&inputStream, &success);
if (!success) {
SkString err;
err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
@@ -122,14 +121,11 @@ static bool run_single_benchmark(const SkString& inputPath,
sk_tools::get_basename(&filename, inputPath);
SkString result;
- result.printf("running bench [%i %i] %s ", picture->width(),
- picture->height(), filename.c_str());
+ result.printf("running bench [%i %i] %s ", picture.width(),
+ picture.height(), filename.c_str());
gLogger.logProgress(result);
- // rescale to avoid memory issues allocating a very large offscreen
- sk_tools::resize_if_needed(&aur);
-
- benchmark.run(aur);
+ benchmark.run(&picture);
return true;
}
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index 864f49aa73..b9bedbb504 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -6,11 +6,9 @@
*/
#include "picture_utils.h"
-#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkBitmap.h"
#include "SkPicture.h"
-#include "SkRefCnt.h"
#include "SkString.h"
#include "SkStream.h"
@@ -92,47 +90,4 @@ namespace sk_tools {
bitmap->allocPixels();
bitmap->eraseColor(0);
}
-
- bool area_too_big(int w, int h, SkISize* newSize) {
- // just a guess, based on what seems to fail on smaller android devices
- static const int64_t kMaxAreaForMemory = 4 * 1024 * 1024;
-
- if ((int64_t)w * h > kMaxAreaForMemory) {
- do {
- w >>= 1;
- h >>= 1;
- } while ((int64_t)w * h > kMaxAreaForMemory);
- if (0 == w) {
- w = 1;
- }
- if (0 == h) {
- h = 1;
- }
- newSize->set(w, h);
- return true;
- }
- return false;
- }
-
- void resize_if_needed(SkAutoTUnref<SkPicture>* aur) {
- SkISize newSize;
- SkPicture* picture = aur->get();
- if (area_too_big(picture->width(), picture->height(), &newSize)) {
- SkPicture* pic = SkNEW(SkPicture);
- picture->ref();
- aur->reset(pic);
-
- SkCanvas* canvas = pic->beginRecording(newSize.width(),
- newSize.height());
- SkScalar scale = SkIntToScalar(newSize.width()) / picture->width();
- canvas->scale(scale, scale);
- canvas->drawPicture(*picture);
- pic->endRecording();
-
- SkDebugf(
- "... rescaling to [%d %d] to avoid overly large allocations\n",
- newSize.width(), newSize.height());
- picture->unref();
- }
- }
}
diff --git a/tools/picture_utils.h b/tools/picture_utils.h
index db996caf55..4c2f6e546a 100644
--- a/tools/picture_utils.h
+++ b/tools/picture_utils.h
@@ -9,9 +9,7 @@
#define picture_utils_DEFINED
#include "SkTypes.h"
-#include "SkSize.h"
-template <typename T> class SkAutoTUnref;
class SkBitmap;
class SkFILEStream;
class SkPicture;
@@ -44,14 +42,6 @@ namespace sk_tools {
// 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
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp
index 5a7ff44e0f..6066334416 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -92,20 +92,16 @@ static bool render_picture(const SkString& inputPath, const SkString& outputDir,
}
bool success = false;
- SkPicture* picture = SkNEW_ARGS(SkPicture, (&inputStream, &success));
- SkAutoTUnref<SkPicture> aur(picture);
+ SkPicture picture(&inputStream, &success);
if (!success) {
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
return false;
}
- SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
+ SkDebugf("drawing... [%i %i] %s\n", picture.width(), picture.height(),
inputPath.c_str());
- // rescale to avoid memory issues allocating a very large offscreen
- sk_tools::resize_if_needed(&aur);
-
- renderer.init(aur);
+ renderer.init(&picture);
SkString outputPath;
make_output_filepath(&outputPath, outputDir, inputFilename);