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

Side by Side Diff: tests/QuickRejectTest.cpp

Issue 2263513003: Fix bug, always keep fIsScaleTranslate in correct state (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Improve comments Created 4 years, 4 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
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
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 }
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