aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/CachedDecodingPixelRefTest.cpp
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2015-09-23 11:53:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-23 11:53:37 -0700
commit60c73d51808b9d78f65381b83f628a3f523042fe (patch)
treed100633576080e72cc65dd20dab46bfc80af6038 /tests/CachedDecodingPixelRefTest.cpp
parenta1a8a601ae5dd3d29406610f39945f6c17f34b50 (diff)
Revert of remove unused SkCachingPixelRef (patchset #1 id:1 of https://codereview.chromium.org/1364743002/ )
Reason for revert: Build failure: https://uberchromegw.corp.google.com/i/client.skia.compile/builders/Build-Ubuntu-GCC-Arm7-Debug-Android_FrameworkDefs/builds/1146 Original issue's description: > remove unused SkCachingPixelRef > > BUG=skia: > TBR= > > Committed: https://skia.googlesource.com/skia/+/70d58b7da535e32bcac35739d11ab8367e99f224 TBR=halcanary@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1359393004
Diffstat (limited to 'tests/CachedDecodingPixelRefTest.cpp')
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp48
1 files changed, 39 insertions, 9 deletions
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index c14fb0052c..b58880b10d 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -6,6 +6,7 @@
*/
#include "SkBitmap.h"
+#include "SkCachingPixelRef.h"
#include "SkCanvas.h"
#include "SkData.h"
#include "SkDiscardableMemoryPool.h"
@@ -140,6 +141,9 @@ static void test_three_encodings(skiatest::Reporter* reporter,
}
////////////////////////////////////////////////////////////////////////////////
+static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) {
+ return SkCachingPixelRef::Install(SkImageGenerator::NewFromEncoded(encoded), dst);
+}
static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
// Use system-default discardable memory.
return SkInstallDiscardablePixelRef(encoded, dst);
@@ -147,10 +151,12 @@ static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
////////////////////////////////////////////////////////////////////////////////
/**
- * This checks to see that SkDiscardablePixelRef works as advertised with a
+ * This checks to see that a SkCachingPixelRef and a
+ * SkDiscardablePixelRef works as advertised with a
* SkDecodingImageGenerator.
*/
DEF_TEST(DecodingImageGenerator, reporter) {
+ test_three_encodings(reporter, install_skCachingPixelRef);
test_three_encodings(reporter, install_skDiscardablePixelRef);
}
@@ -222,14 +228,27 @@ static void check_test_image_generator_bitmap(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, 0 == errors);
}
+enum PixelRefType {
+ kSkCaching_PixelRefType,
+ kSkDiscardable_PixelRefType,
+ kLast_PixelRefType = kSkDiscardable_PixelRefType
+};
+
static void check_pixelref(TestImageGenerator::TestType type,
skiatest::Reporter* reporter,
+ PixelRefType pixelRefType,
SkDiscardableMemory::Factory* factory) {
+ SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType));
SkAutoTDelete<SkImageGenerator> gen(new TestImageGenerator(type, reporter));
REPORTER_ASSERT(reporter, gen.get() != nullptr);
SkBitmap lazy;
- bool success = SkInstallDiscardablePixelRef(gen.detach(), nullptr, &lazy, factory);
-
+ bool success;
+ if (kSkCaching_PixelRefType == pixelRefType) {
+ // Ignore factory; use global cache.
+ success = SkCachingPixelRef::Install(gen.detach(), &lazy);
+ } else {
+ success = SkInstallDiscardablePixelRef(gen.detach(), nullptr, &lazy, factory);
+ }
REPORTER_ASSERT(reporter, success);
if (TestImageGenerator::kSucceedGetPixels_TestType == type) {
check_test_image_generator_bitmap(reporter, lazy);
@@ -258,23 +277,34 @@ static void test_newlockdelete(skiatest::Reporter* reporter) {
DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
test_newlockdelete(reporter);
- check_pixelref(TestImageGenerator::kFailGetPixels_TestType, reporter, nullptr);
- check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, reporter, nullptr);
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
+ reporter, kSkCaching_PixelRefType, nullptr);
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
+ reporter, kSkCaching_PixelRefType, nullptr);
+
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
+ reporter, kSkDiscardable_PixelRefType, nullptr);
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
+ reporter, kSkDiscardable_PixelRefType, nullptr);
SkAutoTUnref<SkDiscardableMemoryPool> pool(
SkDiscardableMemoryPool::Create(1, nullptr));
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
- check_pixelref(TestImageGenerator::kFailGetPixels_TestType, reporter, pool);
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
+ reporter, kSkDiscardable_PixelRefType, pool);
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
- check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, reporter, pool);
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
+ reporter, kSkDiscardable_PixelRefType, pool);
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
// Only acts differently from nullptr on a platform that has a
// default discardable memory implementation that differs from the
// global DM pool.
- check_pixelref(TestImageGenerator::kFailGetPixels_TestType, reporter, globalPool);
- check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, reporter, globalPool);
+ check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
+ reporter, kSkDiscardable_PixelRefType, globalPool);
+ check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
+ reporter, kSkDiscardable_PixelRefType, globalPool);
}
////////////////////////////////////////////////////////////////////////////////