Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: gm/distantclip.cpp

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/nanomsg/picture_demo.cpp ('k') | gm/gmmain.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « experimental/nanomsg/picture_demo.cpp ('k') | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698