@shopify/react-native-skia 0.1.192 → 0.1.193
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +1 -1
- package/android/build.gradle +1 -0
- package/android/cpp/jni/JniPlatformContext.cpp +1 -1
- package/cpp/api/JsiSkImage.h +25 -4
- package/cpp/api/JsiSkImageFactory.h +2 -2
- package/cpp/api/JsiSkPath.h +8 -6
- package/cpp/rnskia/dom/base/Declaration.h +5 -7
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +1 -0
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +2 -2
- package/cpp/rnskia/dom/props/BoxShadowProps.h +2 -0
- package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +2 -8
- package/cpp/skia/include/android/SkImageAndroid.h +101 -0
- package/cpp/skia/include/codec/SkAndroidCodec.h +26 -8
- package/cpp/skia/include/codec/SkCodec.h +31 -17
- package/cpp/skia/include/codec/SkEncodedImageFormat.h +36 -0
- package/cpp/skia/include/codec/SkPixmapUtils.h +31 -0
- package/cpp/skia/include/config/SkUserConfig.h +61 -29
- package/cpp/skia/include/core/SkBitmap.h +25 -25
- package/cpp/skia/include/core/SkBlurTypes.h +0 -2
- package/cpp/skia/include/core/SkCanvas.h +32 -15
- package/cpp/skia/include/core/SkCapabilities.h +2 -2
- package/cpp/skia/include/core/SkColor.h +2 -0
- package/cpp/skia/include/core/SkColorPriv.h +19 -4
- package/cpp/skia/include/core/SkColorSpace.h +14 -17
- package/cpp/skia/include/core/SkColorType.h +1 -0
- package/cpp/skia/include/core/SkContourMeasure.h +1 -1
- package/cpp/skia/include/core/SkCoverageMode.h +0 -2
- package/cpp/skia/include/core/SkCubicMap.h +2 -0
- package/cpp/skia/include/core/SkData.h +5 -2
- package/cpp/skia/include/core/SkDataTable.h +6 -2
- package/cpp/skia/include/core/SkDeferredDisplayList.h +11 -10
- package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +9 -8
- package/cpp/skia/include/core/SkDrawable.h +10 -2
- package/cpp/skia/include/core/SkEncodedImageFormat.h +3 -30
- package/cpp/skia/include/core/SkFlattenable.h +4 -2
- package/cpp/skia/include/core/SkFont.h +1 -0
- package/cpp/skia/include/core/SkFontMetrics.h +1 -0
- package/cpp/skia/include/core/SkFontMgr.h +20 -29
- package/cpp/skia/include/core/SkFontStyle.h +4 -1
- package/cpp/skia/include/core/SkGraphics.h +21 -18
- package/cpp/skia/include/core/SkICC.h +3 -13
- package/cpp/skia/include/core/SkImage.h +395 -717
- package/cpp/skia/include/core/SkImageGenerator.h +19 -74
- package/cpp/skia/include/core/SkImageInfo.h +7 -5
- package/cpp/skia/include/core/SkM44.h +11 -0
- package/cpp/skia/include/core/SkMaskFilter.h +6 -3
- package/cpp/skia/include/core/SkMatrix.h +14 -4
- package/cpp/skia/include/core/SkMesh.h +52 -18
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPaint.h +11 -34
- package/cpp/skia/include/core/SkPath.h +23 -4
- package/cpp/skia/include/core/SkPathBuilder.h +13 -5
- package/cpp/skia/include/core/SkPathMeasure.h +1 -1
- package/cpp/skia/include/core/SkPathTypes.h +0 -2
- package/cpp/skia/include/core/SkPathUtils.h +42 -0
- package/cpp/skia/include/core/SkPicture.h +3 -2
- package/cpp/skia/include/core/SkPictureRecorder.h +2 -0
- package/cpp/skia/include/core/SkPixelRef.h +4 -8
- package/cpp/skia/include/core/SkPixmap.h +12 -20
- package/cpp/skia/include/core/SkPoint.h +4 -2
- package/cpp/skia/include/core/SkPromiseImageTexture.h +2 -2
- package/cpp/skia/include/core/SkRRect.h +5 -1
- package/cpp/skia/include/core/SkRect.h +6 -3
- package/cpp/skia/include/core/SkRefCnt.h +9 -14
- package/cpp/skia/include/core/SkRegion.h +1 -1
- package/cpp/skia/include/core/SkScalar.h +2 -4
- package/cpp/skia/include/core/SkSerialProcs.h +18 -10
- package/cpp/skia/include/core/SkShader.h +1 -64
- package/cpp/skia/include/core/SkSize.h +2 -0
- package/cpp/skia/include/core/SkSpan.h +4 -112
- package/cpp/skia/include/core/SkStream.h +11 -12
- package/cpp/skia/include/core/SkString.h +9 -25
- package/cpp/skia/include/core/SkStrokeRec.h +1 -1
- package/cpp/skia/include/core/SkSurface.h +83 -61
- package/cpp/skia/include/core/SkSurfaceCharacterization.h +3 -3
- package/cpp/skia/include/core/SkSurfaceProps.h +9 -1
- package/cpp/skia/include/core/SkTextBlob.h +2 -2
- package/cpp/skia/include/core/SkTextureCompressionType.h +30 -0
- package/cpp/skia/include/core/SkTime.h +1 -1
- package/cpp/skia/include/core/SkTypeface.h +9 -2
- package/cpp/skia/include/core/SkTypes.h +37 -466
- package/cpp/skia/include/core/SkVertices.h +2 -0
- package/cpp/skia/include/core/SkYUVAInfo.h +4 -0
- package/cpp/skia/include/core/SkYUVAPixmaps.h +7 -1
- package/cpp/skia/include/docs/SkPDFDocument.h +12 -1
- package/cpp/skia/include/effects/SkColorMatrix.h +2 -1
- package/cpp/skia/include/effects/SkGradientShader.h +65 -14
- package/cpp/skia/include/effects/SkImageFilters.h +0 -11
- package/cpp/skia/include/effects/SkRuntimeEffect.h +41 -11
- package/cpp/skia/include/encode/SkEncoder.h +7 -3
- package/cpp/skia/include/encode/SkICC.h +36 -0
- package/cpp/skia/include/encode/SkJpegEncoder.h +102 -71
- package/cpp/skia/include/encode/SkPngEncoder.h +89 -71
- package/cpp/skia/include/encode/SkWebpEncoder.h +65 -38
- package/cpp/skia/include/gpu/GpuTypes.h +23 -1
- package/cpp/skia/include/gpu/GrBackendSurface.h +9 -7
- package/cpp/skia/include/gpu/GrContextOptions.h +28 -9
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +6 -4
- package/cpp/skia/include/gpu/GrDirectContext.h +84 -63
- package/cpp/skia/include/gpu/GrDriverBugWorkarounds.h +2 -1
- package/cpp/skia/include/gpu/GrRecordingContext.h +9 -5
- package/cpp/skia/include/gpu/GrTypes.h +18 -18
- package/cpp/skia/include/gpu/d3d/GrD3DTypes.h +4 -4
- package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +3 -3
- package/cpp/skia/include/gpu/ganesh/GrTextureGenerator.h +77 -0
- package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +385 -0
- package/cpp/skia/include/gpu/gl/GrGLExtensions.h +3 -3
- package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -1
- package/cpp/skia/include/gpu/gl/GrGLInterface.h +0 -3
- package/cpp/skia/include/gpu/gl/GrGLTypes.h +2 -1
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +72 -3
- package/cpp/skia/include/gpu/graphite/Context.h +85 -32
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +15 -11
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +55 -5
- package/cpp/skia/include/gpu/graphite/ImageProvider.h +6 -4
- package/cpp/skia/include/gpu/graphite/Recorder.h +41 -11
- package/cpp/skia/include/gpu/graphite/Recording.h +50 -3
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +47 -8
- package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +139 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +40 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +28 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +1 -1
- package/cpp/skia/include/gpu/graphite/mtl/{MtlTypes.h → MtlGraphiteTypes.h} +7 -6
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +27 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +4 -9
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +28 -0
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +17 -13
- package/cpp/skia/include/gpu/mtl/GrMtlTypes.h +2 -2
- package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/GrVkTypes.h +3 -3
- package/cpp/skia/include/gpu/vk/VulkanExtensions.h +3 -3
- package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +5 -7
- package/cpp/skia/include/pathops/SkPathOps.h +3 -3
- package/cpp/skia/include/ports/SkFontMgr_data.h +22 -0
- package/cpp/skia/include/ports/SkFontMgr_indirect.h +14 -14
- package/cpp/skia/include/ports/SkRemotableFontMgr.h +2 -2
- package/cpp/skia/include/ports/SkTypeface_win.h +2 -1
- package/cpp/skia/include/private/SkChecksum.h +32 -7
- package/cpp/skia/include/private/SkColorData.h +1 -26
- package/cpp/skia/include/private/SkGainmapInfo.h +97 -0
- package/cpp/skia/include/private/SkGainmapShader.h +53 -0
- package/cpp/skia/include/private/SkIDChangeListener.h +4 -3
- package/cpp/skia/include/private/SkJpegGainmapEncoder.h +71 -0
- package/cpp/skia/include/private/SkJpegMetadataDecoder.h +61 -0
- package/cpp/skia/include/private/SkOpts_spi.h +3 -1
- package/cpp/skia/include/private/SkPathRef.h +64 -47
- package/cpp/skia/include/private/SkSLDefines.h +5 -5
- package/cpp/skia/include/private/SkSLSampleUsage.h +0 -4
- package/cpp/skia/include/private/SkSpinlock.h +1 -1
- package/cpp/skia/include/private/SkWeakRefCnt.h +3 -0
- package/cpp/skia/include/private/{SingleOwner.h → base/SingleOwner.h} +8 -5
- package/cpp/skia/include/private/base/SkAPI.h +52 -0
- package/cpp/skia/include/private/base/SkAlign.h +39 -0
- package/cpp/skia/include/private/base/SkAlignedStorage.h +32 -0
- package/cpp/skia/include/private/base/SkAssert.h +92 -0
- package/cpp/skia/include/private/base/SkAttributes.h +102 -0
- package/cpp/skia/include/private/base/SkCPUTypes.h +25 -0
- package/cpp/skia/include/private/base/SkContainers.h +46 -0
- package/cpp/skia/include/private/base/SkDebug.h +27 -0
- package/cpp/skia/include/private/{SkDeque.h → base/SkDeque.h} +3 -1
- package/cpp/skia/include/private/base/SkFeatures.h +151 -0
- package/cpp/skia/include/private/{SkFixed.h → base/SkFixed.h} +9 -7
- package/cpp/skia/include/private/{SkFloatBits.h → base/SkFloatBits.h} +2 -3
- package/cpp/skia/include/private/{SkFloatingPoint.h → base/SkFloatingPoint.h} +18 -9
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +63 -0
- package/cpp/skia/include/private/{SkMacros.h → base/SkMacros.h} +17 -2
- package/cpp/skia/include/private/{SkMalloc.h → base/SkMalloc.h} +4 -7
- package/cpp/skia/include/{core → private/base}/SkMath.h +25 -2
- package/cpp/skia/include/private/{SkMutex.h → base/SkMutex.h} +5 -5
- package/cpp/skia/include/private/{SkNoncopyable.h → base/SkNoncopyable.h} +2 -2
- package/cpp/skia/include/private/{SkOnce.h → base/SkOnce.h} +3 -1
- package/cpp/skia/include/private/base/SkPathEnums.h +25 -0
- package/cpp/skia/include/private/{SkSafe32.h → base/SkSafe32.h} +16 -1
- package/cpp/skia/include/private/{SkSemaphore.h → base/SkSemaphore.h} +4 -3
- package/cpp/skia/include/private/base/SkSpan_impl.h +129 -0
- package/cpp/skia/include/private/base/SkTArray.h +694 -0
- package/cpp/skia/include/private/{SkTDArray.h → base/SkTDArray.h} +17 -54
- package/cpp/skia/include/private/{SkTFitsIn.h → base/SkTFitsIn.h} +14 -8
- package/cpp/skia/include/private/{SkTLogic.h → base/SkTLogic.h} +1 -1
- package/cpp/skia/include/private/{SkTemplates.h → base/SkTemplates.h} +63 -88
- package/cpp/skia/include/private/{SkThreadID.h → base/SkThreadID.h} +5 -2
- package/cpp/skia/include/private/{SkTo.h → base/SkTo.h} +13 -2
- package/cpp/skia/include/private/base/SkTypeTraits.h +33 -0
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +130 -0
- package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +5 -9
- package/cpp/skia/include/private/chromium/SkDiscardableMemory.h +70 -0
- package/cpp/skia/include/private/chromium/Slug.h +0 -9
- package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +2 -1
- package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrDawnTypesPriv.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrMockTypesPriv.h +3 -2
- package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +17 -23
- package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +2 -2
- package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +38 -0
- package/cpp/skia/include/private/gpu/graphite/{MtlTypesPriv.h → MtlGraphiteTypesPriv.h} +5 -5
- package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +1 -9
- package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +4 -0
- package/cpp/skia/include/utils/SkCamera.h +1 -1
- package/cpp/skia/include/utils/SkCustomTypeface.h +7 -1
- package/cpp/skia/include/utils/SkNWayCanvas.h +6 -6
- package/cpp/skia/include/utils/SkOrderedFontMgr.h +7 -6
- package/cpp/skia/include/utils/SkPaintFilterCanvas.h +2 -2
- package/cpp/skia/include/utils/SkParsePath.h +1 -1
- package/cpp/skia/modules/skcms/skcms.h +14 -0
- package/cpp/skia/modules/skcms/src/Transform_inl.h +19 -0
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +2 -2
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +72 -2
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -11
- package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +63 -0
- package/cpp/skia/modules/skparagraph/include/TextStyle.h +27 -4
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +13 -13
- package/cpp/skia/modules/skresources/include/SkResources.h +18 -4
- package/cpp/skia/modules/svg/include/SkSVGAttribute.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +2 -2
- package/cpp/skia/modules/svg/include/SkSVGContainer.h +2 -2
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +2 -2
- package/cpp/skia/modules/svg/include/SkSVGGradient.h +2 -2
- package/cpp/skia/modules/svg/include/SkSVGIDMapper.h +2 -2
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
- package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGTypes.h +22 -21
- package/cpp/skia/modules/svg/include/SkSVGValue.h +1 -1
- package/cpp/skia/{include/private → src/core}/SkTHash.h +41 -37
- package/ios/RNSkia-iOS/ViewScreenshotService.mm +1 -1
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/arm64-v8a/libskshaper.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskshaper.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86/libskshaper.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/android/x86_64/libskshaper.a +0 -0
- package/libs/android/x86_64/libsvg.a +0 -0
- package/libs/ios/libskia.xcframework/Info.plist +5 -5
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/react-native-skia.podspec +1 -1
- package/scripts/install-npm.js +11 -1
- package/cpp/skia/include/core/SkImageEncoder.h +0 -71
- package/cpp/skia/include/gpu/GrConfig.h +0 -53
- package/cpp/skia/include/gpu/graphite/CombinationBuilder.h +0 -195
- package/cpp/skia/include/private/SkHalf.h +0 -38
- package/cpp/skia/include/private/SkImageInfoPriv.h +0 -199
- package/cpp/skia/include/private/SkSLIRNode.h +0 -64
- package/cpp/skia/include/private/SkSLLayout.h +0 -144
- package/cpp/skia/include/private/SkSLModifiers.h +0 -178
- package/cpp/skia/include/private/SkSLProgramElement.h +0 -77
- package/cpp/skia/include/private/SkSLProgramKind.h +0 -35
- package/cpp/skia/include/private/SkSLStatement.h +0 -86
- package/cpp/skia/include/private/SkSLString.h +0 -41
- package/cpp/skia/include/private/SkSLSymbol.h +0 -94
- package/cpp/skia/include/private/SkSafe_math.h +0 -52
- package/cpp/skia/include/private/SkStringView.h +0 -51
- package/cpp/skia/include/private/SkTArray.h +0 -655
- package/cpp/skia/include/private/SkUniquePaintParamsID.h +0 -35
- package/cpp/skia/include/private/SkVx.h +0 -1026
- package/cpp/skia/include/sksl/DSL.h +0 -37
- package/cpp/skia/include/sksl/DSLBlock.h +0 -58
- package/cpp/skia/include/sksl/DSLCase.h +0 -62
- package/cpp/skia/include/sksl/DSLCore.h +0 -492
- package/cpp/skia/include/sksl/DSLExpression.h +0 -241
- package/cpp/skia/include/sksl/DSLFunction.h +0 -113
- package/cpp/skia/include/sksl/DSLLayout.h +0 -92
- package/cpp/skia/include/sksl/DSLModifiers.h +0 -69
- package/cpp/skia/include/sksl/DSLStatement.h +0 -82
- package/cpp/skia/include/sksl/DSLSymbols.h +0 -61
- package/cpp/skia/include/sksl/DSLType.h +0 -271
- package/cpp/skia/include/sksl/DSLVar.h +0 -231
- package/cpp/skia/include/sksl/SkSLErrorReporter.h +0 -65
- package/cpp/skia/include/sksl/SkSLOperator.h +0 -154
- package/cpp/skia/include/sksl/SkSLPosition.h +0 -104
- package/cpp/skia/include/utils/SkRandom.h +0 -169
- package/cpp/skia/src/core/SkLRUCache.h +0 -126
- package/cpp/skia/src/core/SkTInternalLList.h +0 -302
- /package/cpp/skia/include/{core → codec}/SkPngChunkReader.h +0 -0
- /package/cpp/skia/include/private/{SkTPin.h → base/SkTPin.h} +0 -0
- /package/cpp/skia/include/private/{SkThreadAnnotations.h → base/SkThreadAnnotations.h} +0 -0
@@ -8,581 +8,252 @@
|
|
8
8
|
#ifndef SkImage_DEFINED
|
9
9
|
#define SkImage_DEFINED
|
10
10
|
|
11
|
+
#include "include/core/SkAlphaType.h"
|
11
12
|
#include "include/core/SkImageInfo.h"
|
13
|
+
#include "include/core/SkRect.h"
|
12
14
|
#include "include/core/SkRefCnt.h"
|
13
|
-
#include "include/core/
|
14
|
-
#include "include/
|
15
|
-
|
16
|
-
#
|
17
|
-
#include "include/core/SkTileMode.h"
|
18
|
-
#if SK_SUPPORT_GPU
|
19
|
-
#include "include/gpu/GrTypes.h"
|
20
|
-
#endif
|
21
|
-
#if defined(SK_GRAPHITE_ENABLED)
|
15
|
+
#include "include/core/SkSize.h"
|
16
|
+
#include "include/private/base/SkAPI.h"
|
17
|
+
|
18
|
+
#if defined(SK_GRAPHITE)
|
22
19
|
#include "include/gpu/graphite/GraphiteTypes.h"
|
20
|
+
class SkYUVAPixmaps;
|
23
21
|
#endif
|
24
|
-
#include <functional> // std::function
|
25
|
-
#include <optional>
|
26
22
|
|
27
|
-
#
|
28
|
-
#include <
|
29
|
-
#
|
23
|
+
#include <cstddef>
|
24
|
+
#include <cstdint>
|
25
|
+
#include <memory>
|
26
|
+
#include <optional>
|
30
27
|
|
31
|
-
class GrBackendFormat;
|
32
|
-
class GrBackendTexture;
|
33
|
-
class GrContextThreadSafeProxy;
|
34
28
|
class GrDirectContext;
|
35
29
|
class GrRecordingContext;
|
36
|
-
class
|
37
|
-
class
|
38
|
-
class SkCanvas;
|
30
|
+
class SkBitmap;
|
31
|
+
class SkColorSpace;
|
39
32
|
class SkData;
|
40
33
|
class SkImage;
|
41
34
|
class SkImageFilter;
|
42
35
|
class SkImageGenerator;
|
36
|
+
class SkMatrix;
|
43
37
|
class SkMipmap;
|
44
38
|
class SkPaint;
|
45
39
|
class SkPicture;
|
46
40
|
class SkPixmap;
|
47
|
-
class
|
48
|
-
class
|
49
|
-
|
41
|
+
class SkShader;
|
42
|
+
class SkSurfaceProps;
|
43
|
+
enum SkColorType : int;
|
44
|
+
enum class SkTextureCompressionType;
|
45
|
+
enum class SkTileMode;
|
50
46
|
|
51
|
-
|
47
|
+
struct SkIPoint;
|
48
|
+
struct SkSamplingOptions;
|
52
49
|
|
53
|
-
#if defined(
|
50
|
+
#if defined(SK_GRAPHITE)
|
54
51
|
namespace skgpu::graphite {
|
55
52
|
class BackendTexture;
|
56
53
|
class Recorder;
|
57
|
-
|
54
|
+
class TextureInfo;
|
55
|
+
enum class Volatile : bool;
|
56
|
+
class YUVABackendTextures;
|
57
|
+
}
|
58
58
|
#endif
|
59
59
|
|
60
|
-
|
61
|
-
SkImage describes a two dimensional array of pixels to draw. The pixels may be
|
62
|
-
decoded in a raster bitmap, encoded in a SkPicture or compressed data stream,
|
63
|
-
or located in GPU memory as a GPU texture.
|
64
|
-
|
65
|
-
SkImage cannot be modified after it is created. SkImage may allocate additional
|
66
|
-
storage as needed; for instance, an encoded SkImage may decode when drawn.
|
60
|
+
namespace SkImages {
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
GPU texture, YUV_ColorSpace data, or hardware buffer. Encoded streams supported
|
73
|
-
include BMP, GIF, HEIF, ICO, JPEG, PNG, WBMP, WebP. Supported encoding details
|
74
|
-
vary with platform.
|
62
|
+
/** Caller data passed to RasterReleaseProc; may be nullptr. */
|
63
|
+
using ReleaseContext = void*;
|
64
|
+
/** Function called when SkImage no longer shares pixels. ReleaseContext is
|
65
|
+
provided by caller when SkImage is created, and may be nullptr.
|
75
66
|
*/
|
76
|
-
|
77
|
-
public:
|
78
|
-
|
79
|
-
/** Caller data passed to RasterReleaseProc; may be nullptr.
|
80
|
-
*/
|
81
|
-
typedef void* ReleaseContext;
|
82
|
-
|
83
|
-
/** Creates SkImage from SkPixmap and copy of pixels. Since pixels are copied, SkPixmap
|
84
|
-
pixels may be modified or deleted without affecting SkImage.
|
85
|
-
|
86
|
-
SkImage is returned if SkPixmap is valid. Valid SkPixmap parameters include:
|
87
|
-
dimensions are greater than zero;
|
88
|
-
each dimension fits in 29 bits;
|
89
|
-
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
90
|
-
row bytes are large enough to hold one row of pixels;
|
91
|
-
pixel address is not nullptr.
|
92
|
-
|
93
|
-
@param pixmap SkImageInfo, pixel address, and row bytes
|
94
|
-
@return copy of SkPixmap pixels, or nullptr
|
67
|
+
using RasterReleaseProc = void(const void* pixels, ReleaseContext);
|
95
68
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
/** Creates SkImage from SkImageInfo, sharing pixels.
|
69
|
+
/** Creates a CPU-backed SkImage from bitmap, sharing or copying bitmap pixels. If the bitmap
|
70
|
+
is marked immutable, and its pixel memory is shareable, it may be shared
|
71
|
+
instead of copied.
|
101
72
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@param info contains width, height, SkAlphaType, SkColorType, SkColorSpace
|
110
|
-
@param pixels address or pixel storage
|
111
|
-
@param rowBytes size of pixel row or larger
|
112
|
-
@return SkImage sharing pixels, or nullptr
|
113
|
-
*/
|
114
|
-
static sk_sp<SkImage> MakeRasterData(const SkImageInfo& info, sk_sp<SkData> pixels,
|
115
|
-
size_t rowBytes);
|
73
|
+
SkImage is returned if bitmap is valid. Valid SkBitmap parameters include:
|
74
|
+
dimensions are greater than zero;
|
75
|
+
each dimension fits in 29 bits;
|
76
|
+
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
77
|
+
row bytes are large enough to hold one row of pixels;
|
78
|
+
pixel address is not nullptr.
|
116
79
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
/** Creates SkImage from pixmap, sharing SkPixmap pixels. Pixels must remain valid and
|
123
|
-
unchanged until rasterReleaseProc is called. rasterReleaseProc is passed
|
124
|
-
releaseContext when SkImage is deleted or no longer refers to pixmap pixels.
|
125
|
-
|
126
|
-
Pass nullptr for rasterReleaseProc to share SkPixmap without requiring a callback
|
127
|
-
when SkImage is released. Pass nullptr for releaseContext if rasterReleaseProc
|
128
|
-
does not require state.
|
129
|
-
|
130
|
-
SkImage is returned if pixmap is valid. Valid SkPixmap parameters include:
|
131
|
-
dimensions are greater than zero;
|
132
|
-
each dimension fits in 29 bits;
|
133
|
-
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
134
|
-
row bytes are large enough to hold one row of pixels;
|
135
|
-
pixel address is not nullptr.
|
136
|
-
|
137
|
-
@param pixmap SkImageInfo, pixel address, and row bytes
|
138
|
-
@param rasterReleaseProc function called when pixels can be released; or nullptr
|
139
|
-
@param releaseContext state passed to rasterReleaseProc; or nullptr
|
140
|
-
@return SkImage sharing pixmap
|
141
|
-
*/
|
142
|
-
static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap,
|
143
|
-
RasterReleaseProc rasterReleaseProc,
|
144
|
-
ReleaseContext releaseContext);
|
145
|
-
|
146
|
-
/** Creates SkImage from bitmap, sharing or copying bitmap pixels. If the bitmap
|
147
|
-
is marked immutable, and its pixel memory is shareable, it may be shared
|
148
|
-
instead of copied.
|
149
|
-
|
150
|
-
SkImage is returned if bitmap is valid. Valid SkBitmap parameters include:
|
151
|
-
dimensions are greater than zero;
|
152
|
-
each dimension fits in 29 bits;
|
153
|
-
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
154
|
-
row bytes are large enough to hold one row of pixels;
|
155
|
-
pixel address is not nullptr.
|
156
|
-
|
157
|
-
@param bitmap SkImageInfo, row bytes, and pixels
|
158
|
-
@return created SkImage, or nullptr
|
159
|
-
|
160
|
-
example: https://fiddle.skia.org/c/@Image_MakeFromBitmap
|
161
|
-
*/
|
162
|
-
static sk_sp<SkImage> MakeFromBitmap(const SkBitmap& bitmap);
|
163
|
-
|
164
|
-
/** Creates SkImage from data returned by imageGenerator. Generated data is owned by SkImage and
|
165
|
-
may not be shared or accessed.
|
166
|
-
|
167
|
-
SkImage is returned if generator data is valid. Valid data parameters vary by type of data
|
168
|
-
and platform.
|
169
|
-
|
170
|
-
imageGenerator may wrap SkPicture data, codec data, or custom data.
|
171
|
-
|
172
|
-
@param imageGenerator stock or custom routines to retrieve SkImage
|
173
|
-
@return created SkImage, or nullptr
|
174
|
-
*/
|
175
|
-
static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator);
|
176
|
-
|
177
|
-
/**
|
178
|
-
* Return an image backed by the encoded data, but attempt to defer decoding until the image
|
179
|
-
* is actually used/drawn. This deferral allows the system to cache the result, either on the
|
180
|
-
* CPU or on the GPU, depending on where the image is drawn. If memory is low, the cache may
|
181
|
-
* be purged, causing the next draw of the image to have to re-decode.
|
182
|
-
*
|
183
|
-
* If alphaType is nullopt, the image's alpha type will be chosen automatically based on the
|
184
|
-
* image format. Transparent images will default to kPremul_SkAlphaType. If alphaType contains
|
185
|
-
* kPremul_SkAlphaType or kUnpremul_SkAlphaType, that alpha type will be used. Forcing opaque
|
186
|
-
* (passing kOpaque_SkAlphaType) is not allowed, and will return nullptr.
|
187
|
-
*
|
188
|
-
* This is similar to DecodeTo[Raster,Texture], but this method will attempt to defer the
|
189
|
-
* actual decode, while the DecodeTo... method explicitly decode and allocate the backend
|
190
|
-
* when the call is made.
|
191
|
-
*
|
192
|
-
* If the encoded format is not supported, nullptr is returned.
|
193
|
-
*
|
194
|
-
* @param encoded the encoded data
|
195
|
-
* @return created SkImage, or nullptr
|
196
|
-
|
197
|
-
example: https://fiddle.skia.org/c/@Image_MakeFromEncoded
|
198
|
-
*/
|
199
|
-
static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded,
|
200
|
-
std::optional<SkAlphaType> alphaType = std::nullopt);
|
201
|
-
|
202
|
-
/*
|
203
|
-
* Experimental:
|
204
|
-
* Skia | GL_COMPRESSED_* | MTLPixelFormat* | VK_FORMAT_*_BLOCK
|
205
|
-
* --------------------------------------------------------------------------------------
|
206
|
-
* kETC2_RGB8_UNORM | ETC1_RGB8 | ETC2_RGB8 (iOS-only) | ETC2_R8G8B8_UNORM
|
207
|
-
* | RGB8_ETC2 | |
|
208
|
-
* --------------------------------------------------------------------------------------
|
209
|
-
* kBC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | N/A | BC1_RGB_UNORM
|
210
|
-
* --------------------------------------------------------------------------------------
|
211
|
-
* kBC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA (macOS-only)| BC1_RGBA_UNORM
|
212
|
-
*/
|
213
|
-
enum class CompressionType {
|
214
|
-
kNone,
|
215
|
-
kETC2_RGB8_UNORM, // the same as ETC1
|
216
|
-
|
217
|
-
kBC1_RGB8_UNORM,
|
218
|
-
kBC1_RGBA8_UNORM,
|
219
|
-
kLast = kBC1_RGBA8_UNORM,
|
220
|
-
};
|
80
|
+
@param bitmap SkImageInfo, row bytes, and pixels
|
81
|
+
@return created SkImage, or nullptr
|
82
|
+
*/
|
83
|
+
SK_API sk_sp<SkImage> RasterFromBitmap(const SkBitmap& bitmap);
|
221
84
|
|
222
|
-
|
85
|
+
/** Creates a CPU-backed SkImage from compressed data.
|
223
86
|
|
224
|
-
|
87
|
+
This method will decompress the compressed data and create an image wrapping
|
88
|
+
it. Any mipmap levels present in the compressed data are discarded.
|
225
89
|
|
226
|
-
|
90
|
+
@param data compressed data to store in SkImage
|
91
|
+
@param width width of full SkImage
|
92
|
+
@param height height of full SkImage
|
93
|
+
@param type type of compression used
|
94
|
+
@return created SkImage, or nullptr
|
95
|
+
*/
|
96
|
+
SK_API sk_sp<SkImage> RasterFromCompressedTextureData(sk_sp<SkData> data,
|
97
|
+
int width,
|
98
|
+
int height,
|
99
|
+
SkTextureCompressionType type);
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Return a SkImage using the encoded data, but attempts to defer decoding until the
|
103
|
+
* image is actually used/drawn. This deferral allows the system to cache the result, either on the
|
104
|
+
* CPU or on the GPU, depending on where the image is drawn. If memory is low, the cache may
|
105
|
+
* be purged, causing the next draw of the image to have to re-decode.
|
106
|
+
*
|
107
|
+
* If alphaType is nullopt, the image's alpha type will be chosen automatically based on the
|
108
|
+
* image format. Transparent images will default to kPremul_SkAlphaType. If alphaType contains
|
109
|
+
* kPremul_SkAlphaType or kUnpremul_SkAlphaType, that alpha type will be used. Forcing opaque
|
110
|
+
* (passing kOpaque_SkAlphaType) is not allowed, and will return nullptr.
|
111
|
+
*
|
112
|
+
* If the encoded format is not supported, nullptr is returned.
|
113
|
+
*
|
114
|
+
* @param encoded the encoded data
|
115
|
+
* @return created SkImage, or nullptr
|
227
116
|
|
228
|
-
|
229
|
-
|
117
|
+
example: https://fiddle.skia.org/c/@Image_DeferredFromEncodedData
|
118
|
+
*/
|
119
|
+
SK_API sk_sp<SkImage> DeferredFromEncodedData(sk_sp<SkData> encoded,
|
120
|
+
std::optional<SkAlphaType> alphaType = std::nullopt);
|
230
121
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
@param type type of compression used
|
235
|
-
@return created SkImage, or nullptr
|
236
|
-
*/
|
237
|
-
static sk_sp<SkImage> MakeRasterFromCompressed(sk_sp<SkData> data,
|
238
|
-
int width, int height,
|
239
|
-
CompressionType type);
|
122
|
+
/** Creates SkImage from data returned by imageGenerator. The image data will not be created
|
123
|
+
(on either the CPU or GPU) until the image is actually drawn.
|
124
|
+
Generated data is owned by SkImage and may not be shared or accessed.
|
240
125
|
|
241
|
-
|
242
|
-
|
243
|
-
kF16, //!< uses 16-bit float per color component
|
244
|
-
};
|
126
|
+
SkImage is returned if generator data is valid. Valid data parameters vary by type of data
|
127
|
+
and platform.
|
245
128
|
|
246
|
-
|
247
|
-
SkImage draws picture with matrix and paint, set to bitDepth and colorSpace.
|
129
|
+
imageGenerator may wrap SkPicture data, codec data, or custom data.
|
248
130
|
|
249
|
-
|
250
|
-
|
131
|
+
@param imageGenerator stock or custom routines to retrieve SkImage
|
132
|
+
@return created SkImage, or nullptr
|
133
|
+
*/
|
134
|
+
SK_API sk_sp<SkImage> DeferredFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator);
|
251
135
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
@param bitDepth 8-bit integer or 16-bit float: per component
|
257
|
-
@param colorSpace range of colors; may be nullptr
|
258
|
-
@param props props to use when rasterizing the picture
|
259
|
-
@return created SkImage, or nullptr
|
260
|
-
*/
|
261
|
-
static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
|
262
|
-
const SkMatrix* matrix, const SkPaint* paint,
|
263
|
-
BitDepth bitDepth, sk_sp<SkColorSpace> colorSpace,
|
264
|
-
SkSurfaceProps props = {});
|
265
|
-
|
266
|
-
#if SK_SUPPORT_GPU
|
267
|
-
/** Creates a GPU-backed SkImage from compressed data.
|
268
|
-
|
269
|
-
This method will return an SkImage representing the compressed data.
|
270
|
-
If the GPU doesn't support the specified compression method, the data
|
271
|
-
will be decompressed and then wrapped in a GPU-backed image.
|
272
|
-
|
273
|
-
Note: one can query the supported compression formats via
|
274
|
-
GrRecordingContext::compressedBackendFormat.
|
275
|
-
|
276
|
-
@param context GPU context
|
277
|
-
@param data compressed data to store in SkImage
|
278
|
-
@param width width of full SkImage
|
279
|
-
@param height height of full SkImage
|
280
|
-
@param type type of compression used
|
281
|
-
@param mipmapped does 'data' contain data for all the mipmap levels?
|
282
|
-
@param isProtected do the contents of 'data' require DRM protection (on Vulkan)?
|
283
|
-
@return created SkImage, or nullptr
|
284
|
-
*/
|
285
|
-
static sk_sp<SkImage> MakeTextureFromCompressed(GrDirectContext* direct,
|
286
|
-
sk_sp<SkData> data,
|
287
|
-
int width, int height,
|
288
|
-
CompressionType type,
|
289
|
-
GrMipmapped mipmapped = GrMipmapped::kNo,
|
290
|
-
GrProtected isProtected = GrProtected::kNo);
|
291
|
-
|
292
|
-
/** User function called when supplied texture may be deleted.
|
293
|
-
*/
|
294
|
-
typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
|
136
|
+
enum class BitDepth {
|
137
|
+
kU8, //!< uses 8-bit unsigned int per color component
|
138
|
+
kF16, //!< uses 16-bit float per color component
|
139
|
+
};
|
295
140
|
|
296
|
-
|
297
|
-
|
298
|
-
passed releaseContext when SkImage is deleted or no longer refers to texture.
|
141
|
+
/** Creates SkImage from picture. Returned SkImage width and height are set by dimensions.
|
142
|
+
SkImage draws picture with matrix and paint, set to bitDepth and colorSpace.
|
299
143
|
|
300
|
-
|
301
|
-
Recognized formats vary by GPU back-end.
|
144
|
+
The Picture data is not turned into an image (CPU or GPU) until it is drawn.
|
302
145
|
|
303
|
-
|
304
|
-
|
146
|
+
If matrix is nullptr, draws with identity SkMatrix. If paint is nullptr, draws
|
147
|
+
with default SkPaint. colorSpace may be nullptr.
|
305
148
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
const GrBackendTexture& backendTexture,
|
321
|
-
GrSurfaceOrigin origin,
|
322
|
-
SkColorType colorType,
|
323
|
-
SkAlphaType alphaType,
|
149
|
+
@param picture stream of drawing commands
|
150
|
+
@param dimensions width and height
|
151
|
+
@param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
|
152
|
+
@param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
|
153
|
+
@param bitDepth 8-bit integer or 16-bit float: per component
|
154
|
+
@param colorSpace range of colors; may be nullptr
|
155
|
+
@param props props to use when rasterizing the picture
|
156
|
+
@return created SkImage, or nullptr
|
157
|
+
*/
|
158
|
+
SK_API sk_sp<SkImage> DeferredFromPicture(sk_sp<SkPicture> picture,
|
159
|
+
const SkISize& dimensions,
|
160
|
+
const SkMatrix* matrix,
|
161
|
+
const SkPaint* paint,
|
162
|
+
BitDepth bitDepth,
|
324
163
|
sk_sp<SkColorSpace> colorSpace,
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
/** Creates SkImage from backendTexture associated with context. backendTexture and
|
394
|
-
returned SkImage are managed internally, and are released when no longer needed.
|
395
|
-
|
396
|
-
SkImage is returned if format of backendTexture is recognized and supported.
|
397
|
-
Recognized formats vary by GPU back-end.
|
398
|
-
|
399
|
-
@param context GPU context
|
400
|
-
@param backendTexture texture residing on GPU
|
401
|
-
@param textureOrigin origin of backendTexture
|
402
|
-
@param colorType color type of the resulting image
|
403
|
-
@param alphaType alpha type of the resulting image
|
404
|
-
@param colorSpace range of colors; may be nullptr
|
405
|
-
@return created SkImage, or nullptr
|
406
|
-
*/
|
407
|
-
static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
|
408
|
-
const GrBackendTexture& backendTexture,
|
409
|
-
GrSurfaceOrigin textureOrigin,
|
410
|
-
SkColorType colorType);
|
411
|
-
static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
|
412
|
-
const GrBackendTexture& backendTexture,
|
413
|
-
GrSurfaceOrigin textureOrigin,
|
414
|
-
SkColorType colorType,
|
415
|
-
SkAlphaType alphaType);
|
416
|
-
static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
|
417
|
-
const GrBackendTexture& backendTexture,
|
418
|
-
GrSurfaceOrigin textureOrigin,
|
419
|
-
SkColorType colorType,
|
420
|
-
SkAlphaType alphaType,
|
421
|
-
sk_sp<SkColorSpace> colorSpace);
|
422
|
-
|
423
|
-
/** Creates an SkImage from YUV[A] planar textures. This requires that the textures stay valid
|
424
|
-
for the lifetime of the image. The ReleaseContext can be used to know when it is safe to
|
425
|
-
either delete or overwrite the textures. If ReleaseProc is provided it is also called before
|
426
|
-
return on failure.
|
427
|
-
|
428
|
-
@param context GPU context
|
429
|
-
@param yuvaTextures A set of textures containing YUVA data and a description of the
|
430
|
-
data and transformation to RGBA.
|
431
|
-
@param imageColorSpace range of colors of the resulting image after conversion to RGB;
|
432
|
-
may be nullptr
|
433
|
-
@param textureReleaseProc called when the backend textures can be released
|
434
|
-
@param releaseContext state passed to textureReleaseProc
|
435
|
-
@return created SkImage, or nullptr
|
436
|
-
*/
|
437
|
-
static sk_sp<SkImage> MakeFromYUVATextures(GrRecordingContext* context,
|
438
|
-
const GrYUVABackendTextures& yuvaTextures,
|
439
|
-
sk_sp<SkColorSpace> imageColorSpace = nullptr,
|
440
|
-
TextureReleaseProc textureReleaseProc = nullptr,
|
441
|
-
ReleaseContext releaseContext = nullptr);
|
442
|
-
|
443
|
-
/** Creates SkImage from SkYUVAPixmaps.
|
444
|
-
|
445
|
-
The image will remain planar with each plane converted to a texture using the passed
|
446
|
-
GrRecordingContext.
|
447
|
-
|
448
|
-
SkYUVAPixmaps has a SkYUVAInfo which specifies the transformation from YUV to RGB.
|
449
|
-
The SkColorSpace of the resulting RGB values is specified by imageColorSpace. This will
|
450
|
-
be the SkColorSpace reported by the image and when drawn the RGB values will be converted
|
451
|
-
from this space into the destination space (if the destination is tagged).
|
452
|
-
|
453
|
-
Currently, this is only supported using the GPU backend and will fail if context is nullptr.
|
164
|
+
SkSurfaceProps props);
|
165
|
+
SK_API sk_sp<SkImage> DeferredFromPicture(sk_sp<SkPicture> picture,
|
166
|
+
const SkISize& dimensions,
|
167
|
+
const SkMatrix* matrix,
|
168
|
+
const SkPaint* paint,
|
169
|
+
BitDepth bitDepth,
|
170
|
+
sk_sp<SkColorSpace> colorSpace);
|
171
|
+
|
172
|
+
/** Creates a CPU-backed SkImage from pixmap, copying the pixel data.
|
173
|
+
As a result, pixmap pixels may be modified or deleted without affecting SkImage.
|
174
|
+
|
175
|
+
SkImage is returned if SkPixmap is valid. Valid SkPixmap parameters include:
|
176
|
+
dimensions are greater than zero;
|
177
|
+
each dimension fits in 29 bits;
|
178
|
+
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
179
|
+
row bytes are large enough to hold one row of pixels;
|
180
|
+
pixel address is not nullptr.
|
181
|
+
|
182
|
+
@param pixmap SkImageInfo, pixel address, and row bytes
|
183
|
+
@return copy of SkPixmap pixels, or nullptr
|
184
|
+
|
185
|
+
example: https://fiddle.skia.org/c/@Image_RasterFromPixmapCopy
|
186
|
+
*/
|
187
|
+
SK_API sk_sp<SkImage> RasterFromPixmapCopy(const SkPixmap& pixmap);
|
188
|
+
|
189
|
+
/** Creates CPU-backed SkImage from pixmap, sharing SkPixmap pixels. Pixels must remain valid and
|
190
|
+
unchanged until rasterReleaseProc is called. rasterReleaseProc is passed
|
191
|
+
releaseContext when SkImage is deleted or no longer refers to pixmap pixels.
|
192
|
+
|
193
|
+
Pass nullptr for rasterReleaseProc to share SkPixmap without requiring a callback
|
194
|
+
when SkImage is released. Pass nullptr for releaseContext if rasterReleaseProc
|
195
|
+
does not require state.
|
196
|
+
|
197
|
+
SkImage is returned if pixmap is valid. Valid SkPixmap parameters include:
|
198
|
+
dimensions are greater than zero;
|
199
|
+
each dimension fits in 29 bits;
|
200
|
+
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
201
|
+
row bytes are large enough to hold one row of pixels;
|
202
|
+
pixel address is not nullptr.
|
203
|
+
|
204
|
+
@param pixmap SkImageInfo, pixel address, and row bytes
|
205
|
+
@param rasterReleaseProc function called when pixels can be released; or nullptr
|
206
|
+
@param releaseContext state passed to rasterReleaseProc; or nullptr
|
207
|
+
@return SkImage sharing pixmap
|
208
|
+
*/
|
209
|
+
SK_API sk_sp<SkImage> RasterFromPixmap(const SkPixmap& pixmap,
|
210
|
+
RasterReleaseProc rasterReleaseProc,
|
211
|
+
ReleaseContext releaseContext);
|
212
|
+
|
213
|
+
/** Creates CPU-backed SkImage from pixel data described by info.
|
214
|
+
The pixels data will *not* be copied.
|
215
|
+
|
216
|
+
SkImage is returned if SkImageInfo is valid. Valid SkImageInfo parameters include:
|
217
|
+
dimensions are greater than zero;
|
218
|
+
each dimension fits in 29 bits;
|
219
|
+
SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType;
|
220
|
+
rowBytes are large enough to hold one row of pixels;
|
221
|
+
pixels is not nullptr, and contains enough data for SkImage.
|
222
|
+
|
223
|
+
@param info contains width, height, SkAlphaType, SkColorType, SkColorSpace
|
224
|
+
@param pixels address or pixel storage
|
225
|
+
@param rowBytes size of pixel row or larger
|
226
|
+
@return SkImage sharing pixels, or nullptr
|
227
|
+
*/
|
228
|
+
SK_API sk_sp<SkImage> RasterFromData(const SkImageInfo& info,
|
229
|
+
sk_sp<SkData> pixels,
|
230
|
+
size_t rowBytes);
|
454
231
|
|
455
|
-
|
232
|
+
} // namespace SkImages
|
456
233
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
silently ignored if the context does not support mip maps.
|
462
|
-
@param limitToMaxTextureSize downscale image to GPU maximum texture size, if necessary
|
463
|
-
@param imageColorSpace range of colors of the resulting image; may be nullptr
|
464
|
-
@return created SkImage, or nullptr
|
465
|
-
*/
|
466
|
-
static sk_sp<SkImage> MakeFromYUVAPixmaps(GrRecordingContext* context,
|
467
|
-
const SkYUVAPixmaps& pixmaps,
|
468
|
-
GrMipmapped buildMips = GrMipmapped::kNo,
|
469
|
-
bool limitToMaxTextureSize = false,
|
470
|
-
sk_sp<SkColorSpace> imageColorSpace = nullptr);
|
471
|
-
|
472
|
-
using PromiseImageTextureContext = void*;
|
473
|
-
using PromiseImageTextureFulfillProc =
|
474
|
-
sk_sp<SkPromiseImageTexture> (*)(PromiseImageTextureContext);
|
475
|
-
using PromiseImageTextureReleaseProc = void (*)(PromiseImageTextureContext);
|
476
|
-
|
477
|
-
/** Create a new SkImage that is very similar to an SkImage created by MakeFromTexture. The
|
478
|
-
difference is that the caller need not have created the texture nor populated it with the
|
479
|
-
image pixel data. Moreover, the SkImage may be created on a thread as the creation of the
|
480
|
-
image does not require access to the backend API or GrDirectContext. Instead of passing a
|
481
|
-
GrBackendTexture the client supplies a description of the texture consisting of
|
482
|
-
GrBackendFormat, width, height, and GrMipmapped state. The resulting SkImage can be drawn
|
483
|
-
to a SkDeferredDisplayListRecorder or directly to a GPU-backed SkSurface.
|
484
|
-
|
485
|
-
When the actual texture is required to perform a backend API draw, textureFulfillProc will
|
486
|
-
be called to receive a GrBackendTexture. The properties of the GrBackendTexture must match
|
487
|
-
those set during the SkImage creation, and it must refer to a valid existing texture in the
|
488
|
-
backend API context/device, and be populated with the image pixel data. The texture cannot
|
489
|
-
be deleted until textureReleaseProc is called.
|
490
|
-
|
491
|
-
There is at most one call to each of textureFulfillProc and textureReleaseProc.
|
492
|
-
textureReleaseProc is always called even if image creation fails or if the
|
493
|
-
image is never fulfilled (e.g. it is never drawn or all draws are clipped out)
|
494
|
-
|
495
|
-
@param gpuContextProxy the thread-safe proxy of the gpu context. required.
|
496
|
-
@param backendFormat format of promised gpu texture
|
497
|
-
@param dimensions width & height of promised gpu texture
|
498
|
-
@param mipmapped mip mapped state of promised gpu texture
|
499
|
-
@param origin surface origin of promised gpu texture
|
500
|
-
@param colorType color type of promised gpu texture
|
501
|
-
@param alphaType alpha type of promised gpu texture
|
502
|
-
@param colorSpace range of colors; may be nullptr
|
503
|
-
@param textureFulfillProc function called to get actual gpu texture
|
504
|
-
@param textureReleaseProc function called when texture can be deleted
|
505
|
-
@param textureContext state passed to textureFulfillProc and textureReleaseProc
|
506
|
-
@return created SkImage, or nullptr
|
507
|
-
*/
|
508
|
-
static sk_sp<SkImage> MakePromiseTexture(sk_sp<GrContextThreadSafeProxy> gpuContextProxy,
|
509
|
-
const GrBackendFormat& backendFormat,
|
510
|
-
SkISize dimensions,
|
511
|
-
GrMipmapped mipmapped,
|
512
|
-
GrSurfaceOrigin origin,
|
513
|
-
SkColorType colorType,
|
514
|
-
SkAlphaType alphaType,
|
515
|
-
sk_sp<SkColorSpace> colorSpace,
|
516
|
-
PromiseImageTextureFulfillProc textureFulfillProc,
|
517
|
-
PromiseImageTextureReleaseProc textureReleaseProc,
|
518
|
-
PromiseImageTextureContext textureContext);
|
519
|
-
|
520
|
-
/** This entry point operates like 'MakePromiseTexture' but it is used to construct a SkImage
|
521
|
-
from YUV[A] data. The source data may be planar (i.e. spread across multiple textures). In
|
522
|
-
the extreme Y, U, V, and A are all in different planes and thus the image is specified by
|
523
|
-
four textures. 'backendTextureInfo' describes the planar arrangement, texture formats,
|
524
|
-
conversion to RGB, and origin of the textures. Separate 'textureFulfillProc' and
|
525
|
-
'textureReleaseProc' calls are made for each texture. Each texture has its own
|
526
|
-
PromiseImageTextureContext. If 'backendTextureInfo' is not valid then no release proc
|
527
|
-
calls are made. Otherwise, the calls will be made even on failure. 'textureContexts' has one
|
528
|
-
entry for each of the up to four textures, as indicated by 'backendTextureInfo'.
|
529
|
-
|
530
|
-
Currently the mip mapped property of 'backendTextureInfo' is ignored. However, in the
|
531
|
-
near future it will be required that if it is kYes then textureFulfillProc must return
|
532
|
-
a mip mapped texture for each plane in order to successfully draw the image.
|
533
|
-
|
534
|
-
@param gpuContextProxy the thread-safe proxy of the gpu context. required.
|
535
|
-
@param backendTextureInfo info about the promised yuva gpu texture
|
536
|
-
@param imageColorSpace range of colors; may be nullptr
|
537
|
-
@param textureFulfillProc function called to get actual gpu texture
|
538
|
-
@param textureReleaseProc function called when texture can be deleted
|
539
|
-
@param textureContexts state passed to textureFulfillProc and textureReleaseProc
|
540
|
-
@return created SkImage, or nullptr
|
541
|
-
*/
|
542
|
-
static sk_sp<SkImage> MakePromiseYUVATexture(sk_sp<GrContextThreadSafeProxy> gpuContextProxy,
|
543
|
-
const GrYUVABackendTextureInfo& backendTextureInfo,
|
544
|
-
sk_sp<SkColorSpace> imageColorSpace,
|
545
|
-
PromiseImageTextureFulfillProc textureFulfillProc,
|
546
|
-
PromiseImageTextureReleaseProc textureReleaseProc,
|
547
|
-
PromiseImageTextureContext textureContexts[]);
|
234
|
+
/** \class SkImage
|
235
|
+
SkImage describes a two dimensional array of pixels to draw. The pixels may be
|
236
|
+
decoded in a raster bitmap, encoded in a SkPicture or compressed data stream,
|
237
|
+
or located in GPU memory as a GPU texture.
|
548
238
|
|
549
|
-
|
239
|
+
SkImage cannot be modified after it is created. SkImage may allocate additional
|
240
|
+
storage as needed; for instance, an encoded SkImage may decode when drawn.
|
550
241
|
|
551
|
-
|
552
|
-
|
553
|
-
Creates SkImage from Android hardware buffer.
|
554
|
-
Returned SkImage takes a reference on the buffer.
|
242
|
+
SkImage width and height are greater than zero. Creating an SkImage with zero width
|
243
|
+
or height returns SkImage equal to nullptr.
|
555
244
|
|
556
|
-
|
245
|
+
SkImage may be created from SkBitmap, SkPixmap, SkSurface, SkPicture, encoded streams,
|
246
|
+
GPU texture, YUV_ColorSpace data, or hardware buffer. Encoded streams supported
|
247
|
+
include BMP, GIF, HEIF, ICO, JPEG, PNG, WBMP, WebP. Supported encoding details
|
248
|
+
vary with platform.
|
557
249
|
|
558
|
-
|
559
|
-
@param colorSpace range of colors; may be nullptr
|
560
|
-
@return created SkImage, or nullptr
|
561
|
-
*/
|
562
|
-
static sk_sp<SkImage> MakeFromAHardwareBuffer(
|
563
|
-
AHardwareBuffer* hardwareBuffer,
|
564
|
-
SkAlphaType alphaType = kPremul_SkAlphaType,
|
565
|
-
sk_sp<SkColorSpace> colorSpace = nullptr,
|
566
|
-
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
567
|
-
|
568
|
-
/** Creates SkImage from Android hardware buffer and uploads the data from the SkPixmap to it.
|
569
|
-
Returned SkImage takes a reference on the buffer.
|
570
|
-
|
571
|
-
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
572
|
-
|
573
|
-
@param context GPU context
|
574
|
-
@param pixmap SkPixmap that contains data to be uploaded to the AHardwareBuffer
|
575
|
-
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
576
|
-
@param surfaceOrigin surface origin for resulting image
|
577
|
-
@return created SkImage, or nullptr
|
578
|
-
*/
|
579
|
-
static sk_sp<SkImage> MakeFromAHardwareBufferWithData(
|
580
|
-
GrDirectContext* context,
|
581
|
-
const SkPixmap& pixmap,
|
582
|
-
AHardwareBuffer* hardwareBuffer,
|
583
|
-
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
584
|
-
#endif
|
250
|
+
See SkImages namespace for the static factory methods to make SkImages.
|
585
251
|
|
252
|
+
Clients should *not* subclass SkImage as there is a lot of internal machinery that is
|
253
|
+
not publicly accessible.
|
254
|
+
*/
|
255
|
+
class SK_API SkImage : public SkRefCnt {
|
256
|
+
public:
|
586
257
|
/** Returns a SkImageInfo describing the width, height, color type, alpha type, and color space
|
587
258
|
of the SkImage.
|
588
259
|
|
@@ -691,18 +362,12 @@ public:
|
|
691
362
|
*/
|
692
363
|
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions&,
|
693
364
|
const SkMatrix* localMatrix = nullptr) const;
|
694
|
-
|
695
365
|
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions& sampling,
|
696
|
-
const SkMatrix& lm) const
|
697
|
-
|
698
|
-
|
699
|
-
sk_sp<SkShader> makeShader(const SkSamplingOptions& sampling, const SkMatrix& lm) const {
|
700
|
-
return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, &lm);
|
701
|
-
}
|
366
|
+
const SkMatrix& lm) const;
|
367
|
+
/** Defaults to clamp in both X and Y. */
|
368
|
+
sk_sp<SkShader> makeShader(const SkSamplingOptions& sampling, const SkMatrix& lm) const;
|
702
369
|
sk_sp<SkShader> makeShader(const SkSamplingOptions& sampling,
|
703
|
-
const SkMatrix* lm = nullptr) const
|
704
|
-
return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, lm);
|
705
|
-
}
|
370
|
+
const SkMatrix* lm = nullptr) const;
|
706
371
|
|
707
372
|
/**
|
708
373
|
* makeRawShader functions like makeShader, but for images that contain non-color data.
|
@@ -719,20 +384,12 @@ public:
|
|
719
384
|
*/
|
720
385
|
sk_sp<SkShader> makeRawShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions&,
|
721
386
|
const SkMatrix* localMatrix = nullptr) const;
|
722
|
-
|
723
387
|
sk_sp<SkShader> makeRawShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions& sampling,
|
724
|
-
const SkMatrix& lm) const
|
725
|
-
|
726
|
-
|
727
|
-
sk_sp<SkShader> makeRawShader(const SkSamplingOptions& sampling, const SkMatrix& lm) const {
|
728
|
-
return this->makeRawShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, &lm);
|
729
|
-
}
|
388
|
+
const SkMatrix& lm) const;
|
389
|
+
/** Defaults to clamp in both X and Y. */
|
390
|
+
sk_sp<SkShader> makeRawShader(const SkSamplingOptions& sampling, const SkMatrix& lm) const;
|
730
391
|
sk_sp<SkShader> makeRawShader(const SkSamplingOptions& sampling,
|
731
|
-
const SkMatrix* lm = nullptr) const
|
732
|
-
return this->makeRawShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, lm);
|
733
|
-
}
|
734
|
-
|
735
|
-
using CubicResampler = SkCubicResampler;
|
392
|
+
const SkMatrix* lm = nullptr) const;
|
736
393
|
|
737
394
|
/** Copies SkImage pixel address, row bytes, and SkImageInfo to pixmap, if address
|
738
395
|
is available, and returns true. If pixel address is not available, return
|
@@ -752,12 +409,12 @@ public:
|
|
752
409
|
|
753
410
|
example: https://fiddle.skia.org/c/@Image_isTextureBacked
|
754
411
|
*/
|
755
|
-
bool isTextureBacked() const;
|
412
|
+
virtual bool isTextureBacked() const = 0;
|
756
413
|
|
757
414
|
/** Returns an approximation of the amount of texture memory used by the image. Returns
|
758
415
|
zero if the image is not texture backed or if the texture has an external format.
|
759
416
|
*/
|
760
|
-
size_t textureSize() const;
|
417
|
+
virtual size_t textureSize() const = 0;
|
761
418
|
|
762
419
|
/** Returns true if SkImage can be drawn on either raster surface or GPU surface.
|
763
420
|
If context is nullptr, tests if SkImage draws on raster surface;
|
@@ -772,43 +429,7 @@ public:
|
|
772
429
|
|
773
430
|
example: https://fiddle.skia.org/c/@Image_isValid
|
774
431
|
*/
|
775
|
-
bool isValid(GrRecordingContext* context) const;
|
776
|
-
|
777
|
-
#if SK_SUPPORT_GPU
|
778
|
-
/** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
|
779
|
-
texture-backed (including promise texture images) or if the GrDirectContext does not
|
780
|
-
have the same context ID as the context backing the image then this is a no-op.
|
781
|
-
|
782
|
-
If the image was not used in any non-culled draws in the current queue of work for the
|
783
|
-
passed GrDirectContext then this is a no-op unless the GrFlushInfo contains semaphores or
|
784
|
-
a finish proc. Those are respected even when the image has not been used.
|
785
|
-
|
786
|
-
@param context the context on which to flush pending usages of the image.
|
787
|
-
@param info flush options
|
788
|
-
*/
|
789
|
-
GrSemaphoresSubmitted flush(GrDirectContext* context, const GrFlushInfo& flushInfo) const;
|
790
|
-
|
791
|
-
void flush(GrDirectContext* context) const { this->flush(context, {}); }
|
792
|
-
|
793
|
-
/** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the
|
794
|
-
GPU.
|
795
|
-
*/
|
796
|
-
void flushAndSubmit(GrDirectContext*) const;
|
797
|
-
|
798
|
-
/** Retrieves the back-end texture. If SkImage has no back-end texture, an invalid
|
799
|
-
object is returned. Call GrBackendTexture::isValid to determine if the result
|
800
|
-
is valid.
|
801
|
-
|
802
|
-
If flushPendingGrContextIO is true, completes deferred I/O operations.
|
803
|
-
|
804
|
-
If origin in not nullptr, copies location of content drawn into SkImage.
|
805
|
-
|
806
|
-
@param flushPendingGrContextIO flag to flush outstanding requests
|
807
|
-
@return back-end API texture handle; invalid on failure
|
808
|
-
*/
|
809
|
-
GrBackendTexture getBackendTexture(bool flushPendingGrContextIO,
|
810
|
-
GrSurfaceOrigin* origin = nullptr) const;
|
811
|
-
#endif // SK_SUPPORT_GPU
|
432
|
+
virtual bool isValid(GrRecordingContext* context) const = 0;
|
812
433
|
|
813
434
|
/** \enum SkImage::CachingHint
|
814
435
|
CachingHint selects whether Skia may internally cache SkBitmap generated by
|
@@ -941,40 +562,11 @@ public:
|
|
941
562
|
|
942
563
|
enum class RescaleMode {
|
943
564
|
kNearest,
|
565
|
+
kLinear,
|
944
566
|
kRepeatedLinear,
|
945
567
|
kRepeatedCubic,
|
946
568
|
};
|
947
569
|
|
948
|
-
/** Makes image pixel data available to caller, possibly asynchronously.
|
949
|
-
|
950
|
-
Currently asynchronous reads are only supported on the GPU backend and only when the
|
951
|
-
underlying 3D API supports transfer buffers and CPU/GPU synchronization primitives. In all
|
952
|
-
other cases this operates synchronously.
|
953
|
-
|
954
|
-
Data is read from the source sub-rectangle, then converted to the color space, color type,
|
955
|
-
and alpha type of 'info'. A 'srcRect' that is not contained by the bounds of the image
|
956
|
-
causes failure.
|
957
|
-
|
958
|
-
When the pixel data is ready the caller's ReadPixelsCallback is called with a
|
959
|
-
AsyncReadResult containing pixel data in the requested color type, alpha type, and color
|
960
|
-
space. The AsyncReadResult will have count() == 1. Upon failure the callback is called with
|
961
|
-
nullptr for AsyncReadResult. For a GPU image this flushes work but a submit must occur to
|
962
|
-
guarantee a finite time before the callback is called.
|
963
|
-
|
964
|
-
The data is valid for the lifetime of AsyncReadResult with the exception that if the SkImage
|
965
|
-
is GPU-backed the data is immediately invalidated if the context is abandoned or
|
966
|
-
destroyed.
|
967
|
-
|
968
|
-
@param info info of the requested pixels
|
969
|
-
@param srcRect subrectangle of image to read
|
970
|
-
@param callback function to call with result of the read
|
971
|
-
@param context passed to callback
|
972
|
-
*/
|
973
|
-
void asyncReadPixels(const SkImageInfo& info,
|
974
|
-
const SkIRect& srcRect,
|
975
|
-
ReadPixelsCallback callback,
|
976
|
-
ReadPixelsContext context) const;
|
977
|
-
|
978
570
|
/** Makes image pixel data available to caller, possibly asynchronously. It can also rescale
|
979
571
|
the image pixels.
|
980
572
|
|
@@ -1071,44 +663,6 @@ public:
|
|
1071
663
|
bool scalePixels(const SkPixmap& dst, const SkSamplingOptions&,
|
1072
664
|
CachingHint cachingHint = kAllow_CachingHint) const;
|
1073
665
|
|
1074
|
-
/** Encodes SkImage pixels, returning result as SkData.
|
1075
|
-
|
1076
|
-
Returns nullptr if encoding fails, or if encodedImageFormat is not supported.
|
1077
|
-
|
1078
|
-
SkImage encoding in a format requires both building with one or more of:
|
1079
|
-
SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP; and platform support
|
1080
|
-
for the encoded format.
|
1081
|
-
|
1082
|
-
If SK_BUILD_FOR_MAC or SK_BUILD_FOR_IOS is defined, encodedImageFormat can
|
1083
|
-
additionally be one of: SkEncodedImageFormat::kICO, SkEncodedImageFormat::kBMP,
|
1084
|
-
SkEncodedImageFormat::kGIF.
|
1085
|
-
|
1086
|
-
quality is a platform and format specific metric trading off size and encoding
|
1087
|
-
error. When used, quality equaling 100 encodes with the least error. quality may
|
1088
|
-
be ignored by the encoder.
|
1089
|
-
|
1090
|
-
@param encodedImageFormat one of: SkEncodedImageFormat::kJPEG, SkEncodedImageFormat::kPNG,
|
1091
|
-
SkEncodedImageFormat::kWEBP
|
1092
|
-
@param quality encoder specific metric with 100 equaling best
|
1093
|
-
@return encoded SkImage, or nullptr
|
1094
|
-
|
1095
|
-
example: https://fiddle.skia.org/c/@Image_encodeToData
|
1096
|
-
*/
|
1097
|
-
sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const;
|
1098
|
-
|
1099
|
-
/** Encodes SkImage pixels, returning result as SkData. Returns existing encoded data
|
1100
|
-
if present; otherwise, SkImage is encoded with SkEncodedImageFormat::kPNG. Skia
|
1101
|
-
must be built with SK_ENCODE_PNG to encode SkImage.
|
1102
|
-
|
1103
|
-
Returns nullptr if existing encoded data is missing or invalid, and
|
1104
|
-
encoding fails.
|
1105
|
-
|
1106
|
-
@return encoded SkImage, or nullptr
|
1107
|
-
|
1108
|
-
example: https://fiddle.skia.org/c/@Image_encodeToData_2
|
1109
|
-
*/
|
1110
|
-
sk_sp<SkData> encodeToData() const;
|
1111
|
-
|
1112
666
|
/** Returns encoded SkImage pixels as SkData, if SkImage was created from supported
|
1113
667
|
encoded stream format. Platform support for formats vary and may require building
|
1114
668
|
with one or more of: SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP.
|
@@ -1151,33 +705,79 @@ public:
|
|
1151
705
|
*/
|
1152
706
|
sk_sp<SkImage> withDefaultMipmaps() const;
|
1153
707
|
|
1154
|
-
#if
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
allocates mip map levels.
|
1159
|
-
|
1160
|
-
The mipmapped parameter is effectively treated as kNo if MIP maps are not supported by the
|
1161
|
-
GPU.
|
1162
|
-
|
1163
|
-
Returns original SkImage if the image is already texture-backed, the context matches, and
|
1164
|
-
mipmapped is compatible with the backing GPU texture. SkBudgeted is ignored in this case.
|
1165
|
-
|
1166
|
-
Returns nullptr if context is nullptr, or if SkImage was created with another
|
1167
|
-
GrDirectContext.
|
708
|
+
#if defined(SK_GANESH) || defined(SK_GRAPHITE)
|
709
|
+
using ReleaseContext = SkImages::ReleaseContext;
|
710
|
+
using TextureReleaseProc = void (*)(ReleaseContext);
|
711
|
+
#endif
|
1168
712
|
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
713
|
+
#if defined(SK_GRAPHITE)
|
714
|
+
// Passed to both fulfill and imageRelease
|
715
|
+
using GraphitePromiseImageContext = void*;
|
716
|
+
// Returned from fulfill and passed into textureRelease
|
717
|
+
using GraphitePromiseTextureReleaseContext = void*;
|
718
|
+
|
719
|
+
using GraphitePromiseImageFulfillProc =
|
720
|
+
std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext>
|
721
|
+
(*)(GraphitePromiseImageContext);
|
722
|
+
using GraphitePromiseImageReleaseProc = void (*)(GraphitePromiseImageContext);
|
723
|
+
using GraphitePromiseTextureReleaseProc = void (*)(GraphitePromiseTextureReleaseContext);
|
724
|
+
|
725
|
+
/** Create a new SkImage that is very similar to an SkImage created by
|
726
|
+
MakeGraphiteFromBackendTexture. The difference is that the caller need not have created the
|
727
|
+
backend texture nor populated it with data when creating the image. Instead of passing a
|
728
|
+
BackendTexture to the factory the client supplies a description of the texture consisting
|
729
|
+
of dimensions, TextureInfo, SkColorInfo and Volatility.
|
730
|
+
|
731
|
+
In general, 'fulfill' must return a BackendTexture that matches the properties
|
732
|
+
provided at SkImage creation time. The BackendTexture must refer to a valid existing
|
733
|
+
texture in the backend API context/device, and already be populated with data.
|
734
|
+
The texture cannot be deleted until 'textureRelease' is called. 'textureRelease' will
|
735
|
+
be called with the textureReleaseContext returned by 'fulfill'.
|
736
|
+
|
737
|
+
Wrt when and how often the fulfill, imageRelease, and textureRelease callbacks will
|
738
|
+
be called:
|
739
|
+
|
740
|
+
For non-volatile promise images, 'fulfill' will be called at Context::insertRecording
|
741
|
+
time. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease' will always be
|
742
|
+
called only once - when Skia will no longer try calling 'fulfill' to get a backend
|
743
|
+
texture. If 'fulfill' failed (i.e., it didn't return a valid backend texture) then
|
744
|
+
'textureRelease' will never be called. If 'fulfill' was successful then
|
745
|
+
'textureRelease' will be called only once when the GPU is done with the contents of the
|
746
|
+
promise image. This will usually occur during a Context::submit call but it could occur
|
747
|
+
earlier due to error conditions. 'fulfill' can be called multiple times if the promise
|
748
|
+
image is used in multiple recordings. If 'fulfill' fails, the insertRecording itself will
|
749
|
+
fail. Subsequent insertRecording calls (with Recordings that use the promise image) will
|
750
|
+
keep calling 'fulfill' until it succeeds.
|
751
|
+
|
752
|
+
For volatile promise images, 'fulfill' will be called each time the Recording is inserted
|
753
|
+
into a Context. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease'
|
754
|
+
will always be called only once just like the non-volatile case. If 'fulfill' fails at
|
755
|
+
insertRecording-time, 'textureRelease' will never be called. If 'fulfill' was successful
|
756
|
+
then a 'textureRelease' matching that 'fulfill' will be called when the GPU is done with
|
757
|
+
the contents of the promise image. This will usually occur during a Context::submit call
|
758
|
+
but it could occur earlier due to error conditions.
|
759
|
+
|
760
|
+
@param recorder the recorder that will capture the commands creating the image
|
761
|
+
@param dimensions width & height of promised gpu texture
|
762
|
+
@param textureInfo structural information for the promised gpu texture
|
763
|
+
@param colorInfo color type, alpha type and colorSpace information for the image
|
764
|
+
@param isVolatile volatility of the promise image
|
765
|
+
@param fulfill function called to get the actual backend texture
|
766
|
+
@param imageRelease function called when any image-centric data can be deleted
|
767
|
+
@param textureRelease function called when the backend texture can be deleted
|
768
|
+
@param imageContext state passed to fulfill and imageRelease
|
769
|
+
@return created SkImage, or nullptr
|
1174
770
|
*/
|
1175
|
-
sk_sp<SkImage>
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
771
|
+
static sk_sp<SkImage> MakeGraphitePromiseTexture(skgpu::graphite::Recorder*,
|
772
|
+
SkISize dimensions,
|
773
|
+
const skgpu::graphite::TextureInfo&,
|
774
|
+
const SkColorInfo&,
|
775
|
+
skgpu::graphite::Volatile,
|
776
|
+
GraphitePromiseImageFulfillProc,
|
777
|
+
GraphitePromiseImageReleaseProc,
|
778
|
+
GraphitePromiseTextureReleaseProc,
|
779
|
+
GraphitePromiseImageContext);
|
1179
780
|
|
1180
|
-
#ifdef SK_GRAPHITE_ENABLED
|
1181
781
|
/** Creates an SkImage from a GPU texture associated with the recorder.
|
1182
782
|
|
1183
783
|
SkImage is returned if the format of backendTexture is recognized and supported.
|
@@ -1198,12 +798,60 @@ public:
|
|
1198
798
|
const skgpu::graphite::BackendTexture&,
|
1199
799
|
SkColorType colorType,
|
1200
800
|
SkAlphaType alphaType,
|
1201
|
-
sk_sp<SkColorSpace> colorSpace
|
801
|
+
sk_sp<SkColorSpace> colorSpace,
|
802
|
+
TextureReleaseProc = nullptr,
|
803
|
+
ReleaseContext = nullptr);
|
804
|
+
|
805
|
+
/** Creates an SkImage from YUV[A] planar textures associated with the recorder.
|
806
|
+
@param recorder The recorder.
|
807
|
+
@param yuvaBackendTextures A set of textures containing YUVA data and a description of the
|
808
|
+
data and transformation to RGBA.
|
809
|
+
@param imageColorSpace range of colors of the resulting image after conversion to RGB;
|
810
|
+
may be nullptr
|
811
|
+
@param TextureReleaseProc called when the backend textures can be released
|
812
|
+
@param ReleaseContext state passed to TextureReleaseProc
|
813
|
+
@return created SkImage, or nullptr
|
814
|
+
*/
|
815
|
+
static sk_sp<SkImage> MakeGraphiteFromYUVABackendTextures(
|
816
|
+
skgpu::graphite::Recorder* recorder,
|
817
|
+
const skgpu::graphite::YUVABackendTextures& yuvaBackendTextures,
|
818
|
+
sk_sp<SkColorSpace> imageColorSpace,
|
819
|
+
TextureReleaseProc = nullptr,
|
820
|
+
ReleaseContext = nullptr);
|
1202
821
|
|
1203
822
|
struct RequiredImageProperties {
|
1204
|
-
skgpu::
|
823
|
+
skgpu::Mipmapped fMipmapped;
|
1205
824
|
};
|
1206
825
|
|
826
|
+
/** Creates SkImage from SkYUVAPixmaps.
|
827
|
+
|
828
|
+
The image will remain planar with each plane converted to a texture using the passed
|
829
|
+
Recorder.
|
830
|
+
|
831
|
+
SkYUVAPixmaps has a SkYUVAInfo which specifies the transformation from YUV to RGB.
|
832
|
+
The SkColorSpace of the resulting RGB values is specified by imgColorSpace. This will
|
833
|
+
be the SkColorSpace reported by the image and when drawn the RGB values will be converted
|
834
|
+
from this space into the destination space (if the destination is tagged).
|
835
|
+
|
836
|
+
This is only supported using the GPU backend and will fail if recorder is nullptr.
|
837
|
+
|
838
|
+
SkYUVAPixmaps does not need to remain valid after this returns.
|
839
|
+
|
840
|
+
@param Recorder The Recorder to use for storing commands
|
841
|
+
@param pixmaps The planes as pixmaps with supported SkYUVAInfo that
|
842
|
+
specifies conversion to RGB.
|
843
|
+
@param RequiredImageProperties Properties the returned SkImage must possess (e.g.,
|
844
|
+
mipmaps)
|
845
|
+
@param limitToMaxTextureSize Downscale image to GPU maximum texture size, if necessary
|
846
|
+
@param imgColorSpace Range of colors of the resulting image; may be nullptr
|
847
|
+
@return Created SkImage, or nullptr
|
848
|
+
*/
|
849
|
+
static sk_sp<SkImage> MakeGraphiteFromYUVAPixmaps(skgpu::graphite::Recorder*,
|
850
|
+
const SkYUVAPixmaps& pixmaps,
|
851
|
+
RequiredImageProperties = {},
|
852
|
+
bool limitToMaxTextureSize = false,
|
853
|
+
sk_sp<SkColorSpace> imgColorSpace = nullptr);
|
854
|
+
|
1207
855
|
/** Graphite version of makeTextureImage.
|
1208
856
|
|
1209
857
|
Returns an SkImage backed by a Graphite texture, using the provided Recorder for creation
|
@@ -1225,9 +873,70 @@ public:
|
|
1225
873
|
mipmaps)
|
1226
874
|
@return created SkImage, or nullptr
|
1227
875
|
*/
|
1228
|
-
sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
|
1229
|
-
|
1230
|
-
|
876
|
+
virtual sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
|
877
|
+
RequiredImageProperties = {}) const = 0;
|
878
|
+
|
879
|
+
/** Returns subset of this image.
|
880
|
+
|
881
|
+
Returns nullptr if any of the following are true:
|
882
|
+
- Subset is empty
|
883
|
+
- Subset is not contained inside the image's bounds
|
884
|
+
- Pixels in the image could not be read or copied
|
885
|
+
|
886
|
+
If this image is texture-backed, the recorder parameter is required.
|
887
|
+
If the recorder parameter is provided, and the image is raster-backed, the subset will
|
888
|
+
be converted to texture-backed.
|
889
|
+
|
890
|
+
@param subset bounds of returned SkImage
|
891
|
+
@param recorder the recorder in which to create the new image
|
892
|
+
@param RequiredImageProperties properties the returned SkImage must possess (e.g.,
|
893
|
+
mipmaps)
|
894
|
+
@return the subsetted image, or nullptr
|
895
|
+
*/
|
896
|
+
sk_sp<SkImage> makeSubset(const SkIRect& subset,
|
897
|
+
skgpu::graphite::Recorder*,
|
898
|
+
RequiredImageProperties = {}) const;
|
899
|
+
|
900
|
+
/** Creates SkImage in target SkColorSpace.
|
901
|
+
Returns nullptr if SkImage could not be created.
|
902
|
+
|
903
|
+
Returns original SkImage if it is in target SkColorSpace.
|
904
|
+
Otherwise, converts pixels from SkImage SkColorSpace to target SkColorSpace.
|
905
|
+
If SkImage colorSpace() returns nullptr, SkImage SkColorSpace is assumed to be sRGB.
|
906
|
+
|
907
|
+
If this image is graphite-backed, the recorder parameter is required.
|
908
|
+
|
909
|
+
@param targetColorSpace SkColorSpace describing color range of returned SkImage
|
910
|
+
@param recorder The Recorder in which to create the new image
|
911
|
+
@param RequiredImageProperties properties the returned SkImage must possess (e.g.,
|
912
|
+
mipmaps)
|
913
|
+
@return created SkImage in target SkColorSpace
|
914
|
+
*/
|
915
|
+
sk_sp<SkImage> makeColorSpace(sk_sp<SkColorSpace> targetColorSpace,
|
916
|
+
skgpu::graphite::Recorder*,
|
917
|
+
RequiredImageProperties = {}) const;
|
918
|
+
|
919
|
+
/** Experimental.
|
920
|
+
Creates SkImage in target SkColorType and SkColorSpace.
|
921
|
+
Returns nullptr if SkImage could not be created.
|
922
|
+
|
923
|
+
Returns original SkImage if it is in target SkColorType and SkColorSpace.
|
924
|
+
|
925
|
+
If this image is graphite-backed, the recorder parameter is required.
|
926
|
+
|
927
|
+
@param targetColorType SkColorType of returned SkImage
|
928
|
+
@param targetColorSpace SkColorSpace of returned SkImage
|
929
|
+
@param recorder The Recorder in which to create the new image
|
930
|
+
@param RequiredImageProperties properties the returned SkImage must possess (e.g.,
|
931
|
+
mipmaps)
|
932
|
+
@return created SkImage in target SkColorType and SkColorSpace
|
933
|
+
*/
|
934
|
+
sk_sp<SkImage> makeColorTypeAndColorSpace(SkColorType targetColorType,
|
935
|
+
sk_sp<SkColorSpace> targetColorSpace,
|
936
|
+
skgpu::graphite::Recorder*,
|
937
|
+
RequiredImageProperties = {}) const;
|
938
|
+
|
939
|
+
#endif // SK_GRAPHITE
|
1231
940
|
|
1232
941
|
/** Returns raster image or lazy image. Copies SkImage backed by GPU texture into
|
1233
942
|
CPU memory if needed. Returns original SkImage if decoded in raster bitmap,
|
@@ -1285,38 +994,6 @@ public:
|
|
1285
994
|
const SkIRect& clipBounds, SkIRect* outSubset,
|
1286
995
|
SkIPoint* offset) const;
|
1287
996
|
|
1288
|
-
/** Defines a callback function, taking one parameter of type GrBackendTexture with
|
1289
|
-
no return value. Function is called when back-end texture is to be released.
|
1290
|
-
*/
|
1291
|
-
typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc;
|
1292
|
-
|
1293
|
-
#if SK_SUPPORT_GPU
|
1294
|
-
/** Creates a GrBackendTexture from the provided SkImage. Returns true and
|
1295
|
-
stores result in backendTexture and backendTextureReleaseProc if
|
1296
|
-
texture is created; otherwise, returns false and leaves
|
1297
|
-
backendTexture and backendTextureReleaseProc unmodified.
|
1298
|
-
|
1299
|
-
Call backendTextureReleaseProc after deleting backendTexture.
|
1300
|
-
backendTextureReleaseProc cleans up auxiliary data related to returned
|
1301
|
-
backendTexture. The caller must delete returned backendTexture after use.
|
1302
|
-
|
1303
|
-
If SkImage is both texture backed and singly referenced, image is returned in
|
1304
|
-
backendTexture without conversion or making a copy. SkImage is singly referenced
|
1305
|
-
if its was transferred solely using std::move().
|
1306
|
-
|
1307
|
-
If SkImage is not texture backed, returns texture with SkImage contents.
|
1308
|
-
|
1309
|
-
@param context GPU context
|
1310
|
-
@param image SkImage used for texture
|
1311
|
-
@param backendTexture storage for back-end texture
|
1312
|
-
@param backendTextureReleaseProc storage for clean up function
|
1313
|
-
@return true if back-end texture was created
|
1314
|
-
*/
|
1315
|
-
static bool MakeBackendTextureFromSkImage(GrDirectContext* context,
|
1316
|
-
sk_sp<SkImage> image,
|
1317
|
-
GrBackendTexture* backendTexture,
|
1318
|
-
BackendTextureReleaseProc* backendTextureReleaseProc);
|
1319
|
-
#endif
|
1320
997
|
/** Deprecated.
|
1321
998
|
*/
|
1322
999
|
enum LegacyBitmapMode {
|
@@ -1393,7 +1070,8 @@ private:
|
|
1393
1070
|
SkImage(const SkImageInfo& info, uint32_t uniqueID);
|
1394
1071
|
|
1395
1072
|
friend class SkBitmap;
|
1396
|
-
friend class SkImage_Base;
|
1073
|
+
friend class SkImage_Base; // for private ctor
|
1074
|
+
friend class SkImage_Raster; // for withMipmaps
|
1397
1075
|
friend class SkMipmapBuilder;
|
1398
1076
|
|
1399
1077
|
SkImageInfo fInfo;
|