skia2/include/core
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
..
SkAnnotation.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkBBHFactory.h Reenable Wdeprecated-copy-dtor 2021-02-16 17:53:28 +00:00
SkBitmap.h Remove supported for (removed) inheriting paint filter-quality 2021-03-09 00:58:09 +00:00
SkBlendMode.h Work to improve blendmode dox 2021-02-08 18:41:01 +00:00
SkBlurTypes.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkCanvas.h add drawGlyphs for SkRSXform 2021-04-21 19:43:37 +00:00
SkCanvasVirtualEnforcer.h Pass sampling to drawImageSet 2021-01-05 19:40:31 +00:00
SkClipOp.h Update SkClipOp::kMax_EnumValue to match non-deprecated values 2020-09-28 15:30:33 +00:00
SkColor.h Support luminance-alpha GL format for YUVA planes 2020-12-17 14:54:25 +00:00
SkColorFilter.h rm getFlags() from colorfilter -- deprecated 2021-03-11 22:35:31 +00:00
SkColorPriv.h move SkTPin to include/private 2020-10-16 19:45:11 +00:00
SkColorSpace.h Enable ClangTidy check llvm-namespace-comment. 2020-08-06 19:07:52 +00:00
SkContourMeasure.h [canvaskit] Flesh out remaining docs for core CanvasKit. 2020-10-05 11:47:40 +00:00
SkCoverageMode.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkCubicMap.h [skottie] De-dupe sequential cubic mappers 2019-07-17 17:14:46 +00:00
SkData.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SkDataTable.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SkDeferredDisplayList.h Require a direct context to precompile a DDL's programs 2020-08-14 14:35:41 +00:00
SkDeferredDisplayListRecorder.h Add a new entry point for making promise images 2021-02-22 23:33:56 +00:00
SkDocument.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SkDrawable.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkDrawLooper.h Hide (unused) SkDrawLooper 2021-02-07 12:49:53 +00:00
SkEncodedImageFormat.h Reland "heif: Add AVIF type and AVIF sniffing" 2020-11-05 15:25:52 +00:00
SkExecutor.h Reenable Wdeprecated-copy-dtor 2021-02-16 17:53:28 +00:00
SkFilterQuality.h Update comment for SkFilterQuality 2021-02-25 22:15:20 +00:00
SkFlattenable.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SkFont.h Update SkFont::measureText documentation. 2020-11-11 17:15:35 +00:00
SkFontArguments.h Remove SkFontArguments::Axis. 2020-07-15 20:59:22 +00:00
SkFontMetrics.h SkCustomTypefaceBuilder to set SkFontStyle 2020-08-19 00:09:55 +00:00
SkFontMgr.h Revert "Revert "onMatchFaceStyle is unused, so remove it"" 2021-04-27 16:40:29 +00:00
SkFontParameters.h Fix DWrite axis design parameters. 2020-12-01 15:00:33 +00:00
SkFontStyle.h move SkTPin to include/private 2020-10-16 19:45:11 +00:00
SkFontTypes.h Remove SkTextEncoding and SkFontHinting macros. 2019-05-22 20:44:28 +00:00
SkGraphics.h remove {Get,Set}FontCachePointSizeLimit() from API 2021-03-22 20:47:27 +00:00
SkICC.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkImage.h Remove supported for (removed) inheriting paint filter-quality 2021-03-09 00:58:09 +00:00
SkImageEncoder.h Bitmap.asImage() 2020-12-23 15:54:57 +00:00
SkImageFilter.h Remove dead matrixfilter factory 2021-03-21 15:23:38 +00:00
SkImageGenerator.h Remove SkYUVASizeInfo, make SkYUVAIndex a private part of SkYUVAInfo 2021-01-12 15:06:26 +00:00
SkImageInfo.h Add several more values to SkYUVColorSpace 2020-07-24 18:49:10 +00:00
SkM44.h Add mapRect function and RectToRect constructor to SkM44 2021-05-05 19:57:26 +00:00
SkMallocPixelRef.h Enable ClangTidy check llvm-namespace-comment. 2020-08-06 19:07:52 +00:00
SkMaskFilter.h remove unused maskfilter helpers: Combine, Compose 2020-05-05 19:10:00 +00:00
SkMath.h impl SkMulDiv255Round with SkMul16ShiftRound 2020-09-09 17:01:17 +00:00
SkMatrix44.h Revert "transition matrix44 to opt-in only" 2020-04-16 10:01:29 +00:00
SkMatrix.h [skottie] Implement skew & skew axis support 2021-02-08 22:24:38 +00:00
SkMilestone.h Update Skia milestone to 92 2021-04-08 12:26:56 +00:00
SkOverdrawCanvas.h introduce SkCanvas::onDrawGlyphRunList 2021-04-15 19:44:24 +00:00
SkPaint.h Hide getFilterQuality 2021-03-21 02:23:27 +00:00
SkPath.h Add query to test our cached convexity 2021-01-19 14:54:44 +00:00
SkPathBuilder.h SkPathBuider::addPath() 2021-01-26 03:53:49 +00:00
SkPathEffect.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
SkPathMeasure.h [canvaskit] Flesh out remaining docs for core CanvasKit. 2020-10-05 11:47:40 +00:00
SkPathTypes.h Move convexity enum out of public 2020-08-30 13:04:22 +00:00
SkPicture.h Remove legacy support for inheriting sampling from the paint. 2021-03-19 16:17:42 +00:00
SkPictureRecorder.h Almost remove GrContext 2020-10-20 15:52:01 +00:00
SkPixelRef.h Remove dead references to filter-quality 2021-03-21 00:26:07 +00:00
SkPixmap.h Remove dead references to filter-quality 2021-03-21 00:26:07 +00:00
SkPngChunkReader.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkPoint3.h Add clipping for perspective triangles 2019-12-17 23:24:18 +00:00
SkPoint.h Test texture domain effect with local matrix. 2019-11-22 22:37:33 +00:00
SkPromiseImageTexture.h Simplify promise image callbacks. 2020-11-10 02:47:56 +00:00
SkRasterHandleAllocator.h Reenable Wdeprecated-copy-dtor 2021-02-16 17:53:28 +00:00
SkRect.h Use GrVkFramebuffer throughout GrVkOpsRenderPass instead of GrVkRT. 2021-04-16 17:03:43 +00:00
SkRefCnt.h Make GrSurfaceProxy ref counts thread safe. 2019-10-24 19:55:23 +00:00
SkRegion.h remove enum docs 2020-02-11 21:43:07 +00:00
SkRRect.h Add halfWidth/halfHeight functions to SkRectPriv 2020-12-22 20:42:43 +00:00
SkRSXform.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSamplingOptions.h Name common cubic resamplers 2021-02-05 19:21:04 +00:00
SkScalar.h Format and comment SkScalarInterpFunc 2020-08-26 20:50:34 +00:00
SkSerialProcs.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkShader.h Remove dead references to filter-quality 2021-03-21 00:26:07 +00:00
SkSize.h Remove GrSurfaceDesc 2020-02-07 19:48:13 +00:00
SkStream.h Add SkFILEStream constructor which takes a size. 2020-09-11 19:50:24 +00:00
SkString.h Use SkScalar type where appropriate. 2020-07-28 20:13:37 +00:00
SkStrokeRec.h Relax SkStrokeRec::hasEqualEffect 2020-09-15 20:05:40 +00:00
SkSurface.h If no sampling is passed, assume NN for surface.draw 2021-03-20 21:48:16 +00:00
SkSurfaceCharacterization.h Add GrInternalSurfaceFlag for vulkan input attachment. 2020-08-27 20:05:29 +00:00
SkSurfaceProps.h Convert dmsaa to an SkSurfaceProp 2021-04-20 16:24:56 +00:00
SkSwizzle.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkTextBlob.h Expose experimental iterator on SkParagraph 2021-04-16 16:50:33 +00:00
SkTileMode.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkTime.h Remove SK_REQUIRE_LOCAL_VAR macro. 2020-07-31 02:32:01 +00:00
SkTraceMemoryDump.h Add ability to trace wrapped objects and be able to differentiate 2021-04-08 18:38:14 +00:00
SkTypeface.h Make onCreateScalerContext return unique_ptr. 2020-12-28 17:31:09 +00:00
SkTypes.h Move all GrTFlagsMask operators into bitfield macro definitions. 2021-05-04 20:02:15 +00:00
SkUnPreMultiply.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkVertices.h Remove custom SkVertices data and runtime effect varying support 2021-04-19 17:49:25 +00:00
SkYUVAInfo.h Reland "Push SkYUVAInfo into GrYUVToRGBEffect." 2021-01-13 22:08:44 +00:00
SkYUVAPixmaps.h Remove SkYUVASizeInfo, make SkYUVAIndex a private part of SkYUVAInfo 2021-01-12 15:06:26 +00:00