OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 /* Description: | 8 /* Description: |
9 * This test defines a series of elementatry test steps that perform | 9 * This test defines a series of elementatry test steps that perform |
10 * a single or a small group of canvas API calls. Each test step is | 10 * a single or a small group of canvas API calls. Each test step is |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 SkBitmap bitmap; | 166 SkBitmap bitmap; |
167 createBitmap(&bitmap, 0x05060708); | 167 createBitmap(&bitmap, 0x05060708); |
168 return bitmap; | 168 return bitmap; |
169 } | 169 } |
170 }; | 170 }; |
171 | 171 |
172 class Canvas2CanvasClipVisitor : public SkCanvas::ClipVisitor { | 172 class Canvas2CanvasClipVisitor : public SkCanvas::ClipVisitor { |
173 public: | 173 public: |
174 Canvas2CanvasClipVisitor(SkCanvas* target) : fTarget(target) {} | 174 Canvas2CanvasClipVisitor(SkCanvas* target) : fTarget(target) {} |
175 | 175 |
176 void clipRect(const SkRect& r, SkRegion::Op op, bool aa) override { | 176 void clipRect(const SkRect& r, SkCanvas::ClipOp op, bool aa) override { |
177 fTarget->clipRect(r, op, aa); | 177 fTarget->clipRect(r, op, aa); |
178 } | 178 } |
179 void clipRRect(const SkRRect& r, SkRegion::Op op, bool aa) override { | 179 void clipRRect(const SkRRect& r, SkCanvas::ClipOp op, bool aa) override { |
180 fTarget->clipRRect(r, op, aa); | 180 fTarget->clipRRect(r, op, aa); |
181 } | 181 } |
182 void clipPath(const SkPath& p, SkRegion::Op op, bool aa) override { | 182 void clipPath(const SkPath& p, SkCanvas::ClipOp op, bool aa) override { |
183 fTarget->clipPath(p, op, aa); | 183 fTarget->clipPath(p, op, aa); |
184 } | 184 } |
185 | 185 |
186 private: | 186 private: |
187 SkCanvas* fTarget; | 187 SkCanvas* fTarget; |
188 }; | 188 }; |
189 | 189 |
190 static void test_clipstack(skiatest::Reporter* reporter) { | 190 static void test_clipstack(skiatest::Reporter* reporter) { |
191 // The clipstack is refcounted, and needs to be able to out-live the canvas
if a client has | 191 // The clipstack is refcounted, and needs to be able to out-live the canvas
if a client has |
192 // ref'd it. | 192 // ref'd it. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // the state of the canvas. | 292 // the state of the canvas. |
293 | 293 |
294 SIMPLE_TEST_STEP(Translate, translate(SkIntToScalar(1), SkIntToScalar(2))); | 294 SIMPLE_TEST_STEP(Translate, translate(SkIntToScalar(1), SkIntToScalar(2))); |
295 SIMPLE_TEST_STEP(Scale, scale(SkIntToScalar(1), SkIntToScalar(2))); | 295 SIMPLE_TEST_STEP(Scale, scale(SkIntToScalar(1), SkIntToScalar(2))); |
296 SIMPLE_TEST_STEP(Rotate, rotate(SkIntToScalar(1))); | 296 SIMPLE_TEST_STEP(Rotate, rotate(SkIntToScalar(1))); |
297 SIMPLE_TEST_STEP(Skew, skew(SkIntToScalar(1), SkIntToScalar(2))); | 297 SIMPLE_TEST_STEP(Skew, skew(SkIntToScalar(1), SkIntToScalar(2))); |
298 SIMPLE_TEST_STEP(Concat, concat(d.fMatrix)); | 298 SIMPLE_TEST_STEP(Concat, concat(d.fMatrix)); |
299 SIMPLE_TEST_STEP(SetMatrix, setMatrix(d.fMatrix)); | 299 SIMPLE_TEST_STEP(SetMatrix, setMatrix(d.fMatrix)); |
300 SIMPLE_TEST_STEP(ClipRect, clipRect(d.fRect)); | 300 SIMPLE_TEST_STEP(ClipRect, clipRect(d.fRect)); |
301 SIMPLE_TEST_STEP(ClipPath, clipPath(d.fPath)); | 301 SIMPLE_TEST_STEP(ClipPath, clipPath(d.fPath)); |
302 SIMPLE_TEST_STEP(ClipRegion, clipRegion(d.fRegion, SkRegion::kReplace_Op)); | 302 SIMPLE_TEST_STEP(ClipRegion, clipRegion(d.fRegion, SkCanvas::kReplace_Op)); |
303 SIMPLE_TEST_STEP(Clear, clear(d.fColor)); | 303 SIMPLE_TEST_STEP(Clear, clear(d.fColor)); |
304 | 304 |
305 /////////////////////////////////////////////////////////////////////////////// | 305 /////////////////////////////////////////////////////////////////////////////// |
306 // Complex test steps | 306 // Complex test steps |
307 | 307 |
308 static void SaveMatrixClipStep(SkCanvas* canvas, const TestData& d, | 308 static void SaveMatrixClipStep(SkCanvas* canvas, const TestData& d, |
309 skiatest::Reporter* reporter, CanvasTestStep* tes
tStep) { | 309 skiatest::Reporter* reporter, CanvasTestStep* tes
tStep) { |
310 int saveCount = canvas->getSaveCount(); | 310 int saveCount = canvas->getSaveCount(); |
311 canvas->save(); | 311 canvas->save(); |
312 canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); | 312 canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 SkPaint paint; | 731 SkPaint paint; |
732 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED)); | 732 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED)); |
733 | 733 |
734 canvas.save(); | 734 canvas.save(); |
735 canvas.clipRect(SkRect::MakeWH(55, 55)); | 735 canvas.clipRect(SkRect::MakeWH(55, 55)); |
736 canvas.translate(10, 20); | 736 canvas.translate(10, 20); |
737 canvas.drawRect(SkRect::MakeWH(50, 50), paint); | 737 canvas.drawRect(SkRect::MakeWH(50, 50), paint); |
738 canvas.restore(); | 738 canvas.restore(); |
739 } | 739 } |
740 | 740 |
OLD | NEW |