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 "SkData.h" | 11 #include "SkData.h" |
12 #include "SkDecodingImageGenerator.h" | 12 #include "SkDecodingImageGenerator.h" |
13 #include "SkError.h" | 13 #include "SkError.h" |
14 #include "SkImageEncoder.h" | 14 #include "SkImageEncoder.h" |
15 #include "SkImageGenerator.h" | 15 #include "SkImageGenerator.h" |
16 #include "SkPaint.h" | 16 #include "SkPaint.h" |
17 #include "SkPicture.h" | 17 #include "SkPicture.h" |
18 #include "SkPictureUtils.h" | 18 #include "SkPictureUtils.h" |
19 #include "SkQuadTreePicture.h" | 19 #include "SkQuadTreePicture.h" |
20 #include "SkRRect.h" | 20 #include "SkRRect.h" |
21 #include "SkRandom.h" | 21 #include "SkRandom.h" |
| 22 #include "SkRTreePicture.h" |
22 #include "SkShader.h" | 23 #include "SkShader.h" |
23 #include "SkStream.h" | 24 #include "SkStream.h" |
24 #include "SkTileGrid.h" | 25 #include "SkTileGrid.h" |
25 #include "Test.h" | 26 #include "Test.h" |
26 | 27 |
27 static const int gColorScale = 30; | 28 static const int gColorScale = 30; |
28 static const int gColorOffset = 60; | 29 static const int gColorOffset = 60; |
29 | 30 |
30 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { | 31 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { |
31 bm->allocN32Pixels(w, h); | 32 bm->allocN32Pixels(w, h); |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 | 911 |
911 { | 912 { |
912 // tile grid | 913 // tile grid |
913 SkTileGridPicture::TileGridInfo gridInfo; | 914 SkTileGridPicture::TileGridInfo gridInfo; |
914 gridInfo.fMargin.setEmpty(); | 915 gridInfo.fMargin.setEmpty(); |
915 gridInfo.fOffset.setZero(); | 916 gridInfo.fOffset.setZero(); |
916 gridInfo.fTileInterval.set(1, 1); | 917 gridInfo.fTileInterval.set(1, 1); |
917 | 918 |
918 SkAutoTUnref<SkPictureFactory> factory(SkNEW_ARGS(SkTileGridPictureFacto
ry, (gridInfo))); | 919 SkAutoTUnref<SkPictureFactory> factory(SkNEW_ARGS(SkTileGridPictureFacto
ry, (gridInfo))); |
919 SkPictureRecorder recorder(factory); | 920 SkPictureRecorder recorder(factory); |
920 recorder.beginRecording(1, 1, SkPicture::kOptimizeForClippedPlayback_Rec
ordingFlag); | 921 recorder.beginRecording(1, 1); |
921 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 922 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
922 | 923 |
923 canvas.drawPicture(*picture); | 924 canvas.drawPicture(*picture); |
924 } | 925 } |
925 | 926 |
926 { | 927 { |
927 // RTree | 928 // RTree |
928 SkPictureRecorder recorder; | 929 SkAutoTUnref<SkPictureFactory> factory(SkNEW(SkRTreePictureFactory)); |
929 recorder.beginRecording(1, 1, SkPicture::kOptimizeForClippedPlayback_Rec
ordingFlag); | 930 SkPictureRecorder recorder(factory); |
| 931 recorder.beginRecording(1, 1); |
930 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 932 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
931 | 933 |
932 canvas.drawPicture(*picture); | 934 canvas.drawPicture(*picture); |
933 } | 935 } |
934 | 936 |
935 { | 937 { |
936 // quad tree | 938 // quad tree |
937 SkAutoTUnref<SkPictureFactory> factory(SkNEW(SkQuadTreePictureFactory)); | 939 SkAutoTUnref<SkPictureFactory> factory(SkNEW(SkQuadTreePictureFactory)); |
938 SkPictureRecorder recorder(factory); | 940 SkPictureRecorder recorder(factory); |
939 recorder.beginRecording(1, 1, SkPicture::kOptimizeForClippedPlayback_Rec
ordingFlag); | 941 recorder.beginRecording(1, 1); |
940 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 942 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
941 | 943 |
942 canvas.drawPicture(*picture); | 944 canvas.drawPicture(*picture); |
943 } | 945 } |
944 } | 946 } |
945 | 947 |
946 static void test_clip_bound_opt(skiatest::Reporter* reporter) { | 948 static void test_clip_bound_opt(skiatest::Reporter* reporter) { |
947 // Test for crbug.com/229011 | 949 // Test for crbug.com/229011 |
948 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), | 950 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), |
949 SkIntToScalar(2), SkIntToScalar(2)); | 951 SkIntToScalar(2), SkIntToScalar(2)); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 1236 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
1235 } | 1237 } |
1236 | 1238 |
1237 DEF_TEST(Canvas_EmptyBitmap, r) { | 1239 DEF_TEST(Canvas_EmptyBitmap, r) { |
1238 SkBitmap dst; | 1240 SkBitmap dst; |
1239 dst.allocN32Pixels(10, 10); | 1241 dst.allocN32Pixels(10, 10); |
1240 SkCanvas canvas(dst); | 1242 SkCanvas canvas(dst); |
1241 | 1243 |
1242 test_draw_bitmaps(&canvas); | 1244 test_draw_bitmaps(&canvas); |
1243 } | 1245 } |
OLD | NEW |