Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: tests/DrawBitmapRectTest.cpp

Issue 1340803002: discardable pixelrefs are gone, update tests accordingly (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/pictureimagegenerator.cpp ('k') | tests/ImageDecodingTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « gm/pictureimagegenerator.cpp ('k') | tests/ImageDecodingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698