diff options
author | mtklein <mtklein@chromium.org> | 2015-07-07 09:43:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-07 09:43:28 -0700 |
commit | d2baa9093876357c8fbf4bc74d10d68b4c026c6f (patch) | |
tree | 1fdcef82745f3993d32f8e93c2d8d58132c1551c /dm | |
parent | 1c8a587120fd33854974457cf2a795ead98183a9 (diff) |
Make sp- via support SkDrawables; add a GM to test it.
BUG=skia:
Review URL: https://codereview.chromium.org/1212363005
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMSrcSink.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 51c79dac74..f83ba3b368 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -254,26 +254,26 @@ Error CodecSrc::draw(SkCanvas* canvas) const { case SkImageGenerator::kIncompleteInput: break; default: - return SkStringPrintf("%s failed with error message %d", + return SkStringPrintf("%s failed with error message %d", fPath.c_str(), (int) subsetResult); } const size_t bpp = decodeInfo.bytesPerPixel(); - /* - * we copy all the lines at once becuase when calling getScanlines for - * interlaced pngs the entire image must be read regardless of the number + /* + * we copy all the lines at once becuase when calling getScanlines for + * interlaced pngs the entire image must be read regardless of the number * of lines requested. Reading an interlaced png in a loop, line-by-line, would * decode the entire image height times, which is very slow * it is aknowledged that copying each line as you read it in a loop * may be faster for other types of images. Since this is a correctness test * that's okay. */ - char* bufferRow = buffer; + char* bufferRow = buffer; for (int subsetY = 0; subsetY < currentSubsetHeight; ++subsetY) { - memcpy(subsetBm.getAddr(0, subsetY), bufferRow + x*bpp, + memcpy(subsetBm.getAddr(0, subsetY), bufferRow + x*bpp, currentSubsetWidth*bpp); bufferRow += rowBytes; } - + canvas->drawBitmap(subsetBm, SkIntToScalar(x), SkIntToScalar(y)); } } @@ -930,6 +930,7 @@ Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri // This is an only-slightly-exaggerated simluation of Blink's Slimming Paint pictures. struct DrawsAsSingletonPictures { SkCanvas* fCanvas; + const SkDrawableList& fDrawables; SK_CREATE_MEMBER_DETECTOR(paint); @@ -938,7 +939,8 @@ struct DrawsAsSingletonPictures { // We must pass SkMatrix::I() as our initial matrix. // By default SkRecords::Draw() uses the canvas' matrix as its initial matrix, // which would have the funky effect of applying transforms over and over. - SkRecords::Draw(canvas, nullptr, nullptr, 0, &SkMatrix::I())(op); + SkRecords::Draw d(canvas, nullptr, fDrawables.begin(), fDrawables.count(), &SkMatrix::I()); + d(op); } // Most things that have paints are Draw-type ops. Create sub-pictures for each. @@ -975,7 +977,14 @@ Error ViaSingletonPictures::draw( SkPictureRecorder macroRec; SkCanvas* macroCanvas = macroRec.beginRecording(SkIntToScalar(size.width()), SkIntToScalar(size.height())); - DrawsAsSingletonPictures drawsAsSingletonPictures = { macroCanvas }; + + SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList()); + const SkDrawableList empty; + + DrawsAsSingletonPictures drawsAsSingletonPictures = { + macroCanvas, + drawables ? *drawables : empty, + }; for (unsigned i = 0; i < skr.count(); i++) { skr.visit<void>(i, drawsAsSingletonPictures); } |