[graphite] Moving still more files into src/text/gpu

Moving DistanceFieldAdjustTable, SDFMaskFilter, and
SDFTControl.

Bug: skia:13118
Change-Id: Id9ace9bc02068437c0f4fd674e5864da83f83228
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542297
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Jim Van Verth 2022-05-19 12:41:15 -04:00 committed by SkCQ
parent fb21a44e2d
commit 480532d1c8
33 changed files with 225 additions and 195 deletions

View File

@ -324,12 +324,6 @@ skia_gpu_sources = [
# text # text
"$_src/gpu/ganesh/text/GrAtlasManager.cpp", "$_src/gpu/ganesh/text/GrAtlasManager.cpp",
"$_src/gpu/ganesh/text/GrAtlasManager.h", "$_src/gpu/ganesh/text/GrAtlasManager.h",
"$_src/gpu/ganesh/text/GrDistanceFieldAdjustTable.cpp",
"$_src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h",
"$_src/gpu/ganesh/text/GrSDFMaskFilter.cpp",
"$_src/gpu/ganesh/text/GrSDFMaskFilter.h",
"$_src/gpu/ganesh/text/GrSDFTControl.cpp",
"$_src/gpu/ganesh/text/GrSDFTControl.h",
"$_src/gpu/ganesh/text/GrSlug.cpp", "$_src/gpu/ganesh/text/GrSlug.cpp",
"$_src/gpu/ganesh/text/GrTextBlob.cpp", "$_src/gpu/ganesh/text/GrTextBlob.cpp",
"$_src/gpu/ganesh/text/GrTextBlob.h", "$_src/gpu/ganesh/text/GrTextBlob.h",
@ -826,9 +820,15 @@ skia_shared_gpu_sources = [
"$_src/gpu/tessellate/WangsFormula.h", "$_src/gpu/tessellate/WangsFormula.h",
# text # text
"$_src/text/gpu/DistanceFieldAdjustTable.cpp",
"$_src/text/gpu/DistanceFieldAdjustTable.h",
"$_src/text/gpu/Glyph.h", "$_src/text/gpu/Glyph.h",
"$_src/text/gpu/GlyphVector.cpp", "$_src/text/gpu/GlyphVector.cpp",
"$_src/text/gpu/GlyphVector.h", "$_src/text/gpu/GlyphVector.h",
"$_src/text/gpu/SDFMaskFilter.cpp",
"$_src/text/gpu/SDFMaskFilter.h",
"$_src/text/gpu/SDFTControl.cpp",
"$_src/text/gpu/SDFTControl.h",
"$_src/text/gpu/StrikeCache.cpp", "$_src/text/gpu/StrikeCache.cpp",
"$_src/text/gpu/StrikeCache.h", "$_src/text/gpu/StrikeCache.h",
"$_src/text/gpu/SubRunAllocator.cpp", "$_src/text/gpu/SubRunAllocator.cpp",

View File

@ -1218,12 +1218,6 @@ BASE_SRCS_ALL = [
"src/gpu/ganesh/tessellate/VertexChunkPatchAllocator.h", "src/gpu/ganesh/tessellate/VertexChunkPatchAllocator.h",
"src/gpu/ganesh/text/GrAtlasManager.cpp", "src/gpu/ganesh/text/GrAtlasManager.cpp",
"src/gpu/ganesh/text/GrAtlasManager.h", "src/gpu/ganesh/text/GrAtlasManager.h",
"src/gpu/ganesh/text/GrDistanceFieldAdjustTable.cpp",
"src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h",
"src/gpu/ganesh/text/GrSDFMaskFilter.cpp",
"src/gpu/ganesh/text/GrSDFMaskFilter.h",
"src/gpu/ganesh/text/GrSDFTControl.cpp",
"src/gpu/ganesh/text/GrSDFTControl.h",
"src/gpu/ganesh/text/GrSlug.cpp", "src/gpu/ganesh/text/GrSlug.cpp",
"src/gpu/ganesh/text/GrTextBlob.cpp", "src/gpu/ganesh/text/GrTextBlob.cpp",
"src/gpu/ganesh/text/GrTextBlob.h", "src/gpu/ganesh/text/GrTextBlob.h",
@ -1649,9 +1643,15 @@ BASE_SRCS_ALL = [
"src/sksl/transform/SkSLEliminateUnreachableCode.cpp", "src/sksl/transform/SkSLEliminateUnreachableCode.cpp",
"src/sksl/transform/SkSLProgramWriter.h", "src/sksl/transform/SkSLProgramWriter.h",
"src/sksl/transform/SkSLTransform.h", "src/sksl/transform/SkSLTransform.h",
"src/text/gpu/DistanceFieldAdjustTable.cpp",
"src/text/gpu/DistanceFieldAdjustTable.h",
"src/text/gpu/Glyph.h", "src/text/gpu/Glyph.h",
"src/text/gpu/GlyphVector.cpp", "src/text/gpu/GlyphVector.cpp",
"src/text/gpu/GlyphVector.h", "src/text/gpu/GlyphVector.h",
"src/text/gpu/SDFMaskFilter.cpp",
"src/text/gpu/SDFMaskFilter.h",
"src/text/gpu/SDFTControl.cpp",
"src/text/gpu/SDFTControl.h",
"src/text/gpu/StrikeCache.cpp", "src/text/gpu/StrikeCache.cpp",
"src/text/gpu/StrikeCache.h", "src/text/gpu/StrikeCache.h",
"src/text/gpu/SubRunAllocator.cpp", "src/text/gpu/SubRunAllocator.cpp",

View File

@ -2127,7 +2127,7 @@ generated_cc_atom(
":SkScalerContext_hdr", ":SkScalerContext_hdr",
":SkTextBlobPriv_hdr", ":SkTextBlobPriv_hdr",
"//include/core:SkSurfaceProps_hdr", "//include/core:SkSurfaceProps_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr", "//src/text/gpu:SDFTControl_hdr",
], ],
) )
@ -2158,9 +2158,9 @@ generated_cc_atom(
"//include/private:SkTDArray_hdr", "//include/private:SkTDArray_hdr",
"//src/gpu/ganesh:GrColorInfo_hdr", "//src/gpu/ganesh:GrColorInfo_hdr",
"//src/gpu/ganesh:GrDirectContextPriv_hdr", "//src/gpu/ganesh:GrDirectContextPriv_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_hdr", "//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_hdr",
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr", "//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
"//src/text/gpu:SDFTControl_hdr",
], ],
) )
@ -2709,7 +2709,7 @@ generated_cc_atom(
"//src/gpu/ganesh:GrFragmentProcessor_hdr", "//src/gpu/ganesh:GrFragmentProcessor_hdr",
"//src/gpu/ganesh:GrSurfaceProxyView_hdr", "//src/gpu/ganesh:GrSurfaceProxyView_hdr",
"//src/gpu/ganesh:GrTextureProxy_hdr", "//src/gpu/ganesh:GrTextureProxy_hdr",
"//src/gpu/ganesh/text:GrSDFMaskFilter_hdr", "//src/text/gpu:SDFMaskFilter_hdr",
], ],
) )
@ -4726,7 +4726,7 @@ generated_cc_atom(
":SkStrikeForGPU_hdr", ":SkStrikeForGPU_hdr",
"//include/core:SkMaskFilter_hdr", "//include/core:SkMaskFilter_hdr",
"//include/core:SkPathEffect_hdr", "//include/core:SkPathEffect_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr", "//src/text/gpu:SDFTControl_hdr",
], ],
) )
@ -4741,8 +4741,8 @@ generated_cc_atom(
":SkStrikeSpec_hdr", ":SkStrikeSpec_hdr",
":SkTLazy_hdr", ":SkTLazy_hdr",
"//include/core:SkGraphics_hdr", "//include/core:SkGraphics_hdr",
"//src/gpu/ganesh/text:GrSDFMaskFilter_hdr", "//src/text/gpu:SDFMaskFilter_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr", "//src/text/gpu:SDFTControl_hdr",
"//src/text/gpu:StrikeCache_hdr", "//src/text/gpu:StrikeCache_hdr",
], ],
) )
@ -5553,8 +5553,8 @@ generated_cc_atom(
"//include/private:SkTHash_hdr", "//include/private:SkTHash_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr", "//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
"//src/gpu/ganesh:GrDrawOpAtlas_hdr", "//src/gpu/ganesh:GrDrawOpAtlas_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
"//src/gpu/ganesh/text:GrTextBlob_hdr", "//src/gpu/ganesh/text:GrTextBlob_hdr",
"//src/text/gpu:SDFTControl_hdr",
], ],
) )

View File

@ -34,8 +34,8 @@
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "src/gpu/ganesh/GrDrawOpAtlas.h" #include "src/gpu/ganesh/GrDrawOpAtlas.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
#include "src/gpu/ganesh/text/GrTextBlob.h" #include "src/gpu/ganesh/text/GrTextBlob.h"
#include "src/text/gpu/SDFTControl.h"
#endif #endif
namespace { namespace {
@ -785,7 +785,7 @@ class GlyphTrackingDevice final : public SkNoPixelsDevice {
public: public:
GlyphTrackingDevice( GlyphTrackingDevice(
const SkISize& dimensions, const SkSurfaceProps& props, SkStrikeServerImpl* server, const SkISize& dimensions, const SkSurfaceProps& props, SkStrikeServerImpl* server,
sk_sp<SkColorSpace> colorSpace, GrSDFTControl SDFTControl) sk_sp<SkColorSpace> colorSpace, sktext::gpu::SDFTControl SDFTControl)
: SkNoPixelsDevice(SkIRect::MakeSize(dimensions), props, std::move(colorSpace)) : SkNoPixelsDevice(SkIRect::MakeSize(dimensions), props, std::move(colorSpace))
, fStrikeServerImpl(server) , fStrikeServerImpl(server)
, fSDFTControl(SDFTControl) , fSDFTControl(SDFTControl)
@ -849,7 +849,7 @@ protected:
private: private:
SkStrikeServerImpl* const fStrikeServerImpl; SkStrikeServerImpl* const fStrikeServerImpl;
const GrSDFTControl fSDFTControl; const sktext::gpu::SDFTControl fSDFTControl;
SkGlyphRunListPainter fPainter; SkGlyphRunListPainter fPainter;
SkGlyphRunListPainter fConvertPainter; SkGlyphRunListPainter fConvertPainter;
}; };
@ -867,10 +867,10 @@ std::unique_ptr<SkCanvas> SkStrikeServer::makeAnalysisCanvas(int width, int heig
bool DFTSupport) { bool DFTSupport) {
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrContextOptions ctxOptions; GrContextOptions ctxOptions;
auto control = GrSDFTControl{DFTSupport, auto control = sktext::gpu::SDFTControl{DFTSupport,
props.isUseDeviceIndependentFonts(), props.isUseDeviceIndependentFonts(),
ctxOptions.fMinDistanceFieldFontSize, ctxOptions.fMinDistanceFieldFontSize,
ctxOptions.fGlyphsAsPathsFontSize}; ctxOptions.fGlyphsAsPathsFontSize};
sk_sp<SkBaseDevice> trackingDevice(new GlyphTrackingDevice( sk_sp<SkBaseDevice> trackingDevice(new GlyphTrackingDevice(
SkISize::Make(width, height), SkISize::Make(width, height),

View File

@ -22,7 +22,6 @@
#include "src/core/SkScalerContext.h" #include "src/core/SkScalerContext.h"
#include "src/shaders/SkShaderBase.h" #include "src/shaders/SkShaderBase.h"
class GrSDFTControl;
class SkBitmap; class SkBitmap;
class SkColorSpace; class SkColorSpace;
class SkMesh; class SkMesh;
@ -42,12 +41,15 @@ class BaseDevice;
namespace skgpu::graphite { namespace skgpu::graphite {
class Device; class Device;
} }
namespace sktext::gpu {
class SDFTControl;
}
struct SkStrikeDeviceInfo { struct SkStrikeDeviceInfo {
const SkSurfaceProps fSurfaceProps; const SkSurfaceProps fSurfaceProps;
const SkScalerContextFlags fScalerContextFlags; const SkScalerContextFlags fScalerContextFlags;
// This is a pointer so this can be compiled without SK_GPU_SUPPORT. // This is a pointer so this can be compiled without SK_GPU_SUPPORT.
const GrSDFTControl* const fSDFTControl; const sktext::gpu::SDFTControl* const fSDFTControl;
}; };
class SkBaseDevice : public SkRefCnt, public SkMatrixProvider { class SkBaseDevice : public SkRefCnt, public SkMatrixProvider {

View File

@ -11,9 +11,9 @@
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "src/gpu/ganesh/GrColorInfo.h" #include "src/gpu/ganesh/GrColorInfo.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h" #include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
#include "src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.h" #include "src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.h"
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h" #include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
#include "src/text/gpu/SDFTControl.h"
#endif // SK_SUPPORT_GPU #endif // SK_SUPPORT_GPU
#include "include/core/SkBitmap.h" #include "include/core/SkBitmap.h"
@ -293,7 +293,7 @@ void SkGlyphRunListPainter::categorizeGlyphRunList(SkGlyphRunPainterInterface* p
const SkSurfaceProps deviceProps = strikeDeviceInfo.fSurfaceProps; const SkSurfaceProps deviceProps = strikeDeviceInfo.fSurfaceProps;
const SkScalerContextFlags scalerContextFlags = strikeDeviceInfo.fScalerContextFlags; const SkScalerContextFlags scalerContextFlags = strikeDeviceInfo.fScalerContextFlags;
const GrSDFTControl SDFTControl = *strikeDeviceInfo.fSDFTControl; const sktext::gpu::SDFTControl SDFTControl = *strikeDeviceInfo.fSDFTControl;
auto bufferScope = SkSubRunBuffers::EnsureBuffers(glyphRunList); auto bufferScope = SkSubRunBuffers::EnsureBuffers(glyphRunList);
auto [accepted, rejected] = bufferScope.buffers(); auto [accepted, rejected] = bufferScope.buffers();

View File

@ -16,14 +16,16 @@
#include "src/core/SkTextBlobPriv.h" #include "src/core/SkTextBlobPriv.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "src/gpu/ganesh/text/GrSDFTControl.h" #include "src/text/gpu/SDFTControl.h"
class GrColorInfo; class GrColorInfo;
namespace skgpu { namespace v1 { class SurfaceDrawContext; }} namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
#endif #endif
class SkGlyphRunPainterInterface; class SkGlyphRunPainterInterface;
class SkStrikeSpec; class SkStrikeSpec;
class GrSDFTMatrixRange; namespace sktext {
class SDFTMatrixRange;
}
// round and ignorePositionMask are used to calculate the subpixel position of a glyph. // round and ignorePositionMask are used to calculate the subpixel position of a glyph.
// The per component (x or y) calculation is: // The per component (x or y) calculation is:
@ -138,7 +140,7 @@ public:
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, SkScalar strikeToSourceScale,
const SkFont& runFont, const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) = 0; const sktext::gpu::SDFTMatrixRange& matrixRange) = 0;
}; };
#endif // SK_SUPPORT_GPU #endif // SK_SUPPORT_GPU
#endif // SkGlyphRunPainter_DEFINED #endif // SkGlyphRunPainter_DEFINED

View File

@ -22,7 +22,7 @@
#include "src/gpu/ganesh/GrFragmentProcessor.h" #include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h" #include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTextureProxy.h" #include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/text/GrSDFMaskFilter.h" #include "src/text/gpu/SDFMaskFilter.h"
#endif #endif
SkMaskFilterBase::NinePatch::~NinePatch() { SkMaskFilterBase::NinePatch::~NinePatch() {
@ -378,7 +378,7 @@ SkRect SkMaskFilter::approximateFilteredBounds(const SkRect& src) const {
void SkMaskFilter::RegisterFlattenables() { void SkMaskFilter::RegisterFlattenables() {
sk_register_blur_maskfilter_createproc(); sk_register_blur_maskfilter_createproc();
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
gr_register_sdf_maskfilter_createproc(); sktext::gpu::register_sdf_maskfilter_createproc();
#endif #endif
} }

View File

@ -14,8 +14,8 @@
#include "src/core/SkTLazy.h" #include "src/core/SkTLazy.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "src/gpu/ganesh/text/GrSDFMaskFilter.h" #include "src/text/gpu/SDFMaskFilter.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h" #include "src/text/gpu/SDFTControl.h"
#include "src/text/gpu/StrikeCache.h" #include "src/text/gpu/StrikeCache.h"
#endif #endif
@ -171,13 +171,13 @@ SkStrikeSpec SkStrikeSpec::MakePDFVector(const SkTypeface& typeface, int* size)
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
std::tuple<SkStrikeSpec, SkScalar, GrSDFTMatrixRange> std::tuple<SkStrikeSpec, SkScalar, sktext::gpu::SDFTMatrixRange>
SkStrikeSpec::MakeSDFT(const SkFont& font, const SkPaint& paint, SkStrikeSpec::MakeSDFT(const SkFont& font, const SkPaint& paint,
const SkSurfaceProps& surfaceProps, const SkMatrix& deviceMatrix, const SkSurfaceProps& surfaceProps, const SkMatrix& deviceMatrix,
const GrSDFTControl& control) { const sktext::gpu::SDFTControl& control) {
// Add filter to the paint which creates the SDFT data for A8 masks. // Add filter to the paint which creates the SDFT data for A8 masks.
SkPaint dfPaint{paint}; SkPaint dfPaint{paint};
dfPaint.setMaskFilter(GrSDFMaskFilter::Make()); dfPaint.setMaskFilter(sktext::gpu::SDFMaskFilter::Make());
auto [dfFont, strikeToSourceScale, matrixRange] = control.getSDFFont(font, deviceMatrix); auto [dfFont, strikeToSourceScale, matrixRange] = control.getSDFFont(font, deviceMatrix);

View File

@ -16,7 +16,7 @@
#include <tuple> #include <tuple>
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "src/gpu/ganesh/text/GrSDFTControl.h" #include "src/text/gpu/SDFTControl.h"
namespace sktext::gpu { namespace sktext::gpu {
class StrikeCache; class StrikeCache;
class TextStrike; class TextStrike;
@ -73,12 +73,12 @@ public:
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
// Create a strike spec for scaled distance field text. // Create a strike spec for scaled distance field text.
static std::tuple<SkStrikeSpec, SkScalar, GrSDFTMatrixRange> MakeSDFT( static std::tuple<SkStrikeSpec, SkScalar, sktext::gpu::SDFTMatrixRange> MakeSDFT(
const SkFont& font, const SkFont& font,
const SkPaint& paint, const SkPaint& paint,
const SkSurfaceProps& surfaceProps, const SkSurfaceProps& surfaceProps,
const SkMatrix& deviceMatrix, const SkMatrix& deviceMatrix,
const GrSDFTControl& control); const sktext::gpu::SDFTControl& control);
sk_sp<sktext::gpu::TextStrike> findOrCreateTextStrike(sktext::gpu::StrikeCache* cache) const; sk_sp<sktext::gpu::TextStrike> findOrCreateTextStrike(sktext::gpu::StrikeCache* cache) const;
#endif #endif

View File

@ -16,7 +16,10 @@ cc_library(
":Swizzle_src", ":Swizzle_src",
"//src/gpu/tessellate:FixedCountBufferUtils_src", "//src/gpu/tessellate:FixedCountBufferUtils_src",
"//src/gpu/tessellate:Tessellation_src", "//src/gpu/tessellate:Tessellation_src",
"//src/text/gpu:DistanceFieldAdjustTable_src",
"//src/text/gpu:GlyphVector_src", "//src/text/gpu:GlyphVector_src",
"//src/text/gpu:SDFMaskFilter_src",
"//src/text/gpu:SDFTControl_src",
"//src/text/gpu:StrikeCache_src", "//src/text/gpu:StrikeCache_src",
"//src/text/gpu:SubRunAllocator_src", "//src/text/gpu:SubRunAllocator_src",
], ],

View File

@ -188,9 +188,6 @@ cc_library(
"//src/gpu/ganesh/tessellate:PathTessellator_src", "//src/gpu/ganesh/tessellate:PathTessellator_src",
"//src/gpu/ganesh/tessellate:StrokeTessellator_src", "//src/gpu/ganesh/tessellate:StrokeTessellator_src",
"//src/gpu/ganesh/text:GrAtlasManager_src", "//src/gpu/ganesh/text:GrAtlasManager_src",
"//src/gpu/ganesh/text:GrDistanceFieldAdjustTable_src",
"//src/gpu/ganesh/text:GrSDFMaskFilter_src",
"//src/gpu/ganesh/text:GrSDFTControl_src",
"//src/gpu/ganesh/text:GrSlug_src", "//src/gpu/ganesh/text:GrSlug_src",
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_src", "//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_src",
"//src/gpu/ganesh/text:GrTextBlob_src", "//src/gpu/ganesh/text:GrTextBlob_src",
@ -1302,8 +1299,8 @@ generated_cc_atom(
"//src/core:SkTInternalLList_hdr", "//src/core:SkTInternalLList_hdr",
"//src/gpu/ganesh/ops:OpsTask_hdr", "//src/gpu/ganesh/ops:OpsTask_hdr",
"//src/gpu/ganesh/ops:SoftwarePathRenderer_hdr", "//src/gpu/ganesh/ops:SoftwarePathRenderer_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
"//src/image:SkSurface_Gpu_hdr", "//src/image:SkSurface_Gpu_hdr",
"//src/text/gpu:SDFTControl_hdr",
], ],
) )
@ -2169,7 +2166,7 @@ generated_cc_atom(
"//include/core:SkPaint_hdr", "//include/core:SkPaint_hdr",
"//include/gpu:GrRecordingContext_hdr", "//include/gpu:GrRecordingContext_hdr",
"//src/gpu:RefCntedCallback_hdr", "//src/gpu:RefCntedCallback_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr", "//src/text/gpu:SDFTControl_hdr",
], ],
) )

View File

@ -40,8 +40,8 @@
#include "src/gpu/ganesh/GrTransferFromRenderTask.h" #include "src/gpu/ganesh/GrTransferFromRenderTask.h"
#include "src/gpu/ganesh/GrWaitRenderTask.h" #include "src/gpu/ganesh/GrWaitRenderTask.h"
#include "src/gpu/ganesh/GrWritePixelsRenderTask.h" #include "src/gpu/ganesh/GrWritePixelsRenderTask.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
#include "src/image/SkSurface_Gpu.h" #include "src/image/SkSurface_Gpu.h"
#include "src/text/gpu/SDFTControl.h"
#if SK_GPU_V1 #if SK_GPU_V1
#include "src/gpu/ganesh/ops/OpsTask.h" #include "src/gpu/ganesh/ops/OpsTask.h"

View File

@ -59,8 +59,8 @@ void GrRecordingContextPriv::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) {
this->context()->drawingManager()->moveRenderTasksToDDL(ddl); this->context()->drawingManager()->moveRenderTasksToDDL(ddl);
} }
GrSDFTControl GrRecordingContextPriv::getSDFTControl(bool useSDFTForSmallText) const { sktext::gpu::SDFTControl GrRecordingContextPriv::getSDFTControl(bool useSDFTForSmallText) const {
return GrSDFTControl{ return sktext::gpu::SDFTControl{
this->caps()->shaderCaps()->supportsDistanceFieldText(), this->caps()->shaderCaps()->supportsDistanceFieldText(),
useSDFTForSmallText, useSDFTForSmallText,
this->options().fMinDistanceFieldFontSize, this->options().fMinDistanceFieldFontSize,

View File

@ -13,7 +13,7 @@
#include "src/gpu/RefCntedCallback.h" #include "src/gpu/RefCntedCallback.h"
#include "src/gpu/ganesh/BaseDevice.h" #include "src/gpu/ganesh/BaseDevice.h"
#include "src/gpu/ganesh/GrImageContextPriv.h" #include "src/gpu/ganesh/GrImageContextPriv.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h" #include "src/text/gpu/SDFTControl.h"
class GrImageInfo; class GrImageInfo;
class SkDeferredDisplayList; class SkDeferredDisplayList;
@ -108,7 +108,7 @@ public:
DMSAAStats& dmsaaStats() { return this->context()->fDMSAAStats; } DMSAAStats& dmsaaStats() { return this->context()->fDMSAAStats; }
#endif #endif
GrSDFTControl getSDFTControl(bool useSDFTForSmallText) const; sktext::gpu::SDFTControl getSDFTControl(bool useSDFTForSmallText) const;
/** /**
* Create a GrRecordingContext without a resource cache * Create a GrRecordingContext without a resource cache

View File

@ -24,8 +24,8 @@
#include "src/gpu/ganesh/effects/GrDistanceFieldGeoProc.h" #include "src/gpu/ganesh/effects/GrDistanceFieldGeoProc.h"
#include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h" #include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h"
#include "src/gpu/ganesh/text/GrAtlasManager.h" #include "src/gpu/ganesh/text/GrAtlasManager.h"
#include "src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h"
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h" #include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
#include "src/text/gpu/DistanceFieldAdjustTable.h"
#include <new> #include <new>
#include <utility> #include <utility>
@ -444,7 +444,7 @@ GrGeometryProcessor* AtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
const GrSurfaceProxyView* views, const GrSurfaceProxyView* views,
unsigned int numActiveViews) const { unsigned int numActiveViews) const {
static constexpr int kDistanceAdjustLumShift = 5; static constexpr int kDistanceAdjustLumShift = 5;
auto dfAdjustTable = GrDistanceFieldAdjustTable::Get(); auto dfAdjustTable = sktext::gpu::DistanceFieldAdjustTable::Get();
// see if we need to create a new effect // see if we need to create a new effect
if (this->isLCD()) { if (this->isLCD()) {
@ -504,7 +504,7 @@ GrOp::Owner AtlasTextOp::CreateOpTestingOnly(SurfaceDrawContext* sdc,
} }
auto rContext = sdc->recordingContext(); auto rContext = sdc->recordingContext();
GrSDFTControl control = sktext::gpu::SDFTControl control =
rContext->priv().getSDFTControl(sdc->surfaceProps().isUseDeviceIndependentFonts()); rContext->priv().getSDFTControl(sdc->surfaceProps().isUseDeviceIndependentFonts());
SkStrikeDeviceInfo strikeDeviceInfo{sdc->surfaceProps(), SkStrikeDeviceInfo strikeDeviceInfo{sdc->surfaceProps(),

View File

@ -247,8 +247,8 @@ generated_cc_atom(
"//src/gpu/ganesh/effects:GrBitmapTextGeoProc_hdr", "//src/gpu/ganesh/effects:GrBitmapTextGeoProc_hdr",
"//src/gpu/ganesh/effects:GrDistanceFieldGeoProc_hdr", "//src/gpu/ganesh/effects:GrDistanceFieldGeoProc_hdr",
"//src/gpu/ganesh/text:GrAtlasManager_hdr", "//src/gpu/ganesh/text:GrAtlasManager_hdr",
"//src/gpu/ganesh/text:GrDistanceFieldAdjustTable_hdr",
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr", "//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
"//src/text/gpu:DistanceFieldAdjustTable_hdr",
], ],
) )

View File

@ -42,73 +42,6 @@ generated_cc_atom(
], ],
) )
generated_cc_atom(
name = "GrDistanceFieldAdjustTable_hdr",
hdrs = ["GrDistanceFieldAdjustTable.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkScalar_hdr"],
)
generated_cc_atom(
name = "GrDistanceFieldAdjustTable_src",
srcs = ["GrDistanceFieldAdjustTable.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":GrDistanceFieldAdjustTable_hdr",
"//src/core:SkScalerContext_hdr",
],
)
generated_cc_atom(
name = "GrSDFMaskFilter_hdr",
hdrs = ["GrSDFMaskFilter.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkMaskFilter_hdr"],
)
generated_cc_atom(
name = "GrSDFMaskFilter_src",
srcs = ["GrSDFMaskFilter.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":GrSDFMaskFilter_hdr",
"//include/core:SkString_hdr",
"//src/core:SkDistanceFieldGen_hdr",
"//src/core:SkMaskFilterBase_hdr",
"//src/core:SkReadBuffer_hdr",
"//src/core:SkSafeMath_hdr",
"//src/core:SkWriteBuffer_hdr",
],
)
generated_cc_atom(
name = "GrSDFTControl_hdr",
hdrs = ["GrSDFTControl.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkFlattenable_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkScalar_hdr",
],
)
generated_cc_atom(
name = "GrSDFTControl_src",
srcs = ["GrSDFTControl.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":GrSDFTControl_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkGraphics_hdr",
"//include/core:SkMatrix_hdr",
"//include/core:SkPaint_hdr",
"//include/core:SkScalar_hdr",
"//include/core:SkSurfaceProps_hdr",
"//src/core:SkGlyphRunPainter_hdr",
"//src/core:SkReadBuffer_hdr",
],
)
generated_cc_atom( generated_cc_atom(
name = "GrSlug_src", name = "GrSlug_src",
srcs = ["GrSlug.cpp"], srcs = ["GrSlug.cpp"],
@ -150,7 +83,6 @@ generated_cc_atom(
visibility = ["//:__subpackages__"], visibility = ["//:__subpackages__"],
deps = [ deps = [
":GrAtlasManager_hdr", ":GrAtlasManager_hdr",
":GrSDFTControl_hdr",
":GrTextBlob_hdr", ":GrTextBlob_hdr",
"//include/core:SkColorFilter_hdr", "//include/core:SkColorFilter_hdr",
"//include/core:SkScalar_hdr", "//include/core:SkScalar_hdr",
@ -179,6 +111,7 @@ generated_cc_atom(
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr", "//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
"//src/text/gpu:GlyphVector_hdr", "//src/text/gpu:GlyphVector_hdr",
"//src/text/gpu:Glyph_hdr", "//src/text/gpu:Glyph_hdr",
"//src/text/gpu:SDFTControl_hdr",
"//src/text/gpu:StrikeCache_hdr", "//src/text/gpu:StrikeCache_hdr",
"//src/text/gpu:SubRunAllocator_hdr", "//src/text/gpu:SubRunAllocator_hdr",
], ],

View File

@ -28,10 +28,10 @@
#include "src/gpu/ganesh/geometry/GrStyledShape.h" #include "src/gpu/ganesh/geometry/GrStyledShape.h"
#include "src/gpu/ganesh/text/GrAtlasManager.h" #include "src/gpu/ganesh/text/GrAtlasManager.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
#include "src/gpu/ganesh/text/GrTextBlob.h" #include "src/gpu/ganesh/text/GrTextBlob.h"
#include "src/text/gpu/Glyph.h" #include "src/text/gpu/Glyph.h"
#include "src/text/gpu/GlyphVector.h" #include "src/text/gpu/GlyphVector.h"
#include "src/text/gpu/SDFTControl.h"
#include "src/text/gpu/StrikeCache.h" #include "src/text/gpu/StrikeCache.h"
#include "src/text/gpu/SubRunAllocator.h" #include "src/text/gpu/SubRunAllocator.h"
@ -45,6 +45,7 @@ using MaskFormat = skgpu::MaskFormat;
using Glyph = sktext::gpu::Glyph; using Glyph = sktext::gpu::Glyph;
using GlyphVector = sktext::gpu::GlyphVector; using GlyphVector = sktext::gpu::GlyphVector;
using SDFTMatrixRange = sktext::gpu::SDFTMatrixRange;
using StrikeCache = sktext::gpu::StrikeCache; using StrikeCache = sktext::gpu::StrikeCache;
using SubRunAllocator = sktext::gpu::SubRunAllocator; using SubRunAllocator = sktext::gpu::SubRunAllocator;
@ -1731,7 +1732,7 @@ public:
SDFTSubRun(const GrTextReferenceFrame* referenceFrame, SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
bool useLCDText, bool useLCDText,
bool antiAliased, bool antiAliased,
const GrSDFTMatrixRange& matrixRange, const SDFTMatrixRange& matrixRange,
TransformedMaskVertexFiller&& vertexFiller, TransformedMaskVertexFiller&& vertexFiller,
GlyphVector&& glyphs); GlyphVector&& glyphs);
@ -1740,7 +1741,7 @@ public:
const SkFont& runFont, const SkFont& runFont,
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, SkScalar strikeToSourceScale,
const GrSDFTMatrixRange& matrixRange, const SDFTMatrixRange& matrixRange,
SubRunAllocator* alloc); SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame, static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
@ -1792,7 +1793,7 @@ private:
const GrTextReferenceFrame* const fReferenceFrame; const GrTextReferenceFrame* const fReferenceFrame;
const bool fUseLCDText; const bool fUseLCDText;
const bool fAntiAliased; const bool fAntiAliased;
const GrSDFTMatrixRange fMatrixRange; const sktext::gpu::SDFTMatrixRange fMatrixRange;
const TransformedMaskVertexFiller fVertexFiller; const TransformedMaskVertexFiller fVertexFiller;
@ -1804,7 +1805,7 @@ private:
SDFTSubRun::SDFTSubRun(const GrTextReferenceFrame* referenceFrame, SDFTSubRun::SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
bool useLCDText, bool useLCDText,
bool antiAliased, bool antiAliased,
const GrSDFTMatrixRange& matrixRange, const SDFTMatrixRange& matrixRange,
TransformedMaskVertexFiller&& vertexFiller, TransformedMaskVertexFiller&& vertexFiller,
GlyphVector&& glyphs) GlyphVector&& glyphs)
: fReferenceFrame{referenceFrame} : fReferenceFrame{referenceFrame}
@ -1825,7 +1826,7 @@ GrSubRunOwner SDFTSubRun::Make(const GrTextReferenceFrame* referenceFrame,
const SkFont& runFont, const SkFont& runFont,
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, SkScalar strikeToSourceScale,
const GrSDFTMatrixRange& matrixRange, const SDFTMatrixRange& matrixRange,
SubRunAllocator* alloc) { SubRunAllocator* alloc) {
auto vertexFiller = TransformedMaskVertexFiller::Make( auto vertexFiller = TransformedMaskVertexFiller::Make(
MaskFormat::kA8, MaskFormat::kA8,
@ -1851,7 +1852,7 @@ GrSubRunOwner SDFTSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFr
const SkStrikeClient* client) { const SkStrikeClient* client) {
int useLCD = buffer.readInt(); int useLCD = buffer.readInt();
int isAntiAliased = buffer.readInt(); int isAntiAliased = buffer.readInt();
GrSDFTMatrixRange matrixRange = GrSDFTMatrixRange::MakeFromBuffer(buffer); SDFTMatrixRange matrixRange = SDFTMatrixRange::MakeFromBuffer(buffer);
auto vertexFiller = TransformedMaskVertexFiller::MakeFromBuffer(buffer, alloc); auto vertexFiller = TransformedMaskVertexFiller::MakeFromBuffer(buffer, alloc);
if (!buffer.validate(vertexFiller.has_value())) { return {}; } if (!buffer.validate(vertexFiller.has_value())) { return {}; }
auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc); auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
@ -2297,7 +2298,7 @@ void GrTextBlob::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepte
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, SkScalar strikeToSourceScale,
const SkFont& runFont, const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) { const SDFTMatrixRange& matrixRange) {
fSubRunList.append(SDFTSubRun::Make( fSubRunList.append(SDFTSubRun::Make(
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc)); this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
} }
@ -2365,7 +2366,7 @@ public:
void processSourceSDFT( void processSourceSDFT(
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike, const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, const SkFont& runFont, SkScalar strikeToSourceScale, const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) override; const SDFTMatrixRange& matrixRange) override;
const SkMatrix& initialPositionMatrix() const override { return fInitialPositionMatrix; } const SkMatrix& initialPositionMatrix() const override { return fInitialPositionMatrix; }
SkPoint origin() const { return fOrigin; } SkPoint origin() const { return fOrigin; }
@ -2545,7 +2546,7 @@ void Slug::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, SkScalar strikeToSourceScale,
const SkFont& runFont, const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) { const SDFTMatrixRange& matrixRange) {
fSubRuns.append(SDFTSubRun::Make( fSubRuns.append(SDFTSubRun::Make(
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc)); this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
} }

View File

@ -277,7 +277,7 @@ private:
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, SkScalar strikeToSourceScale,
const SkFont& runFont, const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) override; const sktext::gpu::SDFTMatrixRange& matrixRange) override;
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted, void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) override; SkScalar strikeToSourceScale) override;

View File

@ -325,8 +325,8 @@ generated_cc_atom(
"//src/gpu/ganesh/ops:ShadowRRectOp_hdr", "//src/gpu/ganesh/ops:ShadowRRectOp_hdr",
"//src/gpu/ganesh/ops:StrokeRectOp_hdr", "//src/gpu/ganesh/ops:StrokeRectOp_hdr",
"//src/gpu/ganesh/ops:TextureOp_hdr", "//src/gpu/ganesh/ops:TextureOp_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_hdr", "//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_hdr",
"//src/text/gpu:SDFTControl_hdr",
], ],
) )

View File

@ -197,7 +197,7 @@ protected:
SkIRect onDevClipBounds() const override { return fClip.getConservativeBounds(); } SkIRect onDevClipBounds() const override { return fClip.getConservativeBounds(); }
private: private:
const GrSDFTControl fSDFTControl; const sktext::gpu::SDFTControl fSDFTControl;
std::unique_ptr<SurfaceDrawContext> fSurfaceDrawContext; std::unique_ptr<SurfaceDrawContext> fSurfaceDrawContext;

View File

@ -71,9 +71,9 @@
#include "src/gpu/ganesh/ops/ShadowRRectOp.h" #include "src/gpu/ganesh/ops/ShadowRRectOp.h"
#include "src/gpu/ganesh/ops/StrokeRectOp.h" #include "src/gpu/ganesh/ops/StrokeRectOp.h"
#include "src/gpu/ganesh/ops/TextureOp.h" #include "src/gpu/ganesh/ops/TextureOp.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
#include "src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.h" #include "src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.h"
#include "src/gpu/ganesh/v1/PathRenderer.h" #include "src/gpu/ganesh/v1/PathRenderer.h"
#include "src/text/gpu/SDFTControl.h"
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this->drawingManager()->getContext()) #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this->drawingManager()->getContext())
#define ASSERT_SINGLE_OWNER SKGPU_ASSERT_SINGLE_OWNER(this->singleOwner()) #define ASSERT_SINGLE_OWNER SKGPU_ASSERT_SINGLE_OWNER(this->singleOwner())

View File

@ -87,3 +87,70 @@ generated_cc_atom(
"//include/core:SkMath_hdr", "//include/core:SkMath_hdr",
], ],
) )
generated_cc_atom(
name = "DistanceFieldAdjustTable_hdr",
hdrs = ["DistanceFieldAdjustTable.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkScalar_hdr"],
)
generated_cc_atom(
name = "DistanceFieldAdjustTable_src",
srcs = ["DistanceFieldAdjustTable.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":DistanceFieldAdjustTable_hdr",
"//src/core:SkScalerContext_hdr",
],
)
generated_cc_atom(
name = "SDFMaskFilter_hdr",
hdrs = ["SDFMaskFilter.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkMaskFilter_hdr"],
)
generated_cc_atom(
name = "SDFMaskFilter_src",
srcs = ["SDFMaskFilter.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":SDFMaskFilter_hdr",
"//include/core:SkString_hdr",
"//src/core:SkDistanceFieldGen_hdr",
"//src/core:SkMaskFilterBase_hdr",
"//src/core:SkReadBuffer_hdr",
"//src/core:SkSafeMath_hdr",
"//src/core:SkWriteBuffer_hdr",
],
)
generated_cc_atom(
name = "SDFTControl_hdr",
hdrs = ["SDFTControl.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkFlattenable_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkScalar_hdr",
],
)
generated_cc_atom(
name = "SDFTControl_src",
srcs = ["SDFTControl.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":SDFTControl_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkGraphics_hdr",
"//include/core:SkMatrix_hdr",
"//include/core:SkPaint_hdr",
"//include/core:SkScalar_hdr",
"//include/core:SkSurfaceProps_hdr",
"//src/core:SkGlyphRunPainter_hdr",
"//src/core:SkReadBuffer_hdr",
],
)

View File

@ -5,10 +5,12 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h" #include "src/text/gpu/DistanceFieldAdjustTable.h"
#include "src/core/SkScalerContext.h" #include "src/core/SkScalerContext.h"
namespace sktext::gpu {
SkDEBUGCODE(static const int kExpectedDistanceAdjustTableSize = 8;) SkDEBUGCODE(static const int kExpectedDistanceAdjustTableSize = 8;)
SkScalar* build_distance_adjust_table(SkScalar paintGamma, SkScalar deviceGamma) { SkScalar* build_distance_adjust_table(SkScalar paintGamma, SkScalar deviceGamma) {
@ -98,12 +100,14 @@ SkScalar* build_distance_adjust_table(SkScalar paintGamma, SkScalar deviceGamma)
return table; return table;
} }
const GrDistanceFieldAdjustTable* GrDistanceFieldAdjustTable::Get() { const DistanceFieldAdjustTable* DistanceFieldAdjustTable::Get() {
static const GrDistanceFieldAdjustTable* dfat = new GrDistanceFieldAdjustTable; static const DistanceFieldAdjustTable* dfat = new DistanceFieldAdjustTable;
return dfat; return dfat;
} }
GrDistanceFieldAdjustTable::GrDistanceFieldAdjustTable() { DistanceFieldAdjustTable::DistanceFieldAdjustTable() {
fTable = build_distance_adjust_table(SK_GAMMA_EXPONENT, SK_GAMMA_EXPONENT); fTable = build_distance_adjust_table(SK_GAMMA_EXPONENT, SK_GAMMA_EXPONENT);
fGammaCorrectTable = build_distance_adjust_table(SK_Scalar1, SK_Scalar1); fGammaCorrectTable = build_distance_adjust_table(SK_Scalar1, SK_Scalar1);
} }
} // namespace sktext::gpu

View File

@ -5,17 +5,19 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#ifndef GrDistanceFieldAdjustTable_DEFINED #ifndef sktext_gpu_DistanceFieldAdjustTable_DEFINED
#define GrDistanceFieldAdjustTable_DEFINED #define sktext_gpu_DistanceFieldAdjustTable_DEFINED
#include "include/core/SkScalar.h" #include "include/core/SkScalar.h"
// Distance field text needs this table to compute a value for use in the fragment shader. namespace sktext::gpu {
class GrDistanceFieldAdjustTable {
public:
static const GrDistanceFieldAdjustTable* Get();
~GrDistanceFieldAdjustTable() { // Distance field text needs this table to compute a value for use in the fragment shader.
class DistanceFieldAdjustTable {
public:
static const DistanceFieldAdjustTable* Get();
~DistanceFieldAdjustTable() {
delete[] fTable; delete[] fTable;
delete[] fGammaCorrectTable; delete[] fGammaCorrectTable;
} }
@ -25,10 +27,12 @@ public:
} }
private: private:
GrDistanceFieldAdjustTable(); DistanceFieldAdjustTable();
SkScalar* fTable; SkScalar* fTable;
SkScalar* fGammaCorrectTable; SkScalar* fGammaCorrectTable;
}; };
} // namespace sktext::gpu
#endif #endif

View File

@ -11,11 +11,13 @@
#include "src/core/SkReadBuffer.h" #include "src/core/SkReadBuffer.h"
#include "src/core/SkSafeMath.h" #include "src/core/SkSafeMath.h"
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#include "src/gpu/ganesh/text/GrSDFMaskFilter.h" #include "src/text/gpu/SDFMaskFilter.h"
class GrSDFMaskFilterImpl : public SkMaskFilterBase { namespace sktext::gpu {
class SDFMaskFilterImpl : public SkMaskFilterBase {
public: public:
GrSDFMaskFilterImpl(); SDFMaskFilterImpl();
// overrides from SkMaskFilterBase // overrides from SkMaskFilterBase
// This method is not exported to java. // This method is not exported to java.
@ -29,21 +31,21 @@ public:
protected: protected:
private: private:
SK_FLATTENABLE_HOOKS(GrSDFMaskFilterImpl) SK_FLATTENABLE_HOOKS(SDFMaskFilterImpl)
using INHERITED = SkMaskFilter; using INHERITED = SkMaskFilter;
friend void gr_register_sdf_maskfilter_createproc(); friend void register_sdf_maskfilter_createproc();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
GrSDFMaskFilterImpl::GrSDFMaskFilterImpl() {} SDFMaskFilterImpl::SDFMaskFilterImpl() {}
SkMask::Format GrSDFMaskFilterImpl::getFormat() const { SkMask::Format SDFMaskFilterImpl::getFormat() const {
return SkMask::kSDF_Format; return SkMask::kSDF_Format;
} }
bool GrSDFMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src, bool SDFMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
const SkMatrix& matrix, SkIPoint* margin) const { const SkMatrix& matrix, SkIPoint* margin) const {
if (src.fFormat != SkMask::kA8_Format if (src.fFormat != SkMask::kA8_Format
&& src.fFormat != SkMask::kBW_Format && src.fFormat != SkMask::kBW_Format
@ -81,20 +83,22 @@ bool GrSDFMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
} }
} }
void GrSDFMaskFilterImpl::computeFastBounds(const SkRect& src, void SDFMaskFilterImpl::computeFastBounds(const SkRect& src,
SkRect* dst) const { SkRect* dst) const {
dst->setLTRB(src.fLeft - SK_DistanceFieldPad, src.fTop - SK_DistanceFieldPad, dst->setLTRB(src.fLeft - SK_DistanceFieldPad, src.fTop - SK_DistanceFieldPad,
src.fRight + SK_DistanceFieldPad, src.fBottom + SK_DistanceFieldPad); src.fRight + SK_DistanceFieldPad, src.fBottom + SK_DistanceFieldPad);
} }
sk_sp<SkFlattenable> GrSDFMaskFilterImpl::CreateProc(SkReadBuffer& buffer) { sk_sp<SkFlattenable> SDFMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
return GrSDFMaskFilter::Make(); return SDFMaskFilter::Make();
} }
void gr_register_sdf_maskfilter_createproc() { SK_REGISTER_FLATTENABLE(GrSDFMaskFilterImpl); } void register_sdf_maskfilter_createproc() { SK_REGISTER_FLATTENABLE(SDFMaskFilterImpl); }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
sk_sp<SkMaskFilter> GrSDFMaskFilter::Make() { sk_sp<SkMaskFilter> SDFMaskFilter::Make() {
return sk_sp<SkMaskFilter>(new GrSDFMaskFilterImpl()); return sk_sp<SkMaskFilter>(new SDFMaskFilterImpl());
} }
} // namespace sktext::gpu

View File

@ -1,24 +1,28 @@
/* /*
* Copyright 2018 Google Inc. * Copyright 2022 Google Inc.
* *
* Use of this source code is governed by a BSD-style license that can be * Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#ifndef GrSDFMaskFilter_DEFINED #ifndef sktext_gpu_SDFMaskFilter_DEFINED
#define GrSDFMaskFilter_DEFINED #define sktext_gpu_SDFMaskFilter_DEFINED
#include "include/core/SkMaskFilter.h" #include "include/core/SkMaskFilter.h"
/** \class GrSDFMaskFilter namespace sktext::gpu {
/** \class SDFMaskFilter
This mask filter converts an alpha mask to a signed distance field representation This mask filter converts an alpha mask to a signed distance field representation
*/ */
class GrSDFMaskFilter : public SkMaskFilter { class SDFMaskFilter : public SkMaskFilter {
public: public:
static sk_sp<SkMaskFilter> Make(); static sk_sp<SkMaskFilter> Make();
}; };
extern void gr_register_sdf_maskfilter_createproc(); extern void register_sdf_maskfilter_createproc();
} // namespace sktext::gpu
#endif #endif

View File

@ -5,7 +5,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "src/gpu/ganesh/text/GrSDFTControl.h" #include "src/text/gpu/SDFTControl.h"
#include "include/core/SkFont.h" #include "include/core/SkFont.h"
#include "include/core/SkGraphics.h" #include "include/core/SkGraphics.h"
@ -18,6 +18,8 @@
#include <tuple> #include <tuple>
namespace sktext::gpu {
// DF sizes and thresholds for usage of the small and medium sizes. For example, above // DF sizes and thresholds for usage of the small and medium sizes. For example, above
// kSmallDFFontLimit we will use the medium size. The large size is used up until the size at // kSmallDFFontLimit we will use the medium size. The large size is used up until the size at
// which we switch over to drawing as paths as controlled by Control. // which we switch over to drawing as paths as controlled by Control.
@ -28,14 +30,14 @@ static const int kLargeDFFontLimit = 162;
static const int kExtraLargeDFFontLimit = 256; static const int kExtraLargeDFFontLimit = 256;
#endif #endif
SkScalar GrSDFTControl::MinSDFTRange(bool useSDFTForSmallText, SkScalar min) { SkScalar SDFTControl::MinSDFTRange(bool useSDFTForSmallText, SkScalar min) {
if (!useSDFTForSmallText) { if (!useSDFTForSmallText) {
return kLargeDFFontLimit; return kLargeDFFontLimit;
} }
return min; return min;
} }
GrSDFTControl::GrSDFTControl( SDFTControl::SDFTControl(
bool ableToUseSDFT, bool useSDFTForSmallText, SkScalar min, SkScalar max) bool ableToUseSDFT, bool useSDFTForSmallText, SkScalar min, SkScalar max)
: fMinDistanceFieldFontSize{MinSDFTRange(useSDFTForSmallText, min)} : fMinDistanceFieldFontSize{MinSDFTRange(useSDFTForSmallText, min)}
, fMaxDistanceFieldFontSize{max} , fMaxDistanceFieldFontSize{max}
@ -43,12 +45,12 @@ GrSDFTControl::GrSDFTControl(
SkASSERT_RELEASE(0 < min && min <= max); SkASSERT_RELEASE(0 < min && min <= max);
} }
bool GrSDFTControl::isDirect(SkScalar approximateDeviceTextSize, const SkPaint& paint) const { bool SDFTControl::isDirect(SkScalar approximateDeviceTextSize, const SkPaint& paint) const {
return !isSDFT(approximateDeviceTextSize, paint) && return !isSDFT(approximateDeviceTextSize, paint) &&
approximateDeviceTextSize < SkStrikeCommon::kSkSideTooBigForAtlas; approximateDeviceTextSize < SkStrikeCommon::kSkSideTooBigForAtlas;
} }
bool GrSDFTControl::isSDFT(SkScalar approximateDeviceTextSize, const SkPaint& paint) const { bool SDFTControl::isSDFT(SkScalar approximateDeviceTextSize, const SkPaint& paint) const {
return fAbleToUseSDFT && return fAbleToUseSDFT &&
paint.getMaskFilter() == nullptr && paint.getMaskFilter() == nullptr &&
paint.getStyle() == SkPaint::kFill_Style && paint.getStyle() == SkPaint::kFill_Style &&
@ -76,8 +78,8 @@ SkScalar scaled_text_size(const SkScalar textSize, const SkMatrix& viewMatrix) {
return scaledTextSize; return scaledTextSize;
} }
std::tuple<SkFont, SkScalar, GrSDFTMatrixRange> std::tuple<SkFont, SkScalar, SDFTMatrixRange>
GrSDFTControl::getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const { SDFTControl::getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const {
SkScalar textSize = font.getSize(); SkScalar textSize = font.getSize();
SkScalar scaledTextSize = scaled_text_size(textSize, viewMatrix); SkScalar scaledTextSize = scaled_text_size(textSize, viewMatrix);
@ -119,18 +121,20 @@ GrSDFTControl::getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const
return {dfFont, textSize / dfMaskScaleCeil, {minMatrixScale, maxMatrixScale}}; return {dfFont, textSize / dfMaskScaleCeil, {minMatrixScale, maxMatrixScale}};
} }
bool GrSDFTMatrixRange::matrixInRange(const SkMatrix& matrix) const { bool SDFTMatrixRange::matrixInRange(const SkMatrix& matrix) const {
SkScalar maxScale = matrix.getMaxScale(); SkScalar maxScale = matrix.getMaxScale();
return fMatrixMin < maxScale && maxScale <= fMatrixMax; return fMatrixMin < maxScale && maxScale <= fMatrixMax;
} }
void GrSDFTMatrixRange::flatten(SkWriteBuffer& buffer) const { void SDFTMatrixRange::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalar(fMatrixMin); buffer.writeScalar(fMatrixMin);
buffer.writeScalar(fMatrixMax); buffer.writeScalar(fMatrixMax);
} }
GrSDFTMatrixRange GrSDFTMatrixRange::MakeFromBuffer(SkReadBuffer& buffer) { SDFTMatrixRange SDFTMatrixRange::MakeFromBuffer(SkReadBuffer& buffer) {
SkScalar min = buffer.readScalar(); SkScalar min = buffer.readScalar();
SkScalar max = buffer.readScalar(); SkScalar max = buffer.readScalar();
return GrSDFTMatrixRange{min, max}; return SDFTMatrixRange{min, max};
} }
} // namespace sktext::gpu

View File

@ -5,8 +5,8 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#ifndef GrSDFTControl_DEFINED #ifndef sktext_gpu_SDFTControl_DEFINED
#define GrSDFTControl_DEFINED #define sktext_gpu_SDFTControl_DEFINED
#include "include/core/SkFlattenable.h" #include "include/core/SkFlattenable.h"
#include "include/core/SkFont.h" #include "include/core/SkFont.h"
@ -17,27 +17,29 @@
class SkMatrix; class SkMatrix;
class SkSurfaceProps; class SkSurfaceProps;
namespace sktext::gpu {
// Two numbers fMatrixMin and fMatrixMax such that if viewMatrix.getMaxScale() is between them then // Two numbers fMatrixMin and fMatrixMax such that if viewMatrix.getMaxScale() is between them then
// this SDFT size can be reused. // this SDFT size can be reused.
class GrSDFTMatrixRange { class SDFTMatrixRange {
public: public:
GrSDFTMatrixRange(SkScalar min, SkScalar max) : fMatrixMin{min}, fMatrixMax{max} {} SDFTMatrixRange(SkScalar min, SkScalar max) : fMatrixMin{min}, fMatrixMax{max} {}
bool matrixInRange(const SkMatrix& matrix) const; bool matrixInRange(const SkMatrix& matrix) const;
void flatten(SkWriteBuffer& buffer) const; void flatten(SkWriteBuffer& buffer) const;
static GrSDFTMatrixRange MakeFromBuffer(SkReadBuffer& buffer); static SDFTMatrixRange MakeFromBuffer(SkReadBuffer& buffer);
private: private:
const SkScalar fMatrixMin, const SkScalar fMatrixMin,
fMatrixMax; fMatrixMax;
}; };
class GrSDFTControl { class SDFTControl {
public: public:
GrSDFTControl(bool ableToUseSDFT, bool useSDFTForSmallText, SkScalar min, SkScalar max); SDFTControl(bool ableToUseSDFT, bool useSDFTForSmallText, SkScalar min, SkScalar max);
// Produce a font, a scale factor from the nominal size to the source space size, and matrix // Produce a font, a scale factor from the nominal size to the source space size, and matrix
// range where this font can be reused. // range where this font can be reused.
std::tuple<SkFont, SkScalar, GrSDFTMatrixRange> std::tuple<SkFont, SkScalar, SDFTMatrixRange>
getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const; getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const;
bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint& paint) const; bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint& paint) const;
@ -56,4 +58,6 @@ private:
const bool fAbleToUseSDFT; const bool fAbleToUseSDFT;
}; };
#endif // GrSDFTControl_DEFINED } // namespace sktext::gpu
#endif // sktext_SDFTControl_DEFINED

View File

@ -5615,7 +5615,7 @@ generated_cc_atom(
"//src/gpu/ganesh:GrCaps_hdr", "//src/gpu/ganesh:GrCaps_hdr",
"//src/gpu/ganesh:GrDirectContextPriv_hdr", "//src/gpu/ganesh:GrDirectContextPriv_hdr",
"//src/gpu/ganesh:GrRecordingContextPriv_hdr", "//src/gpu/ganesh:GrRecordingContextPriv_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr", "//src/text/gpu:SDFTControl_hdr",
"//tools:Resources_hdr", "//tools:Resources_hdr",
"//tools:ToolUtils_hdr", "//tools:ToolUtils_hdr",
"//tools/fonts:TestEmptyTypeface_hdr", "//tools/fonts:TestEmptyTypeface_hdr",

View File

@ -339,7 +339,7 @@ DEF_TEST(KeyEqualityOnPerspective, r) {
// Build the strike device. // Build the strike device.
SkSurfaceProps props; SkSurfaceProps props;
GrSDFTControl control(false, false, 1, 100); sktext::gpu::SDFTControl control(false, false, 1, 100);
SkStrikeDeviceInfo strikeDevice{props, SkScalerContextFlags::kBoostContrast, &control}; SkStrikeDeviceInfo strikeDevice{props, SkScalerContextFlags::kBoostContrast, &control};
SkMatrix matrix1; SkMatrix matrix1;
matrix1.setAll(1, 0, 0, 0, 1, 0, 1, 1, 1); matrix1.setAll(1, 0, 0, 0, 1, 0, 1, 1, 1);

View File

@ -24,7 +24,7 @@
#include "src/gpu/ganesh/GrCaps.h" #include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h" #include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h" #include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h" #include "src/text/gpu/SDFTControl.h"
#include "tests/Test.h" #include "tests/Test.h"
#include "tools/Resources.h" #include "tools/Resources.h"
#include "tools/ToolUtils.h" #include "tools/ToolUtils.h"
@ -818,7 +818,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsDFT, reporter, c
// A scale transform forces fallback to dft. // A scale transform forces fallback to dft.
SkMatrix matrix = SkMatrix::Scale(16, 16); SkMatrix matrix = SkMatrix::Scale(16, 16);
GrSDFTControl control = direct->priv().asRecordingContext()->priv().getSDFTControl(true); sktext::gpu::SDFTControl control =
direct->priv().asRecordingContext()->priv().getSDFTControl(true);
SkScalar approximateDeviceTextSize = SkFontPriv::ApproximateTransformedTextSize(font, matrix); SkScalar approximateDeviceTextSize = SkFontPriv::ApproximateTransformedTextSize(font, matrix);
REPORTER_ASSERT(reporter, control.isSDFT(approximateDeviceTextSize, paint)); REPORTER_ASSERT(reporter, control.isSDFT(approximateDeviceTextSize, paint));