Example #1
0
// getRecordingCanvas() should return a SkCanvas when recording, null when not recording.
DEF_TEST(Picture_getRecordingCanvas, r) {
    SkPictureRecorder rec;
    REPORTER_ASSERT(r, !rec.getRecordingCanvas());
    for (int i = 0; i < 3; i++) {
        rec.beginRecording(100, 100);
        REPORTER_ASSERT(r, rec.getRecordingCanvas());
        rec.finishRecordingAsPicture();
        REPORTER_ASSERT(r, !rec.getRecordingCanvas());
    }
}
Example #2
0
    void onDraw(int loops, SkCanvas*) override {
        SkLiteRecorder lite;
        SkPictureRecorder rec;
        for (int i = 0; i < loops; i++) {
            SkRect bounds{0,0, 2000,3000};

            sk_sp<SkLiteDL> liteDL;
            SkCanvas* canvas;
            if (kLite) {
                liteDL = SkLiteDL::New(bounds);
                lite.reset(liteDL.get());
                canvas = &lite;
            } else {
                rec.beginRecording(bounds);
                canvas = rec.getRecordingCanvas();
            }

            for (int i = 0; i < kDraws; i++) {
                canvas->drawRect({10,10, 1000, 1000}, SkPaint{});
            }

            if (!kLite) {
                (void)rec.finishRecordingAsPicture();
            }
        }
    }