skia2/tests/SkLiteDLTest.cpp
Derek Sollenberger d7875f57bd Refactor SkLiteDL to no longer extend SkDrawable.
Change-Id: Ieaa849bceba0e98e4c99491c721fe945a0694e68
Reviewed-on: https://skia-review.googlesource.com/9111
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Stan Iliev <stani@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2017-03-02 20:16:17 +00:00

54 lines
1.2 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
#include "SkLiteDL.h"
#include "SkLiteRecorder.h"
DEF_TEST(SkLiteDL_basics, r) {
SkLiteDL p;
p.save();
p.clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
p.drawRect(SkRect{0,0,9,9}, SkPaint{});
p.restore();
}
DEF_TEST(SkLiteDL_unbalanced, r) {
SkLiteRecorder rec;
SkCanvas* c = &rec;
SkLiteDL p;
rec.reset(&p, {2,2,3,3});
c->save();
c->scale(2,2);
c->save();
c->translate(1,1);
// missing restore() but SkLiteDL::draw should balance it for us
c->restore();
// reinit the recorder so we can playback the original SkLiteDL
SkLiteDL p2;
rec.reset(&p2, {2,2,3,3});
REPORTER_ASSERT(r, 1 == rec.getSaveCount());
p.draw(c);
REPORTER_ASSERT(r, 1 == rec.getSaveCount());
}
DEF_TEST(SkLiteRecorder, r) {
SkLiteDL p;
SkLiteRecorder rec;
SkCanvas* c = &rec;
rec.reset(&p, {2,2,3,3});
c->save();
c->clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
c->drawRect(SkRect{0,0,9,9}, SkPaint{});
c->restore();
}