OLD | NEW |
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 "SkLightingImageFilter.h" |
10 #include "SkTypes.h" | 11 #include "SkTypes.h" |
11 #include "Test.h" | 12 #include "Test.h" |
12 | 13 |
13 /* | 14 /* |
14 * Subclass of looper that just draws once, with an offset in X. | 15 * Subclass of looper that just draws once, with an offset in X. |
15 */ | 16 */ |
16 class TestLooper : public SkDrawLooper { | 17 class TestLooper : public SkDrawLooper { |
17 public: | 18 public: |
18 | 19 |
19 SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const overrid
e { | 20 SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const overrid
e { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 REPORTER_ASSERT(reporter, false == canvas.quickReject(r11)); | 139 REPORTER_ASSERT(reporter, false == canvas.quickReject(r11)); |
139 REPORTER_ASSERT(reporter, true == canvas.quickReject(r12)); | 140 REPORTER_ASSERT(reporter, true == canvas.quickReject(r12)); |
140 REPORTER_ASSERT(reporter, true == canvas.quickReject(r13)); | 141 REPORTER_ASSERT(reporter, true == canvas.quickReject(r13)); |
141 } | 142 } |
142 | 143 |
143 DEF_TEST(QuickReject, reporter) { | 144 DEF_TEST(QuickReject, reporter) { |
144 test_drawBitmap(reporter); | 145 test_drawBitmap(reporter); |
145 test_layers(reporter); | 146 test_layers(reporter); |
146 test_quick_reject(reporter); | 147 test_quick_reject(reporter); |
147 } | 148 } |
| 149 |
| 150 // Regression test to make sure that we keep fIsScaleTranslate up to date on the
canvas. |
| 151 // It is possible to set a new matrix on the canvas without calling setMatrix().
This tests |
| 152 // that code path. |
| 153 DEF_TEST(QuickReject_MatrixState, reporter) { |
| 154 SkCanvas canvas(100, 100); |
| 155 |
| 156 SkMatrix matrix; |
| 157 matrix.setRotate(45.0f); |
| 158 canvas.setMatrix(matrix); |
| 159 |
| 160 SkPaint paint; |
| 161 sk_sp<SkImageFilter> filter = SkLightingImageFilter::MakeDistantLitDiffuse( |
| 162 SkPoint3::Make(1.0f, 1.0f, 1.0f), 0xFF0000FF, 2.0f, 0.5f, nullptr); |
| 163 REPORTER_ASSERT(reporter, filter); |
| 164 paint.setImageFilter(filter); |
| 165 SkCanvas::SaveLayerRec rec; |
| 166 rec.fPaint = &paint; |
| 167 canvas.saveLayer(rec); |
| 168 |
| 169 // quickReject() will assert if the matrix is out of sync. |
| 170 canvas.quickReject(SkRect::MakeWH(100.0f, 100.0f)); |
| 171 } |
OLD | NEW |