[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:
parent
fb21a44e2d
commit
480532d1c8
12
gn/gpu.gni
12
gn/gpu.gni
@ -324,12 +324,6 @@ skia_gpu_sources = [
|
||||
# text
|
||||
"$_src/gpu/ganesh/text/GrAtlasManager.cpp",
|
||||
"$_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/GrTextBlob.cpp",
|
||||
"$_src/gpu/ganesh/text/GrTextBlob.h",
|
||||
@ -826,9 +820,15 @@ skia_shared_gpu_sources = [
|
||||
"$_src/gpu/tessellate/WangsFormula.h",
|
||||
|
||||
# text
|
||||
"$_src/text/gpu/DistanceFieldAdjustTable.cpp",
|
||||
"$_src/text/gpu/DistanceFieldAdjustTable.h",
|
||||
"$_src/text/gpu/Glyph.h",
|
||||
"$_src/text/gpu/GlyphVector.cpp",
|
||||
"$_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.h",
|
||||
"$_src/text/gpu/SubRunAllocator.cpp",
|
||||
|
12
public.bzl
12
public.bzl
@ -1218,12 +1218,6 @@ BASE_SRCS_ALL = [
|
||||
"src/gpu/ganesh/tessellate/VertexChunkPatchAllocator.h",
|
||||
"src/gpu/ganesh/text/GrAtlasManager.cpp",
|
||||
"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/GrTextBlob.cpp",
|
||||
"src/gpu/ganesh/text/GrTextBlob.h",
|
||||
@ -1649,9 +1643,15 @@ BASE_SRCS_ALL = [
|
||||
"src/sksl/transform/SkSLEliminateUnreachableCode.cpp",
|
||||
"src/sksl/transform/SkSLProgramWriter.h",
|
||||
"src/sksl/transform/SkSLTransform.h",
|
||||
"src/text/gpu/DistanceFieldAdjustTable.cpp",
|
||||
"src/text/gpu/DistanceFieldAdjustTable.h",
|
||||
"src/text/gpu/Glyph.h",
|
||||
"src/text/gpu/GlyphVector.cpp",
|
||||
"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.h",
|
||||
"src/text/gpu/SubRunAllocator.cpp",
|
||||
|
@ -2127,7 +2127,7 @@ generated_cc_atom(
|
||||
":SkScalerContext_hdr",
|
||||
":SkTextBlobPriv_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",
|
||||
"//src/gpu/ganesh:GrColorInfo_hdr",
|
||||
"//src/gpu/ganesh:GrDirectContextPriv_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_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:GrSurfaceProxyView_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",
|
||||
"//include/core:SkMaskFilter_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",
|
||||
":SkTLazy_hdr",
|
||||
"//include/core:SkGraphics_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFMaskFilter_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/text/gpu:SDFMaskFilter_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
"//src/text/gpu:StrikeCache_hdr",
|
||||
],
|
||||
)
|
||||
@ -5553,8 +5553,8 @@ generated_cc_atom(
|
||||
"//include/private:SkTHash_hdr",
|
||||
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
|
||||
"//src/gpu/ganesh:GrDrawOpAtlas_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/gpu/ganesh/text:GrTextBlob_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -34,8 +34,8 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "include/gpu/GrContextOptions.h"
|
||||
#include "src/gpu/ganesh/GrDrawOpAtlas.h"
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/gpu/ganesh/text/GrTextBlob.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -785,7 +785,7 @@ class GlyphTrackingDevice final : public SkNoPixelsDevice {
|
||||
public:
|
||||
GlyphTrackingDevice(
|
||||
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))
|
||||
, fStrikeServerImpl(server)
|
||||
, fSDFTControl(SDFTControl)
|
||||
@ -849,7 +849,7 @@ protected:
|
||||
|
||||
private:
|
||||
SkStrikeServerImpl* const fStrikeServerImpl;
|
||||
const GrSDFTControl fSDFTControl;
|
||||
const sktext::gpu::SDFTControl fSDFTControl;
|
||||
SkGlyphRunListPainter fPainter;
|
||||
SkGlyphRunListPainter fConvertPainter;
|
||||
};
|
||||
@ -867,10 +867,10 @@ std::unique_ptr<SkCanvas> SkStrikeServer::makeAnalysisCanvas(int width, int heig
|
||||
bool DFTSupport) {
|
||||
#if SK_SUPPORT_GPU
|
||||
GrContextOptions ctxOptions;
|
||||
auto control = GrSDFTControl{DFTSupport,
|
||||
props.isUseDeviceIndependentFonts(),
|
||||
ctxOptions.fMinDistanceFieldFontSize,
|
||||
ctxOptions.fGlyphsAsPathsFontSize};
|
||||
auto control = sktext::gpu::SDFTControl{DFTSupport,
|
||||
props.isUseDeviceIndependentFonts(),
|
||||
ctxOptions.fMinDistanceFieldFontSize,
|
||||
ctxOptions.fGlyphsAsPathsFontSize};
|
||||
|
||||
sk_sp<SkBaseDevice> trackingDevice(new GlyphTrackingDevice(
|
||||
SkISize::Make(width, height),
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "src/core/SkScalerContext.h"
|
||||
#include "src/shaders/SkShaderBase.h"
|
||||
|
||||
class GrSDFTControl;
|
||||
class SkBitmap;
|
||||
class SkColorSpace;
|
||||
class SkMesh;
|
||||
@ -42,12 +41,15 @@ class BaseDevice;
|
||||
namespace skgpu::graphite {
|
||||
class Device;
|
||||
}
|
||||
namespace sktext::gpu {
|
||||
class SDFTControl;
|
||||
}
|
||||
|
||||
struct SkStrikeDeviceInfo {
|
||||
const SkSurfaceProps fSurfaceProps;
|
||||
const SkScalerContextFlags fScalerContextFlags;
|
||||
// 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 {
|
||||
|
@ -11,9 +11,9 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/ganesh/GrColorInfo.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/v1/SurfaceDrawContext_v1.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
#include "include/core/SkBitmap.h"
|
||||
@ -293,7 +293,7 @@ void SkGlyphRunListPainter::categorizeGlyphRunList(SkGlyphRunPainterInterface* p
|
||||
|
||||
const SkSurfaceProps deviceProps = strikeDeviceInfo.fSurfaceProps;
|
||||
const SkScalerContextFlags scalerContextFlags = strikeDeviceInfo.fScalerContextFlags;
|
||||
const GrSDFTControl SDFTControl = *strikeDeviceInfo.fSDFTControl;
|
||||
const sktext::gpu::SDFTControl SDFTControl = *strikeDeviceInfo.fSDFTControl;
|
||||
|
||||
auto bufferScope = SkSubRunBuffers::EnsureBuffers(glyphRunList);
|
||||
auto [accepted, rejected] = bufferScope.buffers();
|
||||
|
@ -16,14 +16,16 @@
|
||||
#include "src/core/SkTextBlobPriv.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
class GrColorInfo;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
#endif
|
||||
|
||||
class SkGlyphRunPainterInterface;
|
||||
class SkStrikeSpec;
|
||||
class GrSDFTMatrixRange;
|
||||
namespace sktext {
|
||||
class SDFTMatrixRange;
|
||||
}
|
||||
|
||||
// round and ignorePositionMask are used to calculate the subpixel position of a glyph.
|
||||
// The per component (x or y) calculation is:
|
||||
@ -138,7 +140,7 @@ public:
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const SkFont& runFont,
|
||||
const GrSDFTMatrixRange& matrixRange) = 0;
|
||||
const sktext::gpu::SDFTMatrixRange& matrixRange) = 0;
|
||||
};
|
||||
#endif // SK_SUPPORT_GPU
|
||||
#endif // SkGlyphRunPainter_DEFINED
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "src/gpu/ganesh/GrFragmentProcessor.h"
|
||||
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
|
||||
#include "src/gpu/ganesh/GrTextureProxy.h"
|
||||
#include "src/gpu/ganesh/text/GrSDFMaskFilter.h"
|
||||
#include "src/text/gpu/SDFMaskFilter.h"
|
||||
#endif
|
||||
|
||||
SkMaskFilterBase::NinePatch::~NinePatch() {
|
||||
@ -378,7 +378,7 @@ SkRect SkMaskFilter::approximateFilteredBounds(const SkRect& src) const {
|
||||
void SkMaskFilter::RegisterFlattenables() {
|
||||
sk_register_blur_maskfilter_createproc();
|
||||
#if SK_SUPPORT_GPU
|
||||
gr_register_sdf_maskfilter_createproc();
|
||||
sktext::gpu::register_sdf_maskfilter_createproc();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include "src/core/SkTLazy.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/ganesh/text/GrSDFMaskFilter.h"
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/text/gpu/SDFMaskFilter.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
#include "src/text/gpu/StrikeCache.h"
|
||||
#endif
|
||||
|
||||
@ -171,13 +171,13 @@ SkStrikeSpec SkStrikeSpec::MakePDFVector(const SkTypeface& typeface, int* size)
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
std::tuple<SkStrikeSpec, SkScalar, GrSDFTMatrixRange>
|
||||
std::tuple<SkStrikeSpec, SkScalar, sktext::gpu::SDFTMatrixRange>
|
||||
SkStrikeSpec::MakeSDFT(const SkFont& font, const SkPaint& paint,
|
||||
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.
|
||||
SkPaint dfPaint{paint};
|
||||
dfPaint.setMaskFilter(GrSDFMaskFilter::Make());
|
||||
dfPaint.setMaskFilter(sktext::gpu::SDFMaskFilter::Make());
|
||||
|
||||
auto [dfFont, strikeToSourceScale, matrixRange] = control.getSDFFont(font, deviceMatrix);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <tuple>
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
namespace sktext::gpu {
|
||||
class StrikeCache;
|
||||
class TextStrike;
|
||||
@ -73,12 +73,12 @@ public:
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
// 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 SkPaint& paint,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
const SkMatrix& deviceMatrix,
|
||||
const GrSDFTControl& control);
|
||||
const sktext::gpu::SDFTControl& control);
|
||||
|
||||
sk_sp<sktext::gpu::TextStrike> findOrCreateTextStrike(sktext::gpu::StrikeCache* cache) const;
|
||||
#endif
|
||||
|
@ -16,7 +16,10 @@ cc_library(
|
||||
":Swizzle_src",
|
||||
"//src/gpu/tessellate:FixedCountBufferUtils_src",
|
||||
"//src/gpu/tessellate:Tessellation_src",
|
||||
"//src/text/gpu:DistanceFieldAdjustTable_src",
|
||||
"//src/text/gpu:GlyphVector_src",
|
||||
"//src/text/gpu:SDFMaskFilter_src",
|
||||
"//src/text/gpu:SDFTControl_src",
|
||||
"//src/text/gpu:StrikeCache_src",
|
||||
"//src/text/gpu:SubRunAllocator_src",
|
||||
],
|
||||
|
@ -188,9 +188,6 @@ cc_library(
|
||||
"//src/gpu/ganesh/tessellate:PathTessellator_src",
|
||||
"//src/gpu/ganesh/tessellate:StrokeTessellator_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:GrTextBlobRedrawCoordinator_src",
|
||||
"//src/gpu/ganesh/text:GrTextBlob_src",
|
||||
@ -1302,8 +1299,8 @@ generated_cc_atom(
|
||||
"//src/core:SkTInternalLList_hdr",
|
||||
"//src/gpu/ganesh/ops:OpsTask_hdr",
|
||||
"//src/gpu/ganesh/ops:SoftwarePathRenderer_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/image:SkSurface_Gpu_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
@ -2169,7 +2166,7 @@ generated_cc_atom(
|
||||
"//include/core:SkPaint_hdr",
|
||||
"//include/gpu:GrRecordingContext_hdr",
|
||||
"//src/gpu:RefCntedCallback_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "src/gpu/ganesh/GrTransferFromRenderTask.h"
|
||||
#include "src/gpu/ganesh/GrWaitRenderTask.h"
|
||||
#include "src/gpu/ganesh/GrWritePixelsRenderTask.h"
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/image/SkSurface_Gpu.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
|
||||
#if SK_GPU_V1
|
||||
#include "src/gpu/ganesh/ops/OpsTask.h"
|
||||
|
@ -59,8 +59,8 @@ void GrRecordingContextPriv::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) {
|
||||
this->context()->drawingManager()->moveRenderTasksToDDL(ddl);
|
||||
}
|
||||
|
||||
GrSDFTControl GrRecordingContextPriv::getSDFTControl(bool useSDFTForSmallText) const {
|
||||
return GrSDFTControl{
|
||||
sktext::gpu::SDFTControl GrRecordingContextPriv::getSDFTControl(bool useSDFTForSmallText) const {
|
||||
return sktext::gpu::SDFTControl{
|
||||
this->caps()->shaderCaps()->supportsDistanceFieldText(),
|
||||
useSDFTForSmallText,
|
||||
this->options().fMinDistanceFieldFontSize,
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
#include "src/gpu/ganesh/BaseDevice.h"
|
||||
#include "src/gpu/ganesh/GrImageContextPriv.h"
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
|
||||
class GrImageInfo;
|
||||
class SkDeferredDisplayList;
|
||||
@ -108,7 +108,7 @@ public:
|
||||
DMSAAStats& dmsaaStats() { return this->context()->fDMSAAStats; }
|
||||
#endif
|
||||
|
||||
GrSDFTControl getSDFTControl(bool useSDFTForSmallText) const;
|
||||
sktext::gpu::SDFTControl getSDFTControl(bool useSDFTForSmallText) const;
|
||||
|
||||
/**
|
||||
* Create a GrRecordingContext without a resource cache
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "src/gpu/ganesh/effects/GrDistanceFieldGeoProc.h"
|
||||
#include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.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/text/gpu/DistanceFieldAdjustTable.h"
|
||||
|
||||
#include <new>
|
||||
#include <utility>
|
||||
@ -444,7 +444,7 @@ GrGeometryProcessor* AtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
|
||||
const GrSurfaceProxyView* views,
|
||||
unsigned int numActiveViews) const {
|
||||
static constexpr int kDistanceAdjustLumShift = 5;
|
||||
auto dfAdjustTable = GrDistanceFieldAdjustTable::Get();
|
||||
auto dfAdjustTable = sktext::gpu::DistanceFieldAdjustTable::Get();
|
||||
|
||||
// see if we need to create a new effect
|
||||
if (this->isLCD()) {
|
||||
@ -504,7 +504,7 @@ GrOp::Owner AtlasTextOp::CreateOpTestingOnly(SurfaceDrawContext* sdc,
|
||||
}
|
||||
|
||||
auto rContext = sdc->recordingContext();
|
||||
GrSDFTControl control =
|
||||
sktext::gpu::SDFTControl control =
|
||||
rContext->priv().getSDFTControl(sdc->surfaceProps().isUseDeviceIndependentFonts());
|
||||
|
||||
SkStrikeDeviceInfo strikeDeviceInfo{sdc->surfaceProps(),
|
||||
|
@ -247,8 +247,8 @@ generated_cc_atom(
|
||||
"//src/gpu/ganesh/effects:GrBitmapTextGeoProc_hdr",
|
||||
"//src/gpu/ganesh/effects:GrDistanceFieldGeoProc_hdr",
|
||||
"//src/gpu/ganesh/text:GrAtlasManager_hdr",
|
||||
"//src/gpu/ganesh/text:GrDistanceFieldAdjustTable_hdr",
|
||||
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
|
||||
"//src/text/gpu:DistanceFieldAdjustTable_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -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(
|
||||
name = "GrSlug_src",
|
||||
srcs = ["GrSlug.cpp"],
|
||||
@ -150,7 +83,6 @@ generated_cc_atom(
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":GrAtlasManager_hdr",
|
||||
":GrSDFTControl_hdr",
|
||||
":GrTextBlob_hdr",
|
||||
"//include/core:SkColorFilter_hdr",
|
||||
"//include/core:SkScalar_hdr",
|
||||
@ -179,6 +111,7 @@ generated_cc_atom(
|
||||
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
|
||||
"//src/text/gpu:GlyphVector_hdr",
|
||||
"//src/text/gpu:Glyph_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
"//src/text/gpu:StrikeCache_hdr",
|
||||
"//src/text/gpu:SubRunAllocator_hdr",
|
||||
],
|
||||
|
@ -28,10 +28,10 @@
|
||||
#include "src/gpu/ganesh/geometry/GrStyledShape.h"
|
||||
|
||||
#include "src/gpu/ganesh/text/GrAtlasManager.h"
|
||||
#include "src/gpu/ganesh/text/GrSDFTControl.h"
|
||||
#include "src/gpu/ganesh/text/GrTextBlob.h"
|
||||
#include "src/text/gpu/Glyph.h"
|
||||
#include "src/text/gpu/GlyphVector.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
#include "src/text/gpu/StrikeCache.h"
|
||||
#include "src/text/gpu/SubRunAllocator.h"
|
||||
|
||||
@ -45,6 +45,7 @@ using MaskFormat = skgpu::MaskFormat;
|
||||
|
||||
using Glyph = sktext::gpu::Glyph;
|
||||
using GlyphVector = sktext::gpu::GlyphVector;
|
||||
using SDFTMatrixRange = sktext::gpu::SDFTMatrixRange;
|
||||
using StrikeCache = sktext::gpu::StrikeCache;
|
||||
using SubRunAllocator = sktext::gpu::SubRunAllocator;
|
||||
|
||||
@ -1731,7 +1732,7 @@ public:
|
||||
SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
|
||||
bool useLCDText,
|
||||
bool antiAliased,
|
||||
const GrSDFTMatrixRange& matrixRange,
|
||||
const SDFTMatrixRange& matrixRange,
|
||||
TransformedMaskVertexFiller&& vertexFiller,
|
||||
GlyphVector&& glyphs);
|
||||
|
||||
@ -1740,7 +1741,7 @@ public:
|
||||
const SkFont& runFont,
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrSDFTMatrixRange& matrixRange,
|
||||
const SDFTMatrixRange& matrixRange,
|
||||
SubRunAllocator* alloc);
|
||||
|
||||
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
|
||||
@ -1792,7 +1793,7 @@ private:
|
||||
const GrTextReferenceFrame* const fReferenceFrame;
|
||||
const bool fUseLCDText;
|
||||
const bool fAntiAliased;
|
||||
const GrSDFTMatrixRange fMatrixRange;
|
||||
const sktext::gpu::SDFTMatrixRange fMatrixRange;
|
||||
|
||||
const TransformedMaskVertexFiller fVertexFiller;
|
||||
|
||||
@ -1804,7 +1805,7 @@ private:
|
||||
SDFTSubRun::SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
|
||||
bool useLCDText,
|
||||
bool antiAliased,
|
||||
const GrSDFTMatrixRange& matrixRange,
|
||||
const SDFTMatrixRange& matrixRange,
|
||||
TransformedMaskVertexFiller&& vertexFiller,
|
||||
GlyphVector&& glyphs)
|
||||
: fReferenceFrame{referenceFrame}
|
||||
@ -1825,7 +1826,7 @@ GrSubRunOwner SDFTSubRun::Make(const GrTextReferenceFrame* referenceFrame,
|
||||
const SkFont& runFont,
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrSDFTMatrixRange& matrixRange,
|
||||
const SDFTMatrixRange& matrixRange,
|
||||
SubRunAllocator* alloc) {
|
||||
auto vertexFiller = TransformedMaskVertexFiller::Make(
|
||||
MaskFormat::kA8,
|
||||
@ -1851,7 +1852,7 @@ GrSubRunOwner SDFTSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFr
|
||||
const SkStrikeClient* client) {
|
||||
int useLCD = buffer.readInt();
|
||||
int isAntiAliased = buffer.readInt();
|
||||
GrSDFTMatrixRange matrixRange = GrSDFTMatrixRange::MakeFromBuffer(buffer);
|
||||
SDFTMatrixRange matrixRange = SDFTMatrixRange::MakeFromBuffer(buffer);
|
||||
auto vertexFiller = TransformedMaskVertexFiller::MakeFromBuffer(buffer, alloc);
|
||||
if (!buffer.validate(vertexFiller.has_value())) { return {}; }
|
||||
auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
|
||||
@ -2297,7 +2298,7 @@ void GrTextBlob::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepte
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const SkFont& runFont,
|
||||
const GrSDFTMatrixRange& matrixRange) {
|
||||
const SDFTMatrixRange& matrixRange) {
|
||||
fSubRunList.append(SDFTSubRun::Make(
|
||||
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
|
||||
}
|
||||
@ -2365,7 +2366,7 @@ public:
|
||||
void processSourceSDFT(
|
||||
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale, const SkFont& runFont,
|
||||
const GrSDFTMatrixRange& matrixRange) override;
|
||||
const SDFTMatrixRange& matrixRange) override;
|
||||
|
||||
const SkMatrix& initialPositionMatrix() const override { return fInitialPositionMatrix; }
|
||||
SkPoint origin() const { return fOrigin; }
|
||||
@ -2545,7 +2546,7 @@ void Slug::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const SkFont& runFont,
|
||||
const GrSDFTMatrixRange& matrixRange) {
|
||||
const SDFTMatrixRange& matrixRange) {
|
||||
fSubRuns.append(SDFTSubRun::Make(
|
||||
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ private:
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const SkFont& runFont,
|
||||
const GrSDFTMatrixRange& matrixRange) override;
|
||||
const sktext::gpu::SDFTMatrixRange& matrixRange) override;
|
||||
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale) override;
|
||||
|
@ -325,8 +325,8 @@ generated_cc_atom(
|
||||
"//src/gpu/ganesh/ops:ShadowRRectOp_hdr",
|
||||
"//src/gpu/ganesh/ops:StrokeRectOp_hdr",
|
||||
"//src/gpu/ganesh/ops:TextureOp_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -197,7 +197,7 @@ protected:
|
||||
SkIRect onDevClipBounds() const override { return fClip.getConservativeBounds(); }
|
||||
|
||||
private:
|
||||
const GrSDFTControl fSDFTControl;
|
||||
const sktext::gpu::SDFTControl fSDFTControl;
|
||||
|
||||
std::unique_ptr<SurfaceDrawContext> fSurfaceDrawContext;
|
||||
|
||||
|
@ -71,9 +71,9 @@
|
||||
#include "src/gpu/ganesh/ops/ShadowRRectOp.h"
|
||||
#include "src/gpu/ganesh/ops/StrokeRectOp.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/v1/PathRenderer.h"
|
||||
#include "src/text/gpu/SDFTControl.h"
|
||||
|
||||
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this->drawingManager()->getContext())
|
||||
#define ASSERT_SINGLE_OWNER SKGPU_ASSERT_SINGLE_OWNER(this->singleOwner())
|
||||
|
@ -87,3 +87,70 @@ generated_cc_atom(
|
||||
"//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",
|
||||
],
|
||||
)
|
||||
|
@ -5,10 +5,12 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h"
|
||||
#include "src/text/gpu/DistanceFieldAdjustTable.h"
|
||||
|
||||
#include "src/core/SkScalerContext.h"
|
||||
|
||||
namespace sktext::gpu {
|
||||
|
||||
SkDEBUGCODE(static const int kExpectedDistanceAdjustTableSize = 8;)
|
||||
|
||||
SkScalar* build_distance_adjust_table(SkScalar paintGamma, SkScalar deviceGamma) {
|
||||
@ -98,12 +100,14 @@ SkScalar* build_distance_adjust_table(SkScalar paintGamma, SkScalar deviceGamma)
|
||||
return table;
|
||||
}
|
||||
|
||||
const GrDistanceFieldAdjustTable* GrDistanceFieldAdjustTable::Get() {
|
||||
static const GrDistanceFieldAdjustTable* dfat = new GrDistanceFieldAdjustTable;
|
||||
const DistanceFieldAdjustTable* DistanceFieldAdjustTable::Get() {
|
||||
static const DistanceFieldAdjustTable* dfat = new DistanceFieldAdjustTable;
|
||||
return dfat;
|
||||
}
|
||||
|
||||
GrDistanceFieldAdjustTable::GrDistanceFieldAdjustTable() {
|
||||
DistanceFieldAdjustTable::DistanceFieldAdjustTable() {
|
||||
fTable = build_distance_adjust_table(SK_GAMMA_EXPONENT, SK_GAMMA_EXPONENT);
|
||||
fGammaCorrectTable = build_distance_adjust_table(SK_Scalar1, SK_Scalar1);
|
||||
}
|
||||
|
||||
} // namespace sktext::gpu
|
@ -5,17 +5,19 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrDistanceFieldAdjustTable_DEFINED
|
||||
#define GrDistanceFieldAdjustTable_DEFINED
|
||||
#ifndef sktext_gpu_DistanceFieldAdjustTable_DEFINED
|
||||
#define sktext_gpu_DistanceFieldAdjustTable_DEFINED
|
||||
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
// Distance field text needs this table to compute a value for use in the fragment shader.
|
||||
class GrDistanceFieldAdjustTable {
|
||||
public:
|
||||
static const GrDistanceFieldAdjustTable* Get();
|
||||
namespace sktext::gpu {
|
||||
|
||||
~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[] fGammaCorrectTable;
|
||||
}
|
||||
@ -25,10 +27,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
GrDistanceFieldAdjustTable();
|
||||
DistanceFieldAdjustTable();
|
||||
|
||||
SkScalar* fTable;
|
||||
SkScalar* fGammaCorrectTable;
|
||||
};
|
||||
|
||||
} // namespace sktext::gpu
|
||||
|
||||
#endif
|
@ -11,11 +11,13 @@
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkSafeMath.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:
|
||||
GrSDFMaskFilterImpl();
|
||||
SDFMaskFilterImpl();
|
||||
|
||||
// overrides from SkMaskFilterBase
|
||||
// This method is not exported to java.
|
||||
@ -29,21 +31,21 @@ public:
|
||||
protected:
|
||||
|
||||
private:
|
||||
SK_FLATTENABLE_HOOKS(GrSDFMaskFilterImpl)
|
||||
SK_FLATTENABLE_HOOKS(SDFMaskFilterImpl)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool GrSDFMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
|
||||
bool SDFMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
|
||||
const SkMatrix& matrix, SkIPoint* margin) const {
|
||||
if (src.fFormat != SkMask::kA8_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 {
|
||||
dst->setLTRB(src.fLeft - SK_DistanceFieldPad, src.fTop - SK_DistanceFieldPad,
|
||||
src.fRight + SK_DistanceFieldPad, src.fBottom + SK_DistanceFieldPad);
|
||||
}
|
||||
|
||||
sk_sp<SkFlattenable> GrSDFMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
return GrSDFMaskFilter::Make();
|
||||
sk_sp<SkFlattenable> SDFMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
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() {
|
||||
return sk_sp<SkMaskFilter>(new GrSDFMaskFilterImpl());
|
||||
sk_sp<SkMaskFilter> SDFMaskFilter::Make() {
|
||||
return sk_sp<SkMaskFilter>(new SDFMaskFilterImpl());
|
||||
}
|
||||
|
||||
} // namespace sktext::gpu
|
@ -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
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrSDFMaskFilter_DEFINED
|
||||
#define GrSDFMaskFilter_DEFINED
|
||||
#ifndef sktext_gpu_SDFMaskFilter_DEFINED
|
||||
#define sktext_gpu_SDFMaskFilter_DEFINED
|
||||
|
||||
#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
|
||||
*/
|
||||
class GrSDFMaskFilter : public SkMaskFilter {
|
||||
class SDFMaskFilter : public SkMaskFilter {
|
||||
public:
|
||||
static sk_sp<SkMaskFilter> Make();
|
||||
};
|
||||
|
||||
extern void gr_register_sdf_maskfilter_createproc();
|
||||
extern void register_sdf_maskfilter_createproc();
|
||||
|
||||
} // namespace sktext::gpu
|
||||
|
||||
#endif
|
@ -5,7 +5,7 @@
|
||||
* 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/SkGraphics.h"
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace sktext::gpu {
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
SkScalar GrSDFTControl::MinSDFTRange(bool useSDFTForSmallText, SkScalar min) {
|
||||
SkScalar SDFTControl::MinSDFTRange(bool useSDFTForSmallText, SkScalar min) {
|
||||
if (!useSDFTForSmallText) {
|
||||
return kLargeDFFontLimit;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
GrSDFTControl::GrSDFTControl(
|
||||
SDFTControl::SDFTControl(
|
||||
bool ableToUseSDFT, bool useSDFTForSmallText, SkScalar min, SkScalar max)
|
||||
: fMinDistanceFieldFontSize{MinSDFTRange(useSDFTForSmallText, min)}
|
||||
, fMaxDistanceFieldFontSize{max}
|
||||
@ -43,12 +45,12 @@ GrSDFTControl::GrSDFTControl(
|
||||
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) &&
|
||||
approximateDeviceTextSize < SkStrikeCommon::kSkSideTooBigForAtlas;
|
||||
}
|
||||
|
||||
bool GrSDFTControl::isSDFT(SkScalar approximateDeviceTextSize, const SkPaint& paint) const {
|
||||
bool SDFTControl::isSDFT(SkScalar approximateDeviceTextSize, const SkPaint& paint) const {
|
||||
return fAbleToUseSDFT &&
|
||||
paint.getMaskFilter() == nullptr &&
|
||||
paint.getStyle() == SkPaint::kFill_Style &&
|
||||
@ -76,8 +78,8 @@ SkScalar scaled_text_size(const SkScalar textSize, const SkMatrix& viewMatrix) {
|
||||
return scaledTextSize;
|
||||
}
|
||||
|
||||
std::tuple<SkFont, SkScalar, GrSDFTMatrixRange>
|
||||
GrSDFTControl::getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const {
|
||||
std::tuple<SkFont, SkScalar, SDFTMatrixRange>
|
||||
SDFTControl::getSDFFont(const SkFont& font, const SkMatrix& viewMatrix) const {
|
||||
SkScalar textSize = font.getSize();
|
||||
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}};
|
||||
}
|
||||
|
||||
bool GrSDFTMatrixRange::matrixInRange(const SkMatrix& matrix) const {
|
||||
bool SDFTMatrixRange::matrixInRange(const SkMatrix& matrix) const {
|
||||
SkScalar maxScale = matrix.getMaxScale();
|
||||
return fMatrixMin < maxScale && maxScale <= fMatrixMax;
|
||||
}
|
||||
|
||||
void GrSDFTMatrixRange::flatten(SkWriteBuffer& buffer) const {
|
||||
void SDFTMatrixRange::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeScalar(fMatrixMin);
|
||||
buffer.writeScalar(fMatrixMax);
|
||||
}
|
||||
|
||||
GrSDFTMatrixRange GrSDFTMatrixRange::MakeFromBuffer(SkReadBuffer& buffer) {
|
||||
SDFTMatrixRange SDFTMatrixRange::MakeFromBuffer(SkReadBuffer& buffer) {
|
||||
SkScalar min = buffer.readScalar();
|
||||
SkScalar max = buffer.readScalar();
|
||||
return GrSDFTMatrixRange{min, max};
|
||||
return SDFTMatrixRange{min, max};
|
||||
}
|
||||
|
||||
} // namespace sktext::gpu
|
@ -5,8 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrSDFTControl_DEFINED
|
||||
#define GrSDFTControl_DEFINED
|
||||
#ifndef sktext_gpu_SDFTControl_DEFINED
|
||||
#define sktext_gpu_SDFTControl_DEFINED
|
||||
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkFont.h"
|
||||
@ -17,27 +17,29 @@
|
||||
class SkMatrix;
|
||||
class SkSurfaceProps;
|
||||
|
||||
namespace sktext::gpu {
|
||||
|
||||
// Two numbers fMatrixMin and fMatrixMax such that if viewMatrix.getMaxScale() is between them then
|
||||
// this SDFT size can be reused.
|
||||
class GrSDFTMatrixRange {
|
||||
class SDFTMatrixRange {
|
||||
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;
|
||||
void flatten(SkWriteBuffer& buffer) const;
|
||||
static GrSDFTMatrixRange MakeFromBuffer(SkReadBuffer& buffer);
|
||||
static SDFTMatrixRange MakeFromBuffer(SkReadBuffer& buffer);
|
||||
|
||||
private:
|
||||
const SkScalar fMatrixMin,
|
||||
fMatrixMax;
|
||||
};
|
||||
|
||||
class GrSDFTControl {
|
||||
class SDFTControl {
|
||||
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
|
||||
// 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;
|
||||
|
||||
bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint& paint) const;
|
||||
@ -56,4 +58,6 @@ private:
|
||||
const bool fAbleToUseSDFT;
|
||||
};
|
||||
|
||||
#endif // GrSDFTControl_DEFINED
|
||||
} // namespace sktext::gpu
|
||||
|
||||
#endif // sktext_SDFTControl_DEFINED
|
@ -5615,7 +5615,7 @@ generated_cc_atom(
|
||||
"//src/gpu/ganesh:GrCaps_hdr",
|
||||
"//src/gpu/ganesh:GrDirectContextPriv_hdr",
|
||||
"//src/gpu/ganesh:GrRecordingContextPriv_hdr",
|
||||
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
|
||||
"//src/text/gpu:SDFTControl_hdr",
|
||||
"//tools:Resources_hdr",
|
||||
"//tools:ToolUtils_hdr",
|
||||
"//tools/fonts:TestEmptyTypeface_hdr",
|
||||
|
@ -339,7 +339,7 @@ DEF_TEST(KeyEqualityOnPerspective, r) {
|
||||
|
||||
// Build the strike device.
|
||||
SkSurfaceProps props;
|
||||
GrSDFTControl control(false, false, 1, 100);
|
||||
sktext::gpu::SDFTControl control(false, false, 1, 100);
|
||||
SkStrikeDeviceInfo strikeDevice{props, SkScalerContextFlags::kBoostContrast, &control};
|
||||
SkMatrix matrix1;
|
||||
matrix1.setAll(1, 0, 0, 0, 1, 0, 1, 1, 1);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "src/gpu/ganesh/GrCaps.h"
|
||||
#include "src/gpu/ganesh/GrDirectContextPriv.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 "tools/Resources.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.
|
||||
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);
|
||||
REPORTER_ASSERT(reporter, control.isSDFT(approximateDeviceTextSize, paint));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user