OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "Test.h" | 8 #include "Test.h" |
8 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
9 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
10 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
11 #include "SkDraw.h" | 12 #include "SkDraw.h" |
12 #include "SkLayerDrawLooper.h" | 13 #include "SkLayerDrawLooper.h" |
13 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
14 #include "SkPaint.h" | 15 #include "SkPaint.h" |
15 #include "SkRect.h" | 16 #include "SkRect.h" |
16 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
17 #include "SkScalar.h" | 18 #include "SkScalar.h" |
18 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
19 | 20 |
20 namespace { | |
21 | |
22 class FakeDevice : public SkBitmapDevice { | 21 class FakeDevice : public SkBitmapDevice { |
23 public: | 22 public: |
24 FakeDevice() : SkBitmapDevice(SkBitmap::kARGB_8888_Config, 100, 100, false)
{ } | 23 FakeDevice() : SkBitmapDevice(SkBitmap::kARGB_8888_Config, 100, 100, false)
{ } |
25 | 24 |
26 virtual void drawRect(const SkDraw& draw, const SkRect& r, | 25 virtual void drawRect(const SkDraw& draw, const SkRect& r, |
27 const SkPaint& paint) SK_OVERRIDE { | 26 const SkPaint& paint) SK_OVERRIDE { |
28 fLastMatrix = *draw.fMatrix; | 27 fLastMatrix = *draw.fMatrix; |
29 INHERITED::drawRect(draw, r, paint); | 28 INHERITED::drawRect(draw, r, paint); |
30 } | 29 } |
31 | 30 |
32 SkMatrix fLastMatrix; | 31 SkMatrix fLastMatrix; |
33 | 32 |
34 private: | 33 private: |
35 typedef SkBitmapDevice INHERITED; | 34 typedef SkBitmapDevice INHERITED; |
36 }; | 35 }; |
37 | 36 |
38 } // namespace | |
39 | |
40 static void test_frontToBack(skiatest::Reporter* reporter) { | 37 static void test_frontToBack(skiatest::Reporter* reporter) { |
41 SkAutoTUnref<SkLayerDrawLooper> looper(SkNEW(SkLayerDrawLooper)); | 38 SkAutoTUnref<SkLayerDrawLooper> looper(SkNEW(SkLayerDrawLooper)); |
42 SkLayerDrawLooper::LayerInfo layerInfo; | 39 SkLayerDrawLooper::LayerInfo layerInfo; |
43 | 40 |
44 // Add the front layer, with the defaults. | 41 // Add the front layer, with the defaults. |
45 (void)looper->addLayer(layerInfo); | 42 (void)looper->addLayer(layerInfo); |
46 | 43 |
47 // Add the back layer, with some layer info set. | 44 // Add the back layer, with some layer info set. |
48 layerInfo.fOffset.set(SkFloatToScalar(10.0f), SkFloatToScalar(20.0f)); | 45 layerInfo.fOffset.set(SkFloatToScalar(10.0f), SkFloatToScalar(20.0f)); |
49 layerInfo.fPaintBits |= SkLayerDrawLooper::kXfermode_Bit; | 46 layerInfo.fPaintBits |= SkLayerDrawLooper::kXfermode_Bit; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 146 } |
150 | 147 |
151 static void TestLayerDrawLooper(skiatest::Reporter* reporter) { | 148 static void TestLayerDrawLooper(skiatest::Reporter* reporter) { |
152 test_frontToBack(reporter); | 149 test_frontToBack(reporter); |
153 test_backToFront(reporter); | 150 test_backToFront(reporter); |
154 test_mixed(reporter); | 151 test_mixed(reporter); |
155 } | 152 } |
156 | 153 |
157 #include "TestClassDef.h" | 154 #include "TestClassDef.h" |
158 DEFINE_TESTCLASS("LayerDrawLooper", TestLayerDrawLooperClass, TestLayerDrawLoope
r) | 155 DEFINE_TESTCLASS("LayerDrawLooper", TestLayerDrawLooperClass, TestLayerDrawLoope
r) |
OLD | NEW |