| Index: gm/distantclip.cpp
|
| diff --git a/gm/distantclip.cpp b/gm/distantclip.cpp
|
| index 9c44140d8ee1c709325ec1e3fdca77398bc16379..0f8955948aa7640312b5fa958cf606b221784a7c 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<SkPicture> 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<SkPicture> 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();
|
|
|
|
|