OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "gm.h" | 9 #include "gm.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 SkPictureRecorder recorder; | 32 SkPictureRecorder recorder; |
33 // We record a picture of huge vertical extents in which we clear the ca
nvas to red, create | 33 // We record a picture of huge vertical extents in which we clear the ca
nvas to red, create |
34 // a 'extents' by 'extents' round rect clip at a vertical offset of 'off
set', then draw | 34 // a 'extents' by 'extents' round rect clip at a vertical offset of 'off
set', then draw |
35 // green into that. | 35 // green into that. |
36 SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents, nu
llptr, 0); | 36 SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents, nu
llptr, 0); |
37 rec->drawColor(SK_ColorRED); | 37 rec->drawColor(SK_ColorRED); |
38 rec->save(); | 38 rec->save(); |
39 SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents,
2 * kExtents); | 39 SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents,
2 * kExtents); |
40 SkPath p; | 40 SkPath p; |
41 p.addRoundRect(r, 5, 5); | 41 p.addRoundRect(r, 5, 5); |
42 rec->clipPath(p, SkCanvas::kIntersect_Op, true); | 42 rec->clipPath(p, true); |
43 rec->drawColor(SK_ColorGREEN); | 43 rec->drawColor(SK_ColorGREEN); |
44 rec->restore(); | 44 rec->restore(); |
45 sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture()); | 45 sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture()); |
46 | 46 |
47 // Next we play that picture into another picture of the same size. | 47 // Next we play that picture into another picture of the same size. |
48 pict->playback(recorder.beginRecording(pict->cullRect().width(), | 48 pict->playback(recorder.beginRecording(pict->cullRect().width(), |
49 pict->cullRect().height(), | 49 pict->cullRect().height(), |
50 nullptr, 0)); | 50 nullptr, 0)); |
51 sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture()); | 51 sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture()); |
52 | 52 |
(...skipping 10 matching lines...) Expand all Loading... |
63 private: | 63 private: |
64 typedef GM INHERITED; | 64 typedef GM INHERITED; |
65 }; | 65 }; |
66 | 66 |
67 /////////////////////////////////////////////////////////////////////////////// | 67 /////////////////////////////////////////////////////////////////////////////// |
68 | 68 |
69 static GM* MyFactory(void*) { return new DistantClipGM; } | 69 static GM* MyFactory(void*) { return new DistantClipGM; } |
70 static GMRegistry reg(MyFactory); | 70 static GMRegistry reg(MyFactory); |
71 | 71 |
72 } | 72 } |
OLD | NEW |