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 "Test.h" | 8 #include "Test.h" |
9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkData.h" | 12 #include "SkData.h" |
13 #include "SkDiscardableMemoryPool.h" | 13 #include "SkDiscardableMemoryPool.h" |
14 #include "SkImageGenerator.h" | 14 #include "SkImageGenerator.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkShader.h" | 16 #include "SkShader.h" |
17 #include "SkSurface.h" | 17 #include "SkSurface.h" |
18 #include "SkRandom.h" | 18 #include "SkRandom.h" |
19 #include "SkMatrixUtils.h" | 19 #include "SkMatrixUtils.h" |
20 | 20 |
21 namespace { | |
22 // A BitmapFactory that always fails when asked to return pixels. | 21 // A BitmapFactory that always fails when asked to return pixels. |
23 class FailureImageGenerator : public SkImageGenerator { | 22 class FailureImageGenerator : public SkImageGenerator { |
24 public: | 23 public: |
25 FailureImageGenerator() { } | 24 FailureImageGenerator() { } |
26 virtual ~FailureImageGenerator() { } | 25 virtual ~FailureImageGenerator() { } |
robertphillips
2014/01/14 13:19:37
SK_OVERRIDE?
tfarina
2014/01/21 23:37:43
Done.
| |
27 virtual bool getInfo(SkImageInfo* info) { | 26 virtual bool getInfo(SkImageInfo* info) { |
28 info->fWidth = 100; | 27 info->fWidth = 100; |
29 info->fHeight = 100; | 28 info->fHeight = 100; |
30 info->fColorType = kPMColor_SkColorType; | 29 info->fColorType = kPMColor_SkColorType; |
31 info->fAlphaType = kPremul_SkAlphaType; | 30 info->fAlphaType = kPremul_SkAlphaType; |
32 return true; | 31 return true; |
33 } | 32 } |
34 virtual bool getPixels(const SkImageInfo& info, | 33 virtual bool getPixels(const SkImageInfo& info, |
35 void* pixels, | 34 void* pixels, |
36 size_t rowBytes) SK_OVERRIDE { | 35 size_t rowBytes) SK_OVERRIDE { |
37 // this will deliberately return false if they are asking us | 36 // this will deliberately return false if they are asking us |
38 // to decode into pixels. | 37 // to decode into pixels. |
39 return false; | 38 return false; |
40 } | 39 } |
41 }; | 40 }; |
42 } // namespace | |
43 | 41 |
44 // crbug.com/295895 | 42 // crbug.com/295895 |
45 // Crashing in skia when a pixelref fails in lockPixels | 43 // Crashing in skia when a pixelref fails in lockPixels |
46 // | 44 // |
47 static void test_faulty_pixelref(skiatest::Reporter* reporter) { | 45 static void test_faulty_pixelref(skiatest::Reporter* reporter) { |
48 // need a cache, but don't expect to use it, so the budget is not critical | 46 // need a cache, but don't expect to use it, so the budget is not critical |
49 SkAutoTUnref<SkDiscardableMemoryPool> pool(SkNEW_ARGS(SkDiscardableMemoryPoo l, | 47 SkAutoTUnref<SkDiscardableMemoryPool> pool(SkNEW_ARGS(SkDiscardableMemoryPoo l, |
50 (10 * 1000, NULL))); | 48 (10 * 1000, NULL))); |
51 SkBitmap bm; | 49 SkBitmap bm; |
52 bool installSuccess = SkInstallDiscardablePixelRef(SkNEW(FailureImageGenerat or), &bm, pool); | 50 bool installSuccess = SkInstallDiscardablePixelRef(SkNEW(FailureImageGenerat or), &bm, pool); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 | 320 |
323 // ensure that we draw nothing if srcR does not intersect the bitmap | 321 // ensure that we draw nothing if srcR does not intersect the bitmap |
324 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); | 322 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); |
325 | 323 |
326 test_nan_antihair(); | 324 test_nan_antihair(); |
327 test_giantrepeat_crbug118018(reporter); | 325 test_giantrepeat_crbug118018(reporter); |
328 | 326 |
329 test_treatAsSprite(reporter); | 327 test_treatAsSprite(reporter); |
330 test_faulty_pixelref(reporter); | 328 test_faulty_pixelref(reporter); |
331 } | 329 } |
OLD | NEW |