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

Side by Side Diff: tests/QuickRejectTest.cpp

Issue 1821533002: guard rasterizer and drawlooper setters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update android sdk Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkDrawLooper.h" 9 #include "SkDrawLooper.h"
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5)); 75 REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5));
76 76
77 // if the bitmap is clipped out, we don't draw it 77 // if the bitmap is clipped out, we don't draw it
78 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); 78 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint);
79 REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5)); 79 REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5));
80 80
81 // now install our looper, which will draw, since it internally translates 81 // now install our looper, which will draw, since it internally translates
82 // to the left. The test is to ensure that canvas' quickReject machinary 82 // to the left. The test is to ensure that canvas' quickReject machinary
83 // allows us through, even though sans-looper we would look like we should 83 // allows us through, even though sans-looper we would look like we should
84 // be clipped out. 84 // be clipped out.
85 paint.setLooper(new TestLooper)->unref(); 85 paint.setLooper(sk_make_sp<TestLooper>());
86 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); 86 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint);
87 REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); 87 REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5));
88 } 88 }
89 89
90 static void test_layers(skiatest::Reporter* reporter) { 90 static void test_layers(skiatest::Reporter* reporter) {
91 SkCanvas canvas(100, 100); 91 SkCanvas canvas(100, 100);
92 92
93 SkRect r = SkRect::MakeWH(10, 10); 93 SkRect r = SkRect::MakeWH(10, 10);
94 REPORTER_ASSERT(reporter, false == canvas.quickReject(r)); 94 REPORTER_ASSERT(reporter, false == canvas.quickReject(r));
95 95
96 r.offset(300, 300); 96 r.offset(300, 300);
97 REPORTER_ASSERT(reporter, true == canvas.quickReject(r)); 97 REPORTER_ASSERT(reporter, true == canvas.quickReject(r));
98 98
99 // Test that saveLayer updates quickReject 99 // Test that saveLayer updates quickReject
100 SkRect bounds = SkRect::MakeLTRB(50, 50, 70, 70); 100 SkRect bounds = SkRect::MakeLTRB(50, 50, 70, 70);
101 canvas.saveLayer(&bounds, nullptr); 101 canvas.saveLayer(&bounds, nullptr);
102 REPORTER_ASSERT(reporter, true == canvas.quickReject(SkRect::MakeWH(10, 10)) ); 102 REPORTER_ASSERT(reporter, true == canvas.quickReject(SkRect::MakeWH(10, 10)) );
103 REPORTER_ASSERT(reporter, false == canvas.quickReject(SkRect::MakeWH(60, 60) )); 103 REPORTER_ASSERT(reporter, false == canvas.quickReject(SkRect::MakeWH(60, 60) ));
104 } 104 }
105 105
106 DEF_TEST(QuickReject, reporter) { 106 DEF_TEST(QuickReject, reporter) {
107 test_drawBitmap(reporter); 107 test_drawBitmap(reporter);
108 test_layers(reporter); 108 test_layers(reporter);
109 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698