Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: tests/DrawFilterTest.cpp

Issue 1077353002: setDrawFilter needs to trigger any deferred saves (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698