Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 272153002: fix bugs found by computing flat clips in 800K skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix maybe-uninitialized error in unbuntu Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsSkpTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 #include "SkBitmap.h" 2 #include "SkBitmap.h"
3 #include "SkCanvas.h" 3 #include "SkCanvas.h"
4 #include "SkColor.h" 4 #include "SkColor.h"
5 #include "SkColorPriv.h" 5 #include "SkColorPriv.h"
6 #include "SkDevice.h" 6 #include "SkDevice.h"
7 #include "SkGraphics.h" 7 #include "SkGraphics.h"
8 #include "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
9 #include "SkImageEncoder.h" 9 #include "SkImageEncoder.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
11 #include "SkPathOpsDebug.h" 11 #include "SkPathOpsDebug.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkRTConf.h" 13 #include "SkRTConf.h"
14 #include "SkTSort.h" 14 #include "SkTSort.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "SkString.h" 16 #include "SkString.h"
17 #include "SkTArray.h" 17 #include "SkTArray.h"
18 #include "SkTDArray.h" 18 #include "SkTDArray.h"
19 #include "SkThreadPool.h" 19 #include "SkThreadPool.h"
20 #include "SkTime.h" 20 #include "SkTime.h"
21 #include "Test.h" 21 #include "Test.h"
22 22
23 #ifdef SK_BUILD_FOR_WIN 23 #ifdef SK_BUILD_FOR_WIN
24 #define PATH_SLASH "\\" 24 #define PATH_SLASH "\\"
25 #define IN_DIR "D:\\skp\\slave" 25 #define IN_DIR "D:\\skp\\slave"
26 #define OUT_DIR "D:\\skpOut\\1\\" 26 #define OUT_DIR "D:\\skpOut\\1\\"
27 #else 27 #else
28 #define PATH_SLASH "/" 28 #define PATH_SLASH "/"
29 #define IN_DIR "/skp/2311328-7fc2228/slave" 29 #define IN_DIR "/skp/2311328-7fc2228/slave"
30 #define OUT_DIR "/skpOut/2/" 30 #define OUT_DIR "/skpOut/4/"
31 #endif 31 #endif
32 32
33 const struct { 33 const struct {
34 int directory; 34 int directory;
35 const char* filename; 35 const char* filename;
36 } skipOverSept[] = { 36 } skipOverSept[] = {
37 { 9, "http___www_catingueiraonline_com_.skp"}, // infinite loop 37 { 3, "http___www_americascup_com_.skp"}, // !simple->closed()
38 {13, "http___www_galaxystwo_com_.skp"}, // infinite loop
39 {15, "http___www_giffingtool_com_.skp"}, // joinCoincidence / findT / asser t
40 {15, "http___www_thaienews_blogspot_com_.skp"}, // infinite loop
41 {17, "http___www_gruposejaumdivulgador_com_br_.skp"}, // calcCoincidentWindi ng asserts zeroSpan
42 {18, "http___www_argus_presse_fr_.skp"}, // can't find winding of remaining vertical edge 38 {18, "http___www_argus_presse_fr_.skp"}, // can't find winding of remaining vertical edge
43 {21, "http___www_fashionscandal_com_.skp"}, // infinite loop 39 {31, "http___www_narayana_verlag_de_.skp"}, // !simple->closed()
44 {21, "http___www_kenlevine_blogspot_com_.skp"}, // infinite loop 40 {36, "http___www_educationalcraft_com_.skp"}, // cubic / cubic near end / a ssert in SkIntersections::insert
45 {25, "http___www_defense_studies_blogspot_com_.skp"}, // infinite loop
46 {27, "http___www_brokeroutpost_com_.skp"}, // suspect infinite loop
47 {28, "http___www_jaimebatistadasilva_blogspot_com_br_.skp"}, // suspect inf inite loop
48 {28, "http___www_odia_com_br_.skp"}, // !simple->isClosed()
49 {29, "http___www_hubbyscook_com_.skp"}, // joinCoincidence / findT / assert
50 {30, "http___www_spankystokes_com_.skp"}, // suspect infinite loop
51 {32, "http___www_adalbertoday_blogspot_com_br_.skp"}, // suspect infinite l oop
52 {32, "http___www_galery_annisa_com_.skp"}, // suspect infinite loop
53 {33, "http___www_pindosiya_com_.skp"}, // line quad intersection SkIntersec tions::assert
54 {36, "http___www_educationalcraft_com_.skp"}, // cubic / cubic near end / a ssert in SkIntersections::insert (missing skp test)
55 {36, "http___www_shaam_org_.skp"}, // suspect infinite loop
56 {36, "http___www_my_pillow_book_blogspot_gr_.skp"}, // suspect infinite loo p
57 {39, "http___www_opbeat_com_.skp"}, // suspect infinite loop
58 {40, "http___www_phototransferapp_com_.skp"}, // !simple->isClosed()
59 {41, "http___www_freeismylife_com_.skp"}, // suspect infinite loop
60 {41, "http___www_accordidelmomento_com_.skp"}, // suspect infinite loop
61 {41, "http___www_evolvehq_com_.skp"}, // joinCoincidence / findT / assert
62 {44, "http___www_contextualnewsfeeds_com_.skp"}, // !simple->isClosed()
63 {44, "http___www_cooksnaps_com_.skp"}, // !simple->isClosed() 41 {44, "http___www_cooksnaps_com_.skp"}, // !simple->isClosed()
64 {44, "http___www_helha_be_.skp"}, // !simple->isClosed() 42 {48, "http___www_narayana_publishers_com_.skp"}, // !simple->isClosed()
65 {45, "http___www_blondesmakemoney_blogspot_com_.skp"}, // suspect infinite loop 43 {51, "http___www_freedominthe50states_org_.skp"}, // corrupt dash data
66 {46, "http___www_cheaphealthygood_blogspot_com_.skp"}, // suspect infinite loop 44 {52, "http___www_aceinfographics_com_.skp"}, // right angle winding assert
67 {47, "http___www_ajitvadakayil_blogspot_in_.skp"}, // suspect infinite loop
68 {49, "http___www_karnivool_com_au_.skp"}, // SkOpAngle::setSector SkASSERT( fSectorStart >= 0);
69 {49, "http___www_tunero_de_.skp"}, // computeonesumreverse calls markwindin g with 0 winding
70 {49, "http___www_thaienews_blogspot_sg_.skp"}, // suspect infinite loop
71 {50, "http___www_docgelo_com_.skp"}, // rightAngleWinding (probably same as argus_presse)
72 {53, "http___www_lojaanabotafogo_com_br_.skp"}, // rrect validate assert 45 {53, "http___www_lojaanabotafogo_com_br_.skp"}, // rrect validate assert
73 {54, "http___www_odecktestanswer2013_blogspot_in_.skp"}, // suspect infinit e loop 46 {57, "http___www_vantageproduction_com_.skp"}, // !isClosed()
74 {54, "http___www_cleristonsilva_com_br_.skp"}, // suspect infinite loop 47 {64, "http___www_etiqadd_com_.skp"}, // !simple->closed()
75 {56, "http___www_simplysaru_com_.skp"}, // joinCoincidence / findT / assert 48 {84, "http___www_swapspacesystems_com_.skp"}, // !simple->closed()
76 {57, "http___www_koukfamily_blogspot_gr_.skp"}, // suspect infinite loop 49 {90, "http___www_tcmevents_org_.skp"}, // !simple->closed()
77 {57, "http___www_dinar2010_blogspot_com_.skp"}, // suspect infinite loop 50 {96, "http___www_paseoitaigara_com_br_.skp"}, // !simple->closed()
78 {58, "http___www_artblart_com_.skp"}, // rightAngleWinding 51 {98, "http___www_mortgagemarketguide_com_.skp"}, // !simple->closed()
79 {59, "http___www_accrispin_blogspot_com_.skp"}, // suspect infinite loop 52 {99, "http___www_kitcheninspirations_wordpress_com_.skp"}, // checkSmall / bumpSpan
80 {59, "http___www_vicisitudysordidez_blogspot_com_es_.skp"}, // suspect infi nite loop
81 {60, "http___www_thehousingbubbleblog_com_.skp"}, // suspect infinite loop
82 {61, "http___www_jessicaslens_wordpress_com_.skp"}, // joinCoincidence / fi ndT / assert
83 {61, "http___www_partsdata_de_.skp"}, // cubic-cubic intersection reduce ch eckLinear assert
84 {62, "http___www_blondesmakemoney_blogspot_com_au_.skp"}, // suspect infini te loop
85 {62, "http___www_intellibriefs_blogspot_in_.skp"}, // suspect infinite loop
86 {63, "http___www_tankerenemy_com_.skp"}, // suspect infinite loop
87 {65, "http___www_kpopexplorer_net_.skp"}, // joinCoincidence / findT / asse rt
88 {65, "http___www_bestthingsinbeauty_blogspot_com_.skp"}, // suspect infinit e loop
89 {65, "http___www_wartepop_blogspot_com_br_.skp"}, // !simple->isClosed()
90 {65, "http___www_eolake_blogspot_com_.skp"}, // suspect infinite loop
91 {67, "http___www_cacadordemisterio_blogspot_com_br_.skp"}, // suspect infin ite loop
92 {69, "http___www_misnotasyapuntes_blogspot_mx_.skp"}, // suspect infinite l oop
93 {69, "http___www_awalkintheparknyc_blogspot_com_.skp"}, // suspect infinite loop
94 {71, "http___www_lokado_de_.skp"}, // joinCoincidence / findT / assert
95 {72, "http___www_karlosdesanjuan_blogspot_com_.skp"}, // suspect infinite l oop
96 {73, "http___www_cyberlawsinindia_blogspot_in_.skp"}, // suspect infinite l oop
97 {73, "http___www_taxiemmovimento_blogspot_com_br_.skp"}, // suspect infinit e loop
98 {74, "http___www_giveusliberty1776_blogspot_com_.skp"}, // suspect infinite loop
99 {75, "http___www_e_cynical_blogspot_gr_.skp"}, // suspect infinite loop
100 {76, "http___www_seopack_blogspot_com_.skp"}, // SkOpAngle::setSector SkASS ERT(fSectorStart >= 0);
101 {77, "http___www_sunsky_russia_com_.skp"}, // joinCoincidence / findT / ass ert (no op test, already fixed hopefully)
102 {78, "http___www_bisnisonlineinfo_com_.skp"}, // suspect infinite loop
103 {79, "http___www_danielsgroupcpa_com_.skp"}, // joinCoincidence / findT / a ssert (no op test, already fixed hopefully)
104 {80, "http___www_clinique_portugal_com_.skp"}, // suspect infinite loop
105 {81, "http___www_europebusines_blogspot_com_.skp"}, // suspect infinite loo p
106 {82, "http___www_apopsignomi_blogspot_gr_.skp"}, // suspect infinite loop
107 {85, "http___www_ajitvadakayil_blogspot_com_.skp"}, // suspect infinite loo p
108 {86, "http___www_madhousefamilyreviews_blogspot_co_uk_.skp"}, // suspect in finite loop
109 }; 53 };
110 54
55 /* stats
56 97 http___www_brandyandvinca_com_.skp pixelError=3
57 95 http___www_into_asia_com_.skp pixelError=12
58 93 http___www_lunarplanner_com_.skp pixelError=14
59 98 http___www_lovelyitalia_com_.skp pixelError=17
60 90 http___www_inter_partner_blogspot_com_.skp pixelError=18
61 99 http___www_maxarea_com_.skp pixelError=26
62 98 http___www_maroonsnet_org_.skp pixelError=33
63 92 http___www_belinaart_ru_.skp pixelError=50
64 100 http___www_chroot_ro_.skp pixelError=62
65 99 http___www_hsbrands_com_.skp pixelError=98
66 95 http___www_tournamentindicator_com_.skp pixelError=122
67 93 http___www_businesses_com_au_.skp pixelError=162
68 90 http___www_regenesys_net_.skp pixelError=182
69 88 http___www_1863544208148625103_c18eac63985503fa85b06358959c1ba27fc36f82_blogs pot_com_.skp pixelError=186
70 97 http___www_pregacoesevangelica_com_br_.skp pixelError=240
71 77 http___www_zhenggang_org_.skp pixelError=284
72 96 http___slidesharemailer_com_.skp pixelError=522
73 94 http___www_gensteel_com_.skp pixelError=555
74 68 http___www_jf_eti_br_.skp pixelError=610
75 83 http___www_swishiat_com_.skp pixelError=706
76 96 http___www_matusikmissive_com_au_.skp pixelError=2580
77 95 http___www_momentumnation_com_.skp pixelError=3938
78 92 http___www_rssowl_com_.skp pixelError=5113
79 96 http___www_sexxygirl_tv_.skp pixelError=7605
80 99 http___www_georgevalah_wordpress_com_.skp pixelError=8386
81 78 http___www_furbo_org_.skp pixelError=8656
82 78 http___www_djxhemary_wordpress_com_.skp pixelError=8976
83 100 http___www_mindcontrolblackassassins_com_.skp pixelError=31950
84 98 http___bababillgates_free_fr_.skp pixelError=40237
85 98 http___hepatite_ro_.skp pixelError=44370
86 86 http___www_somethingwagging_com_.skp pixelError=47794
87 84 http___www_beverageuniverse_com_.skp pixelError=65450
88 50 http___www_aveksa_com_.skp pixelError=68194
89 10 http___www_publiker_pl_.skp pixelError=89997
90 61 http___www_dominos_co_id_.skp pixelError=476868
91 87 http___www_du_edu_om_.skp time=46
92 87 http___www_bigload_de_.skp time=46
93 100 http___www_home_forum_com_.skp time=48
94 97 http___www_hotamateurchat_com_.skp time=48
95 97 http___www_myrsky_com_cn_.skp time=48
96 98 http___www_techiegeex_com_.skp time=49
97 82 http___www_fashionoutletsofchicago_com_.skp time=50
98 77 http___www_dynamischbureau_nl_.skp time=50
99 82 http___www_mayihelpu_co_in_.skp time=50
100 84 http___www_vbox7_com_user_history_viewers_.skp time=50
101 85 http___www_ktokogda_com_.skp time=50
102 85 http___www_propertyturkeysale_com_.skp time=50
103 85 http___www_51play_com_.skp time=50
104 86 http___www_bayalarm_com_.skp time=50
105 87 http___www_eaglepictures_com_.skp time=50
106 88 http___www_atlasakvaryum_com_.skp time=50
107 91 http___www_pioneerchryslerjeep_com_.skp time=50
108 94 http___www_thepulsemag_com_.skp time=50
109 95 http___www_dcshoes_com_ph_.skp time=50
110 96 http___www_montrealmassage_ca_.skp time=50
111 96 http___www_jkshahclasses_com_.skp time=50
112 96 http___www_webcamconsult_com_.skp time=51
113 100 http___www_bsoscblog_com_.skp time=52
114 95 http___www_flaktwoods_com_.skp time=53
115 91 http___www_qivivo_com_.skp time=54
116 90 http___www_unitender_com_.skp time=56
117 97 http___www_casinogaming_com_.skp time=56
118 97 http___www_rootdownload_com_.skp time=56
119 94 http___www_aspa_ev_de_.skp time=57
120 98 http___www_tenpieknyswiat_pl_.skp time=57
121 93 http___www_transocean_de_.skp time=58
122 94 http___www_vdo2_blogspot_com_.skp time=58
123 94 http___www_asmaissexy_com_br_.skp time=58
124 100 http___www_prefeiturasjm_com_br_.skp time=60
125 100 http___www_eduinsuranceclick_blogspot_com_.skp time=60
126 96 http___www_bobdunsire_com_.skp time=61
127 96 http___www_omgkettlecorn_com_.skp time=61
128 85 http___www_fbbsessions_com_.skp time=62
129 86 http___www_hector_ru_.skp time=62
130 87 http___www_wereldsupporter_nl_.skp time=62
131 90 http___www_arello_com_.skp time=62
132 93 http___www_bayerplastics_com_.skp time=62
133 93 http___www_superandolamovida_com_ar_.skp time=62
134 96 http___www_med_rbf_ru_.skp time=62
135 81 http___www_carnegiescience_edu_.skp time=65
136 87 http___www_asanewengland_com_.skp time=65
137 92 http___www_turkce_karakter_appspot_com_.skp time=65
138 94 http___www_k3a_org_.skp time=65
139 96 http___www_powermaccenter_com_.skp time=65
140 98 http___www_avto49_ru_.skp time=67
141 100 http___www_hetoldeambaecht_nl_.skp time=68
142 95 http___www_marine_ie_.skp time=69
143 96 http___www_quebecvapeboutique_com_.skp time=69
144 95 http___www_brays_ingles_com_.skp time=70
145 100 http___www_lacondesa_com_.skp time=72
146 95 http___www_timbarrathai_com_au_.skp time=76
147 95 http___www_cuissedegrenouille_com_.skp time=76
148 95 http___www_iwama51_ru_.skp time=76
149 99 http___www_fotoantologia_it_.skp time=76
150 92 http___www_indian_architects_com_.skp time=78
151 92 http___www_totalwomanspa_com_.skp time=78
152 100 http___www_fachverband_spielhallen_de_.skp time=83
153 93 http___www_golshanemehr_ir_.skp time=84
154 95 http___www_maryesses_com_.skp time=84
155 99 http___www_ddcorp_ca_.skp time=89
156 90 http___www_brontops_com_.skp time=89
157 94 http___www_robgolding_com_.skp time=89
158 91 http___www_tecban_com_br_.skp time=91
159 98 http___www_costamesakarate_com_.skp time=100
160 95 http___www_monsexyblog_com_.skp time=103
161 97 http___www_stornowaygazette_co_uk_.skp time=103
162 93 http___www_fitforaframe_com_.skp time=104
163 98 http___www_intentionoftheday_com_.skp time=113
164 100 http___www_tailgateclothing_com_.skp time=117
165 95 http___www_senbros_com_.skp time=118
166 93 http___www_lettoblog_com_.skp time=121
167 94 http___www_maxineschallenge_com_au_.skp time=125
168 95 http___www_savvycard_net_.skp time=127
169 95 http___www_open_ac_mu_.skp time=129
170 96 http___www_avgindia_in_.skp time=135
171 97 http___www_stocktonseaview_com_.skp time=135
172 96 http___www_distroller_com_.skp time=142
173 94 http___www_travoggalop_dk_.skp time=144
174 100 http___www_history_im_.skp time=144
175 94 http___www_playradio_sk_.skp time=145
176 92 http___www_linglongglass_com_.skp time=151
177 97 http___www_bizzna_com_.skp time=151
178 96 http___www_spiros_ws_.skp time=154
179 91 http___www_rosen_meents_co_il_.skp time=156
180 81 http___www_hoteldeluxeportland_com_.skp time=158
181 92 http___www_freetennis_org_.skp time=161
182 93 http___www_aircharternetwork_com_au_.skp time=161
183 94 http___www_austinparks_org_.skp time=165
184 89 http___www_bevvy_co_.skp time=168
185 91 http___www_sosyalhile_net_.skp time=168
186 98 http___www_minvih_gob_ve_.skp time=171
187 89 http___www_streetfoodmtl_com_.skp time=172
188 92 http___www_loveslatinas_tumblr_com_.skp time=178
189 93 http___www_madbites_co_in_.skp time=180
190 94 http___www_rocktarah_ir_.skp time=185
191 97 http___www_penthouselife_com_.skp time=185
192 96 http___www_appymonkey_com_.skp time=196
193 92 http___www_pasargadhotels_com_.skp time=203
194 99 http___www_marina_mil_pe_.skp time=203
195 89 http___www_kays_co_uk_.skp time=205
196 77 http___www_334588_com_.skp time=211
197 83 http___www_trendbad24_de_.skp time=211
198 81 http___www_cdnetworks_co_kr_.skp time=216
199 94 http___www_schellgames_com_.skp time=223
200 95 http___www_juliaweddingnews_cn_.skp time=230
201 92 http___www_xcrafters_pl_.skp time=253
202 93 http___www_pondoo_com_.skp time=253
203 96 http___www_helsinkicapitalpartners_fi_.skp time=255
204 88 http___www_nadtexican_com_.skp time=259
205 85 http___www_canstockphoto_hu_.skp time=266
206 78 http___www_ecovacs_com_cn_.skp time=271
207 93 http___www_brookfieldplaceny_com_.skp time=334
208 93 http___www_fmastrengthtraining_com_.skp time=337
209 94 http___www_turtleonthebeach_com_.skp time=394
210 90 http___www_temptationthemovie_com_.skp time=413
211 95 http___www_patongsawaddi_com_.skp time=491
212 91 http___www_online_radio_appspot_com_.skp time=511
213 68 http___www_richardmiller_co_uk_.skp time=528
214 63 http___www_eschrade_com_.skp time=543
215 55 http___www_interaction_inf_br_.skp time=625
216 38 http___www_huskyliners_com_.skp time=632
217 86 http___granda_net_.skp time=1067
218 24 http___www_cocacolafm_com_br_.skp time=1081
219 */
220
111 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]); 221 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]);
112 222
113 enum TestStep { 223 enum TestStep {
114 kCompareBits, 224 kCompareBits,
115 kEncodeFiles, 225 kEncodeFiles,
116 }; 226 };
117 227
118 enum { 228 enum {
119 kMaxLength = 128, 229 kMaxLength = 256,
120 kMaxFiles = 128, 230 kMaxFiles = 128,
121 kSmallLimit = 1000, 231 kSmallLimit = 1000,
122 }; 232 };
123 233
124 struct TestResult { 234 struct TestResult {
125 void init(int dirNo) { 235 void init(int dirNo) {
126 fDirNo = dirNo; 236 fDirNo = dirNo;
127 sk_bzero(fFilename, sizeof(fFilename)); 237 sk_bzero(fFilename, sizeof(fFilename));
128 fTestStep = kCompareBits; 238 fTestStep = kCompareBits;
129 fScale = 1; 239 fScale = 1;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 293 }
184 }; 294 };
185 295
186 class SortByTime : public TestResult { 296 class SortByTime : public TestResult {
187 public: 297 public:
188 bool operator<(const SortByTime& rh) const { 298 bool operator<(const SortByTime& rh) const {
189 return fTime < rh.fTime; 299 return fTime < rh.fTime;
190 } 300 }
191 }; 301 };
192 302
303 class SortByName : public TestResult {
304 public:
305 bool operator<(const SortByName& rh) const {
306 return strcmp(fFilename, rh.fFilename) < 0;
307 }
308 };
309
193 struct TestState { 310 struct TestState {
194 void init(int dirNo, skiatest::Reporter* reporter) { 311 void init(int dirNo, skiatest::Reporter* reporter) {
195 fReporter = reporter; 312 fReporter = reporter;
196 fResult.init(dirNo); 313 fResult.init(dirNo);
197 } 314 }
198 315
199 SkTDArray<SortByPixel> fPixelWorst; 316 SkTDArray<SortByPixel> fPixelWorst;
200 SkTDArray<SortByTime> fSlowest; 317 SkTDArray<SortByTime> fSlowest;
201 skiatest::Reporter* fReporter; 318 skiatest::Reporter* fReporter;
202 TestResult fResult; 319 TestResult fResult;
203 }; 320 };
204 321
205 struct TestRunner { 322 struct TestRunner {
206 TestRunner(skiatest::Reporter* reporter, int threadCount) 323 TestRunner(skiatest::Reporter* reporter, int threadCount)
207 : fNumThreads(threadCount) 324 : fNumThreads(threadCount)
208 , fReporter(reporter) { 325 , fReporter(reporter) {
209 } 326 }
210 327
211 ~TestRunner(); 328 ~TestRunner();
212 void render(); 329 void render();
213 int fNumThreads; 330 int fNumThreads;
214 SkTDArray<class TestRunnable*> fRunnables; 331 SkTDArray<class TestRunnable*> fRunnables;
215 skiatest::Reporter* fReporter; 332 skiatest::Reporter* fReporter;
216 }; 333 };
217 334
218 class TestRunnable : public SkRunnable { 335 class TestRunnable : public SkRunnable {
219 public: 336 public:
220 TestRunnable(void (*testFun)(TestState*), int dirNo, TestRunner* runner) {
221 fState.init(dirNo, runner->fReporter);
222 fTestFun = testFun;
223 }
224
225 virtual void run() SK_OVERRIDE { 337 virtual void run() SK_OVERRIDE {
226 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); 338 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
227 (*fTestFun)(&fState); 339 (*fTestFun)(&fState);
228 } 340 }
229 341
230 TestState fState; 342 TestState fState;
231 void (*fTestFun)(TestState*); 343 void (*fTestFun)(TestState*);
232 }; 344 };
233 345
346
347 class TestRunnableDir : public TestRunnable {
348 public:
349 TestRunnableDir(void (*testFun)(TestState*), int dirNo, TestRunner* runner) {
350 fState.init(dirNo, runner->fReporter);
351 fTestFun = testFun;
352 }
353
354 };
355
356 class TestRunnableFile : public TestRunnable {
357 public:
358 TestRunnableFile(void (*testFun)(TestState*), int dirNo, const char* name, T estRunner* runner) {
359 fState.init(dirNo, runner->fReporter);
360 strcpy(fState.fResult.fFilename, name);
361 fTestFun = testFun;
362 }
363 };
364
365 class TestRunnableEncode : public TestRunnableFile {
366 public:
367 TestRunnableEncode(void (*testFun)(TestState*), int dirNo, const char* name, TestRunner* runner)
368 : TestRunnableFile(testFun, dirNo, name, runner) {
369 fState.fResult.fTestStep = kEncodeFiles;
370 }
371 };
372
234 TestRunner::~TestRunner() { 373 TestRunner::~TestRunner() {
235 for (int index = 0; index < fRunnables.count(); index++) { 374 for (int index = 0; index < fRunnables.count(); index++) {
236 SkDELETE(fRunnables[index]); 375 SkDELETE(fRunnables[index]);
237 } 376 }
238 } 377 }
239 378
240 void TestRunner::render() { 379 void TestRunner::render() {
241 SkThreadPool pool(fNumThreads); 380 SkThreadPool pool(fNumThreads);
242 for (int index = 0; index < fRunnables.count(); ++ index) { 381 for (int index = 0; index < fRunnables.count(); ++ index) {
243 pool.add(fRunnables[index]); 382 pool.add(fRunnables[index]);
(...skipping 21 matching lines...) Expand all
265 static SkString make_in_dir_name(int dirNo) { 404 static SkString make_in_dir_name(int dirNo) {
266 SkString dirName(IN_DIR); 405 SkString dirName(IN_DIR);
267 dirName.appendf("%d", dirNo); 406 dirName.appendf("%d", dirNo);
268 if (!sk_exists(dirName.c_str())) { 407 if (!sk_exists(dirName.c_str())) {
269 SkDebugf("could not read dir %s\n", dirName.c_str()); 408 SkDebugf("could not read dir %s\n", dirName.c_str());
270 return SkString(); 409 return SkString();
271 } 410 }
272 return dirName; 411 return dirName;
273 } 412 }
274 413
414 static SkString make_stat_dir_name(int dirNo) {
415 SkString dirName(outStatusDir);
416 dirName.appendf("%d", dirNo);
417 if (!sk_exists(dirName.c_str())) {
418 SkDebugf("could not read dir %s\n", dirName.c_str());
419 return SkString();
420 }
421 return dirName;
422 }
423
275 static bool make_one_out_dir(const char* outDirStr) { 424 static bool make_one_out_dir(const char* outDirStr) {
276 SkString outDir = make_filepath(0, outDirStr, ""); 425 SkString outDir = make_filepath(0, outDirStr, "");
277 if (!sk_exists(outDir.c_str())) { 426 if (!sk_exists(outDir.c_str())) {
278 if (!sk_mkdir(outDir.c_str())) { 427 if (!sk_mkdir(outDir.c_str())) {
279 SkDebugf("could not create dir %s\n", outDir.c_str()); 428 SkDebugf("could not create dir %s\n", outDir.c_str());
280 return false; 429 return false;
281 } 430 }
282 } 431 }
283 return true; 432 return true;
284 } 433 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 } 817 }
669 818
670 static bool initTest() { 819 static bool initTest() {
671 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC 820 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC
672 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); 821 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true);
673 SK_CONF_SET("images.png.suppressDecoderWarnings", true); 822 SK_CONF_SET("images.png.suppressDecoderWarnings", true);
674 #endif 823 #endif
675 return make_out_dirs(); 824 return make_out_dirs();
676 } 825 }
677 826
827 static bool initUberTest(int firstDirNo, int lastDirNo) {
828 if (!initTest()) {
829 return false;
830 }
831 for (int index = firstDirNo; index <= lastDirNo; ++index) {
832 SkString statusDir(outStatusDir);
833 statusDir.appendf("%d", index);
834 if (!make_one_out_dir(statusDir.c_str())) {
835 return false;
836 }
837 }
838 return true;
839 }
840
841
842 static void testSkpClipEncode(TestState* data) {
843 data->fResult.testOne();
844 if (data->fReporter->verbose()) {
845 SkDebugf("+");
846 }
847 }
848
678 static void encodeFound(skiatest::Reporter* reporter, TestState& state) { 849 static void encodeFound(skiatest::Reporter* reporter, TestState& state) {
679 if (reporter->verbose()) { 850 if (reporter->verbose()) {
680 SkTDArray<SortByPixel*> worst; 851 if (state.fPixelWorst.count()) {
681 for (int index = 0; index < state.fPixelWorst.count(); ++index) { 852 SkTDArray<SortByPixel*> worst;
682 *worst.append() = &state.fPixelWorst[index]; 853 for (int index = 0; index < state.fPixelWorst.count(); ++index) {
854 *worst.append() = &state.fPixelWorst[index];
855 }
856 SkTQSort<SortByPixel>(worst.begin(), worst.end() - 1);
857 for (int index = 0; index < state.fPixelWorst.count(); ++index) {
858 const TestResult& result = *worst[index];
859 SkDebugf("%d %s pixelError=%d\n", result.fDirNo, result.fFilenam e, result.fPixelError);
860 }
683 } 861 }
684 SkTQSort<SortByPixel>(worst.begin(), worst.end() - 1); 862 if (state.fSlowest.count()) {
685 for (int index = 0; index < state.fPixelWorst.count(); ++index) { 863 SkTDArray<SortByTime*> slowest;
686 const TestResult& result = *worst[index]; 864 for (int index = 0; index < state.fSlowest.count(); ++index) {
687 SkDebugf("%d %s pixelError=%d\n", result.fDirNo, result.fFilename, r esult.fPixelError); 865 *slowest.append() = &state.fSlowest[index];
688 } 866 }
689 SkTDArray<SortByTime*> slowest; 867 if (slowest.count() > 0) {
690 for (int index = 0; index < state.fSlowest.count(); ++index) { 868 SkTQSort<SortByTime>(slowest.begin(), slowest.end() - 1);
691 *slowest.append() = &state.fSlowest[index]; 869 for (int index = 0; index < slowest.count(); ++index) {
692 } 870 const TestResult& result = *slowest[index];
693 SkTQSort<SortByTime>(slowest.begin(), slowest.end() - 1); 871 SkDebugf("%d %s time=%d\n", result.fDirNo, result.fFilename, result.fTime);
694 for (int index = 0; index < slowest.count(); ++index) { 872 }
695 const TestResult& result = *slowest[index]; 873 }
696 SkDebugf("%d %s time=%d\n", result.fDirNo, result.fFilename, result. fTime);
697 } 874 }
698 } 875 }
876
877 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1;
878 TestRunner testRunner(reporter, threadCount);
699 for (int index = 0; index < state.fPixelWorst.count(); ++index) { 879 for (int index = 0; index < state.fPixelWorst.count(); ++index) {
700 const TestResult& result = state.fPixelWorst[index]; 880 const TestResult& result = state.fPixelWorst[index];
701 TestResult::Test(result.fDirNo, result.fFilename, kEncodeFiles); 881 SkString filename(result.fFilename);
702 if (state.fReporter->verbose()) SkDebugf("+"); 882 if (!filename.endsWith(".skp")) {
883 filename.append(".skp");
884 }
885 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableEncode,
886 (&testSkpClipEncode, result.fDirNo, filename.c_str(), &testRunne r));
703 } 887 }
888 testRunner.render();
889 #if 0
890 for (int index = 0; index < state.fPixelWorst.count(); ++index) {
891 const TestResult& result = state.fPixelWorst[index];
892 SkString filename(result.fFilename);
893 if (!filename.endsWith(".skp")) {
894 filename.append(".skp");
895 }
896 TestResult::Test(result.fDirNo, filename.c_str(), kEncodeFiles);
897 if (reporter->verbose()) SkDebugf("+");
898 }
899 #endif
704 } 900 }
705 901
706 DEF_TEST(PathOpsSkpClip, reporter) { 902 DEF_TEST(PathOpsSkpClip, reporter) {
707 if (!initTest()) { 903 if (!initTest()) {
708 return; 904 return;
709 } 905 }
710 SkTArray<TestResult, true> errors; 906 SkTArray<TestResult, true> errors;
711 TestState state; 907 TestState state;
712 state.init(0, reporter); 908 state.init(0, reporter);
713 for (int dirNo = 1; dirNo <= 100; ++dirNo) { 909 for (int dirNo = 1; dirNo <= 100; ++dirNo) {
(...skipping 11 matching lines...) Expand all
725 static void testSkpClipMain(TestState* data) { 921 static void testSkpClipMain(TestState* data) {
726 (void) doOneDir(data, true); 922 (void) doOneDir(data, true);
727 } 923 }
728 924
729 DEF_TEST(PathOpsSkpClipThreaded, reporter) { 925 DEF_TEST(PathOpsSkpClipThreaded, reporter) {
730 if (!initTest()) { 926 if (!initTest()) {
731 return; 927 return;
732 } 928 }
733 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; 929 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1;
734 TestRunner testRunner(reporter, threadCount); 930 TestRunner testRunner(reporter, threadCount);
735 for (int dirNo = 1; dirNo <= 100; ++dirNo) { 931 const int firstDirNo = 1;
736 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnable, 932 for (int dirNo = firstDirNo; dirNo <= 100; ++dirNo) {
933 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableDir,
737 (&testSkpClipMain, dirNo, &testRunner)); 934 (&testSkpClipMain, dirNo, &testRunner));
738 } 935 }
739 testRunner.render(); 936 testRunner.render();
740 TestState state; 937 TestState state;
741 state.init(0, reporter); 938 state.init(0, reporter);
742 for (int dirNo = 1; dirNo <= 100; ++dirNo) { 939 for (int dirNo = firstDirNo; dirNo <= 100; ++dirNo) {
743 TestState& testState = testRunner.fRunnables[dirNo - 1]->fState; 940 TestState& testState = testRunner.fRunnables[dirNo - 1]->fState;
941 SkASSERT(testState.fResult.fDirNo == dirNo);
744 for (int inner = 0; inner < testState.fPixelWorst.count(); ++inner) { 942 for (int inner = 0; inner < testState.fPixelWorst.count(); ++inner) {
745 SkASSERT(testState.fResult.fDirNo == dirNo);
746 addError(&state, testState.fPixelWorst[inner]); 943 addError(&state, testState.fPixelWorst[inner]);
747 } 944 }
945 for (int inner = 0; inner < testState.fSlowest.count(); ++inner) {
946 addError(&state, testState.fSlowest[inner]);
947 }
748 } 948 }
749 encodeFound(reporter, state); 949 encodeFound(reporter, state);
750 } 950 }
951
952 static void testSkpClipUber(TestState* data) {
953 data->fResult.testOne();
954 SkString dirName = make_stat_dir_name(data->fResult.fDirNo);
955 if (!dirName.size()) {
956 return;
957 }
958 SkString statName(data->fResult.fFilename);
959 SkASSERT(statName.endsWith(".skp"));
960 statName.remove(statName.size() - 4, 4);
961 statName.appendf(".%d.%d.skp", data->fResult.fPixelError, data->fResult.fTim e);
962 SkString statusFile = make_filepath(data->fResult.fDirNo, outStatusDir, stat Name.c_str());
963 SkFILE* file = sk_fopen(statusFile.c_str(), kWrite_SkFILE_Flag);
964 if (!file) {
965 SkDebugf("failed to create %s", statusFile.c_str());
966 return;
967 }
968 sk_fclose(file);
969 if (data->fReporter->verbose()) {
970 if (data->fResult.fPixelError || data->fResult.fTime) {
971 SkDebugf("%s", data->fResult.progress().c_str());
972 } else {
973 SkDebugf(".");
974 }
975 }
976 }
977
978 static bool buildTests(skiatest::Reporter* reporter, int firstDirNo, int lastDir No, SkTDArray<TestResult>* tests,
979 SkTDArray<SortByName*>* sorted) {
980 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) {
981 SkString dirName = make_stat_dir_name(dirNo);
982 if (!dirName.size()) {
983 return false;
984 }
985 SkOSFile::Iter iter(dirName.c_str(), "skp");
986 SkString filename;
987 while (iter.next(&filename)) {
988 TestResult test;
989 test.init(dirNo);
990 SkString spaceFile(filename);
991 char* spaces = spaceFile.writable_str();
992 int spaceSize = (int) spaceFile.size();
993 for (int index = 0; index < spaceSize; ++index) {
994 if (spaces[index] == '.') {
995 spaces[index] = ' ';
996 }
997 }
998 int success = sscanf(spaces, "%s %d %d skp", test.fFilename,
999 &test.fPixelError, &test.fTime);
1000 if (success < 3) {
1001 SkDebugf("failed to scan %s matched=%d\n", filename.c_str(), suc cess);
1002 return false;
1003 }
1004 *tests[dirNo - firstDirNo].append() = test;
1005 }
1006 if (!sorted) {
1007 continue;
1008 }
1009 SkTDArray<TestResult>& testSet = tests[dirNo - firstDirNo];
1010 int count = testSet.count();
1011 for (int index = 0; index < count; ++index) {
1012 *sorted[dirNo - firstDirNo].append() = (SortByName*) &testSet[index] ;
1013 }
1014 if (sorted[dirNo - firstDirNo].count()) {
1015 SkTQSort<SortByName>(sorted[dirNo - firstDirNo].begin(),
1016 sorted[dirNo - firstDirNo].end() - 1);
1017 if (reporter->verbose()) {
1018 SkDebugf("+");
1019 }
1020 }
1021 }
1022 return true;
1023 }
1024
1025 bool Less(const SortByName& a, const SortByName& b);
1026 bool Less(const SortByName& a, const SortByName& b) {
1027 return a < b;
1028 }
1029
1030 DEF_TEST(PathOpsSkpClipUberThreaded, reporter) {
1031 const int firstDirNo = 1;
1032 const int lastDirNo = 100;
1033 if (!initUberTest(firstDirNo, lastDirNo)) {
1034 return;
1035 }
1036 const int dirCount = lastDirNo - firstDirNo + 1;
1037 SkTDArray<TestResult> tests[dirCount];
1038 SkTDArray<SortByName*> sorted[dirCount];
1039 if (!buildTests(reporter, firstDirNo, lastDirNo, tests, sorted)) {
1040 return;
1041 }
1042 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1;
1043 TestRunner testRunner(reporter, threadCount);
1044 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) {
1045 SkString dirName = make_in_dir_name(dirNo);
1046 if (!dirName.size()) {
1047 continue;
1048 }
1049 SkOSFile::Iter iter(dirName.c_str(), "skp");
1050 SkString filename;
1051 while (iter.next(&filename)) {
1052 int count;
1053 SortByName name;
1054 for (size_t index = 0; index < skipOverSeptCount; ++index) {
1055 if (skipOverSept[index].directory == dirNo
1056 && strcmp(filename.c_str(), skipOverSept[index].filename ) == 0) {
1057 goto checkEarlyExit;
1058 }
1059 }
1060 name.init(dirNo);
1061 strncpy(name.fFilename, filename.c_str(), filename.size() - 4); // drop .skp
1062 count = sorted[dirNo - firstDirNo].count();
1063 if (SkTSearch<SortByName, Less>(sorted[dirNo - firstDirNo].begin(),
1064 count, &name, sizeof(&name)) < 0) {
1065 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableFile,
1066 (&testSkpClipUber, dirNo, filename.c_str(), &testRunner) );
1067 }
1068 checkEarlyExit:
1069 ;
1070 }
1071
1072 }
1073 testRunner.render();
1074 SkTDArray<TestResult> results[dirCount];
1075 if (!buildTests(reporter, firstDirNo, lastDirNo, results, NULL)) {
1076 return;
1077 }
1078 SkTDArray<TestResult> allResults;
1079 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) {
1080 SkTDArray<TestResult>& array = results[dirNo - firstDirNo];
1081 allResults.append(array.count(), array.begin());
1082 }
1083 int allCount = allResults.count();
1084 SkTDArray<SortByPixel*> pixels;
1085 SkTDArray<SortByTime*> times;
1086 for (int index = 0; index < allCount; ++index) {
1087 *pixels.append() = (SortByPixel*) &allResults[index];
1088 *times.append() = (SortByTime*) &allResults[index];
1089 }
1090 TestState state;
1091 if (pixels.count()) {
1092 SkTQSort<SortByPixel>(pixels.begin(), pixels.end() - 1);
1093 for (int inner = 0; inner < kMaxFiles; ++inner) {
1094 *state.fPixelWorst.append() = *pixels[allCount - inner - 1];
1095 }
1096 }
1097 if (times.count()) {
1098 SkTQSort<SortByTime>(times.begin(), times.end() - 1);
1099 for (int inner = 0; inner < kMaxFiles; ++inner) {
1100 *state.fSlowest.append() = *times[allCount - inner - 1];
1101 }
1102 }
1103 encodeFound(reporter, state);
1104 }
751 1105
752 DEF_TEST(PathOpsSkpClipOneOff, reporter) { 1106 DEF_TEST(PathOpsSkpClipOneOff, reporter) {
753 if (!initTest()) { 1107 if (!initTest()) {
754 return; 1108 return;
755 } 1109 }
756 const int testIndex = 43 - 37; 1110 const int testIndex = 43 - 37;
757 int dirNo = skipOverSept[testIndex].directory; 1111 int dirNo = skipOverSept[testIndex].directory;
758 SkAssertResult(make_in_dir_name(dirNo).size()); 1112 SkAssertResult(make_in_dir_name(dirNo).size());
759 SkString filename(skipOverSept[testIndex].filename); 1113 SkString filename(skipOverSept[testIndex].filename);
760 TestResult state; 1114 TestResult state;
761 state.test(dirNo, filename); 1115 state.test(dirNo, filename);
762 if (reporter->verbose()) { 1116 if (reporter->verbose()) {
763 SkDebugf("%s", state.status().c_str()); 1117 SkDebugf("%s", state.status().c_str());
764 } 1118 }
765 state.fTestStep = kEncodeFiles; 1119 state.fTestStep = kEncodeFiles;
766 state.testOne(); 1120 state.testOne();
767 } 1121 }
OLDNEW
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsSkpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698