Index: tests/CachedDecodingPixelRefTest.cpp |
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp |
index 8a329d88380ed055f79e53c1e57031c3dcc8e36e..9ac5f8139259f2261e5fb98a5d6be76ada9b6dab 100644 |
--- a/tests/CachedDecodingPixelRefTest.cpp |
+++ b/tests/CachedDecodingPixelRefTest.cpp |
@@ -166,8 +166,6 @@ DEF_TEST(DecodingImageGenerator, reporter) { |
test_three_encodings(reporter, install_skDiscardablePixelRef); |
} |
-//////////////////////////////////////////////////////////////////////////////// |
-namespace { |
class TestImageGenerator : public SkImageGenerator { |
public: |
enum TestType { |
@@ -183,8 +181,8 @@ public: |
: fType(type), fReporter(reporter) { |
SkASSERT((fType <= kLast_TestType) && (fType >= 0)); |
} |
- ~TestImageGenerator() { } |
- bool getInfo(SkImageInfo* info) SK_OVERRIDE { |
+ virtual ~TestImageGenerator() { } |
+ virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE { |
REPORTER_ASSERT(fReporter, NULL != info); |
if ((NULL == info) || (kFailGetInfo_TestType == fType)) { |
return false; |
@@ -195,9 +193,9 @@ public: |
info->fAlphaType = kOpaque_SkAlphaType; |
return true; |
} |
- bool getPixels(const SkImageInfo& info, |
- void* pixels, |
- size_t rowBytes) SK_OVERRIDE { |
+ virtual bool getPixels(const SkImageInfo& info, |
+ void* pixels, |
+ size_t rowBytes) SK_OVERRIDE { |
REPORTER_ASSERT(fReporter, pixels != NULL); |
size_t minRowBytes |
= static_cast<size_t>(info.fWidth * info.bytesPerPixel()); |
@@ -221,8 +219,8 @@ private: |
skiatest::Reporter* const fReporter; |
}; |
-void CheckTestImageGeneratorBitmap(skiatest::Reporter* reporter, |
- const SkBitmap& bm) { |
+static void check_test_image_generator_bitmap(skiatest::Reporter* reporter, |
+ const SkBitmap& bm) { |
REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width()); |
REPORTER_ASSERT(reporter, TestImageGenerator::Height() == bm.height()); |
SkAutoLockPixels autoLockPixels(bm); |
@@ -246,10 +244,11 @@ enum PixelRefType { |
kSkDiscardable_PixelRefType, |
kLast_PixelRefType = kSkDiscardable_PixelRefType |
}; |
-void CheckPixelRef(TestImageGenerator::TestType type, |
- skiatest::Reporter* reporter, |
- PixelRefType pixelRefType, |
- SkDiscardableMemory::Factory* factory) { |
+ |
+static void check_pixelref(TestImageGenerator::TestType type, |
+ skiatest::Reporter* reporter, |
+ PixelRefType pixelRefType, |
+ SkDiscardableMemory::Factory* factory) { |
SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType)); |
SkAutoTDelete<SkImageGenerator> gen(SkNEW_ARGS(TestImageGenerator, |
(type, reporter))); |
@@ -265,20 +264,18 @@ void CheckPixelRef(TestImageGenerator::TestType type, |
REPORTER_ASSERT(reporter, success |
== (TestImageGenerator::kFailGetInfo_TestType != type)); |
if (TestImageGenerator::kSucceedGetPixels_TestType == type) { |
- CheckTestImageGeneratorBitmap(reporter, lazy); |
+ check_test_image_generator_bitmap(reporter, lazy); |
} else if (TestImageGenerator::kFailGetPixels_TestType == type) { |
SkAutoLockPixels autoLockPixels(lazy); |
REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); |
} |
} |
-} // namespace |
// new/lock/delete is an odd pattern for a pixelref, but it needs to not assert |
static void test_newlockdelete(skiatest::Reporter* reporter) { |
SkBitmap bm; |
SkImageGenerator* ig = new TestImageGenerator( |
- TestImageGenerator::kSucceedGetPixels_TestType, |
- reporter); |
+ TestImageGenerator::kSucceedGetPixels_TestType, reporter); |
SkInstallDiscardablePixelRef(ig, &bm, NULL); |
bm.pixelRef()->lockPixels(); |
} |
@@ -291,37 +288,36 @@ static void test_newlockdelete(skiatest::Reporter* reporter) { |
DEF_TEST(DiscardableAndCachingPixelRef, reporter) { |
test_newlockdelete(reporter); |
- CheckPixelRef(TestImageGenerator::kFailGetInfo_TestType, |
- reporter, kSkCaching_PixelRefType, NULL); |
- CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, |
- reporter, kSkCaching_PixelRefType, NULL); |
- CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, |
- reporter, kSkCaching_PixelRefType, NULL); |
+ check_pixelref(TestImageGenerator::kFailGetInfo_TestType, |
+ reporter, kSkCaching_PixelRefType, NULL); |
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType, |
+ reporter, kSkCaching_PixelRefType, NULL); |
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, |
+ reporter, kSkCaching_PixelRefType, NULL); |
- CheckPixelRef(TestImageGenerator::kFailGetInfo_TestType, |
- reporter, kSkDiscardable_PixelRefType, NULL); |
- CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, |
- reporter, kSkDiscardable_PixelRefType, NULL); |
- CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, |
- reporter, kSkDiscardable_PixelRefType, NULL); |
+ check_pixelref(TestImageGenerator::kFailGetInfo_TestType, |
+ reporter, kSkDiscardable_PixelRefType, NULL); |
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType, |
+ reporter, kSkDiscardable_PixelRefType, NULL); |
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, |
+ reporter, kSkDiscardable_PixelRefType, NULL); |
SkAutoTUnref<SkDiscardableMemoryPool> pool( |
SkNEW_ARGS(SkDiscardableMemoryPool, (1, NULL))); |
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); |
- CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, |
- reporter, kSkDiscardable_PixelRefType, pool); |
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType, |
+ reporter, kSkDiscardable_PixelRefType, pool); |
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); |
- CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, |
- reporter, kSkDiscardable_PixelRefType, pool); |
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, |
+ reporter, kSkDiscardable_PixelRefType, pool); |
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); |
SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); |
// Only acts differently from NULL on a platform that has a |
// default discardable memory implementation that differs from the |
// global DM pool. |
- CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, |
- reporter, kSkDiscardable_PixelRefType, globalPool); |
- CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, |
- reporter, kSkDiscardable_PixelRefType, globalPool); |
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType, |
+ reporter, kSkDiscardable_PixelRefType, globalPool); |
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, |
+ reporter, kSkDiscardable_PixelRefType, globalPool); |
} |
-//////////////////////////////////////////////////////////////////////////////// |