skia2/bench
Michael Ludwig daa9b8e4d9 Add mapRect function and RectToRect constructor to SkM44
The SkM44::RectToRect function matches the semantics of
SkMatrix::RectToRect(kFill_ScaleToFit). No other ScaleToFit variants are
ported over to SkM44.

skottie uses some instances of kCenter_ScaleToFit so that functionality
may need to be added in the future (in SkM44 or in skottie). There are
no current usages of the kStart and kEnd_ScaleToFit semantics.

The SkM44::mapRect() function is implemented to correspond to the
SkMatrix::mapRect() that returns the mapped rect (instead of modifying a
pointer) and always has ApplyPerspectiveClip::kYes. This was chosen to
keep its behavior simple and because perspective clipping is almost
always the right thing to do. In the new implementation there is no
longer a performance cliff to worry about (see below). For the timebeing
mapRect is hidden behind SkMatrixPriv::MapRect().

Performance:
I added benchmarks for mapRect() on SkM44 and SkMatrix that use the same
matrices to get a fair comparison on their different specializations.
SkMatrix has a very efficient mapRect when it's scale+translate or
simpler, then another impl. for affine matrices, and then falls back to
SkPath clipping when there's perspective. On the other hand, SkM44 only
has 2 modes: affine and perspective.

On my desktop, with a Ryzen 9 3900X, here are the times for 100,000 calls
to mapRect for different types of matrices:
                         SkMatrix    SkM44
scale+translate           0.35 ms    0.42 ms
rotate                    1.70 ms    0.42 ms
perspective              63.90 ms    0.66 ms
clipped-perspective      138.0 ms    0.96 ms

To summarize, the SkM44::mapRect is almost as fast as the s+t specialization
in SkMatrix, but for all non-perspective matrices. For perspective matrices
it's only 2x slower than that specialization when no vertices are clipped,
and still almost 2x faster than the affine specialization when vertices are
clipped (and 100x faster than falling back to SkPath).

Given that, there's the open question of whether or not keeping an affine
specialization is worth it for SkM44's code size.

Bug: skia:11720
Change-Id: I6771956729ed64f3b287a9de503513375c9f42a0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402957
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
2021-05-05 19:57:26 +00:00
..
AAClipBench.cpp Use SkClipOp::kIntersect instead of kReplace_ClipOp 2020-09-16 18:37:37 +00:00
AlternatingColorPatternBench.cpp Simplify common case of linear filtering with no mips 2021-01-15 16:47:16 +00:00
AndroidCodecBench.cpp Reland "Reland "SkSurface asynchronous read APIs allow client to extend pixel lifetime"" 2019-10-03 19:14:22 +00:00
AndroidCodecBench.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BenchLogger.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
BenchLogger.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
Benchmark.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
Benchmark.h Collect DMSAA stats 2021-05-01 00:46:22 +00:00
BezierBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BigPathBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BitmapRegionDecoderBench.cpp Move SkBitmapRegionCodec into client_utils/android 2020-05-20 20:06:48 +00:00
BitmapRegionDecoderBench.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BlendmodeBench.cpp Update blendmode benchmark to allow less than 1000 iterations. 2021-03-24 21:32:23 +00:00
BlurBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BlurImageFilterBench.cpp drawBitmap is deprecated 2021-01-24 17:39:15 +00:00
BlurRectBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BlurRectsBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
BulkRectBench.cpp filter-quality is deprecated, pass sampling to drawImage 2021-01-28 03:22:51 +00:00
ChartBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
check_bench_regressions.py Fix Python3 compatibility 2021-03-25 14:15:35 +00:00
ChecksumBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ChromeBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ClearBench.cpp Remove public getter for GrSurfaceDrawContext on SkSCanvas. 2020-12-23 16:13:07 +00:00
ClipMaskBench.cpp remove (unused) clipmask from savelayer 2020-06-15 14:26:44 +00:00
ClipStrategyBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
CmapBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
CodecBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
CodecBench.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
CodecBenchPriv.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
ColorFilterBench.cpp Convert some SkRuntimeEffect::Make to use stage-specific factories 2021-04-21 16:19:57 +00:00
ColorPrivBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
CompositingImagesBench.cpp Hide misc non-sampling draw methods 2021-01-25 17:54:56 +00:00
ControlBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
CoverageBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
CreateBackendTextureBench.cpp Rename SkTArray::reserve to reserve_back. 2020-10-14 21:42:11 +00:00
CubicMapBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
DashBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
DDLRecorderBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
DisplacementBench.cpp filter-quality is deprecated, pass sampling to drawImage 2021-01-28 03:22:51 +00:00
DrawBitmapAABench.cpp Simplify common case of linear filtering with no mips 2021-01-15 16:47:16 +00:00
EncodeBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
FilteringBench.cpp other ways to organize samplingoptions? 2020-11-21 02:00:26 +00:00
FontCacheBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
FSRectBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
GameBench.cpp drawBitmap is deprecated 2021-01-24 17:39:15 +00:00
GeometryBench.cpp Only expose isConvex on path publicly. 2020-08-28 16:56:29 +00:00
GlyphQuadFillBench.cpp use GrArenas for direct glyph drawing 2021-04-22 16:43:31 +00:00
GMBench.cpp Add a convenience to downcast contexts into GrDirectContext 2020-07-07 18:13:50 +00:00
GMBench.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
GradientBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
GrMemoryPoolBench.cpp replace std::aligned_storage 2020-11-10 14:47:36 +00:00
GrMipmapBench.cpp Don't use filter-quality 2021-01-30 16:09:23 +00:00
GrPathUtilsBench.cpp Move cubic cusp existence test into GrStrokeHardwareTessellator.cpp 2021-02-24 08:24:53 +00:00
GrQuadBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
GrResourceCacheBench.cpp Rename GrContextPriv to GrDirectContextPriv 2020-10-14 16:46:01 +00:00
gUniqueGlyphIDs.h Make header files self-sufficient 2017-02-10 01:19:52 +00:00
HairlinePathBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
HardStopGradientBench_ScaleNumColors.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
HardStopGradientBench_ScaleNumHardStops.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
HardStopGradientBench_SpecialHardStops.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
ImageBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ImageCacheBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ImageCacheBudgetBench.cpp filter-quality is deprecated, pass sampling to drawImage 2021-01-28 03:22:51 +00:00
ImageCycleBench.cpp More hiding of legacy drawImage calls 2021-01-22 13:53:42 +00:00
ImageFilterCollapse.cpp drawBitmap is deprecated 2021-01-24 17:39:15 +00:00
ImageFilterDAGBench.cpp Add SkImageFilters::Blend rename for Xfermode filter 2020-10-13 14:28:26 +00:00
InterpBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
JSONBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
LightingBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
LineBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
MathBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
Matrix44Bench.cpp Add mapRect function and RectToRect constructor to SkM44 2021-05-05 19:57:26 +00:00
MatrixBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
MatrixConvolutionBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
MemsetBench.cpp Reland "add ERMS (enhanced rep mov/sto) SkOpts slice" 2020-11-12 18:00:39 +00:00
MergeBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
microbench.json Fix the other microbench schema 2014-07-25 08:30:11 -07:00
MipmapBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
MorphologyBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
MSKPBench.cpp MSKP support in nanobench 2021-04-30 20:04:08 +00:00
MSKPBench.h MSKP support in nanobench 2021-04-30 20:04:08 +00:00
MutexBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
nanobench.cpp Collect DMSAA stats 2021-05-01 00:46:22 +00:00
nanobench.h Convert dmsaa to an SkSurfaceProp 2021-04-20 16:24:56 +00:00
ParagraphBench.cpp improve SkParagraph's bench accuracy 2021-03-19 14:14:48 +00:00
PatchBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PathBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PathIterBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PathOpsBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PathTextBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PDFBench.cpp Bitmap.asImage() 2020-12-23 15:54:57 +00:00
PerlinNoiseBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PictureNestingBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PictureOverheadBench.cpp remove SkLiteDL 2019-05-14 18:55:44 +00:00
PicturePlaybackBench.cpp Enable ClangTidy check modernize-make-unique. 2020-08-03 17:53:52 +00:00
PolyUtilsBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
PremulAndUnpremulAlphaOpsBench.cpp Bitmap.asImage() 2020-12-23 15:54:57 +00:00
QuickRejectBench.cpp Revert "Revert "move onto new factories for SkMatrix"" 2020-05-21 16:58:39 +00:00
ReadPixBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RecordingBench.cpp Can we remove this flag to picture-recording? 2020-08-20 12:29:42 +00:00
RecordingBench.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RectanizerBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RectBench.cpp Bitmap should use sampling options 2020-12-12 15:36:21 +00:00
RefCntBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RegionBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RegionContainBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RepeatTileBench.cpp Bitmap should use sampling options 2020-12-12 15:36:21 +00:00
ResultsWriter.h Don't keep "outResultsFile" open in nanobench 2019-10-24 16:09:02 +00:00
RotatedRectBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
RTreeBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ScalarBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ShaderMaskFilterBench.cpp Must pass filtering to picture shader 2021-03-18 22:18:47 +00:00
ShadowBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
ShaperBench.cpp Shaper Tests: fix g3 build 2019-05-03 18:10:46 +00:00
ShapesBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
Sk4fBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkGlyphCacheBench.cpp Reland "Remove use of legacy display globals." 2020-10-05 19:13:58 +00:00
SkGlyphCacheBench.h nanobench: option to execute directory of TextBlobTraces as benches 2019-10-25 13:28:49 +00:00
SKPAnimationBench.cpp Remove uses of SkCanvas::flush 2020-11-20 21:42:38 +00:00
SKPAnimationBench.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SKPBench.cpp Collect DMSAA stats 2021-05-01 00:46:22 +00:00
SKPBench.h Collect DMSAA stats 2021-05-01 00:46:22 +00:00
skpbench.json Fix scale type in JSON format 2014-06-26 15:39:31 -07:00
SkSLBench.cpp Add runtime color filter and shader modes to the SkSL compiler 2021-04-15 13:30:59 +00:00
SkSLBench.h Add heap usage of SkSL::Compiler to nanobench output 2020-07-09 00:05:28 +00:00
SortBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
StreamBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
StrokeBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SwizzleBench.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
TableBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
TessellateBench.cpp Implement a fixed count stroke tessellator 2021-04-22 20:34:04 +00:00
TextBlobBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
TileBench.cpp Simplify common case of linear filtering with no mips 2021-01-15 16:47:16 +00:00
TileImageFilterBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
TopoSortBench.cpp Move SkTTopoSort to src/gpu and rename it to GrTTopoSort 2020-11-17 14:17:03 +00:00
TriangulatorBench.cpp Make GrTriangulator immutable 2021-01-28 02:38:51 +00:00
TypefaceBench.cpp use std::make_unique 2019-12-12 22:32:45 +00:00
VertBench.cpp Hide misc non-sampling draw methods 2021-01-25 17:54:56 +00:00
VertexColorSpaceBench.cpp Delete mixed samples 2021-04-22 20:11:34 +00:00
WritePixelsBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
WriterBench.cpp Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00