DM: conserve memory when using --skps

- limit to maximum 1000x1000 viewport like in bench_pictures and nanobench
 - use lazy bitmap decoding when reading the pictures from disk

BUG=skia:
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/448263002
This commit is contained in:
mtklein 2014-08-07 14:27:03 -07:00 коммит произвёл Commit bot
Родитель c863ab07c2
Коммит 72ebb9f1dc
3 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -2,6 +2,7 @@
// For a high-level overview, please see dm/README.
#include "CrashHandler.h"
#include "LazyDecodeBitmap.h"
#include "SkCommonFlags.h"
#include "SkForceLinking.h"
#include "SkGraphics.h"
@ -143,7 +144,8 @@ static void kick_off_skps(const SkTArray<SkString>& skps,
SkDebugf("Could not read %s.\n", skps[i].c_str());
exit(1);
}
SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream.get()));
SkAutoTUnref<SkPicture> pic(
SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeBitmap));
if (pic.get() == NULL) {
SkDebugf("Could not read %s as an SkPicture.\n", skps[i].c_str());
exit(1);

Просмотреть файл

@ -6,6 +6,8 @@
#include "SkPictureRecorder.h"
DEFINE_bool(skr, true, "Test that SKPs draw the same when re-recorded with SkRecord backend.");
DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width.");
DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height.");
namespace DM {
@ -28,7 +30,7 @@ public:
SkAutoTDelete<const SkPicture> skrPicture(recorder.endRecording());
SkBitmap bitmap;
AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
AllocatePixels(kN32_SkColorType, fReference.width(), fReference.height(), &bitmap);
DrawPicture(*skrPicture, &bitmap);
if (!BitmapsEqual(fReference, bitmap)) {
@ -48,8 +50,10 @@ SKPTask::SKPTask(Reporter* r, TaskRunner* tr, const SkPicture* pic, SkString fil
: CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {}
void SKPTask::draw() {
const int width = SkTMin(fPicture->width(), FLAGS_skpMaxWidth),
height = SkTMin(fPicture->height(), FLAGS_skpMaxHeight);
SkBitmap bitmap;
AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
AllocatePixels(kN32_SkColorType, width, height, &bitmap);
DrawPicture(*fPicture, &bitmap);
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));

Просмотреть файл

@ -50,6 +50,7 @@
'../src/utils/debugger/SkDebugCanvas.cpp',
'../src/utils/debugger/SkDrawCommand.cpp',
'../src/utils/debugger/SkObjectParser.cpp',
'../tools/LazyDecodeBitmap.cpp',
],
'conditions': [
[ 'skia_gpu == 1', {