OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 protected: | 25 protected: |
26 // default onGetPixels() returns kUnimplemented, which is what we want. | 26 // default onGetPixels() returns kUnimplemented, which is what we want. |
27 }; | 27 }; |
28 | 28 |
29 // crbug.com/295895 | 29 // crbug.com/295895 |
30 // Crashing in skia when a pixelref fails in lockPixels | 30 // Crashing in skia when a pixelref fails in lockPixels |
31 // | 31 // |
32 static void test_faulty_pixelref(skiatest::Reporter* reporter) { | 32 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 | 33 // need a cache, but don't expect to use it, so the budget is not critical |
34 SkAutoTUnref<SkDiscardableMemoryPool> pool( | 34 SkAutoTUnref<SkDiscardableMemoryPool> pool( |
35 SkDiscardableMemoryPool::Create(10 * 1000, NULL)); | 35 SkDiscardableMemoryPool::Create(10 * 1000, nullptr)); |
36 SkBitmap bm; | 36 SkBitmap bm; |
37 bool success = SkInstallDiscardablePixelRef(new FailureImageGenerator, NULL,
&bm, pool); | 37 bool success = SkInstallDiscardablePixelRef(new FailureImageGenerator, nullp
tr, &bm, pool); |
38 REPORTER_ASSERT(reporter, success); | 38 REPORTER_ASSERT(reporter, success); |
39 // now our bitmap has a pixelref, but we know it will fail to lock | 39 // now our bitmap has a pixelref, but we know it will fail to lock |
40 | 40 |
41 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200)); | 41 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200)); |
42 SkCanvas* canvas = surface->getCanvas(); | 42 SkCanvas* canvas = surface->getCanvas(); |
43 | 43 |
44 const SkFilterQuality levels[] = { | 44 const SkFilterQuality levels[] = { |
45 kNone_SkFilterQuality, | 45 kNone_SkFilterQuality, |
46 kLow_SkFilterQuality, | 46 kLow_SkFilterQuality, |
47 kMedium_SkFilterQuality, | 47 kMedium_SkFilterQuality, |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 SkBitmap src, dst; | 293 SkBitmap src, dst; |
294 | 294 |
295 create(&src, 0xFFFFFFFF); | 295 create(&src, 0xFFFFFFFF); |
296 create(&dst, 0); | 296 create(&dst, 0); |
297 | 297 |
298 SkCanvas canvas(dst); | 298 SkCanvas canvas(dst); |
299 | 299 |
300 SkIRect srcR = { gWidth, 0, gWidth + 16, 16 }; | 300 SkIRect srcR = { gWidth, 0, gWidth + 16, 16 }; |
301 SkRect dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) }; | 301 SkRect dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) }; |
302 | 302 |
303 canvas.drawBitmapRect(src, srcR, dstR, NULL); | 303 canvas.drawBitmapRect(src, srcR, dstR, nullptr); |
304 | 304 |
305 // ensure that we draw nothing if srcR does not intersect the bitmap | 305 // ensure that we draw nothing if srcR does not intersect the bitmap |
306 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); | 306 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); |
307 | 307 |
308 test_nan_antihair(); | 308 test_nan_antihair(); |
309 test_giantrepeat_crbug118018(reporter); | 309 test_giantrepeat_crbug118018(reporter); |
310 | 310 |
311 test_treatAsSprite(reporter); | 311 test_treatAsSprite(reporter); |
312 test_faulty_pixelref(reporter); | 312 test_faulty_pixelref(reporter); |
313 } | 313 } |
OLD | NEW |