| 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" |
| 11 #include "SkData.h" | 11 #include "SkData.h" |
| 12 #include "SkDiscardableMemoryPool.h" | 12 #include "SkDiscardableMemoryPool.h" |
| 13 #include "SkDiscardablePixelRef.h" | 13 #include "SkImageGenerator.h" |
| 14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
| 15 #include "SkShader.h" | 15 #include "SkShader.h" |
| 16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
| 17 #include "SkRandom.h" | 17 #include "SkRandom.h" |
| 18 #include "SkMatrixUtils.h" | 18 #include "SkMatrixUtils.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 // A BitmapFactory that always fails when asked to return pixels. | 21 // A BitmapFactory that always fails when asked to return pixels. |
| 22 class FailureImageGenerator : public SkImageGenerator { | 22 class FailureImageGenerator : public SkImageGenerator { |
| 23 public: | 23 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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 // 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 |
| 48 SkAutoTUnref<SkDiscardableMemoryPool> pool(SkNEW_ARGS(SkDiscardableMemoryPoo
l, | 48 SkAutoTUnref<SkDiscardableMemoryPool> pool(SkNEW_ARGS(SkDiscardableMemoryPoo
l, |
| 49 (10 * 1000, NULL))); | 49 (10 * 1000, NULL))); |
| 50 SkBitmap bm; | 50 SkBitmap bm; |
| 51 bool installSuccess = SkDiscardablePixelRef::Install(SkNEW(FailureImageGener
ator), &bm, pool); | 51 bool installSuccess = SkInstallDiscardablePixelRef(SkNEW(FailureImageGenerat
or), &bm, pool); |
| 52 REPORTER_ASSERT(reporter, installSuccess); | 52 REPORTER_ASSERT(reporter, installSuccess); |
| 53 // 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 |
| 54 | 54 |
| 55 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200)); | 55 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200)); |
| 56 SkCanvas* canvas = surface->getCanvas(); | 56 SkCanvas* canvas = surface->getCanvas(); |
| 57 | 57 |
| 58 const SkPaint::FilterLevel levels[] = { | 58 const SkPaint::FilterLevel levels[] = { |
| 59 SkPaint::kNone_FilterLevel, | 59 SkPaint::kNone_FilterLevel, |
| 60 SkPaint::kLow_FilterLevel, | 60 SkPaint::kLow_FilterLevel, |
| 61 SkPaint::kMedium_FilterLevel, | 61 SkPaint::kMedium_FilterLevel, |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 test_nan_antihair(); | 327 test_nan_antihair(); |
| 328 test_giantrepeat_crbug118018(reporter); | 328 test_giantrepeat_crbug118018(reporter); |
| 329 | 329 |
| 330 test_treatAsSprite(reporter); | 330 test_treatAsSprite(reporter); |
| 331 test_faulty_pixelref(reporter); | 331 test_faulty_pixelref(reporter); |
| 332 } | 332 } |
| 333 | 333 |
| 334 #include "TestClassDef.h" | 334 #include "TestClassDef.h" |
| 335 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) | 335 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) |
| OLD | NEW |