Pre-cache fDirection and fConvexity for recorded SkPaths too.
authormtklein <mtklein@chromium.org>
Tue, 20 Jan 2015 21:47:19 +0000 (13:47 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 20 Jan 2015 21:47:19 +0000 (13:47 -0800)
http://build.chromium.org/p/client.skia/builders/Test-Ubuntu13.10-GCE-NoGPU-x86_64-Release-TSAN/builds/1211/steps/dm/logs/stdio

I don't see any big perf hit locally:

desk_googlespreadsheetdashed.skp 1.68ms -> 1.74ms 1.04x
             desk_mobilenews.skp  643us ->  665us 1.04x
               desk_tigersvg.skp 51.1us -> 52.5us 1.03x
     desk_jsfiddlehumperclip.skp   37us -> 37.9us 1.02x
               desk_samoasvg.skp  373us ->  380us 1.02x
              desk_wordpress.skp  697us ->  708us 1.02x
                 desk_mapsvg.skp  698us ->  708us 1.02x
             tabl_googleblog.skp  553us ->  560us 1.01x
                desk_wowwiki.skp 1.31ms -> 1.32ms 1.01x
                tabl_mozilla.skp 1.44ms -> 1.45ms 1.01x
                 desk_sfgate.skp  156us ->  157us 1.01x
             desk_chalkboard.skp  376us ->  378us 1x
                  desk_baidu.skp  101us ->  101us 1x
            desk_gmailthread.skp  231us ->  231us 1x
                 desk_carsvg.skp  379us ->  379us 1x
             desk_googlehome.skp 38.1us -> 38.1us 1x
          desk_css3gradients.skp 89.6us -> 89.2us 1x
      desk_googlespreadsheet.skp  549us ->  546us 0.99x
            desk_pokemonwiki.skp 8.67ms -> 8.62ms 0.99x
                    tabl_mlb.skp  294us ->  291us 0.99x
            tabl_gamedeksiam.skp  700us ->  692us 0.99x
           tabl_worldjournal.skp  143us ->  142us 0.99x
                desk_blogger.skp  441us ->  436us 0.99x
                desk_twitter.skp  452us ->  446us 0.99x
                    desk_gws.skp  152us ->  150us 0.99x
                  tabl_gmail.skp 24.2us -> 23.9us 0.99x
                tabl_sahadan.skp 84.7us -> 83.5us 0.99x
                    tabl_cnn.skp 1.24ms -> 1.22ms 0.99x
                  tabl_ukwsj.skp  543us ->  535us 0.99x
           desk_yahooanswers.skp  124us ->  123us 0.99x
                desk_booking.skp  905us ->  891us 0.98x
          tabl_androidpolice.skp 1.76ms -> 1.73ms 0.98x
          desk_ugamsolutions.skp  281us ->  276us 0.98x
                desk_nytimes.skp  209us ->  204us 0.98x
               tabl_techmeme.skp 98.4us -> 96.1us 0.98x
                 tabl_nofolo.skp 59.2us -> 57.8us 0.98x
                desk_weather.skp  244us ->  238us 0.98x
               desk_facebook.skp  546us ->  531us 0.97x
               desk_linkedin.skp  321us ->  311us 0.97x
                   tabl_digg.skp  801us ->  770us 0.96x
      tabl_culturalsolutions.skp  332us ->  319us 0.96x
                 desk_amazon.skp  103us ->   99us 0.96x
               tabl_engadget.skp  610us ->  579us 0.95x
                   tabl_cnet.skp  144us ->  136us 0.95x
               desk_fontwipe.skp 36.6us -> 34.7us 0.95x
                   desk_ebay.skp  173us ->  164us 0.94x
                   tabl_hsfi.skp 5.95us -> 5.58us 0.94x
             tabl_deviantart.skp  134us ->  126us 0.94x
                   desk_espn.skp  261us ->  243us 0.93x

BUG=skia:

Review URL: https://codereview.chromium.org/861853002

src/core/SkRecords.h

index aab3949..522bf68 100644 (file)
@@ -200,10 +200,13 @@ private:
 };
 
 // SkPath::getBounds() isn't thread safe unless we precache the bounds in a singlethreaded context.
-// Recording is a convenient time to do this, but we could delay it to between record and playback.
-struct BoundedPath : public SkPath {
-    explicit BoundedPath(const SkPath& path) : SkPath(path) {
+// SkPath::cheapComputeDirection() is similar.
+// Recording is a convenient time to cache these, or we can delay it to between record and playback.
+struct PreCachedPath : public SkPath {
+    explicit PreCachedPath(const SkPath& path) : SkPath(path) {
         this->updateBoundsCache();
+        SkPath::Direction junk;
+        (void)this->cheapComputeDirection(&junk);
     }
 };
 
@@ -230,10 +233,10 @@ struct RegionOpAndAA {
 };
 SK_COMPILE_ASSERT(sizeof(RegionOpAndAA) == 4, RegionOpAndAASize);
 
-RECORD3(ClipPath,   SkIRect, devBounds, BoundedPath, path, RegionOpAndAA, opAA);
-RECORD3(ClipRRect,  SkIRect, devBounds, SkRRect,    rrect, RegionOpAndAA, opAA);
-RECORD3(ClipRect,   SkIRect, devBounds, SkRect,      rect, RegionOpAndAA, opAA);
-RECORD3(ClipRegion, SkIRect, devBounds, SkRegion,  region, SkRegion::Op,    op);
+RECORD3(ClipPath,   SkIRect, devBounds, PreCachedPath,  path, RegionOpAndAA, opAA);
+RECORD3(ClipRRect,  SkIRect, devBounds, SkRRect,       rrect, RegionOpAndAA, opAA);
+RECORD3(ClipRect,   SkIRect, devBounds, SkRect,         rect, RegionOpAndAA, opAA);
+RECORD3(ClipRegion, SkIRect, devBounds, SkRegion,     region, SkRegion::Op,    op);
 
 RECORD1(BeginCommentGroup, PODArray<char>, description);
 RECORD2(AddComment, PODArray<char>, key, PODArray<char>, value);
@@ -268,7 +271,7 @@ RECORD4(DrawImageRect, Optional<SkPaint>, paint,
                        SkRect, dst);
 RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
 RECORD1(DrawPaint, SkPaint, paint);
-RECORD2(DrawPath, SkPaint, paint, BoundedPath, path);
+RECORD2(DrawPath, SkPaint, paint, PreCachedPath, path);
 RECORD3(DrawPicture, Optional<SkPaint>, paint,
                      RefBox<const SkPicture>, picture,
                      TypedMatrix, matrix);
@@ -297,7 +300,7 @@ RECORD4(DrawTextBlob, SkPaint, paint,
 RECORD5(DrawTextOnPath, SkPaint, paint,
                         PODArray<char>, text,
                         size_t, byteLength,
-                        BoundedPath, path,
+                        PreCachedPath, path,
                         TypedMatrix, matrix);
 
 RECORD5(DrawPatch, SkPaint, paint,