Chromium Code Reviews| 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. | |
|
tomhudson
2016/08/19 15:09:03
Presumably the point is that sometimes we set a ma
msarett
2016/08/19 15:15:31
Yes, updating comment.
| |
| 151 DEF_TEST(QuickReject_MatrixState, reporter) { | |
| 152 SkCanvas canvas(100, 100); | |
| 153 | |
| 154 // Set rotation matrix. | |
|
tomhudson
2016/08/19 15:09:03
Nit: this is not a useful comment?
msarett
2016/08/19 15:15:31
Removed.
| |
| 155 SkMatrix matrix; | |
| 156 matrix.setRotate(45.0f); | |
| 157 canvas.setMatrix(matrix); | |
| 158 | |
| 159 // Set image filter. | |
|
tomhudson
2016/08/19 15:09:03
Nit: nor is this.
msarett
2016/08/19 15:15:31
Removed.
| |
| 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 // Call quickReject(). It will assert if the matrix is out of sync. | |
|
tomhudson
2016/08/19 15:09:03
// quickReject() will assert if the matrix is out
msarett
2016/08/19 15:15:31
Done.
| |
| 170 canvas.quickReject(SkRect::MakeWH(100.0f, 100.0f)); | |
| 171 } | |
| OLD | NEW |