blob: 514464aaf9b8692e287b55eeef8f3b8be60965eb [file] [log] [blame]
mtklein9c5052f2016-08-06 12:51:51 -07001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Test.h"
9#include "SkLiteDL.h"
10#include "SkLiteRecorder.h"
11
mtklein9c5052f2016-08-06 12:51:51 -070012DEF_TEST(SkLiteDL_basics, r) {
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050013 SkLiteDL p;
14 p.save();
15 p.clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
16 p.drawRect(SkRect{0,0,9,9}, SkPaint{});
17 p.restore();
mtklein9c5052f2016-08-06 12:51:51 -070018}
19
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050020DEF_TEST(SkLiteDL_unbalanced, r) {
mtklein9c5052f2016-08-06 12:51:51 -070021 SkLiteRecorder rec;
22 SkCanvas* c = &rec;
23
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050024 SkLiteDL p;
25 rec.reset(&p, {2,2,3,3});
26 c->save();
27 c->scale(2,2);
28 c->save();
29 c->translate(1,1);
30 // missing restore() but SkLiteDL::draw should balance it for us
31 c->restore();
32
33 // reinit the recorder so we can playback the original SkLiteDL
34 SkLiteDL p2;
35 rec.reset(&p2, {2,2,3,3});
36
37 REPORTER_ASSERT(r, 1 == rec.getSaveCount());
38 p.draw(c);
39 REPORTER_ASSERT(r, 1 == rec.getSaveCount());
40}
41
42DEF_TEST(SkLiteRecorder, r) {
43 SkLiteDL p;
44 SkLiteRecorder rec;
45 SkCanvas* c = &rec;
46
47 rec.reset(&p, {2,2,3,3});
mtklein9c5052f2016-08-06 12:51:51 -070048
49 c->save();
Mike Reedc1f77742016-12-09 09:00:50 -050050 c->clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
mtklein9c5052f2016-08-06 12:51:51 -070051 c->drawRect(SkRect{0,0,9,9}, SkPaint{});
52 c->restore();
53}