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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkDashPathEffect.h" |
11 #include "SkData.h" | 12 #include "SkData.h" |
12 #include "SkDecodingImageGenerator.h" | 13 #include "SkDecodingImageGenerator.h" |
13 #include "SkError.h" | 14 #include "SkError.h" |
14 #include "SkImageEncoder.h" | 15 #include "SkImageEncoder.h" |
15 #include "SkImageGenerator.h" | 16 #include "SkImageGenerator.h" |
16 #include "SkPaint.h" | 17 #include "SkPaint.h" |
17 #include "SkPicture.h" | 18 #include "SkPicture.h" |
18 #include "SkPictureRecorder.h" | 19 #include "SkPictureRecorder.h" |
19 #include "SkPictureUtils.h" | 20 #include "SkPictureUtils.h" |
20 #include "SkRRect.h" | 21 #include "SkRRect.h" |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 canvas->restore(); | 688 canvas->restore(); |
688 } else if (unit <= 0.9) { | 689 } else if (unit <= 0.9) { |
689 // SkDebugf("clip\n"); | 690 // SkDebugf("clip\n"); |
690 canvas->clipRect(rect); | 691 canvas->clipRect(rect); |
691 } else { | 692 } else { |
692 // SkDebugf("draw\n"); | 693 // SkDebugf("draw\n"); |
693 canvas->drawPaint(paint); | 694 canvas->drawPaint(paint); |
694 } | 695 } |
695 } | 696 } |
696 | 697 |
| 698 static void test_gpu_veto(skiatest::Reporter* reporter) { |
| 699 |
| 700 SkPictureRecorder recorder; |
| 701 |
| 702 SkCanvas* canvas = recorder.beginRecording(100, 100, NULL, 0); |
| 703 { |
| 704 SkPath path; |
| 705 path.moveTo(0, 0); |
| 706 path.lineTo(50, 50); |
| 707 |
| 708 SkScalar intervals[] = { 1.0f, 1.0f }; |
| 709 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals,
2, 0)); |
| 710 |
| 711 SkPaint paint; |
| 712 paint.setStyle(SkPaint::kStroke_Style); |
| 713 paint.setPathEffect(dash); |
| 714 |
| 715 canvas->drawPath(path, paint); |
| 716 } |
| 717 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 718 // path effects currently render an SkPicture undesireable for GPU rendering |
| 719 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); |
| 720 |
| 721 canvas = recorder.beginRecording(100, 100, NULL, 0); |
| 722 { |
| 723 SkPath path; |
| 724 |
| 725 path.moveTo(0, 0); |
| 726 path.lineTo(0, 50); |
| 727 path.lineTo(25, 25); |
| 728 path.lineTo(50, 50); |
| 729 path.lineTo(50, 0); |
| 730 path.close(); |
| 731 REPORTER_ASSERT(reporter, !path.isConvex()); |
| 732 |
| 733 SkPaint paint; |
| 734 canvas->drawPath(path, paint); |
| 735 } |
| 736 picture.reset(recorder.endRecording()); |
| 737 // concave paths currently render an SkPicture undesireable for GPU renderin
g |
| 738 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); |
| 739 } |
| 740 |
697 static void set_canvas_to_save_count_4(SkCanvas* canvas) { | 741 static void set_canvas_to_save_count_4(SkCanvas* canvas) { |
698 canvas->restoreToCount(1); | 742 canvas->restoreToCount(1); |
699 canvas->save(); | 743 canvas->save(); |
700 canvas->save(); | 744 canvas->save(); |
701 canvas->save(); | 745 canvas->save(); |
702 } | 746 } |
703 | 747 |
704 static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { | 748 static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { |
705 SkCanvas testCanvas(100, 100); | 749 SkCanvas testCanvas(100, 100); |
706 set_canvas_to_save_count_4(&testCanvas); | 750 set_canvas_to_save_count_4(&testCanvas); |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 | 1234 |
1191 DEF_TEST(Picture, reporter) { | 1235 DEF_TEST(Picture, reporter) { |
1192 #ifdef SK_DEBUG | 1236 #ifdef SK_DEBUG |
1193 test_deleting_empty_playback(); | 1237 test_deleting_empty_playback(); |
1194 test_serializing_empty_picture(); | 1238 test_serializing_empty_picture(); |
1195 #else | 1239 #else |
1196 test_bad_bitmap(); | 1240 test_bad_bitmap(); |
1197 #endif | 1241 #endif |
1198 test_unbalanced_save_restores(reporter); | 1242 test_unbalanced_save_restores(reporter); |
1199 test_peephole(); | 1243 test_peephole(); |
| 1244 test_gpu_veto(reporter); |
1200 test_gatherpixelrefs(reporter); | 1245 test_gatherpixelrefs(reporter); |
1201 test_gatherpixelrefsandrects(reporter); | 1246 test_gatherpixelrefsandrects(reporter); |
1202 test_bitmap_with_encoded_data(reporter); | 1247 test_bitmap_with_encoded_data(reporter); |
1203 test_clone_empty(reporter); | 1248 test_clone_empty(reporter); |
1204 test_draw_empty(reporter); | 1249 test_draw_empty(reporter); |
1205 test_clip_bound_opt(reporter); | 1250 test_clip_bound_opt(reporter); |
1206 test_clip_expansion(reporter); | 1251 test_clip_expansion(reporter); |
1207 test_hierarchical(reporter); | 1252 test_hierarchical(reporter); |
1208 test_gen_id(reporter); | 1253 test_gen_id(reporter); |
1209 } | 1254 } |
(...skipping 24 matching lines...) Expand all Loading... |
1234 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 1279 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
1235 } | 1280 } |
1236 | 1281 |
1237 DEF_TEST(Canvas_EmptyBitmap, r) { | 1282 DEF_TEST(Canvas_EmptyBitmap, r) { |
1238 SkBitmap dst; | 1283 SkBitmap dst; |
1239 dst.allocN32Pixels(10, 10); | 1284 dst.allocN32Pixels(10, 10); |
1240 SkCanvas canvas(dst); | 1285 SkCanvas canvas(dst); |
1241 | 1286 |
1242 test_draw_bitmaps(&canvas); | 1287 test_draw_bitmaps(&canvas); |
1243 } | 1288 } |
OLD | NEW |