From a8d7f0b13cd4c6d773fcf055fe17db75d260fa05 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Fri, 29 Aug 2014 08:03:56 -0700 Subject: Try out scalar picture sizes This paves the way for removing the 'fTile' parameter from SkPictureShader (although that should be a different CL). If we like this we could also move to providing an entire cull SkRect. R=reed@google.com, mtklein@google.com, fmalita@google.com, fmalita@chromium.org Author: robertphillips@google.com Review URL: https://codereview.chromium.org/513983002 --- gm/distantclip.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'gm/distantclip.cpp') diff --git a/gm/distantclip.cpp b/gm/distantclip.cpp index 9c44140d8e..0f8955948a 100644 --- a/gm/distantclip.cpp +++ b/gm/distantclip.cpp @@ -27,37 +27,33 @@ protected: SkISize onISize() { return SkISize::Make(100, 100); } virtual void onDraw(SkCanvas* canvas) { - int offset = 35000; - int extents = 1000; + static const SkScalar kOffset = 35000.0f; + static const SkScalar kExtents = 1000.0f; SkPictureRecorder recorder; // We record a picture of huge vertical extents in which we clear the canvas to red, create // a 'extents' by 'extents' round rect clip at a vertical offset of 'offset', then draw // green into that. - SkCanvas* rec = recorder.beginRecording(100, offset + extents, NULL, 0); - rec->drawColor(0xffff0000); + SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents, NULL, 0); + rec->drawColor(SK_ColorRED); rec->save(); - SkRect r = { - SkIntToScalar(-extents), - SkIntToScalar(offset - extents), - SkIntToScalar(extents), - SkIntToScalar(offset + extents) - }; + SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents, 2 * kExtents); SkPath p; p.addRoundRect(r, 5, 5); rec->clipPath(p, SkRegion::kIntersect_Op, true); - rec->drawColor(0xff00ff00); + rec->drawColor(SK_ColorGREEN); rec->restore(); SkAutoTUnref pict(recorder.endRecording()); // Next we play that picture into another picture of the same size. - pict->draw(recorder.beginRecording(100, offset + extents, NULL, 0)); + pict->draw(recorder.beginRecording(pict->cullRect().width(), + pict->cullRect().height(), + NULL, 0)); SkAutoTUnref pict2(recorder.endRecording()); // Finally we play the part of that second picture that should be green into the canvas. canvas->save(); - canvas->translate(SkIntToScalar(extents / 2), - SkIntToScalar(-(offset - extents / 2))); + canvas->translate(kExtents / 2, -(kOffset - kExtents / 2)); pict2->draw(canvas); canvas->restore(); -- cgit v1.2.3