| OLD | NEW |
| 1 #include "Test.h" | 1 #include "Test.h" |
| 2 #include "TestClassDef.h" | 2 #include "TestClassDef.h" |
| 3 | 3 |
| 4 #include "SkPixelRef.h" | 4 #include "SkPixelRef.h" |
| 5 #include "SkMallocPixelRef.h" | 5 #include "SkMallocPixelRef.h" |
| 6 | 6 |
| 7 static void test_info(skiatest::Reporter* reporter) { | 7 static void test_info(skiatest::Reporter* reporter) { |
| 8 static const struct { | 8 static const struct { |
| 9 SkBitmap::Config fConfig; | 9 SkBitmap::Config fConfig; |
| 10 SkAlphaType fAlphaType; | 10 SkAlphaType fAlphaType; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public: | 44 public: |
| 45 explicit TestListener(int* ptr) : fPtr(ptr) {} | 45 explicit TestListener(int* ptr) : fPtr(ptr) {} |
| 46 void onChange() SK_OVERRIDE { (*fPtr)++; } | 46 void onChange() SK_OVERRIDE { (*fPtr)++; } |
| 47 private: | 47 private: |
| 48 int* fPtr; | 48 int* fPtr; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 DEF_TEST(PixelRef_GenIDChange, r) { | 53 DEF_TEST(PixelRef_GenIDChange, r) { |
| 54 SkImageInfo info = { 10, 10, kPMColor_SkColorType, kPremul_SkAlphaType }; | 54 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); |
| 55 | 55 |
| 56 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL
L)); | 56 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL
L)); |
| 57 | 57 |
| 58 // Register a listener. | 58 // Register a listener. |
| 59 int count = 0; | 59 int count = 0; |
| 60 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); | 60 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); |
| 61 REPORTER_ASSERT(r, 0 == count); | 61 REPORTER_ASSERT(r, 0 == count); |
| 62 | 62 |
| 63 // No one has looked at our pixelRef's generation ID, so invalidating it doe
sn't make sense. | 63 // No one has looked at our pixelRef's generation ID, so invalidating it doe
sn't make sense. |
| 64 // (An SkPixelRef tree falls in the forest but there's nobody around to hear
it. Do we care?) | 64 // (An SkPixelRef tree falls in the forest but there's nobody around to hear
it. Do we care?) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 pixelRef->notifyPixelsChanged(); | 78 pixelRef->notifyPixelsChanged(); |
| 79 REPORTER_ASSERT(r, 1 == count); | 79 REPORTER_ASSERT(r, 1 == count); |
| 80 | 80 |
| 81 // Quick check that NULL is safe. | 81 // Quick check that NULL is safe. |
| 82 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); | 82 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); |
| 83 pixelRef->addGenIDChangeListener(NULL); | 83 pixelRef->addGenIDChangeListener(NULL); |
| 84 pixelRef->notifyPixelsChanged(); | 84 pixelRef->notifyPixelsChanged(); |
| 85 | 85 |
| 86 test_info(r); | 86 test_info(r); |
| 87 } | 87 } |
| OLD | NEW |