Home | History | Annotate | Download | only in tests
      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 "Test.h"
      9 #include "SkLiteDL.h"
     10 #include "SkLiteRecorder.h"
     11 
     12 DEF_TEST(SkLiteDL_basics, r) {
     13     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();
     18 }
     19 
     20 DEF_TEST(SkLiteDL_unbalanced, r) {
     21     SkLiteRecorder rec;
     22     SkCanvas* c = &rec;
     23 
     24     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 
     42 DEF_TEST(SkLiteRecorder, r) {
     43     SkLiteDL p;
     44     SkLiteRecorder rec;
     45     SkCanvas* c = &rec;
     46 
     47     rec.reset(&p, {2,2,3,3});
     48 
     49     c->save();
     50         c->clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
     51         c->drawRect(SkRect{0,0,9,9}, SkPaint{});
     52     c->restore();
     53 }
     54