| OLD | NEW |
| 1 | 1 |
| 2 | |
| 3 /* | 2 /* |
| 4 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 5 * | 4 * |
| 6 * 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 |
| 7 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 8 */ | 7 */ |
| 9 | 8 |
| 10 #include "gm.h" | 9 #include "gm.h" |
| 11 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 12 #include "SkPicture.h" | 11 #include "SkPicture.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 39 rec->save(); | 38 rec->save(); |
| 40 SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents,
2 * kExtents); | 39 SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents,
2 * kExtents); |
| 41 SkPath p; | 40 SkPath p; |
| 42 p.addRoundRect(r, 5, 5); | 41 p.addRoundRect(r, 5, 5); |
| 43 rec->clipPath(p, SkRegion::kIntersect_Op, true); | 42 rec->clipPath(p, SkRegion::kIntersect_Op, true); |
| 44 rec->drawColor(SK_ColorGREEN); | 43 rec->drawColor(SK_ColorGREEN); |
| 45 rec->restore(); | 44 rec->restore(); |
| 46 sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture()); | 45 sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture()); |
| 47 | 46 |
| 48 // 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. |
| 49 pict->playback(recorder.beginRecording(pict->cullRect().width(), | 48 pict->playback(recorder.beginRecording(pict->cullRect().width(), |
| 50 pict->cullRect().height(), | 49 pict->cullRect().height(), |
| 51 nullptr, 0)); | 50 nullptr, 0)); |
| 52 sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture()); | 51 sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture()); |
| 53 | 52 |
| 54 // Finally we play the part of that second picture that should be green
into the canvas. | 53 // Finally we play the part of that second picture that should be green
into the canvas. |
| 55 canvas->save(); | 54 canvas->save(); |
| 56 canvas->translate(kExtents / 2, -(kOffset - kExtents / 2)); | 55 canvas->translate(kExtents / 2, -(kOffset - kExtents / 2)); |
| 57 pict2->playback(canvas); | 56 pict2->playback(canvas); |
| 58 canvas->restore(); | 57 canvas->restore(); |
| 59 | 58 |
| 60 // If the image is red, we erroneously decided the clipPath was empty an
d didn't record | 59 // If the image is red, we erroneously decided the clipPath was empty an
d didn't record |
| 61 // the green drawColor, if it's green we're all good. | 60 // the green drawColor, if it's green we're all good. |
| 62 } | 61 } |
| 63 | 62 |
| 64 private: | 63 private: |
| 65 typedef GM INHERITED; | 64 typedef GM INHERITED; |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 /////////////////////////////////////////////////////////////////////////////// | 67 /////////////////////////////////////////////////////////////////////////////// |
| 69 | 68 |
| 70 static GM* MyFactory(void*) { return new DistantClipGM; } | 69 static GM* MyFactory(void*) { return new DistantClipGM; } |
| 71 static GMRegistry reg(MyFactory); | 70 static GMRegistry reg(MyFactory); |
| 72 | 71 |
| 73 } | 72 } |
| OLD | NEW |