OLD | NEW |
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 "SkTypes.h" | 10 #include "SkTypes.h" |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 /* | 13 /* |
14 * Subclass of looper that just draws once, with an offset in X. | 14 * Subclass of looper that just draws once, with an offset in X. |
15 */ | 15 */ |
16 class TestLooper : public SkDrawLooper { | 16 class TestLooper : public SkDrawLooper { |
17 public: | 17 public: |
18 | 18 |
19 virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const
SK_OVERRIDE { | 19 virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const
SK_OVERRIDE { |
20 return SkNEW_PLACEMENT(storage, TestDrawLooperContext); | 20 return SkNEW_PLACEMENT(storage, TestDrawLooperContext); |
21 } | 21 } |
22 | 22 |
23 virtual size_t contextSize() const SK_OVERRIDE { return sizeof(TestDrawLoope
rContext); } | 23 virtual size_t contextSize() const SK_OVERRIDE { return sizeof(TestDrawLoope
rContext); } |
24 | 24 |
25 #ifdef SK_DEVELOPER | 25 #ifndef SK_IGNORE_TO_STRING |
26 virtual void toString(SkString* str) const SK_OVERRIDE { | 26 virtual void toString(SkString* str) const SK_OVERRIDE { |
27 str->append("TestLooper:"); | 27 str->append("TestLooper:"); |
28 } | 28 } |
29 #endif | 29 #endif |
30 | 30 |
31 private: | 31 private: |
32 class TestDrawLooperContext : public SkDrawLooper::Context { | 32 class TestDrawLooperContext : public SkDrawLooper::Context { |
33 public: | 33 public: |
34 TestDrawLooperContext() : fOnce(true) {} | 34 TestDrawLooperContext() : fOnce(true) {} |
35 virtual ~TestDrawLooperContext() {} | 35 virtual ~TestDrawLooperContext() {} |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // allows us through, even though sans-looper we would look like we should | 81 // allows us through, even though sans-looper we would look like we should |
82 // be clipped out. | 82 // be clipped out. |
83 paint.setLooper(new TestLooper)->unref(); | 83 paint.setLooper(new TestLooper)->unref(); |
84 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); | 84 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); |
85 REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); | 85 REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); |
86 } | 86 } |
87 | 87 |
88 DEF_TEST(QuickReject, reporter) { | 88 DEF_TEST(QuickReject, reporter) { |
89 test_drawBitmap(reporter); | 89 test_drawBitmap(reporter); |
90 } | 90 } |
OLD | NEW |