• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "SkLiteDL.h"
9 #include "SkLiteRecorder.h"
10 #include "SkRSXform.h"
11 #include "Test.h"
12 
DEF_TEST(SkLiteDL_basics,r)13 DEF_TEST(SkLiteDL_basics, r) {
14     SkLiteDL p;
15     p.save();
16         p.clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
17         p.drawRect(SkRect{0,0,9,9}, SkPaint{});
18     p.restore();
19 }
20 
DEF_TEST(SkLiteDL_unbalanced,r)21 DEF_TEST(SkLiteDL_unbalanced, r) {
22     SkLiteRecorder rec;
23     SkCanvas* c = &rec;
24 
25     SkLiteDL p;
26     rec.reset(&p, {2,2,3,3});
27     c->save();
28         c->scale(2,2);
29         c->save();
30             c->translate(1,1);
31         // missing restore() but SkLiteDL::draw should balance it for us
32     c->restore();
33 
34     // reinit the recorder so we can playback the original SkLiteDL
35     SkLiteDL p2;
36     rec.reset(&p2, {2,2,3,3});
37 
38     REPORTER_ASSERT(r, 1 == rec.getSaveCount());
39     p.draw(c);
40     REPORTER_ASSERT(r, 1 == rec.getSaveCount());
41 }
42 
DEF_TEST(SkLiteRecorder,r)43 DEF_TEST(SkLiteRecorder, r) {
44     SkLiteDL p;
45     SkLiteRecorder rec;
46     SkCanvas* c = &rec;
47 
48     rec.reset(&p, {2,2,3,3});
49 
50     c->save();
51         c->clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
52         c->drawRect(SkRect{0,0,9,9}, SkPaint{});
53     c->restore();
54 }
55 
DEF_TEST(SkLiteRecorder_RecordsFlush,r)56 DEF_TEST(SkLiteRecorder_RecordsFlush, r) {
57     SkLiteDL dl;
58 
59     SkLiteRecorder canvas;
60     canvas.reset(&dl, {0,0,100,100});
61 
62     REPORTER_ASSERT(r,  dl.empty());
63     canvas.flush();
64     REPORTER_ASSERT(r, !dl.empty());
65 }
66