aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/CachedDecodingPixelRefTest.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-03-19 08:31:14 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-19 08:31:14 -0700
commit3ef71e343bf075888fb50892350390b4dd47de24 (patch)
treed4765ef144928600322cf21bdb41b37f05a55697 /tests/CachedDecodingPixelRefTest.cpp
parent647211f1243f2dc925588e75038be49cad7b5431 (diff)
guarded change to SkImageGenerator to make getInfo() const
Diffstat (limited to 'tests/CachedDecodingPixelRefTest.cpp')
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index d6edda75cb..ddc0994e56 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -163,7 +163,6 @@ DEF_TEST(DecodingImageGenerator, reporter) {
class TestImageGenerator : public SkImageGenerator {
public:
enum TestType {
- kFailGetInfo_TestType,
kFailGetPixels_TestType,
kSucceedGetPixels_TestType,
kLast_TestType = kSucceedGetPixels_TestType
@@ -172,22 +171,24 @@ public:
static int Height() { return 10; }
static uint32_t Color() { return 0xff123456; }
TestImageGenerator(TestType type, skiatest::Reporter* reporter)
- : fType(type), fReporter(reporter) {
+ : INHERITED(GetMyInfo()), fType(type), fReporter(reporter) {
SkASSERT((fType <= kLast_TestType) && (fType >= 0));
}
virtual ~TestImageGenerator() { }
protected:
+ static SkImageInfo GetMyInfo() {
+ return SkImageInfo::MakeN32(TestImageGenerator::Width(), TestImageGenerator::Height(),
+ kOpaque_SkAlphaType);
+ }
+
+#ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
REPORTER_ASSERT(fReporter, info);
- if ((NULL == info) || (kFailGetInfo_TestType == fType)) {
- return false;
- }
- *info = SkImageInfo::MakeN32(TestImageGenerator::Width(),
- TestImageGenerator::Height(),
- kOpaque_SkAlphaType);
+ *info = GetMyInfo();
return true;
}
+#endif
virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
const Options&,
@@ -212,6 +213,8 @@ protected:
private:
const TestType fType;
skiatest::Reporter* const fReporter;
+
+ typedef SkImageGenerator INHERITED;
};
static void check_test_image_generator_bitmap(skiatest::Reporter* reporter,
@@ -256,8 +259,7 @@ static void check_pixelref(TestImageGenerator::TestType type,
} else {
success = SkInstallDiscardablePixelRef(gen.detach(), &lazy, factory);
}
- REPORTER_ASSERT(reporter, success
- == (TestImageGenerator::kFailGetInfo_TestType != type));
+ REPORTER_ASSERT(reporter, success);
if (TestImageGenerator::kSucceedGetPixels_TestType == type) {
check_test_image_generator_bitmap(reporter, lazy);
} else if (TestImageGenerator::kFailGetPixels_TestType == type) {
@@ -283,15 +285,11 @@ static void test_newlockdelete(skiatest::Reporter* reporter) {
DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
test_newlockdelete(reporter);
- 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);
- check_pixelref(TestImageGenerator::kFailGetInfo_TestType,
- reporter, kSkDiscardable_PixelRefType, NULL);
check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
reporter, kSkDiscardable_PixelRefType, NULL);
check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
@@ -321,7 +319,6 @@ DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
DEF_TEST(Image_NewFromGenerator, r) {
TestImageGenerator::TestType testTypes[] = {
- TestImageGenerator::kFailGetInfo_TestType,
TestImageGenerator::kFailGetPixels_TestType,
TestImageGenerator::kSucceedGetPixels_TestType,
};
@@ -329,10 +326,6 @@ DEF_TEST(Image_NewFromGenerator, r) {
TestImageGenerator::TestType test = testTypes[i];
SkImageGenerator* gen = SkNEW_ARGS(TestImageGenerator, (test, r));
SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen));
- if (TestImageGenerator::kFailGetInfo_TestType == test) {
- REPORTER_ASSERT(r, NULL == image.get());
- continue;
- }
if (NULL == image.get()) {
ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed ["
SK_SIZE_T_SPECIFIER "]", i);