OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 "SkCanvas.h" |
| 9 #include "SkDrawFilter.h" |
| 10 #include "SkSurface.h" |
| 11 #include "Test.h" |
| 12 |
| 13 class TestFilter : public SkDrawFilter { |
| 14 public: |
| 15 bool filter(SkPaint* p, Type) override { |
| 16 return true; |
| 17 } |
| 18 }; |
| 19 |
| 20 /** |
| 21 * canvas.setDrawFilter is defined to be local to the save/restore block, such
that if you |
| 22 * do the following: save / modify-drawfilter / restore, the current drawfilter
should be what |
| 23 * it was before the save. |
| 24 */ |
| 25 static void test_saverestore(skiatest::Reporter* reporter) { |
| 26 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10)); |
| 27 SkCanvas* canvas = surface->getCanvas(); |
| 28 |
| 29 |
| 30 SkAutoTUnref<TestFilter> df(SkNEW(TestFilter)); |
| 31 |
| 32 REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter()); |
| 33 |
| 34 canvas->save(); |
| 35 canvas->setDrawFilter(df); |
| 36 REPORTER_ASSERT(reporter, NULL != canvas->getDrawFilter()); |
| 37 canvas->restore(); |
| 38 |
| 39 REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter()); |
| 40 } |
| 41 |
| 42 DEF_TEST(DrawFilter, reporter) { |
| 43 test_saverestore(reporter); |
| 44 } |
OLD | NEW |