| 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 SkPath path; |
| 700 path.moveTo(0, 0); |
| 701 path.lineTo(50, 50); |
| 702 |
| 703 SkScalar intervals[] = { 1.0f, 1.0f }; |
| 704 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0
)); |
| 705 |
| 706 SkPaint paint; |
| 707 paint.setStyle(SkPaint::kStroke_Style); |
| 708 paint.setPathEffect(dash); |
| 709 |
| 710 SkPictureRecorder recorder; |
| 711 |
| 712 SkCanvas* canvas = recorder.beginRecording(100, 100, NULL, 0); |
| 713 canvas->drawPath(path, paint); |
| 714 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 715 |
| 716 // path effects currently render an SkPicture undesireable for GPU rendering |
| 717 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); |
| 718 } |
| 719 |
| 697 static void set_canvas_to_save_count_4(SkCanvas* canvas) { | 720 static void set_canvas_to_save_count_4(SkCanvas* canvas) { |
| 698 canvas->restoreToCount(1); | 721 canvas->restoreToCount(1); |
| 699 canvas->save(); | 722 canvas->save(); |
| 700 canvas->save(); | 723 canvas->save(); |
| 701 canvas->save(); | 724 canvas->save(); |
| 702 } | 725 } |
| 703 | 726 |
| 704 static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { | 727 static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { |
| 705 SkCanvas testCanvas(100, 100); | 728 SkCanvas testCanvas(100, 100); |
| 706 set_canvas_to_save_count_4(&testCanvas); | 729 set_canvas_to_save_count_4(&testCanvas); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 | 1213 |
| 1191 DEF_TEST(Picture, reporter) { | 1214 DEF_TEST(Picture, reporter) { |
| 1192 #ifdef SK_DEBUG | 1215 #ifdef SK_DEBUG |
| 1193 test_deleting_empty_playback(); | 1216 test_deleting_empty_playback(); |
| 1194 test_serializing_empty_picture(); | 1217 test_serializing_empty_picture(); |
| 1195 #else | 1218 #else |
| 1196 test_bad_bitmap(); | 1219 test_bad_bitmap(); |
| 1197 #endif | 1220 #endif |
| 1198 test_unbalanced_save_restores(reporter); | 1221 test_unbalanced_save_restores(reporter); |
| 1199 test_peephole(); | 1222 test_peephole(); |
| 1223 test_gpu_veto(reporter); |
| 1200 test_gatherpixelrefs(reporter); | 1224 test_gatherpixelrefs(reporter); |
| 1201 test_gatherpixelrefsandrects(reporter); | 1225 test_gatherpixelrefsandrects(reporter); |
| 1202 test_bitmap_with_encoded_data(reporter); | 1226 test_bitmap_with_encoded_data(reporter); |
| 1203 test_clone_empty(reporter); | 1227 test_clone_empty(reporter); |
| 1204 test_draw_empty(reporter); | 1228 test_draw_empty(reporter); |
| 1205 test_clip_bound_opt(reporter); | 1229 test_clip_bound_opt(reporter); |
| 1206 test_clip_expansion(reporter); | 1230 test_clip_expansion(reporter); |
| 1207 test_hierarchical(reporter); | 1231 test_hierarchical(reporter); |
| 1208 test_gen_id(reporter); | 1232 test_gen_id(reporter); |
| 1209 } | 1233 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1234 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 1258 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 1235 } | 1259 } |
| 1236 | 1260 |
| 1237 DEF_TEST(Canvas_EmptyBitmap, r) { | 1261 DEF_TEST(Canvas_EmptyBitmap, r) { |
| 1238 SkBitmap dst; | 1262 SkBitmap dst; |
| 1239 dst.allocN32Pixels(10, 10); | 1263 dst.allocN32Pixels(10, 10); |
| 1240 SkCanvas canvas(dst); | 1264 SkCanvas canvas(dst); |
| 1241 | 1265 |
| 1242 test_draw_bitmaps(&canvas); | 1266 test_draw_bitmaps(&canvas); |
| 1243 } | 1267 } |
| OLD | NEW |