Index: tests/DrawBitmapRectTest.cpp |
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp |
index 8836a7bd5c22801074ddee493533dac0eb341fa6..2eb181960b36aacda4ceb2c8081c67be72ae2366 100644 |
--- a/tests/DrawBitmapRectTest.cpp |
+++ b/tests/DrawBitmapRectTest.cpp |
@@ -13,17 +13,18 @@ |
#include "SkMatrixUtils.h" |
#include "SkPaint.h" |
#include "SkPath.h" |
+#include "SkPixelRef.h" |
#include "SkRandom.h" |
#include "SkShader.h" |
#include "SkSurface.h" |
#include "Test.h" |
-// A BitmapFactory that always fails when asked to return pixels. |
-class FailureImageGenerator : public SkImageGenerator { |
+class FailurePixelRef : public SkPixelRef { |
public: |
- FailureImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(100, 100)) {} |
+ FailurePixelRef(const SkImageInfo& info) : SkPixelRef(info) {} |
protected: |
- // default onGetPixels() returns kUnimplemented, which is what we want. |
+ bool onNewLockPixels(LockRec*) override { return false; } |
+ void onUnlockPixels() override {} |
}; |
// crbug.com/295895 |
@@ -33,9 +34,11 @@ static void test_faulty_pixelref(skiatest::Reporter* reporter) { |
// need a cache, but don't expect to use it, so the budget is not critical |
SkAutoTUnref<SkDiscardableMemoryPool> pool( |
SkDiscardableMemoryPool::Create(10 * 1000, nullptr)); |
+ |
SkBitmap bm; |
- bool success = SkInstallDiscardablePixelRef(new FailureImageGenerator, nullptr, &bm, pool); |
- REPORTER_ASSERT(reporter, success); |
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
+ bm.setInfo(info); |
+ bm.setPixelRef(new FailurePixelRef(info), 0, 0)->unref(); |
// now our bitmap has a pixelref, but we know it will fail to lock |
SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200)); |