| 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     SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVER
    RIDE { | 
| 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     size_t contextSize() const SK_OVERRIDE { return sizeof(TestDrawLooperContext
    ); } | 
| 24 | 24 | 
| 25 #ifndef SK_IGNORE_TO_STRING | 25 #ifndef SK_IGNORE_TO_STRING | 
| 26     virtual void toString(SkString* str) const SK_OVERRIDE { | 26     void toString(SkString* str) const SK_OVERRIDE { | 
| 27         str->append("TestLooper:"); | 27         str->append("TestLooper:"); | 
| 28     } | 28     } | 
| 29 #endif | 29 #endif | 
| 30 | 30 | 
| 31     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestLooper); | 31     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestLooper); | 
| 32 | 32 | 
| 33 private: | 33 private: | 
| 34     class TestDrawLooperContext : public SkDrawLooper::Context { | 34     class TestDrawLooperContext : public SkDrawLooper::Context { | 
| 35     public: | 35     public: | 
| 36         TestDrawLooperContext() : fOnce(true) {} | 36         TestDrawLooperContext() : fOnce(true) {} | 
| 37         virtual ~TestDrawLooperContext() {} | 37         virtual ~TestDrawLooperContext() {} | 
| 38 | 38 | 
| 39         virtual bool next(SkCanvas* canvas, SkPaint*) SK_OVERRIDE { | 39         bool next(SkCanvas* canvas, SkPaint*) SK_OVERRIDE { | 
| 40             if (fOnce) { | 40             if (fOnce) { | 
| 41                 fOnce = false; | 41                 fOnce = false; | 
| 42                 canvas->translate(SkIntToScalar(10), 0); | 42                 canvas->translate(SkIntToScalar(10), 0); | 
| 43                 return true; | 43                 return true; | 
| 44             } | 44             } | 
| 45             return false; | 45             return false; | 
| 46         } | 46         } | 
| 47     private: | 47     private: | 
| 48         bool fOnce; | 48         bool fOnce; | 
| 49     }; | 49     }; | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 83     // allows us through, even though sans-looper we would look like we should | 83     // allows us through, even though sans-looper we would look like we should | 
| 84     // be clipped out. | 84     // be clipped out. | 
| 85     paint.setLooper(new TestLooper)->unref(); | 85     paint.setLooper(new TestLooper)->unref(); | 
| 86     canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); | 86     canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); | 
| 87     REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); | 87     REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); | 
| 88 } | 88 } | 
| 89 | 89 | 
| 90 DEF_TEST(QuickReject, reporter) { | 90 DEF_TEST(QuickReject, reporter) { | 
| 91     test_drawBitmap(reporter); | 91     test_drawBitmap(reporter); | 
| 92 } | 92 } | 
| OLD | NEW | 
|---|