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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « gm/pictureimagegenerator.cpp ('k') | tests/ImageDecodingTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
11 #include "SkDiscardableMemoryPool.h" 11 #include "SkDiscardableMemoryPool.h"
12 #include "SkImageGeneratorPriv.h" 12 #include "SkImageGeneratorPriv.h"
13 #include "SkMatrixUtils.h" 13 #include "SkMatrixUtils.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkPath.h" 15 #include "SkPath.h"
16 #include "SkPixelRef.h"
16 #include "SkRandom.h" 17 #include "SkRandom.h"
17 #include "SkShader.h" 18 #include "SkShader.h"
18 #include "SkSurface.h" 19 #include "SkSurface.h"
19 #include "Test.h" 20 #include "Test.h"
20 21
21 // A BitmapFactory that always fails when asked to return pixels. 22 class FailurePixelRef : public SkPixelRef {
22 class FailureImageGenerator : public SkImageGenerator {
23 public: 23 public:
24 FailureImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(100, 1 00)) {} 24 FailurePixelRef(const SkImageInfo& info) : SkPixelRef(info) {}
25 protected: 25 protected:
26 // default onGetPixels() returns kUnimplemented, which is what we want. 26 bool onNewLockPixels(LockRec*) override { return false; }
27 void onUnlockPixels() override {}
27 }; 28 };
28 29
29 // crbug.com/295895 30 // crbug.com/295895
30 // Crashing in skia when a pixelref fails in lockPixels 31 // Crashing in skia when a pixelref fails in lockPixels
31 // 32 //
32 static void test_faulty_pixelref(skiatest::Reporter* reporter) { 33 static void test_faulty_pixelref(skiatest::Reporter* reporter) {
33 // need a cache, but don't expect to use it, so the budget is not critical 34 // need a cache, but don't expect to use it, so the budget is not critical
34 SkAutoTUnref<SkDiscardableMemoryPool> pool( 35 SkAutoTUnref<SkDiscardableMemoryPool> pool(
35 SkDiscardableMemoryPool::Create(10 * 1000, nullptr)); 36 SkDiscardableMemoryPool::Create(10 * 1000, nullptr));
37
36 SkBitmap bm; 38 SkBitmap bm;
37 bool success = SkInstallDiscardablePixelRef(new FailureImageGenerator, nullp tr, &bm, pool); 39 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
38 REPORTER_ASSERT(reporter, success); 40 bm.setInfo(info);
41 bm.setPixelRef(new FailurePixelRef(info), 0, 0)->unref();
39 // now our bitmap has a pixelref, but we know it will fail to lock 42 // now our bitmap has a pixelref, but we know it will fail to lock
40 43
41 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200)); 44 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200));
42 SkCanvas* canvas = surface->getCanvas(); 45 SkCanvas* canvas = surface->getCanvas();
43 46
44 const SkFilterQuality levels[] = { 47 const SkFilterQuality levels[] = {
45 kNone_SkFilterQuality, 48 kNone_SkFilterQuality,
46 kLow_SkFilterQuality, 49 kLow_SkFilterQuality,
47 kMedium_SkFilterQuality, 50 kMedium_SkFilterQuality,
48 kHigh_SkFilterQuality, 51 kHigh_SkFilterQuality,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 307
305 // ensure that we draw nothing if srcR does not intersect the bitmap 308 // ensure that we draw nothing if srcR does not intersect the bitmap
306 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); 309 REPORTER_ASSERT(reporter, check_for_all_zeros(dst));
307 310
308 test_nan_antihair(); 311 test_nan_antihair();
309 test_giantrepeat_crbug118018(reporter); 312 test_giantrepeat_crbug118018(reporter);
310 313
311 test_treatAsSprite(reporter); 314 test_treatAsSprite(reporter);
312 test_faulty_pixelref(reporter); 315 test_faulty_pixelref(reporter);
313 } 316 }
OLDNEW
« 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