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 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkDraw.h" | 11 #include "SkDraw.h" |
12 #include "SkLayerDrawLooper.h" | 12 #include "SkLayerDrawLooper.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
15 #include "SkRect.h" | 15 #include "SkRect.h" |
16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
17 #include "SkScalar.h" | 17 #include "SkScalar.h" |
18 #include "SkSmallAllocator.h" | 18 #include "SkSmallAllocator.h" |
19 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
20 #include "Test.h" | 20 #include "Test.h" |
21 | 21 |
22 static SkBitmap make_bm(int w, int h) { | 22 static SkBitmap make_bm(int w, int h) { |
23 SkBitmap bm; | 23 SkBitmap bm; |
24 bm.allocN32Pixels(w, h); | 24 bm.allocN32Pixels(w, h); |
25 return bm; | 25 return bm; |
26 } | 26 } |
27 | 27 |
| 28 // TODO: can this be derived from SkBaseDevice? |
28 class FakeDevice : public SkBitmapDevice { | 29 class FakeDevice : public SkBitmapDevice { |
29 public: | 30 public: |
30 FakeDevice() : SkBitmapDevice(make_bm(100, 100)) { } | 31 FakeDevice() : INHERITED(make_bm(100, 100), SkSurfaceProps(0, kUnknown_SkPix
elGeometry)) { |
| 32 } |
31 | 33 |
32 virtual void drawRect(const SkDraw& draw, const SkRect& r, | 34 void drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) ove
rride { |
33 const SkPaint& paint) override { | |
34 fLastMatrix = *draw.fMatrix; | 35 fLastMatrix = *draw.fMatrix; |
35 this->INHERITED::drawRect(draw, r, paint); | 36 this->INHERITED::drawRect(draw, r, paint); |
36 } | 37 } |
37 | 38 |
38 SkMatrix fLastMatrix; | 39 SkMatrix fLastMatrix; |
39 | 40 |
40 private: | 41 private: |
41 typedef SkBitmapDevice INHERITED; | 42 typedef SkBitmapDevice INHERITED; |
42 }; | 43 }; |
43 | 44 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 // Only two layers were added, so that should be the end. | 161 // Only two layers were added, so that should be the end. |
161 REPORTER_ASSERT(reporter, !context->next(&canvas, &paint)); | 162 REPORTER_ASSERT(reporter, !context->next(&canvas, &paint)); |
162 } | 163 } |
163 | 164 |
164 DEF_TEST(LayerDrawLooper, reporter) { | 165 DEF_TEST(LayerDrawLooper, reporter) { |
165 test_frontToBack(reporter); | 166 test_frontToBack(reporter); |
166 test_backToFront(reporter); | 167 test_backToFront(reporter); |
167 test_mixed(reporter); | 168 test_mixed(reporter); |
168 } | 169 } |
OLD | NEW |