OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBlitter.h" | 8 #include "SkBlitter.h" |
9 #include "SkMask.h" | 9 #include "SkMask.h" |
10 #include "SkUtils.h" | |
bungeman-skia
2015/11/20 16:55:36
Is there a reason for adding this?
herb_g
2015/11/20 17:11:10
Done.
| |
10 #include "Test.h" | 11 #include "Test.h" |
11 | 12 |
12 class TestBlitter : public SkBlitter { | 13 class TestBlitter : public SkBlitter { |
13 public: | 14 public: |
14 TestBlitter(SkIRect bounds, skiatest::Reporter* reporter) | 15 TestBlitter(SkIRect bounds, skiatest::Reporter* reporter) |
15 : fBounds(bounds) | 16 : fBounds(bounds) |
16 , fReporter(reporter) { } | 17 , fReporter(reporter) { } |
17 | 18 |
18 void blitH(int x, int y, int width) override { | 19 void blitH(int x, int y, int width) override { |
19 | 20 |
(...skipping 11 matching lines...) Expand all Loading... | |
31 | 32 |
32 // Exercise all clips compared with different widths of bitMask. Make sure that no buffer | 33 // Exercise all clips compared with different widths of bitMask. Make sure that no buffer |
33 // overruns happen. | 34 // overruns happen. |
34 DEF_TEST(BlitAndClip, reporter) { | 35 DEF_TEST(BlitAndClip, reporter) { |
35 const int originX = 100; | 36 const int originX = 100; |
36 const int originY = 100; | 37 const int originY = 100; |
37 for (int width = 1; width <= 32; width++) { | 38 for (int width = 1; width <= 32; width++) { |
38 const int height = 2; | 39 const int height = 2; |
39 int rowBytes = (width + 7) >> 3; | 40 int rowBytes = (width + 7) >> 3; |
40 uint8_t* bits = new uint8_t[rowBytes * height]; | 41 uint8_t* bits = new uint8_t[rowBytes * height]; |
42 for (int i = 0; i < rowBytes * height; i++) { | |
bungeman-skia
2015/11/20 16:55:36
memset?
herb_g
2015/11/20 17:11:10
Done.
| |
43 bits[i] = 0xAA; | |
44 } | |
41 | 45 |
42 SkIRect b = {originX, originY, originX + width, originY + height}; | 46 SkIRect b = {originX, originY, originX + width, originY + height}; |
43 | 47 |
44 SkMask mask; | 48 SkMask mask; |
45 mask.fFormat = SkMask::kBW_Format; | 49 mask.fFormat = SkMask::kBW_Format; |
46 mask.fBounds = b; | 50 mask.fBounds = b; |
47 mask.fImage = (uint8_t*)bits; | 51 mask.fImage = (uint8_t*)bits; |
48 mask.fRowBytes = rowBytes; | 52 mask.fRowBytes = rowBytes; |
49 | 53 |
50 TestBlitter tb(mask.fBounds, reporter); | 54 TestBlitter tb(mask.fBounds, reporter); |
51 | 55 |
52 for (int top = b.fTop; top < b.fBottom; top++) { | 56 for (int top = b.fTop; top < b.fBottom; top++) { |
53 for (int bottom = top + 1; bottom <= b.fBottom; bottom++) { | 57 for (int bottom = top + 1; bottom <= b.fBottom; bottom++) { |
54 for (int left = b.fLeft; left < b.fRight; left++) { | 58 for (int left = b.fLeft; left < b.fRight; left++) { |
55 for (int right = left + 1; right <= b.fRight; right++) { | 59 for (int right = left + 1; right <= b.fRight; right++) { |
56 SkIRect clipRect = {left, top, right, bottom}; | 60 SkIRect clipRect = {left, top, right, bottom}; |
57 tb.blitMask(mask, clipRect); | 61 tb.blitMask(mask, clipRect); |
58 } | 62 } |
59 } | 63 } |
60 } | 64 } |
61 } | 65 } |
62 | 66 |
63 delete [] bits; | 67 delete [] bits; |
64 } | 68 } |
65 } | 69 } |
OLD | NEW |