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 "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkColorMatrixFilter.h" | 11 #include "SkColorMatrixFilter.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #include "SkDashPathEffect.h" | 13 #include "SkDashPathEffect.h" |
14 #include "SkData.h" | 14 #include "SkData.h" |
15 #include "SkDecodingImageGenerator.h" | 15 #include "SkDecodingImageGenerator.h" |
16 #include "SkError.h" | 16 #include "SkError.h" |
17 #include "SkImageEncoder.h" | 17 #include "SkImageEncoder.h" |
18 #include "SkImageGenerator.h" | 18 #include "SkImageGenerator.h" |
| 19 #include "SkLayerInfo.h" |
19 #include "SkPaint.h" | 20 #include "SkPaint.h" |
20 #include "SkPicture.h" | 21 #include "SkPicture.h" |
21 #include "SkPictureRecorder.h" | 22 #include "SkPictureRecorder.h" |
22 #include "SkPictureUtils.h" | 23 #include "SkPictureUtils.h" |
23 #include "SkPixelRef.h" | 24 #include "SkPixelRef.h" |
24 #include "SkRRect.h" | 25 #include "SkRRect.h" |
25 #include "SkRandom.h" | 26 #include "SkRandom.h" |
26 #include "SkShader.h" | 27 #include "SkShader.h" |
27 #include "SkStream.h" | 28 #include "SkStream.h" |
28 | 29 |
29 #if SK_SUPPORT_GPU | 30 #if SK_SUPPORT_GPU |
30 #include "SkSurface.h" | 31 #include "SkSurface.h" |
31 #include "GrContextFactory.h" | 32 #include "GrContextFactory.h" |
32 #include "GrPictureUtils.h" | |
33 #endif | 33 #endif |
34 #include "Test.h" | 34 #include "Test.h" |
35 | 35 |
36 #include "SkLumaColorFilter.h" | 36 #include "SkLumaColorFilter.h" |
37 #include "SkColorFilterImageFilter.h" | 37 #include "SkColorFilterImageFilter.h" |
38 | 38 |
39 static const int gColorScale = 30; | 39 static const int gColorScale = 30; |
40 static const int gColorOffset = 60; | 40 static const int gColorOffset = 60; |
41 | 41 |
42 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { | 42 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 864 |
865 // Nest the previous picture inside a new one. | 865 // Nest the previous picture inside a new one. |
866 canvas = recorder.beginRecording(100, 100); | 866 canvas = recorder.beginRecording(100, 100); |
867 { | 867 { |
868 canvas->drawPicture(picture.get()); | 868 canvas->drawPicture(picture.get()); |
869 } | 869 } |
870 picture.reset(recorder.endRecording()); | 870 picture.reset(recorder.endRecording()); |
871 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); | 871 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); |
872 } | 872 } |
873 | 873 |
874 static void test_gpu_picture_optimization(skiatest::Reporter* reporter, | 874 #endif |
875 GrContextFactory* factory) { | 875 |
876 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 876 static void test_savelayer_extraction(skiatest::Reporter* reporter) { |
877 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; | 877 static const int kWidth = 100; |
878 | 878 static const int kHeight = 100; |
879 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { | 879 |
880 continue; | 880 // Create complex paint that the bounding box computation code can't |
| 881 // optimize away |
| 882 SkScalar blueToRedMatrix[20] = { 0 }; |
| 883 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1; |
| 884 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueToRedM
atrix)); |
| 885 SkAutoTUnref<SkImageFilter> filter(SkColorFilterImageFilter::Create(blueToRe
d.get())); |
| 886 |
| 887 SkPaint complexPaint; |
| 888 complexPaint.setImageFilter(filter); |
| 889 |
| 890 SkAutoTUnref<SkPicture> pict, child; |
| 891 SkRTreeFactory bbhFactory; |
| 892 |
| 893 { |
| 894 SkPictureRecorder recorder; |
| 895 |
| 896 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScal
ar(kHeight), |
| 897 &bbhFactory, |
| 898 SkPictureRecorder::kComputeSaveLay
erInfo_RecordFlag); |
| 899 |
| 900 c->saveLayer(NULL, &complexPaint); |
| 901 c->restore(); |
| 902 |
| 903 child.reset(recorder.endRecording()); |
| 904 } |
| 905 |
| 906 // create a picture with the structure: |
| 907 // 1) |
| 908 // SaveLayer |
| 909 // Restore |
| 910 // 2) |
| 911 // SaveLayer |
| 912 // Translate |
| 913 // SaveLayer w/ bound |
| 914 // Restore |
| 915 // Restore |
| 916 // 3) |
| 917 // SaveLayer w/ copyable paint |
| 918 // Restore |
| 919 // 4) |
| 920 // SaveLayer |
| 921 // DrawPicture (which has a SaveLayer/Restore pair) |
| 922 // Restore |
| 923 // 5) |
| 924 // SaveLayer |
| 925 // DrawPicture with Matrix & Paint (with SaveLayer/Restore pair) |
| 926 // Restore |
| 927 { |
| 928 SkPictureRecorder recorder; |
| 929 |
| 930 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), |
| 931 SkIntToScalar(kHeight), |
| 932 &bbhFactory, |
| 933 SkPictureRecorder::kComputeSaveLay
erInfo_RecordFlag); |
| 934 // 1) |
| 935 c->saveLayer(NULL, &complexPaint); // layer #0 |
| 936 c->restore(); |
| 937 |
| 938 // 2) |
| 939 c->saveLayer(NULL, NULL); // layer #1 |
| 940 c->translate(kWidth/2.0f, kHeight/2.0f); |
| 941 SkRect r = SkRect::MakeXYWH(0, 0, kWidth/2, kHeight/2); |
| 942 c->saveLayer(&r, &complexPaint); // layer #2 |
| 943 c->restore(); |
| 944 c->restore(); |
| 945 |
| 946 // 3) |
| 947 { |
| 948 c->saveLayer(NULL, &complexPaint); // layer #3 |
| 949 c->restore(); |
881 } | 950 } |
882 | 951 |
883 GrContext* context = factory->get(glCtxType); | 952 SkPaint layerPaint; |
884 | 953 layerPaint.setColor(SK_ColorRED); // Non-alpha only to avoid SaveLayerD
rawRestoreNooper |
885 if (NULL == context) { | 954 // 4) |
886 continue; | 955 { |
| 956 c->saveLayer(NULL, &layerPaint); // layer #4 |
| 957 c->drawPicture(child); // layer #5 inside picture |
| 958 c->restore(); |
887 } | 959 } |
888 | 960 // 5 |
889 static const int kWidth = 100; | |
890 static const int kHeight = 100; | |
891 | |
892 // Create complex paint that the bounding box computation code can't | |
893 // optimize away | |
894 SkScalar blueToRedMatrix[20] = { 0 }; | |
895 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1; | |
896 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueTo
RedMatrix)); | |
897 SkAutoTUnref<SkImageFilter> filter(SkColorFilterImageFilter::Create(blue
ToRed.get())); | |
898 | |
899 SkPaint complexPaint; | |
900 complexPaint.setImageFilter(filter); | |
901 | |
902 SkAutoTUnref<SkPicture> pict, child; | |
903 SkRTreeFactory bbhFactory; | |
904 | |
905 { | 961 { |
906 SkPictureRecorder recorder; | 962 SkPaint picturePaint; |
907 | 963 SkMatrix trans; |
908 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), SkIntTo
Scalar(kHeight), | 964 trans.setTranslate(10, 10); |
909 &bbhFactory, | 965 |
910 SkPictureRecorder::kComputeSav
eLayerInfo_RecordFlag); | 966 c->saveLayer(NULL, &layerPaint); // layer #6 |
911 | 967 c->drawPicture(child, &trans, &picturePaint); // layer #7 inside
picture |
912 c->saveLayer(NULL, &complexPaint); | 968 c->restore(); |
913 c->restore(); | |
914 | |
915 child.reset(recorder.endRecording()); | |
916 } | 969 } |
917 | 970 |
918 // create a picture with the structure: | 971 pict.reset(recorder.endRecording()); |
919 // 1) | 972 } |
920 // SaveLayer | 973 |
921 // Restore | 974 // Now test out the SaveLayer extraction |
922 // 2) | 975 { |
923 // SaveLayer | 976 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); |
924 // Translate | 977 |
925 // SaveLayer w/ bound | 978 const SkPicture::AccelData* data = pict->EXPERIMENTAL_getAccelData(key); |
926 // Restore | 979 REPORTER_ASSERT(reporter, data); |
927 // Restore | 980 |
928 // 3) | 981 const SkLayerInfo *gpuData = static_cast<const SkLayerInfo*>(data); |
929 // SaveLayer w/ copyable paint | 982 REPORTER_ASSERT(reporter, 8 == gpuData->numBlocks()); |
930 // Restore | 983 |
931 // 4) | 984 const SkLayerInfo::BlockInfo& info0 = gpuData->block(0); |
932 // SaveLayer | 985 // The parent/child layers appear in reverse order |
933 // DrawPicture (which has a SaveLayer/Restore pair) | 986 const SkLayerInfo::BlockInfo& info1 = gpuData->block(2); |
934 // Restore | 987 const SkLayerInfo::BlockInfo& info2 = gpuData->block(1); |
935 // 5) | 988 |
936 // SaveLayer | 989 const SkLayerInfo::BlockInfo& info3 = gpuData->block(3); |
937 // DrawPicture with Matrix & Paint (with SaveLayer/Restore pair
) | 990 |
938 // Restore | 991 // The parent/child layers appear in reverse order |
939 { | 992 const SkLayerInfo::BlockInfo& info4 = gpuData->block(5); |
940 SkPictureRecorder recorder; | 993 const SkLayerInfo::BlockInfo& info5 = gpuData->block(4); |
941 | 994 |
942 SkCanvas* c = recorder.beginRecording(SkIntToScalar(kWidth), | 995 // The parent/child layers appear in reverse order |
943 SkIntToScalar(kHeight), | 996 const SkLayerInfo::BlockInfo& info6 = gpuData->block(7); |
944 &bbhFactory, | 997 const SkLayerInfo::BlockInfo& info7 = gpuData->block(6); |
945 SkPictureRecorder::kComputeSav
eLayerInfo_RecordFlag); | 998 |
946 // 1) | 999 REPORTER_ASSERT(reporter, NULL == info0.fPicture); |
947 c->saveLayer(NULL, &complexPaint); // layer #0 | 1000 REPORTER_ASSERT(reporter, kWidth == info0.fBounds.width() && |
948 c->restore(); | 1001 kHeight == info0.fBounds.height()); |
949 | 1002 REPORTER_ASSERT(reporter, info0.fLocalMat.isIdentity()); |
950 // 2) | 1003 REPORTER_ASSERT(reporter, info0.fPreMat.isIdentity()); |
951 c->saveLayer(NULL, NULL); // layer #1 | 1004 REPORTER_ASSERT(reporter, 0 == info0.fBounds.fLeft && 0 == info0.fBounds
.fTop); |
952 c->translate(kWidth/2.0f, kHeight/2.0f); | 1005 REPORTER_ASSERT(reporter, NULL != info0.fPaint); |
953 SkRect r = SkRect::MakeXYWH(0, 0, kWidth/2, kHeight/2); | 1006 REPORTER_ASSERT(reporter, !info0.fIsNested && !info0.fHasNestedLayers); |
954 c->saveLayer(&r, &complexPaint); // layer #2 | 1007 |
955 c->restore(); | 1008 REPORTER_ASSERT(reporter, NULL == info1.fPicture); |
956 c->restore(); | 1009 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.width() && |
957 | 1010 kHeight/2.0 == info1.fBounds.height()); |
958 // 3) | 1011 REPORTER_ASSERT(reporter, info1.fLocalMat.isIdentity()); |
959 { | 1012 REPORTER_ASSERT(reporter, info1.fPreMat.isIdentity()); |
960 c->saveLayer(NULL, &complexPaint); // layer #3 | 1013 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.fLeft && |
961 c->restore(); | 1014 kHeight/2.0 == info1.fBounds.fTop); |
962 } | 1015 REPORTER_ASSERT(reporter, NULL == info1.fPaint); |
963 | 1016 REPORTER_ASSERT(reporter, !info1.fIsNested && |
964 SkPaint layerPaint; | 1017 info1.fHasNestedLayers); // has a nested SL |
965 layerPaint.setColor(SK_ColorRED); // Non-alpha only to avoid SaveLa
yerDrawRestoreNooper | 1018 |
966 // 4) | 1019 REPORTER_ASSERT(reporter, NULL == info2.fPicture); |
967 { | 1020 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.width() && |
968 c->saveLayer(NULL, &layerPaint); // layer #4 | 1021 kHeight / 2 == info2.fBounds.height()); // bou
nd reduces size |
969 c->drawPicture(child); // layer #5 inside picture | 1022 REPORTER_ASSERT(reporter, !info2.fLocalMat.isIdentity()); |
970 c->restore(); | 1023 REPORTER_ASSERT(reporter, info2.fPreMat.isIdentity()); |
971 } | 1024 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.fLeft && // tran
slated |
972 // 5 | 1025 kHeight / 2 == info2.fBounds.fTop); |
973 { | 1026 REPORTER_ASSERT(reporter, NULL != info2.fPaint); |
974 SkPaint picturePaint; | 1027 REPORTER_ASSERT(reporter, info2.fIsNested && !info2.fHasNestedLayers); /
/ is nested |
975 SkMatrix trans; | 1028 |
976 trans.setTranslate(10, 10); | 1029 REPORTER_ASSERT(reporter, NULL == info3.fPicture); |
977 | 1030 REPORTER_ASSERT(reporter, kWidth == info3.fBounds.width() && |
978 c->saveLayer(NULL, &layerPaint); // layer #6 | 1031 kHeight == info3.fBounds.height()); |
979 c->drawPicture(child, &trans, &picturePaint); // layer #7 in
side picture | 1032 REPORTER_ASSERT(reporter, info3.fLocalMat.isIdentity()); |
980 c->restore(); | 1033 REPORTER_ASSERT(reporter, info3.fPreMat.isIdentity()); |
981 } | 1034 REPORTER_ASSERT(reporter, 0 == info3.fBounds.fLeft && 0 == info3.fBounds
.fTop); |
982 | 1035 REPORTER_ASSERT(reporter, info3.fPaint); |
983 pict.reset(recorder.endRecording()); | 1036 REPORTER_ASSERT(reporter, !info3.fIsNested && !info3.fHasNestedLayers); |
984 } | 1037 |
985 | 1038 REPORTER_ASSERT(reporter, NULL == info4.fPicture); |
986 // Now test out the SaveLayer extraction | 1039 REPORTER_ASSERT(reporter, kWidth == info4.fBounds.width() && |
987 { | 1040 kHeight == info4.fBounds.height()); |
988 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); | 1041 REPORTER_ASSERT(reporter, 0 == info4.fBounds.fLeft && 0 == info4.fBounds
.fTop); |
989 | 1042 REPORTER_ASSERT(reporter, info4.fLocalMat.isIdentity()); |
990 const SkPicture::AccelData* data = pict->EXPERIMENTAL_getAccelData(k
ey); | 1043 REPORTER_ASSERT(reporter, info4.fPreMat.isIdentity()); |
991 REPORTER_ASSERT(reporter, data); | 1044 REPORTER_ASSERT(reporter, info4.fPaint); |
992 | 1045 REPORTER_ASSERT(reporter, !info4.fIsNested && |
993 const GrAccelData *gpuData = static_cast<const GrAccelData*>(data); | 1046 info4.fHasNestedLayers); // has a nested SL |
994 REPORTER_ASSERT(reporter, 8 == gpuData->numSaveLayers()); | 1047 |
995 | 1048 REPORTER_ASSERT(reporter, child == info5.fPicture); // in a child pictur
e |
996 const GrAccelData::SaveLayerInfo& info0 = gpuData->saveLayerInfo(0); | 1049 REPORTER_ASSERT(reporter, kWidth == info5.fBounds.width() && |
997 // The parent/child layers appear in reverse order | 1050 kHeight == info5.fBounds.height()); |
998 const GrAccelData::SaveLayerInfo& info1 = gpuData->saveLayerInfo(2); | 1051 REPORTER_ASSERT(reporter, 0 == info5.fBounds.fLeft && 0 == info5.fBounds
.fTop); |
999 const GrAccelData::SaveLayerInfo& info2 = gpuData->saveLayerInfo(1); | 1052 REPORTER_ASSERT(reporter, info5.fLocalMat.isIdentity()); |
1000 | 1053 REPORTER_ASSERT(reporter, info5.fPreMat.isIdentity()); |
1001 const GrAccelData::SaveLayerInfo& info3 = gpuData->saveLayerInfo(3); | 1054 REPORTER_ASSERT(reporter, NULL != info5.fPaint); |
1002 | 1055 REPORTER_ASSERT(reporter, info5.fIsNested && !info5.fHasNestedLayers); /
/ is nested |
1003 // The parent/child layers appear in reverse order | 1056 |
1004 const GrAccelData::SaveLayerInfo& info4 = gpuData->saveLayerInfo(5); | 1057 REPORTER_ASSERT(reporter, NULL == info6.fPicture); |
1005 const GrAccelData::SaveLayerInfo& info5 = gpuData->saveLayerInfo(4); | 1058 REPORTER_ASSERT(reporter, kWidth-10 == info6.fBounds.width() && |
1006 | 1059 kHeight-10 == info6.fBounds.height()); |
1007 // The parent/child layers appear in reverse order | 1060 REPORTER_ASSERT(reporter, 10 == info6.fBounds.fLeft && 10 == info6.fBoun
ds.fTop); |
1008 const GrAccelData::SaveLayerInfo& info6 = gpuData->saveLayerInfo(7); | 1061 REPORTER_ASSERT(reporter, info6.fLocalMat.isIdentity()); |
1009 const GrAccelData::SaveLayerInfo& info7 = gpuData->saveLayerInfo(6); | 1062 REPORTER_ASSERT(reporter, info6.fPreMat.isIdentity()); |
1010 | 1063 REPORTER_ASSERT(reporter, info6.fPaint); |
1011 REPORTER_ASSERT(reporter, NULL == info0.fPicture); | 1064 REPORTER_ASSERT(reporter, !info6.fIsNested && |
1012 REPORTER_ASSERT(reporter, kWidth == info0.fBounds.width() && | 1065 info6.fHasNestedLayers); // has a nested SL |
1013 kHeight == info0.fBounds.height()); | 1066 |
1014 REPORTER_ASSERT(reporter, info0.fLocalMat.isIdentity()); | 1067 REPORTER_ASSERT(reporter, child == info7.fPicture); // in a child pictur
e |
1015 REPORTER_ASSERT(reporter, info0.fPreMat.isIdentity()); | 1068 REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() && |
1016 REPORTER_ASSERT(reporter, 0 == info0.fBounds.fLeft && 0 == info0.fBo
unds.fTop); | 1069 kHeight == info7.fBounds.height()); |
1017 REPORTER_ASSERT(reporter, NULL != info0.fPaint); | 1070 REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds
.fTop); |
1018 REPORTER_ASSERT(reporter, !info0.fIsNested && !info0.fHasNestedLayer
s); | 1071 REPORTER_ASSERT(reporter, info7.fLocalMat.isIdentity()); |
1019 | 1072 REPORTER_ASSERT(reporter, info7.fPreMat.isIdentity()); |
1020 REPORTER_ASSERT(reporter, NULL == info1.fPicture); | 1073 REPORTER_ASSERT(reporter, NULL != info7.fPaint); |
1021 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.width() && | 1074 REPORTER_ASSERT(reporter, info7.fIsNested && !info7.fHasNestedLayers); /
/ is nested |
1022 kHeight/2.0 == info1.fBounds.height()); | |
1023 REPORTER_ASSERT(reporter, info1.fLocalMat.isIdentity()); | |
1024 REPORTER_ASSERT(reporter, info1.fPreMat.isIdentity()); | |
1025 REPORTER_ASSERT(reporter, kWidth/2.0 == info1.fBounds.fLeft && | |
1026 kHeight/2.0 == info1.fBounds.fTop); | |
1027 REPORTER_ASSERT(reporter, NULL == info1.fPaint); | |
1028 REPORTER_ASSERT(reporter, !info1.fIsNested && | |
1029 info1.fHasNestedLayers); // has a nested S
L | |
1030 | |
1031 REPORTER_ASSERT(reporter, NULL == info2.fPicture); | |
1032 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.width() && | |
1033 kHeight / 2 == info2.fBounds.height()); //
bound reduces size | |
1034 REPORTER_ASSERT(reporter, !info2.fLocalMat.isIdentity()); | |
1035 REPORTER_ASSERT(reporter, info2.fPreMat.isIdentity()); | |
1036 REPORTER_ASSERT(reporter, kWidth / 2 == info2.fBounds.fLeft && //
translated | |
1037 kHeight / 2 == info2.fBounds.fTop); | |
1038 REPORTER_ASSERT(reporter, NULL != info2.fPaint); | |
1039 REPORTER_ASSERT(reporter, info2.fIsNested && !info2.fHasNestedLayers
); // is nested | |
1040 | |
1041 REPORTER_ASSERT(reporter, NULL == info3.fPicture); | |
1042 REPORTER_ASSERT(reporter, kWidth == info3.fBounds.width() && | |
1043 kHeight == info3.fBounds.height()); | |
1044 REPORTER_ASSERT(reporter, info3.fLocalMat.isIdentity()); | |
1045 REPORTER_ASSERT(reporter, info3.fPreMat.isIdentity()); | |
1046 REPORTER_ASSERT(reporter, 0 == info3.fBounds.fLeft && 0 == info3.fBo
unds.fTop); | |
1047 REPORTER_ASSERT(reporter, info3.fPaint); | |
1048 REPORTER_ASSERT(reporter, !info3.fIsNested && !info3.fHasNestedLayer
s); | |
1049 | |
1050 REPORTER_ASSERT(reporter, NULL == info4.fPicture); | |
1051 REPORTER_ASSERT(reporter, kWidth == info4.fBounds.width() && | |
1052 kHeight == info4.fBounds.height()); | |
1053 REPORTER_ASSERT(reporter, 0 == info4.fBounds.fLeft && 0 == info4.fBo
unds.fTop); | |
1054 REPORTER_ASSERT(reporter, info4.fLocalMat.isIdentity()); | |
1055 REPORTER_ASSERT(reporter, info4.fPreMat.isIdentity()); | |
1056 REPORTER_ASSERT(reporter, info4.fPaint); | |
1057 REPORTER_ASSERT(reporter, !info4.fIsNested && | |
1058 info4.fHasNestedLayers); // has a nested S
L | |
1059 | |
1060 REPORTER_ASSERT(reporter, child == info5.fPicture); // in a child pi
cture | |
1061 REPORTER_ASSERT(reporter, kWidth == info5.fBounds.width() && | |
1062 kHeight == info5.fBounds.height()); | |
1063 REPORTER_ASSERT(reporter, 0 == info5.fBounds.fLeft && 0 == info5.fBo
unds.fTop); | |
1064 REPORTER_ASSERT(reporter, info5.fLocalMat.isIdentity()); | |
1065 REPORTER_ASSERT(reporter, info5.fPreMat.isIdentity()); | |
1066 REPORTER_ASSERT(reporter, NULL != info5.fPaint); | |
1067 REPORTER_ASSERT(reporter, info5.fIsNested && !info5.fHasNestedLayers
); // is nested | |
1068 | |
1069 REPORTER_ASSERT(reporter, NULL == info6.fPicture); | |
1070 REPORTER_ASSERT(reporter, kWidth-10 == info6.fBounds.width() && | |
1071 kHeight-10 == info6.fBounds.height()); | |
1072 REPORTER_ASSERT(reporter, 10 == info6.fBounds.fLeft && 10 == info6.f
Bounds.fTop); | |
1073 REPORTER_ASSERT(reporter, info6.fLocalMat.isIdentity()); | |
1074 REPORTER_ASSERT(reporter, info6.fPreMat.isIdentity()); | |
1075 REPORTER_ASSERT(reporter, info6.fPaint); | |
1076 REPORTER_ASSERT(reporter, !info6.fIsNested && | |
1077 info6.fHasNestedLayers); // has a nested S
L | |
1078 | |
1079 REPORTER_ASSERT(reporter, child == info7.fPicture); // in a child pi
cture | |
1080 REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() && | |
1081 kHeight == info7.fBounds.height()); | |
1082 REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBo
unds.fTop); | |
1083 REPORTER_ASSERT(reporter, info7.fLocalMat.isIdentity()); | |
1084 REPORTER_ASSERT(reporter, info7.fPreMat.isIdentity()); | |
1085 REPORTER_ASSERT(reporter, NULL != info7.fPaint); | |
1086 REPORTER_ASSERT(reporter, info7.fIsNested && !info7.fHasNestedLayers
); // is nested | |
1087 } | |
1088 } | 1075 } |
1089 } | 1076 } |
1090 | 1077 |
1091 #endif | |
1092 | |
1093 static void test_has_text(skiatest::Reporter* reporter) { | 1078 static void test_has_text(skiatest::Reporter* reporter) { |
1094 SkPictureRecorder recorder; | 1079 SkPictureRecorder recorder; |
1095 | 1080 |
1096 SkCanvas* canvas = recorder.beginRecording(100,100); | 1081 SkCanvas* canvas = recorder.beginRecording(100,100); |
1097 { | 1082 { |
1098 canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint()); | 1083 canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint()); |
1099 } | 1084 } |
1100 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 1085 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
1101 REPORTER_ASSERT(reporter, !picture->hasText()); | 1086 REPORTER_ASSERT(reporter, !picture->hasText()); |
1102 | 1087 |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 #endif | 1735 #endif |
1751 test_has_text(reporter); | 1736 test_has_text(reporter); |
1752 test_analysis(reporter); | 1737 test_analysis(reporter); |
1753 test_gatherpixelrefs(reporter); | 1738 test_gatherpixelrefs(reporter); |
1754 test_gatherpixelrefsandrects(reporter); | 1739 test_gatherpixelrefsandrects(reporter); |
1755 test_bitmap_with_encoded_data(reporter); | 1740 test_bitmap_with_encoded_data(reporter); |
1756 test_clip_bound_opt(reporter); | 1741 test_clip_bound_opt(reporter); |
1757 test_clip_expansion(reporter); | 1742 test_clip_expansion(reporter); |
1758 test_hierarchical(reporter); | 1743 test_hierarchical(reporter); |
1759 test_gen_id(reporter); | 1744 test_gen_id(reporter); |
| 1745 test_savelayer_extraction(reporter); |
1760 } | 1746 } |
1761 | 1747 |
1762 #if SK_SUPPORT_GPU | |
1763 DEF_GPUTEST(GPUPicture, reporter, factory) { | |
1764 test_gpu_picture_optimization(reporter, factory); | |
1765 } | |
1766 #endif | |
1767 | |
1768 static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { | 1748 static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { |
1769 const SkPaint paint; | 1749 const SkPaint paint; |
1770 const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f }; | 1750 const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f }; |
1771 const SkIRect irect = { 2, 2, 3, 3 }; | 1751 const SkIRect irect = { 2, 2, 3, 3 }; |
1772 | 1752 |
1773 // Don't care what these record, as long as they're legal. | 1753 // Don't care what these record, as long as they're legal. |
1774 canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint); | 1754 canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint); |
1775 canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_Dr
awBitmapRectFlag); | 1755 canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_Dr
awBitmapRectFlag); |
1776 canvas->drawBitmapMatrix(bitmap, SkMatrix::I(), &paint); | 1756 canvas->drawBitmapMatrix(bitmap, SkMatrix::I(), &paint); |
1777 canvas->drawBitmapNine(bitmap, irect, rect, &paint); | 1757 canvas->drawBitmapNine(bitmap, irect, rect, &paint); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 | 1887 |
1908 // The picture shares the immutable pixels but copies the mutable ones. | 1888 // The picture shares the immutable pixels but copies the mutable ones. |
1909 REPORTER_ASSERT(r, mut.pixelRef()->unique()); | 1889 REPORTER_ASSERT(r, mut.pixelRef()->unique()); |
1910 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); | 1890 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); |
1911 | 1891 |
1912 // When the picture goes away, it's just our bitmaps holding the refs. | 1892 // When the picture goes away, it's just our bitmaps holding the refs. |
1913 pic.reset(NULL); | 1893 pic.reset(NULL); |
1914 REPORTER_ASSERT(r, mut.pixelRef()->unique()); | 1894 REPORTER_ASSERT(r, mut.pixelRef()->unique()); |
1915 REPORTER_ASSERT(r, immut.pixelRef()->unique()); | 1895 REPORTER_ASSERT(r, immut.pixelRef()->unique()); |
1916 } | 1896 } |
OLD | NEW |