| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
| 9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 912 |
| 913 #endif | 913 #endif |
| 914 | 914 |
| 915 static void set_canvas_to_save_count_4(SkCanvas* canvas) { | 915 static void set_canvas_to_save_count_4(SkCanvas* canvas) { |
| 916 canvas->restoreToCount(1); | 916 canvas->restoreToCount(1); |
| 917 canvas->save(); | 917 canvas->save(); |
| 918 canvas->save(); | 918 canvas->save(); |
| 919 canvas->save(); | 919 canvas->save(); |
| 920 } | 920 } |
| 921 | 921 |
| 922 #ifdef SK_BUILD_FOR_ANDROID | |
| 923 /** | 922 /** |
| 924 * A canvas that records the number of saves, saveLayers and restores. | 923 * A canvas that records the number of saves, saveLayers and restores. |
| 925 */ | 924 */ |
| 926 class SaveCountingCanvas : public SkCanvas { | 925 class SaveCountingCanvas : public SkCanvas { |
| 927 public: | 926 public: |
| 928 SaveCountingCanvas(int width, int height) | 927 SaveCountingCanvas(int width, int height) |
| 929 : INHERITED(width, height) | 928 : INHERITED(width, height) |
| 930 , fSaveCount(0) | 929 , fSaveCount(0) |
| 931 , fSaveLayerCount(0) | 930 , fSaveLayerCount(0) |
| 932 , fRestoreCount(0){ | 931 , fRestoreCount(0){ |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 | 1034 |
| 1036 SkAutoTUnref<SkPicture> final(recorder.endRecording()); | 1035 SkAutoTUnref<SkPicture> final(recorder.endRecording()); |
| 1037 REPORTER_ASSERT(reporter, final->willPlayBackBitmaps()); | 1036 REPORTER_ASSERT(reporter, final->willPlayBackBitmaps()); |
| 1038 | 1037 |
| 1039 REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID()); | 1038 REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID()); |
| 1040 | 1039 |
| 1041 // The snapshot shouldn't pick up any operations added after it was made | 1040 // The snapshot shouldn't pick up any operations added after it was made |
| 1042 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps()); | 1041 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps()); |
| 1043 } | 1042 } |
| 1044 } | 1043 } |
| 1045 #endif | |
| 1046 | 1044 |
| 1047 static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { | 1045 static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { |
| 1048 SkCanvas testCanvas(100, 100); | 1046 SkCanvas testCanvas(100, 100); |
| 1049 set_canvas_to_save_count_4(&testCanvas); | 1047 set_canvas_to_save_count_4(&testCanvas); |
| 1050 | 1048 |
| 1051 REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount()); | 1049 REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount()); |
| 1052 | 1050 |
| 1053 SkPaint paint; | 1051 SkPaint paint; |
| 1054 SkRect rect = SkRect::MakeLTRB(-10000000, -10000000, 10000000, 10000000); | 1052 SkRect rect = SkRect::MakeLTRB(-10000000, -10000000, 10000000, 10000000); |
| 1055 | 1053 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 1584 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 1587 } | 1585 } |
| 1588 | 1586 |
| 1589 DEF_TEST(Canvas_EmptyBitmap, r) { | 1587 DEF_TEST(Canvas_EmptyBitmap, r) { |
| 1590 SkBitmap dst; | 1588 SkBitmap dst; |
| 1591 dst.allocN32Pixels(10, 10); | 1589 dst.allocN32Pixels(10, 10); |
| 1592 SkCanvas canvas(dst); | 1590 SkCanvas canvas(dst); |
| 1593 | 1591 |
| 1594 test_draw_bitmaps(&canvas); | 1592 test_draw_bitmaps(&canvas); |
| 1595 } | 1593 } |
| OLD | NEW |