OLD | NEW |
(Empty) | |
| 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 #if 0 // This test doesn't make sense when run in a threaded environment. It
tests global state. |
| 13 DEF_TEST(SkLiteDL_freelisting, r) { |
| 14 // TODO: byte and count limit tests |
| 15 sk_sp<SkLiteDL> sp1 = SkLiteDL::New({1,1,10,10}), |
| 16 sp2 = SkLiteDL::New({2,2,20,20}); |
| 17 |
| 18 SkLiteDL* p1 = sp1.get(); |
| 19 SkLiteDL* p2 = sp2.get(); |
| 20 REPORTER_ASSERT(r, p1 != p2); |
| 21 REPORTER_ASSERT(r, p1->getBounds().left() == 1); |
| 22 REPORTER_ASSERT(r, p2->getBounds().left() == 2); |
| 23 |
| 24 sp2.reset(); |
| 25 |
| 26 sk_sp<SkLiteDL> sp3 = SkLiteDL::New({3,3,30,30}); |
| 27 SkLiteDL* p3 = sp3.get(); |
| 28 REPORTER_ASSERT(r, p1 != p3); |
| 29 REPORTER_ASSERT(r, p2 == p3); |
| 30 REPORTER_ASSERT(r, p1->getBounds().left() == 1); |
| 31 REPORTER_ASSERT(r, p3->getBounds().left() == 3); |
| 32 |
| 33 sp3.reset(); |
| 34 sp1.reset(); |
| 35 |
| 36 sk_sp<SkLiteDL> sp4 = SkLiteDL::New({4,4,40,40}); |
| 37 SkLiteDL* p4 = sp4.get(); |
| 38 REPORTER_ASSERT(r, p4 == p1); // Checks that we operate in stack order. Ni
ce, not essential. |
| 39 REPORTER_ASSERT(r, p4->getBounds().left() == 4); |
| 40 } |
| 41 #endif |
| 42 |
| 43 DEF_TEST(SkLiteDL_basics, r) { |
| 44 sk_sp<SkLiteDL> p { SkLiteDL::New({2,2,3,3}) }; |
| 45 |
| 46 p->save(); |
| 47 p->clipRect(SkRect{2,3,4,5}, SkRegion::kIntersect_Op, true); |
| 48 p->drawRect(SkRect{0,0,9,9}, SkPaint{}); |
| 49 p->restore(); |
| 50 } |
| 51 |
| 52 DEF_TEST(SkLiteRecorder, r) { |
| 53 sk_sp<SkLiteDL> p { SkLiteDL::New({2,2,3,3}) }; |
| 54 |
| 55 SkLiteRecorder rec; |
| 56 SkCanvas* c = &rec; |
| 57 |
| 58 rec.reset(p.get()); |
| 59 |
| 60 c->save(); |
| 61 c->clipRect(SkRect{2,3,4,5}, SkRegion::kIntersect_Op, true); |
| 62 c->drawRect(SkRect{0,0,9,9}, SkPaint{}); |
| 63 c->restore(); |
| 64 } |
OLD | NEW |