aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/distantclip.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-08-29 08:03:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-29 08:03:56 -0700
commita8d7f0b13cd4c6d773fcf055fe17db75d260fa05 (patch)
tree37e85b212ccd5761b9a736282e75ebf838840798 /gm/distantclip.cpp
parent77d724c07878b21602e96e095f6a446c429a079a (diff)
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
Diffstat (limited to 'gm/distantclip.cpp')
-rw-r--r--gm/distantclip.cpp24
1 files changed, 10 insertions, 14 deletions
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<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();