| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // to decode into pixels. | 37 // to decode into pixels. |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 }; | 40 }; |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // crbug.com/295895 | 43 // crbug.com/295895 |
| 44 // Crashing in skia when a pixelref fails in lockPixels | 44 // Crashing in skia when a pixelref fails in lockPixels |
| 45 // | 45 // |
| 46 static void test_faulty_pixelref(skiatest::Reporter* reporter) { | 46 static void test_faulty_pixelref(skiatest::Reporter* reporter) { |
| 47 SkImageInfo info; | |
| 48 info.fWidth = 100; | |
| 49 info.fHeight = 100; | |
| 50 info.fColorType = kPMColor_SkColorType; | |
| 51 info.fAlphaType = kPremul_SkAlphaType; | |
| 52 | |
| 53 // need a cache, but don't expect to use it, so the budget is not critical | 47 // need a cache, but don't expect to use it, so the budget is not critical |
| 54 SkAutoTUnref<SkDiscardableMemoryPool> pool(SkNEW_ARGS(SkDiscardableMemoryPoo
l, | 48 SkAutoTUnref<SkDiscardableMemoryPool> pool(SkNEW_ARGS(SkDiscardableMemoryPoo
l, |
| 55 (10 * 1000, NULL))); | 49 (10 * 1000, NULL))); |
| 56 SkBitmap bm; | 50 SkBitmap bm; |
| 57 bool installSuccess = SkDiscardablePixelRef::Install(SkNEW(FailureImageGener
ator), &bm, pool); | 51 bool installSuccess = SkDiscardablePixelRef::Install(SkNEW(FailureImageGener
ator), &bm, pool); |
| 58 REPORTER_ASSERT(reporter, installSuccess); | 52 REPORTER_ASSERT(reporter, installSuccess); |
| 59 | |
| 60 // now our bitmap has a pixelref, but we know it will fail to lock | 53 // now our bitmap has a pixelref, but we know it will fail to lock |
| 61 | 54 |
| 62 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200)); | 55 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200)); |
| 63 SkCanvas* canvas = surface->getCanvas(); | 56 SkCanvas* canvas = surface->getCanvas(); |
| 64 | 57 |
| 65 const SkPaint::FilterLevel levels[] = { | 58 const SkPaint::FilterLevel levels[] = { |
| 66 SkPaint::kNone_FilterLevel, | 59 SkPaint::kNone_FilterLevel, |
| 67 SkPaint::kLow_FilterLevel, | 60 SkPaint::kLow_FilterLevel, |
| 68 SkPaint::kMedium_FilterLevel, | 61 SkPaint::kMedium_FilterLevel, |
| 69 SkPaint::kHigh_FilterLevel, | 62 SkPaint::kHigh_FilterLevel, |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 326 |
| 334 test_nan_antihair(); | 327 test_nan_antihair(); |
| 335 test_giantrepeat_crbug118018(reporter); | 328 test_giantrepeat_crbug118018(reporter); |
| 336 | 329 |
| 337 test_treatAsSprite(reporter); | 330 test_treatAsSprite(reporter); |
| 338 test_faulty_pixelref(reporter); | 331 test_faulty_pixelref(reporter); |
| 339 } | 332 } |
| 340 | 333 |
| 341 #include "TestClassDef.h" | 334 #include "TestClassDef.h" |
| 342 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) | 335 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) |
| OLD | NEW |