From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- gfx/2d/2D.h | 2283 +++++++ gfx/2d/AutoHelpersWin.h | 71 + gfx/2d/BaseCoord.h | 101 + gfx/2d/BaseMargin.h | 164 + gfx/2d/BasePoint.h | 120 + gfx/2d/BasePoint3D.h | 142 + gfx/2d/BasePoint4D.h | 132 + gfx/2d/BaseRect.h | 743 +++ gfx/2d/BaseSize.h | 113 + gfx/2d/BezierUtils.cpp | 326 + gfx/2d/BezierUtils.h | 186 + gfx/2d/BigEndianInts.h | 66 + gfx/2d/Blur.cpp | 904 +++ gfx/2d/Blur.h | 198 + gfx/2d/BlurLS3.cpp | 569 ++ gfx/2d/BlurNEON.cpp | 303 + gfx/2d/BlurSSE2.cpp | 345 + gfx/2d/BorrowedContext.h | 131 + gfx/2d/BufferEdgePad.cpp | 104 + gfx/2d/BufferEdgePad.h | 23 + gfx/2d/BufferUnrotate.cpp | 74 + gfx/2d/BufferUnrotate.h | 21 + gfx/2d/ConicGradientEffectD2D1.cpp | 375 ++ gfx/2d/ConicGradientEffectD2D1.h | 103 + gfx/2d/ConvolutionFilter.cpp | 114 + gfx/2d/ConvolutionFilter.h | 54 + gfx/2d/ConvolutionFilterAVX2.cpp | 104 + gfx/2d/ConvolutionFilterNEON.cpp | 287 + gfx/2d/ConvolutionFilterSSE2.cpp | 304 + gfx/2d/Coord.h | 176 + gfx/2d/CriticalSection.h | 84 + gfx/2d/DWriteSettings.cpp | 173 + gfx/2d/DWriteSettings.h | 41 + gfx/2d/DataSourceSurface.cpp | 20 + gfx/2d/DataSourceSurfaceWrapper.h | 49 + gfx/2d/DataSurfaceHelpers.cpp | 343 + gfx/2d/DataSurfaceHelpers.h | 131 + gfx/2d/DrawEventRecorder.cpp | 159 + gfx/2d/DrawEventRecorder.h | 277 + gfx/2d/DrawTarget.cpp | 339 + gfx/2d/DrawTargetCairo.cpp | 2010 ++++++ gfx/2d/DrawTargetCairo.h | 252 + gfx/2d/DrawTargetD2D1.cpp | 2383 +++++++ gfx/2d/DrawTargetD2D1.h | 332 + gfx/2d/DrawTargetOffset.cpp | 226 + gfx/2d/DrawTargetOffset.h | 191 + gfx/2d/DrawTargetRecording.cpp | 770 +++ gfx/2d/DrawTargetRecording.h | 367 ++ gfx/2d/DrawTargetSkia.cpp | 2070 ++++++ gfx/2d/DrawTargetSkia.h | 212 + gfx/2d/ExtendInputEffectD2D1.cpp | 190 + gfx/2d/ExtendInputEffectD2D1.h | 87 + gfx/2d/Factory.cpp | 1355 ++++ gfx/2d/FilterNodeD2D1.cpp | 1140 ++++ gfx/2d/FilterNodeD2D1.h | 158 + gfx/2d/FilterNodeSoftware.cpp | 3748 +++++++++++ gfx/2d/FilterNodeSoftware.h | 780 +++ gfx/2d/FilterProcessing.cpp | 282 + gfx/2d/FilterProcessing.h | 209 + gfx/2d/FilterProcessingSIMD-inl.h | 1299 ++++ gfx/2d/FilterProcessingSSE2.cpp | 126 + gfx/2d/FilterProcessingScalar.cpp | 299 + gfx/2d/Filters.h | 446 ++ gfx/2d/FontVariation.h | 28 + gfx/2d/GenericRefCounted.h | 119 + gfx/2d/GradientStopsD2D.h | 42 + gfx/2d/Helpers.h | 80 + gfx/2d/HelpersCairo.h | 333 + gfx/2d/HelpersD2D.h | 983 +++ gfx/2d/HelpersSkia.h | 360 + gfx/2d/HelpersWinFonts.h | 33 + gfx/2d/ImageScaling.cpp | 245 + gfx/2d/ImageScaling.h | 84 + gfx/2d/ImageScalingSSE2.cpp | 333 + gfx/2d/InlineTranslator.cpp | 117 + gfx/2d/InlineTranslator.h | 191 + gfx/2d/IterableArena.h | 175 + gfx/2d/Logging.h | 965 +++ gfx/2d/LoggingConstants.h | 31 + gfx/2d/LuminanceNEON.cpp | 88 + gfx/2d/LuminanceNEON.h | 18 + gfx/2d/MMIHelpers.h | 232 + gfx/2d/MacIOSurface.cpp | 621 ++ gfx/2d/MacIOSurface.h | 162 + gfx/2d/Matrix.cpp | 179 + gfx/2d/Matrix.h | 2330 +++++++ gfx/2d/MatrixFwd.h | 39 + gfx/2d/NativeFontResource.cpp | 52 + gfx/2d/NativeFontResourceDWrite.cpp | 269 + gfx/2d/NativeFontResourceDWrite.h | 60 + gfx/2d/NativeFontResourceFreeType.cpp | 92 + gfx/2d/NativeFontResourceFreeType.h | 79 + gfx/2d/NativeFontResourceGDI.cpp | 52 + gfx/2d/NativeFontResourceGDI.h | 51 + gfx/2d/NativeFontResourceMac.cpp | 174 + gfx/2d/NativeFontResourceMac.h | 49 + gfx/2d/NumericTools.h | 46 + gfx/2d/Path.cpp | 552 ++ gfx/2d/PathAnalysis.h | 67 + gfx/2d/PathCairo.cpp | 301 + gfx/2d/PathCairo.h | 97 + gfx/2d/PathD2D.cpp | 422 ++ gfx/2d/PathD2D.h | 112 + gfx/2d/PathHelpers.cpp | 290 + gfx/2d/PathHelpers.h | 390 ++ gfx/2d/PathRecording.cpp | 307 + gfx/2d/PathRecording.h | 238 + gfx/2d/PathSkia.cpp | 273 + gfx/2d/PathSkia.h | 110 + gfx/2d/PatternHelpers.h | 141 + gfx/2d/Point.h | 403 ++ gfx/2d/Polygon.h | 396 ++ gfx/2d/QuartzSupport.h | 106 + gfx/2d/QuartzSupport.mm | 582 ++ gfx/2d/Quaternion.cpp | 23 + gfx/2d/Quaternion.h | 150 + gfx/2d/RadialGradientEffectD2D1.cpp | 405 ++ gfx/2d/RadialGradientEffectD2D1.h | 103 + gfx/2d/RecordedEvent.cpp | 209 + gfx/2d/RecordedEvent.h | 517 ++ gfx/2d/RecordedEventImpl.h | 4088 ++++++++++++ gfx/2d/RecordingTypes.h | 71 + gfx/2d/Rect.h | 495 ++ gfx/2d/RectAbsolute.h | 305 + gfx/2d/SFNTData.cpp | 206 + gfx/2d/SFNTData.h | 59 + gfx/2d/SIMD.h | 1039 +++ gfx/2d/SSEHelpers.h | 18 + gfx/2d/SVGTurbulenceRenderer-inl.h | 362 ++ gfx/2d/Scale.h | 39 + gfx/2d/ScaleFactor.h | 98 + gfx/2d/ScaleFactors2D.h | 198 + gfx/2d/ScaledFontBase.cpp | 223 + gfx/2d/ScaledFontBase.h | 59 + gfx/2d/ScaledFontDWrite.cpp | 769 +++ gfx/2d/ScaledFontDWrite.h | 105 + gfx/2d/ScaledFontFontconfig.cpp | 550 ++ gfx/2d/ScaledFontFontconfig.h | 91 + gfx/2d/ScaledFontFreeType.cpp | 139 + gfx/2d/ScaledFontFreeType.h | 74 + gfx/2d/ScaledFontMac.cpp | 796 +++ gfx/2d/ScaledFontMac.h | 102 + gfx/2d/ScaledFontWin.cpp | 121 + gfx/2d/ScaledFontWin.h | 46 + gfx/2d/ShadersD2D.fx | 824 +++ gfx/2d/ShadersD2D.h | 10855 +++++++++++++++++++++++++++++++ gfx/2d/ShadersD2D1.h | 1186 ++++ gfx/2d/ShadersD2D1.hlsl | 162 + gfx/2d/SkConvolver.cpp | 559 ++ gfx/2d/SkConvolver.h | 169 + gfx/2d/SourceSurfaceCairo.cpp | 129 + gfx/2d/SourceSurfaceCairo.h | 71 + gfx/2d/SourceSurfaceD2D1.cpp | 245 + gfx/2d/SourceSurfaceD2D1.h | 102 + gfx/2d/SourceSurfaceRawData.cpp | 72 + gfx/2d/SourceSurfaceRawData.h | 129 + gfx/2d/SourceSurfaceSkia.cpp | 228 + gfx/2d/SourceSurfaceSkia.h | 78 + gfx/2d/StackArray.h | 33 + gfx/2d/Swizzle.cpp | 1574 +++++ gfx/2d/Swizzle.h | 112 + gfx/2d/SwizzleAVX2.cpp | 83 + gfx/2d/SwizzleNEON.cpp | 451 ++ gfx/2d/SwizzleSSE2.cpp | 391 ++ gfx/2d/SwizzleSSSE3.cpp | 65 + gfx/2d/Tools.h | 198 + gfx/2d/Triangle.h | 61 + gfx/2d/Types.cpp | 102 + gfx/2d/Types.h | 1135 ++++ gfx/2d/UnscaledFontDWrite.h | 59 + gfx/2d/UnscaledFontFreeType.cpp | 242 + gfx/2d/UnscaledFontFreeType.h | 110 + gfx/2d/UnscaledFontGDI.h | 46 + gfx/2d/UnscaledFontMac.h | 94 + gfx/2d/UserData.h | 214 + gfx/2d/dw-extra.h | 136 + gfx/2d/genshaders.sh | 12 + gfx/2d/gfx2d.sln | 29 + gfx/2d/gfx2d.vcxproj | 139 + gfx/2d/moz.build | 236 + gfx/2d/ssse3-scaler.c | 527 ++ gfx/2d/ssse3-scaler.h | 24 + gfx/2d/unittest/Main.cpp | 51 + gfx/2d/unittest/SanityChecks.cpp | 15 + gfx/2d/unittest/SanityChecks.h | 16 + gfx/2d/unittest/TestBase.cpp | 44 + gfx/2d/unittest/TestBase.h | 53 + gfx/2d/unittest/TestBugs.cpp | 80 + gfx/2d/unittest/TestBugs.h | 17 + gfx/2d/unittest/TestCairo.cpp | 99 + gfx/2d/unittest/TestDrawTargetBase.cpp | 103 + gfx/2d/unittest/TestDrawTargetBase.h | 38 + gfx/2d/unittest/TestDrawTargetD2D.cpp | 22 + gfx/2d/unittest/TestDrawTargetD2D.h | 19 + gfx/2d/unittest/TestPoint.cpp | 53 + gfx/2d/unittest/TestPoint.h | 18 + gfx/2d/unittest/TestScaling.cpp | 235 + gfx/2d/unittest/TestScaling.h | 22 + gfx/2d/unittest/unittest.vcxproj | 94 + 199 files changed, 76004 insertions(+) create mode 100644 gfx/2d/2D.h create mode 100644 gfx/2d/AutoHelpersWin.h create mode 100644 gfx/2d/BaseCoord.h create mode 100644 gfx/2d/BaseMargin.h create mode 100644 gfx/2d/BasePoint.h create mode 100644 gfx/2d/BasePoint3D.h create mode 100644 gfx/2d/BasePoint4D.h create mode 100644 gfx/2d/BaseRect.h create mode 100644 gfx/2d/BaseSize.h create mode 100644 gfx/2d/BezierUtils.cpp create mode 100644 gfx/2d/BezierUtils.h create mode 100644 gfx/2d/BigEndianInts.h create mode 100644 gfx/2d/Blur.cpp create mode 100644 gfx/2d/Blur.h create mode 100644 gfx/2d/BlurLS3.cpp create mode 100644 gfx/2d/BlurNEON.cpp create mode 100644 gfx/2d/BlurSSE2.cpp create mode 100644 gfx/2d/BorrowedContext.h create mode 100644 gfx/2d/BufferEdgePad.cpp create mode 100644 gfx/2d/BufferEdgePad.h create mode 100644 gfx/2d/BufferUnrotate.cpp create mode 100644 gfx/2d/BufferUnrotate.h create mode 100644 gfx/2d/ConicGradientEffectD2D1.cpp create mode 100644 gfx/2d/ConicGradientEffectD2D1.h create mode 100644 gfx/2d/ConvolutionFilter.cpp create mode 100644 gfx/2d/ConvolutionFilter.h create mode 100644 gfx/2d/ConvolutionFilterAVX2.cpp create mode 100644 gfx/2d/ConvolutionFilterNEON.cpp create mode 100644 gfx/2d/ConvolutionFilterSSE2.cpp create mode 100644 gfx/2d/Coord.h create mode 100644 gfx/2d/CriticalSection.h create mode 100644 gfx/2d/DWriteSettings.cpp create mode 100644 gfx/2d/DWriteSettings.h create mode 100644 gfx/2d/DataSourceSurface.cpp create mode 100644 gfx/2d/DataSourceSurfaceWrapper.h create mode 100644 gfx/2d/DataSurfaceHelpers.cpp create mode 100644 gfx/2d/DataSurfaceHelpers.h create mode 100644 gfx/2d/DrawEventRecorder.cpp create mode 100644 gfx/2d/DrawEventRecorder.h create mode 100644 gfx/2d/DrawTarget.cpp create mode 100644 gfx/2d/DrawTargetCairo.cpp create mode 100644 gfx/2d/DrawTargetCairo.h create mode 100644 gfx/2d/DrawTargetD2D1.cpp create mode 100644 gfx/2d/DrawTargetD2D1.h create mode 100644 gfx/2d/DrawTargetOffset.cpp create mode 100644 gfx/2d/DrawTargetOffset.h create mode 100644 gfx/2d/DrawTargetRecording.cpp create mode 100644 gfx/2d/DrawTargetRecording.h create mode 100644 gfx/2d/DrawTargetSkia.cpp create mode 100644 gfx/2d/DrawTargetSkia.h create mode 100644 gfx/2d/ExtendInputEffectD2D1.cpp create mode 100644 gfx/2d/ExtendInputEffectD2D1.h create mode 100644 gfx/2d/Factory.cpp create mode 100644 gfx/2d/FilterNodeD2D1.cpp create mode 100644 gfx/2d/FilterNodeD2D1.h create mode 100644 gfx/2d/FilterNodeSoftware.cpp create mode 100644 gfx/2d/FilterNodeSoftware.h create mode 100644 gfx/2d/FilterProcessing.cpp create mode 100644 gfx/2d/FilterProcessing.h create mode 100644 gfx/2d/FilterProcessingSIMD-inl.h create mode 100644 gfx/2d/FilterProcessingSSE2.cpp create mode 100644 gfx/2d/FilterProcessingScalar.cpp create mode 100644 gfx/2d/Filters.h create mode 100644 gfx/2d/FontVariation.h create mode 100644 gfx/2d/GenericRefCounted.h create mode 100644 gfx/2d/GradientStopsD2D.h create mode 100644 gfx/2d/Helpers.h create mode 100644 gfx/2d/HelpersCairo.h create mode 100644 gfx/2d/HelpersD2D.h create mode 100644 gfx/2d/HelpersSkia.h create mode 100644 gfx/2d/HelpersWinFonts.h create mode 100644 gfx/2d/ImageScaling.cpp create mode 100644 gfx/2d/ImageScaling.h create mode 100644 gfx/2d/ImageScalingSSE2.cpp create mode 100644 gfx/2d/InlineTranslator.cpp create mode 100644 gfx/2d/InlineTranslator.h create mode 100644 gfx/2d/IterableArena.h create mode 100644 gfx/2d/Logging.h create mode 100644 gfx/2d/LoggingConstants.h create mode 100644 gfx/2d/LuminanceNEON.cpp create mode 100644 gfx/2d/LuminanceNEON.h create mode 100644 gfx/2d/MMIHelpers.h create mode 100644 gfx/2d/MacIOSurface.cpp create mode 100644 gfx/2d/MacIOSurface.h create mode 100644 gfx/2d/Matrix.cpp create mode 100644 gfx/2d/Matrix.h create mode 100644 gfx/2d/MatrixFwd.h create mode 100644 gfx/2d/NativeFontResource.cpp create mode 100644 gfx/2d/NativeFontResourceDWrite.cpp create mode 100644 gfx/2d/NativeFontResourceDWrite.h create mode 100644 gfx/2d/NativeFontResourceFreeType.cpp create mode 100644 gfx/2d/NativeFontResourceFreeType.h create mode 100644 gfx/2d/NativeFontResourceGDI.cpp create mode 100644 gfx/2d/NativeFontResourceGDI.h create mode 100644 gfx/2d/NativeFontResourceMac.cpp create mode 100644 gfx/2d/NativeFontResourceMac.h create mode 100644 gfx/2d/NumericTools.h create mode 100644 gfx/2d/Path.cpp create mode 100644 gfx/2d/PathAnalysis.h create mode 100644 gfx/2d/PathCairo.cpp create mode 100644 gfx/2d/PathCairo.h create mode 100644 gfx/2d/PathD2D.cpp create mode 100644 gfx/2d/PathD2D.h create mode 100644 gfx/2d/PathHelpers.cpp create mode 100644 gfx/2d/PathHelpers.h create mode 100644 gfx/2d/PathRecording.cpp create mode 100644 gfx/2d/PathRecording.h create mode 100644 gfx/2d/PathSkia.cpp create mode 100644 gfx/2d/PathSkia.h create mode 100644 gfx/2d/PatternHelpers.h create mode 100644 gfx/2d/Point.h create mode 100644 gfx/2d/Polygon.h create mode 100644 gfx/2d/QuartzSupport.h create mode 100644 gfx/2d/QuartzSupport.mm create mode 100644 gfx/2d/Quaternion.cpp create mode 100644 gfx/2d/Quaternion.h create mode 100644 gfx/2d/RadialGradientEffectD2D1.cpp create mode 100644 gfx/2d/RadialGradientEffectD2D1.h create mode 100644 gfx/2d/RecordedEvent.cpp create mode 100644 gfx/2d/RecordedEvent.h create mode 100644 gfx/2d/RecordedEventImpl.h create mode 100644 gfx/2d/RecordingTypes.h create mode 100644 gfx/2d/Rect.h create mode 100644 gfx/2d/RectAbsolute.h create mode 100644 gfx/2d/SFNTData.cpp create mode 100644 gfx/2d/SFNTData.h create mode 100644 gfx/2d/SIMD.h create mode 100644 gfx/2d/SSEHelpers.h create mode 100644 gfx/2d/SVGTurbulenceRenderer-inl.h create mode 100644 gfx/2d/Scale.h create mode 100644 gfx/2d/ScaleFactor.h create mode 100644 gfx/2d/ScaleFactors2D.h create mode 100644 gfx/2d/ScaledFontBase.cpp create mode 100644 gfx/2d/ScaledFontBase.h create mode 100644 gfx/2d/ScaledFontDWrite.cpp create mode 100644 gfx/2d/ScaledFontDWrite.h create mode 100644 gfx/2d/ScaledFontFontconfig.cpp create mode 100644 gfx/2d/ScaledFontFontconfig.h create mode 100644 gfx/2d/ScaledFontFreeType.cpp create mode 100644 gfx/2d/ScaledFontFreeType.h create mode 100644 gfx/2d/ScaledFontMac.cpp create mode 100644 gfx/2d/ScaledFontMac.h create mode 100644 gfx/2d/ScaledFontWin.cpp create mode 100644 gfx/2d/ScaledFontWin.h create mode 100644 gfx/2d/ShadersD2D.fx create mode 100644 gfx/2d/ShadersD2D.h create mode 100644 gfx/2d/ShadersD2D1.h create mode 100644 gfx/2d/ShadersD2D1.hlsl create mode 100644 gfx/2d/SkConvolver.cpp create mode 100644 gfx/2d/SkConvolver.h create mode 100644 gfx/2d/SourceSurfaceCairo.cpp create mode 100644 gfx/2d/SourceSurfaceCairo.h create mode 100644 gfx/2d/SourceSurfaceD2D1.cpp create mode 100644 gfx/2d/SourceSurfaceD2D1.h create mode 100644 gfx/2d/SourceSurfaceRawData.cpp create mode 100644 gfx/2d/SourceSurfaceRawData.h create mode 100644 gfx/2d/SourceSurfaceSkia.cpp create mode 100644 gfx/2d/SourceSurfaceSkia.h create mode 100644 gfx/2d/StackArray.h create mode 100644 gfx/2d/Swizzle.cpp create mode 100644 gfx/2d/Swizzle.h create mode 100644 gfx/2d/SwizzleAVX2.cpp create mode 100644 gfx/2d/SwizzleNEON.cpp create mode 100644 gfx/2d/SwizzleSSE2.cpp create mode 100644 gfx/2d/SwizzleSSSE3.cpp create mode 100644 gfx/2d/Tools.h create mode 100644 gfx/2d/Triangle.h create mode 100644 gfx/2d/Types.cpp create mode 100644 gfx/2d/Types.h create mode 100644 gfx/2d/UnscaledFontDWrite.h create mode 100644 gfx/2d/UnscaledFontFreeType.cpp create mode 100644 gfx/2d/UnscaledFontFreeType.h create mode 100644 gfx/2d/UnscaledFontGDI.h create mode 100644 gfx/2d/UnscaledFontMac.h create mode 100644 gfx/2d/UserData.h create mode 100644 gfx/2d/dw-extra.h create mode 100644 gfx/2d/genshaders.sh create mode 100644 gfx/2d/gfx2d.sln create mode 100644 gfx/2d/gfx2d.vcxproj create mode 100644 gfx/2d/moz.build create mode 100644 gfx/2d/ssse3-scaler.c create mode 100644 gfx/2d/ssse3-scaler.h create mode 100644 gfx/2d/unittest/Main.cpp create mode 100644 gfx/2d/unittest/SanityChecks.cpp create mode 100644 gfx/2d/unittest/SanityChecks.h create mode 100644 gfx/2d/unittest/TestBase.cpp create mode 100644 gfx/2d/unittest/TestBase.h create mode 100644 gfx/2d/unittest/TestBugs.cpp create mode 100644 gfx/2d/unittest/TestBugs.h create mode 100644 gfx/2d/unittest/TestCairo.cpp create mode 100644 gfx/2d/unittest/TestDrawTargetBase.cpp create mode 100644 gfx/2d/unittest/TestDrawTargetBase.h create mode 100644 gfx/2d/unittest/TestDrawTargetD2D.cpp create mode 100644 gfx/2d/unittest/TestDrawTargetD2D.h create mode 100644 gfx/2d/unittest/TestPoint.cpp create mode 100644 gfx/2d/unittest/TestPoint.h create mode 100644 gfx/2d/unittest/TestScaling.cpp create mode 100644 gfx/2d/unittest/TestScaling.h create mode 100644 gfx/2d/unittest/unittest.vcxproj (limited to 'gfx/2d') diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h new file mode 100644 index 0000000000..3f16e39445 --- /dev/null +++ b/gfx/2d/2D.h @@ -0,0 +1,2283 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _MOZILLA_GFX_2D_H +#define _MOZILLA_GFX_2D_H + +#include "Types.h" +#include "Point.h" +#include "Rect.h" +#include "Matrix.h" +#include "Quaternion.h" +#include "UserData.h" +#include "FontVariation.h" +#include + +// GenericRefCountedBase allows us to hold on to refcounted objects of any type +// (contrary to RefCounted which requires knowing the type T) and, in +// particular, without having a dependency on that type. This is used for +// DrawTargetSkia to be able to hold on to a GLContext. +#include "mozilla/GenericRefCounted.h" +#include "mozilla/MemoryReporting.h" +#include "mozilla/Path.h" + +// This RefPtr class isn't ideal for usage in Azure, as it doesn't allow T** +// outparams using the &-operator. But it will have to do as there's no easy +// solution. +#include "mozilla/RefPtr.h" +#include "mozilla/StaticMutex.h" +#include "mozilla/StaticPtr.h" +#include "mozilla/ThreadSafeWeakPtr.h" +#include "mozilla/Atomics.h" + +#include "mozilla/DebugOnly.h" + +#include "nsRegionFwd.h" + +#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK) +# ifndef MOZ_ENABLE_FREETYPE +# define MOZ_ENABLE_FREETYPE +# endif +#endif + +struct _cairo_surface; +typedef _cairo_surface cairo_surface_t; + +struct _cairo_scaled_font; +typedef _cairo_scaled_font cairo_scaled_font_t; + +struct FT_LibraryRec_; +typedef FT_LibraryRec_* FT_Library; + +struct FT_FaceRec_; +typedef FT_FaceRec_* FT_Face; + +typedef int FT_Error; + +struct _FcPattern; +typedef _FcPattern FcPattern; + +struct ID3D11Texture2D; +struct ID3D11Device; +struct ID2D1Device; +struct ID2D1DeviceContext; +struct ID2D1Multithread; +struct IDWriteFactory; +struct IDWriteRenderingParams; +struct IDWriteFontFace; +struct IDWriteFontCollection; + +class SkCanvas; +struct gfxFontStyle; + +struct CGContext; +typedef struct CGContext* CGContextRef; + +struct CGFont; +typedef CGFont* CGFontRef; + +namespace mozilla { + +class Mutex; + +namespace layers { +class TextureData; +} + +namespace wr { +struct FontInstanceOptions; +struct FontInstancePlatformOptions; +} // namespace wr + +namespace gfx { +class UnscaledFont; +class ScaledFont; +} // namespace gfx + +namespace gfx { + +class AlphaBoxBlur; +class ScaledFont; +class SourceSurface; +class DataSourceSurface; +class DrawTarget; +class DrawEventRecorder; +class FilterNode; +class LogForwarder; + +struct NativeSurface { + NativeSurfaceType mType; + SurfaceFormat mFormat; + gfx::IntSize mSize; + void* mSurface; +}; + +/** + * This structure is used to send draw options that are universal to all drawing + * operations. + */ +struct DrawOptions { + /// For constructor parameter description, see member data documentation. + explicit DrawOptions(Float aAlpha = 1.0f, + CompositionOp aCompositionOp = CompositionOp::OP_OVER, + AntialiasMode aAntialiasMode = AntialiasMode::DEFAULT) + : mAlpha(aAlpha), + mCompositionOp(aCompositionOp), + mAntialiasMode(aAntialiasMode) {} + + Float mAlpha; /**< Alpha value by which the mask generated by this + operation is multiplied. */ + CompositionOp mCompositionOp; /**< The operator that indicates how the source + and destination patterns are blended. */ + AntialiasMode mAntialiasMode; /**< The AntiAlias mode used for this drawing + operation. */ +}; + +struct StoredStrokeOptions; + +/** + * This structure is used to send stroke options that are used in stroking + * operations. + */ +struct StrokeOptions { + /// For constructor parameter description, see member data documentation. + explicit StrokeOptions(Float aLineWidth = 1.0f, + JoinStyle aLineJoin = JoinStyle::MITER_OR_BEVEL, + CapStyle aLineCap = CapStyle::BUTT, + Float aMiterLimit = 10.0f, size_t aDashLength = 0, + const Float* aDashPattern = 0, Float aDashOffset = 0.f) + : mLineWidth(aLineWidth), + mMiterLimit(aMiterLimit), + mDashPattern(aDashLength > 0 ? aDashPattern : 0), + mDashLength(aDashLength), + mDashOffset(aDashOffset), + mLineJoin(aLineJoin), + mLineCap(aLineCap) { + MOZ_ASSERT(aDashLength == 0 || aDashPattern); + } + + Float mLineWidth; //!< Width of the stroke in userspace. + Float mMiterLimit; //!< Miter limit in units of linewidth + const Float* mDashPattern; /**< Series of on/off userspace lengths defining + dash. Owned by the caller; must live at least as + long as this StrokeOptions. + mDashPattern != null <=> mDashLength > 0. */ + size_t mDashLength; //!< Number of on/off lengths in mDashPattern. + Float mDashOffset; /**< Userspace offset within mDashPattern at which + stroking begins. */ + JoinStyle mLineJoin; //!< Join style used for joining lines. + CapStyle mLineCap; //!< Cap style used for capping lines. + + StoredStrokeOptions* Clone() const; + + bool operator==(const StrokeOptions& aOther) const { + return mLineWidth == aOther.mLineWidth && + mMiterLimit == aOther.mMiterLimit && + mDashLength == aOther.mDashLength && + (!mDashLength || (mDashPattern && aOther.mDashPattern && + !memcmp(mDashPattern, aOther.mDashPattern, + mDashLength * sizeof(Float)))) && + mDashOffset == aOther.mDashOffset && mLineJoin == aOther.mLineJoin && + mLineCap == aOther.mLineCap; + } +}; + +/** + * Heap-allocated variation of StrokeOptions that ensures dash patterns are + * properly allocated and destroyed even if the source was stack-allocated. + */ +struct StoredStrokeOptions : public StrokeOptions { + explicit StoredStrokeOptions(const StrokeOptions& aOptions) + : StrokeOptions(aOptions) { + if (mDashLength) { + Float* pattern = new Float[mDashLength]; + memcpy(pattern, mDashPattern, mDashLength * sizeof(Float)); + mDashPattern = pattern; + } + } + + ~StoredStrokeOptions() { + if (mDashPattern) { + delete[] mDashPattern; + } + } +}; + +inline StoredStrokeOptions* StrokeOptions::Clone() const { + return new StoredStrokeOptions(*this); +} + +/** + * This structure supplies additional options for calls to DrawSurface. + */ +struct DrawSurfaceOptions { + /// For constructor parameter description, see member data documentation. + explicit DrawSurfaceOptions( + SamplingFilter aSamplingFilter = SamplingFilter::LINEAR, + SamplingBounds aSamplingBounds = SamplingBounds::UNBOUNDED) + : mSamplingFilter(aSamplingFilter), mSamplingBounds(aSamplingBounds) {} + + SamplingFilter + mSamplingFilter; /**< SamplingFilter used when resampling source surface + region to the destination region. */ + SamplingBounds mSamplingBounds; /**< This indicates whether the implementation + is allowed to sample pixels outside the + source rectangle as specified in + DrawSurface on the surface. */ +}; + +/** + * ShadowOptions supplies options necessary for describing the appearance of a + * a shadow in draw calls that use shadowing. + */ +struct ShadowOptions { + explicit ShadowOptions(const DeviceColor& aColor = DeviceColor(0.0f, 0.0f, + 0.0f), + const Point& aOffset = Point(), Float aSigma = 0.0f) + : mColor(aColor), mOffset(aOffset), mSigma(aSigma) {} + + DeviceColor mColor; /**< Color of the drawn shadow. */ + Point mOffset; /**< Offset of the shadow. */ + Float mSigma; /**< Sigma used for the Gaussian filter kernel. */ + + int32_t BlurRadius() const; +}; + +/** + * This class is used to store gradient stops, it can only be used with a + * matching DrawTarget. Not adhering to this condition will make a draw call + * fail. + */ +class GradientStops : public SupportsThreadSafeWeakPtr { + public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GradientStops) + virtual ~GradientStops() = default; + + virtual BackendType GetBackendType() const = 0; + virtual bool IsValid() const { return true; } + + protected: + GradientStops() = default; +}; + +/** + * This is the base class for 'patterns'. Patterns describe the pixels used as + * the source for a masked composition operation that is done by the different + * drawing commands. These objects are not backend specific, however for + * example the gradient stops on a gradient pattern can be backend specific. + */ +class Pattern { + public: + virtual ~Pattern() = default; + + virtual PatternType GetType() const = 0; + + /** Instantiate a new clone with the same pattern type and values. Any + * internal strong references will be converted to weak references. */ + virtual Pattern* CloneWeak() const { return nullptr; } + + /** Whether the pattern holds an internal weak reference. */ + virtual bool IsWeak() const { return false; } + + /** Whether any internal weak references still point to a target. */ + virtual bool IsValid() const { return true; } + + /** Determine if the pattern type and values exactly match. */ + virtual bool operator==(const Pattern& aOther) const = 0; + + bool operator!=(const Pattern& aOther) const { return !(*this == aOther); } + + protected: + Pattern() = default; + + // Utility functions to check if a weak reference is still valid. + template + static inline bool IsRefValid(const RefPtr& aPtr) { + // RefPtrs are always valid. + return true; + } + + template + static inline bool IsRefValid(const ThreadSafeWeakPtr& aPtr) { + // Weak refs are only valid if they aren't dead. + return !aPtr.IsDead(); + } +}; + +class ColorPattern : public Pattern { + public: + // Explicit because consumers should generally use ToDeviceColor when + // creating a ColorPattern. + explicit ColorPattern(const DeviceColor& aColor) : mColor(aColor) {} + + PatternType GetType() const override { return PatternType::COLOR; } + + Pattern* CloneWeak() const override { return new ColorPattern(mColor); } + + bool operator==(const Pattern& aOther) const override { + if (aOther.GetType() != PatternType::COLOR) { + return false; + } + const ColorPattern& other = static_cast(aOther); + return mColor == other.mColor; + } + + DeviceColor mColor; +}; + +/** + * This class is used for Linear Gradient Patterns, the gradient stops are + * stored in a separate object and are backend dependent. This class itself + * may be used on the stack. + */ +template