Reland "Move SkSubRun to src/text"

Added changes for public.bzl

This is a reland of commit 4a375fe213

Original change's description:
> Move SkSubRun to src/text
>
> Change-Id: I5c1040b8236dc792de20495a3fea3c0be6e31c20
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549847
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I86e342a416a3c97bf972c496b93b37e35cd09c19
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550496
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2022-06-14 14:59:21 -04:00 committed by SkCQ
parent 48e98da982
commit 1aea903381
59 changed files with 334 additions and 259 deletions

View File

@ -48,7 +48,7 @@ class DirectMaskGlyphVertexFillBenchmark : public Benchmark {
SkMatrix view = SkMatrix::I();
size_t len = strlen(gText);
SkGlyphRunBuilder builder;
sktext::GlyphRunBuilder builder;
SkPaint paint;
auto glyphRunList = builder.textToGlyphRunList(font, paint, gText, len, {100, 100});
SkASSERT(!glyphRunList.empty());

View File

@ -232,8 +232,6 @@ skia_core_sources = [
"$_src/core/SkGlyph.h",
"$_src/core/SkGlyphBuffer.cpp",
"$_src/core/SkGlyphBuffer.h",
"$_src/core/SkGlyphRun.cpp",
"$_src/core/SkGlyphRun.h",
"$_src/core/SkGlyphRunPainter.cpp",
"$_src/core/SkGlyphRunPainter.h",
"$_src/core/SkGpuBlurUtils.cpp",
@ -483,6 +481,8 @@ skia_core_sources = [
"$_src/shaders/SkShaderBase.h",
"$_src/shaders/SkTransformShader.cpp",
"$_src/shaders/SkTransformShader.h",
"$_src/text/GlyphRun.cpp",
"$_src/text/GlyphRun.h",
# private
"$_include/private/SkChecksum.h",

View File

@ -38,6 +38,11 @@
#define SK_SUPPORT_LEGACY_GETTOTALMATRIX
#endif
namespace sktext {
class GlyphRunBuilder;
class GlyphRunList;
}
class AutoLayerForImageFilter;
class GrBackendRenderTarget;
class GrRecordingContext;
@ -47,8 +52,6 @@ class SkData;
class SkDrawable;
struct SkDrawShadowRec;
class SkFont;
class SkGlyphRunBuilder;
class SkGlyphRunList;
class SkImage;
class SkImageFilter;
class SkPaintFilterCanvas;
@ -2225,7 +2228,7 @@ protected:
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint);
virtual void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint);
virtual void onDrawGlyphRunList(const sktext::GlyphRunList& glyphRunList, const SkPaint& paint);
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
@ -2279,7 +2282,7 @@ protected:
/** Experimental
*/
virtual sk_sp<sktext::gpu::Slug> onConvertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList, const SkPaint& paint);
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint);
/** Experimental
*/
@ -2540,7 +2543,7 @@ private:
class AutoUpdateQRBounds;
void validateClip() const;
std::unique_ptr<SkGlyphRunBuilder> fScratchGlyphRunBuilder;
std::unique_ptr<sktext::GlyphRunBuilder> fScratchGlyphRunBuilder;
using INHERITED = SkRefCnt;
};

View File

@ -22,7 +22,8 @@ public:
SkOverdrawCanvas(SkCanvas*);
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void onDrawGlyphRunList(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
const SkPaint&) override;
void onDrawPaint(const SkPaint&) override;

View File

@ -20,6 +20,10 @@ struct SkRSXform;
struct SkSerialProcs;
struct SkDeserialProcs;
namespace sktext {
class GlyphRunList;
}
/** \class SkTextBlob
SkTextBlob combines multiple text runs into an immutable container. Each text
run consists of glyphs, SkPaint, and position. Only parts of SkPaint related to
@ -250,7 +254,7 @@ private:
fCacheID.store(cacheID);
}
friend class SkGlyphRunList;
friend class sktext::GlyphRunList;
friend class SkTextBlobBuilder;
friend class SkTextBlobPriv;
friend class SkTextBlobRunIterator;

View File

@ -22,9 +22,12 @@
#include "include/private/SkTDArray.h"
#include "include/utils/SkNoDrawCanvas.h"
namespace sktext {
class GlyphRunList;
}
class SkData;
class SkDrawable;
class SkGlyphRunList;
class SkImage;
class SkMatrix;
class SkPaint;
@ -69,7 +72,7 @@ protected:
void didTranslate(SkScalar, SkScalar) override;
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
void onDrawGlyphRunList(const SkGlyphRunList&, const SkPaint&) override;
void onDrawGlyphRunList(const sktext::GlyphRunList&, const SkPaint&) override;
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
#if SK_SUPPORT_GPU

View File

@ -21,10 +21,13 @@
#include "include/private/SkTDArray.h"
#include "include/utils/SkNWayCanvas.h"
namespace sktext {
class GlyphRunList;
}
class GrRecordingContext;
class SkData;
class SkDrawable;
class SkGlyphRunList;
class SkImage;
class SkMatrix;
class SkPaint;
@ -103,7 +106,7 @@ protected:
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
void onDrawGlyphRunList(const SkGlyphRunList&, const SkPaint&) override;
void onDrawGlyphRunList(const sktext::GlyphRunList&, const SkPaint&) override;
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override;

View File

@ -477,8 +477,6 @@ BASE_SRCS_ALL = [
"src/core/SkGlyph.h",
"src/core/SkGlyphBuffer.cpp",
"src/core/SkGlyphBuffer.h",
"src/core/SkGlyphRun.cpp",
"src/core/SkGlyphRun.h",
"src/core/SkGlyphRunPainter.cpp",
"src/core/SkGlyphRunPainter.h",
"src/core/SkGpuBlurUtils.cpp",
@ -1639,6 +1637,8 @@ BASE_SRCS_ALL = [
"src/sksl/transform/SkSLEliminateUnreachableCode.cpp",
"src/sksl/transform/SkSLProgramWriter.h",
"src/sksl/transform/SkSLTransform.h",
"src/text/GlyphRun.cpp",
"src/text/GlyphRun.h",
"src/text/gpu/DistanceFieldAdjustTable.cpp",
"src/text/gpu/DistanceFieldAdjustTable.h",
"src/text/gpu/Glyph.h",

View File

@ -18,6 +18,7 @@ filegroup(
"//src/ports:srcs",
"//src/sfnt:srcs",
"//src/shaders:srcs",
"//src/text:srcs",
"//src/utils:srcs",
] + select({
"//bazel/common_config_settings:has_gpu_backend": [
@ -45,6 +46,7 @@ filegroup(
"//src/ports:private_hdrs",
"//src/sfnt:private_hdrs",
"//src/shaders:private_hdrs",
"//src/text:private_hdrs",
"//src/utils:private_hdrs",
] + select({
"//bazel/common_config_settings:has_gpu_backend": [

View File

@ -148,8 +148,6 @@ CORE_FILES = [
"SkGlyph.h",
"SkGlyphBuffer.cpp",
"SkGlyphBuffer.h",
"SkGlyphRun.cpp",
"SkGlyphRun.h",
"SkGlyphRunPainter.cpp",
"SkGlyphRunPainter.h",
"SkGpuBlurUtils.cpp",

View File

@ -18,7 +18,6 @@
#include "include/core/SkSurface.h"
#include "include/core/SkVertices.h"
#include "src/core/SkDraw.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkRasterClip.h"
@ -26,6 +25,7 @@
#include "src/core/SkStrikeCache.h"
#include "src/core/SkTLazy.h"
#include "src/image/SkImage_Base.h"
#include "src/text/GlyphRun.h"
struct Bounder {
SkRect fBounds;
@ -516,7 +516,7 @@ void SkBitmapDevice::drawImageRect(const SkImage* image, const SkRect* src, cons
}
void SkBitmapDevice::onDrawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
SkASSERT(!glyphRunList.hasRSXForm());

View File

@ -109,7 +109,7 @@ protected:
///////////////////////////////////////////////////////////////////////////
void onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList&,
const sktext::GlyphRunList&,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;
bool onReadPixels(const SkPixmap&, int x, int y) override;

View File

@ -27,7 +27,6 @@
#include "src/core/SkClipStack.h"
#include "src/core/SkColorFilterBase.h"
#include "src/core/SkDraw.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkLatticeIter.h"
@ -46,6 +45,7 @@
#include "src/core/SkVerticesPriv.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkSurface_Base.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkPatchUtils.h"
#include <memory>
@ -422,7 +422,7 @@ void SkCanvas::init(sk_sp<SkBaseDevice> device) {
fSurfaceBase = nullptr;
fBaseDevice = std::move(device);
fScratchGlyphRunBuilder = std::make_unique<SkGlyphRunBuilder>();
fScratchGlyphRunBuilder = std::make_unique<sktext::GlyphRunBuilder>();
fQuickRejectBounds = this->computeDeviceClipBounds();
}
@ -2334,7 +2334,7 @@ void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
this->onDrawGlyphRunList(glyphRunList, paint);
}
void SkCanvas::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
void SkCanvas::onDrawGlyphRunList(const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
SkRect bounds = glyphRunList.sourceBounds();
if (this->internalQuickReject(bounds, paint)) {
return;
@ -2354,7 +2354,8 @@ sk_sp<Slug> SkCanvas::convertBlobToSlug(
}
sk_sp<Slug>
SkCanvas::onConvertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
SkCanvas::onConvertGlyphRunListToSlug(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
SkRect bounds = glyphRunList.sourceBounds();
if (bounds.isEmpty() || !bounds.isFinite() || paint.nothingToDraw()) {
return nullptr;
@ -2392,7 +2393,7 @@ void SkCanvas::drawSimpleText(const void* text, size_t byteLength, SkTextEncodin
TRACE_EVENT0("skia", TRACE_FUNC);
if (byteLength) {
sk_msan_assert_initialized(text, SkTAddOffset<const void>(text, byteLength));
const SkGlyphRunList& glyphRunList =
const sktext::GlyphRunList& glyphRunList =
fScratchGlyphRunBuilder->textToGlyphRunList(
font, paint, text, byteLength, {x, y}, encoding);
if (!glyphRunList.empty()) {
@ -2406,7 +2407,7 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID* glyphs, const SkPoint* pos
SkPoint origin, const SkFont& font, const SkPaint& paint) {
if (count <= 0) { return; }
SkGlyphRun glyphRun {
sktext::GlyphRun glyphRun {
font,
SkSpan(positions, count),
SkSpan(glyphs, count),
@ -2414,7 +2415,7 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID* glyphs, const SkPoint* pos
SkSpan(clusters, count),
SkSpan<SkVector>()
};
SkGlyphRunList glyphRunList = fScratchGlyphRunBuilder->makeGlyphRunList(
sktext::GlyphRunList glyphRunList = fScratchGlyphRunBuilder->makeGlyphRunList(
glyphRun, glyphRun.sourceBounds(paint).makeOffset(origin), origin);
this->onDrawGlyphRunList(glyphRunList, paint);
}
@ -2423,7 +2424,7 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint pos
SkPoint origin, const SkFont& font, const SkPaint& paint) {
if (count <= 0) { return; }
SkGlyphRun glyphRun {
sktext::GlyphRun glyphRun {
font,
SkSpan(positions, count),
SkSpan(glyphs, count),
@ -2431,7 +2432,7 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint pos
SkSpan<const uint32_t>(),
SkSpan<SkVector>()
};
SkGlyphRunList glyphRunList = fScratchGlyphRunBuilder->makeGlyphRunList(
sktext::GlyphRunList glyphRunList = fScratchGlyphRunBuilder->makeGlyphRunList(
glyphRun, glyphRun.sourceBounds(paint).makeOffset(origin), origin);
this->onDrawGlyphRunList(glyphRunList, paint);
}
@ -2443,7 +2444,7 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkRSXform x
auto [positions, rotateScales] =
fScratchGlyphRunBuilder->convertRSXForm(SkSpan(xforms, count));
SkGlyphRun glyphRun {
sktext::GlyphRun glyphRun {
font,
positions,
SkSpan(glyphs, count),
@ -2451,7 +2452,7 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkRSXform x
SkSpan<const uint32_t>(),
rotateScales
};
SkGlyphRunList glyphRunList = fScratchGlyphRunBuilder->makeGlyphRunList(
sktext::GlyphRunList glyphRunList = fScratchGlyphRunBuilder->makeGlyphRunList(
glyphRun, glyphRun.sourceBounds(paint).makeOffset(origin), origin);
this->onDrawGlyphRunList(glyphRunList, paint);
}
@ -2894,7 +2895,7 @@ SkTestCanvas<SkSlugTestKey>::SkTestCanvas(SkCanvas* canvas)
: SkCanvas(sk_ref_sp(canvas->baseDevice())) {}
void SkTestCanvas<SkSlugTestKey>::onDrawGlyphRunList(
const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
SkRect bounds = glyphRunList.sourceBounds();
if (this->internalQuickReject(bounds, paint)) {
return;

View File

@ -22,7 +22,6 @@
#include "src/core/SkDevice.h"
#include "src/core/SkDraw.h"
#include "src/core/SkEnumerate.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkScalerCache.h"
#include "src/core/SkStrikeCache.h"
@ -30,6 +29,7 @@
#include "src/core/SkTLazy.h"
#include "src/core/SkTraceEvent.h"
#include "src/core/SkTypeface_remote.h"
#include "src/text/GlyphRun.h"
#if SK_SUPPORT_GPU
#include "include/gpu/GrContextOptions.h"
@ -761,7 +761,7 @@ public:
protected:
void onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override {
SkMatrix drawMatrix = this->localToDevice();
@ -778,7 +778,7 @@ protected:
"Cache Diff");
}
sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList,
sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override {
// Full matrix for placing glyphs.

View File

@ -17,7 +17,6 @@
#include "include/core/SkVertices.h"
#include "include/private/SkTo.h"
#include "src/core/SkDraw.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkImagePriv.h"
@ -32,6 +31,7 @@
#include "src/core/SkTextBlobPriv.h"
#include "src/image/SkImage_Base.h"
#include "src/shaders/SkLocalMatrixShader.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkPatchUtils.h"
#if SK_SUPPORT_GPU
#include "include/private/chromium/Slug.h"
@ -388,7 +388,6 @@ bool SkBaseDevice::peekPixels(SkPixmap* pmap) {
#include "src/core/SkUtils.h"
// TODO: This does not work for arbitrary shader DAGs (when there is no single leaf local matrix).
// What we really need is proper post-LM plumbing for shaders.
static sk_sp<SkShader> make_post_inverse_lm(const SkShader* shader, const SkMatrix& m) {
@ -426,7 +425,7 @@ static sk_sp<SkShader> make_post_inverse_lm(const SkShader* shader, const SkMatr
}
void SkBaseDevice::drawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
if (!this->localToDevice().isFinite()) {
@ -441,10 +440,10 @@ void SkBaseDevice::drawGlyphRunList(SkCanvas* canvas,
}
void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
for (const SkGlyphRun& run : glyphRunList) {
for (const sktext::GlyphRun& run : glyphRunList) {
if (run.scaledRotations().empty()) {
auto subList = glyphRunList.builder()->makeGlyphRunList(
run, run.sourceBounds(drawingPaint), {0, 0});
@ -453,7 +452,7 @@ void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas,
SkPoint origin = glyphRunList.origin();
SkPoint sharedPos{0, 0}; // we're at the origin
SkGlyphID sharedGlyphID;
SkGlyphRun glyphRun {
sktext::GlyphRun glyphRun {
run.font(),
SkSpan<const SkPoint>{&sharedPos, 1},
SkSpan<const SkGlyphID>{&sharedGlyphID, 1},
@ -478,7 +477,7 @@ void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas,
make_post_inverse_lm(drawingPaint.getShader(), glyphToLocal));
SkAutoCanvasRestore acr(canvas, true);
canvas->concat(SkM44(glyphToLocal));
SkGlyphRunList subList = glyphRunList.builder()->makeGlyphRunList(
sktext::GlyphRunList subList = glyphRunList.builder()->makeGlyphRunList(
glyphRun, glyphRun.sourceBounds(drawingPaint), {0, 0});
this->drawGlyphRunList(canvas, subList, initialPaint, invertingPaint);
}
@ -488,7 +487,7 @@ void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas,
#if (SK_SUPPORT_GPU || defined(SK_GRAPHITE_ENABLED))
sk_sp<sktext::gpu::Slug> SkBaseDevice::convertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
return nullptr;

View File

@ -22,12 +22,14 @@
#include "src/core/SkScalerContext.h"
#include "src/shaders/SkShaderBase.h"
namespace sktext {
class GlyphRun;
class GlyphRunList;
}
class SkBitmap;
class SkColorSpace;
class SkMesh;
struct SkDrawShadowRec;
class SkGlyphRun;
class SkGlyphRunList;
class SkImageFilter;
class SkImageFilterCache;
struct SkIRect;
@ -217,7 +219,7 @@ public:
// Ensure that non-RSXForm runs are passed to onDrawGlyphRunList.
void drawGlyphRunList(SkCanvas*,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint);
@ -332,14 +334,14 @@ protected:
// Only called with glyphRunLists that do not contain RSXForm.
virtual void onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList&,
const sktext::GlyphRunList&,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) = 0;
// Slug handling routines.
#if (SK_SUPPORT_GPU || defined(SK_GRAPHITE_ENABLED))
virtual sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint);
virtual void drawSlug(SkCanvas*, const sktext::gpu::Slug* slug, const SkPaint& drawingPaint);
@ -461,7 +463,7 @@ private:
friend class DeviceTestingAccess;
void simplifyGlyphRunRSXFormAndRedraw(SkCanvas*,
const SkGlyphRunList&,
const sktext::GlyphRunList&,
const SkPaint& initialPaint,
const SkPaint& drawingPaint);
@ -576,7 +578,7 @@ protected:
#endif
void onDrawGlyphRunList(
SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override {}
SkCanvas*, const sktext::GlyphRunList&, const SkPaint&, const SkPaint&) override {}
bool isNoPixelsDevice() const override { return true; }

View File

@ -63,7 +63,7 @@ public:
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
void drawGlyphRunList(SkCanvas* canvas,
SkGlyphRunListPainterCPU* glyphPainter,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint) const;
/* If skipColorXform, skips color conversion when assigning per-vertex colors */
void drawVertices(const SkVertices*,

View File

@ -8,13 +8,13 @@
#include "include/core/SkBitmap.h"
#include "src/core/SkDraw.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkPaintPriv.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkScalerCache.h"
#include "src/core/SkScalerContext.h"
#include "src/core/SkUtils.h"
#include "src/text/GlyphRun.h"
#include <climits>
// disable warning : local variable used without having been initialized
@ -108,7 +108,7 @@ void SkDraw::paintMasks(SkDrawableGlyphBuffer* accepted, const SkPaint& paint) c
void SkDraw::drawGlyphRunList(SkCanvas* canvas,
SkGlyphRunListPainterCPU* glyphPainter,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint) const {
SkDEBUGCODE(this->validate();)

View File

@ -28,13 +28,13 @@
#include "src/core/SkEnumerate.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyphBuffer.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkScalerCache.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkStrikeForGPU.h"
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkTraceEvent.h"
#include "src/text/GlyphRun.h"
#include <cinttypes>
#include <climits>
@ -64,8 +64,8 @@ SkGlyphRunListPainterCPU::SkGlyphRunListPainterCPU(const SkSurfaceProps& props,
void SkGlyphRunListPainterCPU::drawForBitmapDevice(
SkCanvas* canvas, const BitmapDevicePainter* bitmapDevice,
const SkGlyphRunList& glyphRunList, const SkPaint& paint, const SkMatrix& drawMatrix) {
auto bufferScope = SkSubRunBuffers::EnsureBuffers(glyphRunList);
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint, const SkMatrix& drawMatrix) {
auto bufferScope = sktext::SkSubRunBuffers::EnsureBuffers(glyphRunList);
auto [accepted, rejected] = bufferScope.buffers();
// The bitmap blitters can only draw lcd text to a N32 bitmap in srcOver. Otherwise,

View File

@ -13,7 +13,9 @@
#include "src/core/SkScalerContext.h"
class SkColorSpace;
class SkGlyphRunList;
namespace sktext {
class GlyphRunList;
}
class SkStrikeCommon {
public:
@ -42,7 +44,8 @@ public:
void drawForBitmapDevice(
SkCanvas* canvas, const BitmapDevicePainter* bitmapDevice,
const SkGlyphRunList& glyphRunList, const SkPaint& paint, const SkMatrix& drawMatrix);
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint,
const SkMatrix& drawMatrix);
private:
// The props as on the actual device.
const SkSurfaceProps fDeviceProps;

View File

@ -17,12 +17,12 @@
#include "src/core/SkDevice.h"
#include "src/core/SkDrawShadowInfo.h"
#include "src/core/SkGlyphBuffer.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkGlyphRunPainter.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkLatticeIter.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkTextBlobPriv.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkPatchUtils.h"
SkOverdrawCanvas::SkOverdrawCanvas(SkCanvas* canvas)
@ -65,7 +65,7 @@ public:
const SkSamplingOptions&, const SkPaint&) const override {}
void onDrawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override {
SkASSERT(!glyphRunList.hasRSXForm());
@ -81,13 +81,13 @@ private:
void SkOverdrawCanvas::onDrawTextBlob(
const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) {
SkGlyphRunBuilder b;
sktext::GlyphRunBuilder b;
auto glyphRunList = b.blobToGlyphRunList(*blob, {x, y});
this->onDrawGlyphRunList(glyphRunList, paint);
}
void SkOverdrawCanvas::onDrawGlyphRunList(
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint) {
SkSurfaceProps props{0, kUnknown_SkPixelGeometry};
this->getProps(&props);

View File

@ -14,7 +14,7 @@
#include "include/private/chromium/Slug.h"
#include "src/core/SkBigPicture.h"
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkPatchUtils.h"
#include <memory>
@ -241,7 +241,8 @@ void SkRecorder::onDrawSlug(const sktext::gpu::Slug* slug) {
}
#endif
void SkRecorder::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
void SkRecorder::onDrawGlyphRunList(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
sk_sp<SkTextBlob> blob = sk_ref_sp(glyphRunList.blob());
if (glyphRunList.blob() == nullptr) {
blob = glyphRunList.makeBlob();

View File

@ -76,7 +76,8 @@ public:
#if SK_SUPPORT_GPU
void onDrawSlug(const sktext::gpu::Slug* slug) override;
#endif
void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void onDrawGlyphRunList(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode,
const SkPaint& paint) override;

View File

@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
#include "include/core/SkRSXform.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkRSXform.h"
#include "include/core/SkTypeface.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkPaintPriv.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkSafeMath.h"
@ -17,6 +17,7 @@
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkTextBlobPriv.h"
#include "src/core/SkWriteBuffer.h"
#include "src/text/GlyphRun.h"
#include <atomic>
#include <limits>
@ -860,7 +861,7 @@ size_t SkTextBlob::serialize(const SkSerialProcs& procs, void* memory, size_t me
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace {
int get_glyph_run_intercepts(const SkGlyphRun& glyphRun,
int get_glyph_run_intercepts(const sktext::GlyphRun& glyphRun,
const SkPaint& paint,
const SkScalar bounds[2],
SkScalar intervals[],
@ -922,11 +923,11 @@ int SkTextBlob::getIntercepts(const SkScalar bounds[2], SkScalar intervals[],
paint = defaultPaint.get();
}
SkGlyphRunBuilder builder;
sktext::GlyphRunBuilder builder;
auto glyphRunList = builder.blobToGlyphRunList(*this, {0, 0});
int intervalCount = 0;
for (const SkGlyphRun& glyphRun : glyphRunList) {
for (const sktext::GlyphRun& glyphRun : glyphRunList) {
// Ignore RSXForm runs.
if (glyphRun.scaledRotations().empty()) {
intervalCount = get_glyph_run_intercepts(
@ -947,7 +948,7 @@ std::vector<SkScalar> SkFont::getIntercepts(const SkGlyphID glyphs[], int count,
const SkPaint paint(paintPtr ? *paintPtr : SkPaint());
const SkScalar bounds[] = {top, bottom};
const SkGlyphRun run(*this,
const sktext::GlyphRun run(*this,
{positions, size_t(count)}, {glyphs, size_t(count)},
{nullptr, 0}, {nullptr, 0}, {nullptr, 0});

View File

@ -83,7 +83,8 @@ SkTextBlobTrace::Capture::Capture() : fTypefaceSet(new SkRefCntSet) {
SkTextBlobTrace::Capture::~Capture() = default;
void SkTextBlobTrace::Capture::capture(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
void SkTextBlobTrace::Capture::capture(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
const SkTextBlob* blob = glyphRunList.blob();
if (blob != nullptr) {
fWriteBuffer.writeUInt(blob->uniqueID());

View File

@ -9,8 +9,8 @@
#include "include/core/SkPoint.h"
#include "include/core/SkStream.h"
#include "include/core/SkTextBlob.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkWriteBuffer.h"
#include "src/text/GlyphRun.h"
#include <cstdint>
#include <vector>
@ -32,7 +32,7 @@ class Capture {
public:
Capture();
~Capture();
void capture(const SkGlyphRunList&, const SkPaint&);
void capture(const sktext::GlyphRunList&, const SkPaint&);
// If `dst` is nullptr, write to a file.
void dump(SkWStream* dst = nullptr) const;

View File

@ -10,7 +10,6 @@
#include "include/core/SkPoint3.h"
#include "include/core/SkSpan.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkMatrixProvider.h"
@ -26,6 +25,7 @@
#include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h"
#include "src/gpu/ganesh/text/GrAtlasManager.h"
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
#include "src/text/GlyphRun.h"
#include "src/text/gpu/DistanceFieldAdjustTable.h"
#include <new>
@ -498,7 +498,7 @@ GrOp::Owner AtlasTextOp::CreateOpTestingOnly(SurfaceDrawContext* sdc,
SkMatrix drawMatrix(mtxProvider.localToDevice());
drawMatrix.preTranslate(x, y);
auto drawOrigin = SkPoint::Make(x, y);
SkGlyphRunBuilder builder;
sktext::GlyphRunBuilder builder;
auto glyphRunList = builder.textToGlyphRunList(font, skPaint, text, textLen, drawOrigin);
if (glyphRunList.empty()) {
return nullptr;

View File

@ -22,7 +22,6 @@
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkClipStack.h"
#include "src/core/SkDraw.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkLatticeIter.h"
@ -49,6 +48,7 @@
#include "src/image/SkImage_Base.h"
#include "src/image/SkReadPixelsRec.h"
#include "src/image/SkSurface_Gpu.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkUTF.h"
#if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_STRIKE_SERIALIZE)
@ -1107,7 +1107,7 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlugAndStrike(
#endif
void Device::onDrawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
ASSERT_SINGLE_OWNER

View File

@ -158,12 +158,12 @@ protected:
void onRestore() override { fClip.restore(); }
void onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList&,
const sktext::GlyphRunList&,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;
sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;

View File

@ -331,7 +331,7 @@ void SurfaceDrawContext::willReplaceOpsTask(OpsTask* prevTask, OpsTask* nextTask
void SurfaceDrawContext::drawGlyphRunList(SkCanvas* canvas,
const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
SkStrikeDeviceInfo strikeDeviceInfo,
const SkPaint& paint) {
ASSERT_SINGLE_OWNER

View File

@ -37,7 +37,6 @@ class GrTextureProxy;
struct GrTextureSetEntry;
struct GrUserStencilSettings;
struct SkDrawShadowRec;
class SkGlyphRunList;
struct SkIPoint;
struct SkIRect;
class SkLatticeIter;
@ -53,6 +52,10 @@ struct SkRSXform;
class SkTextBlob;
class SkVertices;
namespace sktext {
class GlyphRunList;
}
namespace skgpu::v1 {
/**
@ -478,7 +481,7 @@ public:
const SkRect& dst);
/**
* Draw the text specified by the SkGlyphRunList.
* Draw the text specified by the GlyphRunList.
*
* @param viewMatrix transformationMatrix
* @param glyphRunList text, text positions, and paint.
@ -486,7 +489,7 @@ public:
void drawGlyphRunList(SkCanvas*,
const GrClip*,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
SkStrikeDeviceInfo strikeDeviceInfo,
const SkPaint& paint);

View File

@ -526,7 +526,7 @@ void Device::drawImageRect(const SkImage* image, const SkRect* src, const SkRect
}
void Device::onDrawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
fRecorder->priv().textBlobCache()->drawGlyphRunList(canvas,

View File

@ -111,7 +111,7 @@ private:
bool onWritePixels(const SkPixmap&, int x, int y) override;
void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&,
void onDrawGlyphRunList(SkCanvas*, const sktext::GlyphRunList&,
const SkPaint&, const SkPaint&) override;
// TODO: This will likely be implemented with the same primitive building block that drawRect

View File

@ -8,7 +8,7 @@
#include "src/pdf/SkClusterator.h"
#include "include/private/SkTo.h"
#include "src/core/SkGlyphRun.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkUTF.h"
static bool is_reversed(const uint32_t* clusters, uint32_t count) {
@ -25,7 +25,7 @@ static bool is_reversed(const uint32_t* clusters, uint32_t count) {
return true;
}
SkClusterator::SkClusterator(const SkGlyphRun& run)
SkClusterator::SkClusterator(const sktext::GlyphRun& run)
: fClusters(run.clusters().data())
, fUtf8Text(run.text().data())
, fGlyphCount(SkToU32(run.glyphsIDs().size()))

View File

@ -7,16 +7,18 @@
#ifndef SkClusterator_DEFINED
#define SkClusterator_DEFINED
#include <vector>
#include <cstdint>
#include <vector>
class SkGlyphRun;
namespace sktext {
class GlyphRun;
}
/** Given the m-to-n glyph-to-character mapping data (as returned by
harfbuzz), iterate over the clusters. */
class SkClusterator {
public:
SkClusterator(const SkGlyphRun& run);
SkClusterator(const sktext::GlyphRun& run);
uint32_t glyphCount() const { return fGlyphCount; }
bool reversedChars() const { return fReversedChars; }
struct Cluster {
@ -42,6 +44,4 @@ private:
bool const fReversedChars;
uint32_t fCurrentGlyphIndex = 0;
};
#endif // SkClusterator_DEFINED

View File

@ -26,7 +26,6 @@
#include "src/core/SkBitmapDevice.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkDraw.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkMaskFilterBase.h"
@ -47,6 +46,7 @@
#include "src/pdf/SkPDFShader.h"
#include "src/pdf/SkPDFTypes.h"
#include "src/pdf/SkPDFUtils.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkClipStackUtils.h"
#include "src/utils/SkUTF.h"
@ -753,7 +753,7 @@ static bool contains(const SkRect& r, SkPoint p) {
}
void SkPDFDevice::drawGlyphRunAsPath(
const SkGlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint) {
const sktext::GlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint) {
const SkFont& font = glyphRun.font();
SkPath path;
@ -778,7 +778,7 @@ void SkPDFDevice::drawGlyphRunAsPath(
SkFont transparentFont = glyphRun.font();
transparentFont.setEmbolden(false); // Stop Recursion
SkGlyphRun tmpGlyphRun(glyphRun, transparentFont);
sktext::GlyphRun tmpGlyphRun(glyphRun, transparentFont);
SkPaint transparent;
transparent.setColor(SK_ColorTRANSPARENT);
@ -809,7 +809,7 @@ static bool needs_new_font(SkPDFFont* font, const SkGlyph* glyph,
}
void SkPDFDevice::internalDrawGlyphRun(
const SkGlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint) {
const sktext::GlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint) {
const SkGlyphID* glyphIDs = glyphRun.glyphsIDs().data();
uint32_t glyphCount = SkToU32(glyphRun.glyphsIDs().size());
@ -948,11 +948,11 @@ void SkPDFDevice::internalDrawGlyphRun(
}
void SkPDFDevice::onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
SkASSERT(!glyphRunList.hasRSXForm());
for (const SkGlyphRun& glyphRun : glyphRunList) {
for (const sktext::GlyphRun& glyphRun : glyphRunList) {
this->internalDrawGlyphRun(glyphRun, glyphRunList.origin(), drawingPaint);
}
}

View File

@ -25,7 +25,11 @@
#include <vector>
class SkGlyphRunList;
namespace sktext {
class GlyphRun;
class GlyphRunList;
}
class SkKeyedImage;
class SkPDFArray;
class SkPDFDevice;
@ -85,7 +89,7 @@ public:
const SkPaint&,
SkCanvas::SrcRectConstraint) override;
void onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList&,
const sktext::GlyphRunList&,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
@ -166,8 +170,10 @@ private:
void finishContentEntry(const SkClipStack*, SkBlendMode, SkPDFIndirectReference, SkPath*);
bool isContentEmpty();
void internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint);
void drawGlyphRunAsPath(const SkGlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint);
void internalDrawGlyphRun(
const sktext::GlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint);
void drawGlyphRunAsPath(
const sktext::GlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint);
void internalDrawImageRect(SkKeyedImage,
const SkRect* src,

View File

@ -48,14 +48,14 @@
#include "src/core/SkClipStack.h"
#include "src/core/SkDevice.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkTLazy.h"
#include "src/image/SkImage_Base.h"
#include "src/shaders/SkShaderBase.h"
#include "src/text/GlyphRun.h"
#include "src/xml/SkXMLWriter.h"
#include <string>
#include <memory>
#include <string>
#include <utility>
#if SK_SUPPORT_GPU
@ -208,7 +208,7 @@ bool RequiresViewportReset(const SkPaint& paint) {
return false;
}
void AddPath(const SkGlyphRun& glyphRun, const SkPoint& offset, SkPath* path) {
void AddPath(const sktext::GlyphRun& glyphRun, const SkPoint& offset, SkPath* path) {
struct Rec {
SkPath* fPath;
const SkPoint fOffset;
@ -1017,7 +1017,7 @@ void SkSVGDevice::drawImageRect(const SkImage* image, const SkRect* src, const S
class SVGTextBuilder : SkNoncopyable {
public:
SVGTextBuilder(SkPoint origin, const SkGlyphRun& glyphRun)
SVGTextBuilder(SkPoint origin, const sktext::GlyphRun& glyphRun)
: fOrigin(origin) {
auto runSize = glyphRun.runSize();
SkAutoSTArray<64, SkUnichar> unichars(runSize);
@ -1105,7 +1105,7 @@ private:
};
void SkSVGDevice::onDrawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
SkASSERT(!glyphRunList.hasRSXForm());

View File

@ -17,12 +17,15 @@
#include <memory>
namespace sktext {
class GlyphRunList;
}
class SkBaseDevice;
class SkBitmap;
class SkBlender;
class SkClipStack;
class SkData;
class SkGlyphRunList;
class SkImage;
class SkPaint;
class SkPath;
@ -58,7 +61,7 @@ protected:
bool pathIsMutable = false) override;
void onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList&,
const sktext::GlyphRunList&,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;

27
src/text/BUILD.bazel Normal file
View File

@ -0,0 +1,27 @@
load("//bazel:macros.bzl", "exports_files_legacy", "split_srcs_and_hdrs")
licenses(["notice"])
exports_files_legacy()
TEXT_FILES = [
"GlyphRun.cpp",
"GlyphRun.h",
]
split_srcs_and_hdrs(
name = "text",
files = TEXT_FILES,
)
filegroup(
name = "srcs",
srcs = [":text_srcs"],
visibility = ["//src:__pkg__"],
)
filegroup(
name = "private_hdrs",
srcs = [":text_hdrs"],
visibility = ["//src:__pkg__"],
)

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "src/core/SkGlyphRun.h"
#include "src/text/GlyphRun.h"
#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
@ -19,26 +19,27 @@
#include "src/core/SkTextBlobPriv.h"
#include "src/core/SkUtils.h"
// -- SkGlyphRun -----------------------------------------------------------------------------------
SkGlyphRun::SkGlyphRun(const SkFont& font,
SkSpan<const SkPoint> positions,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters,
SkSpan<const SkVector> scaledRotations)
namespace sktext {
// -- GlyphRun -------------------------------------------------------------------------------------
GlyphRun::GlyphRun(const SkFont& font,
SkSpan<const SkPoint> positions,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters,
SkSpan<const SkVector> scaledRotations)
: fSource{SkMakeZip(glyphIDs, positions)}
, fText{text}
, fClusters{clusters}
, fScaledRotations{scaledRotations}
, fFont{font} {}
SkGlyphRun::SkGlyphRun(const SkGlyphRun& that, const SkFont& font)
GlyphRun::GlyphRun(const GlyphRun& that, const SkFont& font)
: fSource{that.fSource}
, fText{that.fText}
, fClusters{that.fClusters}
, fFont{font} {}
SkRect SkGlyphRun::sourceBounds(const SkPaint& paint) const {
SkRect GlyphRun::sourceBounds(const SkPaint& paint) const {
SkASSERT(this->runSize() > 0);
const SkRect fontBounds = SkFontPriv::GetFontBounds(fFont);
@ -102,35 +103,34 @@ SkRect SkGlyphRun::sourceBounds(const SkPaint& paint) const {
}
}
// -- SkGlyphRunList -------------------------------------------------------------------------------
SkGlyphRunList::SkGlyphRunList(
const SkTextBlob* blob,
SkRect bounds,
SkPoint origin,
SkSpan<const SkGlyphRun> glyphRunList,
SkGlyphRunBuilder* builder)
// -- GlyphRunList ---------------------------------------------------------------------------------
GlyphRunList::GlyphRunList(const SkTextBlob* blob,
SkRect bounds,
SkPoint origin,
SkSpan<const GlyphRun> glyphRunList,
GlyphRunBuilder* builder)
: fGlyphRuns{glyphRunList}
, fOriginalTextBlob{blob}
, fSourceBounds{bounds}
, fOrigin{origin}
, fBuilder{builder} {}
SkGlyphRunList::SkGlyphRunList(const SkGlyphRun& glyphRun,
const SkRect& bounds,
SkPoint origin,
SkGlyphRunBuilder* builder)
: fGlyphRuns{SkSpan<const SkGlyphRun>{&glyphRun, 1}}
GlyphRunList::GlyphRunList(const GlyphRun& glyphRun,
const SkRect& bounds,
SkPoint origin,
GlyphRunBuilder* builder)
: fGlyphRuns{SkSpan<const GlyphRun>{&glyphRun, 1}}
, fOriginalTextBlob{nullptr}
, fSourceBounds{bounds}
, fOrigin{origin}
, fBuilder{builder} {}
uint64_t SkGlyphRunList::uniqueID() const {
uint64_t GlyphRunList::uniqueID() const {
return fOriginalTextBlob != nullptr ? fOriginalTextBlob->uniqueID()
: SK_InvalidUniqueID;
}
bool SkGlyphRunList::anyRunsLCD() const {
bool GlyphRunList::anyRunsLCD() const {
for (const auto& r : fGlyphRuns) {
if (r.font().getEdging() == SkFont::Edging::kSubpixelAntiAlias) {
return true;
@ -139,12 +139,12 @@ bool SkGlyphRunList::anyRunsLCD() const {
return false;
}
void SkGlyphRunList::temporaryShuntBlobNotifyAddedToCache(uint32_t cacheID) const {
void GlyphRunList::temporaryShuntBlobNotifyAddedToCache(uint32_t cacheID) const {
SkASSERT(fOriginalTextBlob != nullptr);
fOriginalTextBlob->notifyAddedToCache(cacheID);
}
sk_sp<SkTextBlob> SkGlyphRunList::makeBlob() const {
sk_sp<SkTextBlob> GlyphRunList::makeBlob() const {
SkTextBlobBuilder builder;
for (auto& run : *this) {
SkTextBlobBuilder::RunBuffer buffer;
@ -174,10 +174,10 @@ sk_sp<SkTextBlob> SkGlyphRunList::makeBlob() const {
return builder.make();
}
// -- SkGlyphRunBuilder ----------------------------------------------------------------------------
SkGlyphRunList SkGlyphRunBuilder::makeGlyphRunList(
const SkGlyphRun& run, SkRect bounds, SkPoint origin) {
return SkGlyphRunList{run, bounds, origin, this};
// -- GlyphRunBuilder ------------------------------------------------------------------------------
GlyphRunList GlyphRunBuilder::makeGlyphRunList(
const GlyphRun& run, SkRect bounds, SkPoint origin) {
return GlyphRunList{run, bounds, origin, this};
}
static SkSpan<const SkPoint> draw_text_positions(
@ -195,7 +195,7 @@ static SkSpan<const SkPoint> draw_text_positions(
return SkSpan(buffer, glyphIDs.size());
}
const SkGlyphRunList& SkGlyphRunBuilder::textToGlyphRunList(
const GlyphRunList& GlyphRunBuilder::textToGlyphRunList(
const SkFont& font, const SkPaint& paint,
const void* bytes, size_t byteLength, SkPoint origin,
SkTextEncoding encoding) {
@ -216,7 +216,7 @@ const SkGlyphRunList& SkGlyphRunBuilder::textToGlyphRunList(
return this->setGlyphRunList(nullptr, bounds.makeOffset(origin), origin);
}
const SkGlyphRunList& SkGlyphRunBuilder::blobToGlyphRunList(
const GlyphRunList& sktext::GlyphRunBuilder::blobToGlyphRunList(
const SkTextBlob& blob, SkPoint origin) {
// Pre-size all the buffers, so they don't move during processing.
this->initialize(blob);
@ -277,7 +277,7 @@ const SkGlyphRunList& SkGlyphRunBuilder::blobToGlyphRunList(
}
std::tuple<SkSpan<const SkPoint>, SkSpan<const SkVector>>
SkGlyphRunBuilder::convertRSXForm(SkSpan<const SkRSXform> xforms) {
GlyphRunBuilder::convertRSXForm(SkSpan<const SkRSXform> xforms) {
const int count = SkCount(xforms);
this->prepareBuffers(count, count);
auto positions = SkSpan(fPositions.get(), count);
@ -290,7 +290,7 @@ SkGlyphRunBuilder::convertRSXForm(SkSpan<const SkRSXform> xforms) {
return {positions, scaledRotations};
}
void SkGlyphRunBuilder::initialize(const SkTextBlob& blob) {
void GlyphRunBuilder::initialize(const SkTextBlob& blob) {
int positionCount = 0;
int rsxFormCount = 0;
for (SkTextBlobRunIterator it(&blob); !it.done(); it.next()) {
@ -305,7 +305,7 @@ void SkGlyphRunBuilder::initialize(const SkTextBlob& blob) {
prepareBuffers(positionCount, rsxFormCount);
}
void SkGlyphRunBuilder::prepareBuffers(int positionCount, int RSXFormCount) {
void GlyphRunBuilder::prepareBuffers(int positionCount, int RSXFormCount) {
if (positionCount > fMaxTotalRunSize) {
fMaxTotalRunSize = positionCount;
fPositions.reset(fMaxTotalRunSize);
@ -319,7 +319,7 @@ void SkGlyphRunBuilder::prepareBuffers(int positionCount, int RSXFormCount) {
fGlyphRunListStorage.clear();
}
SkSpan<const SkGlyphID> SkGlyphRunBuilder::textToGlyphIDs(
SkSpan<const SkGlyphID> GlyphRunBuilder::textToGlyphIDs(
const SkFont& font, const void* bytes, size_t byteLength, SkTextEncoding encoding) {
if (encoding != SkTextEncoding::kGlyphID) {
int count = font.countText(bytes, byteLength, encoding);
@ -335,7 +335,7 @@ SkSpan<const SkGlyphID> SkGlyphRunBuilder::textToGlyphIDs(
}
}
void SkGlyphRunBuilder::makeGlyphRun(
void GlyphRunBuilder::makeGlyphRun(
const SkFont& font,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const SkPoint> positions,
@ -355,16 +355,16 @@ void SkGlyphRunBuilder::makeGlyphRun(
}
}
const SkGlyphRunList& SkGlyphRunBuilder::setGlyphRunList(
const GlyphRunList& sktext::GlyphRunBuilder::setGlyphRunList(
const SkTextBlob* blob, const SkRect& bounds, SkPoint origin) {
fGlyphRunList.emplace(blob, bounds, origin, SkSpan(fGlyphRunListStorage), this);
return fGlyphRunList.value();
}
// -- SkSubRunBuffers ------------------------------------------------------------------------------
auto SkSubRunBuffers::EnsureBuffers(const SkGlyphRunList& glyphRunList) -> ScopedBuffers {
// -- SKSubRunBuffers ------------------------------------------------------------------------------
auto SkSubRunBuffers::EnsureBuffers(const GlyphRunList& glyphRunList) -> ScopedBuffers {
size_t size = 0;
for (const SkGlyphRun& run : glyphRunList) {
for (const GlyphRun& run : glyphRunList) {
size = std::max(run.runSize(), size);
}
return ScopedBuffers(glyphRunList.buffers(), size);
@ -379,3 +379,4 @@ SkSubRunBuffers::ScopedBuffers::~ScopedBuffers() {
fBuffers->fAccepted.reset();
fBuffers->fRejected.reset();
}
} // namespace sktext

View File

@ -25,11 +25,13 @@
class SkBaseDevice;
class SkCanvas;
class SkGlyph;
class SkGlyphRunList;
class SkGlyphRunBuilder;
class SkTextBlob;
class SkTextBlobRunIterator;
namespace sktext {
class GlyphRunBuilder;
class GlyphRunList;
class SkSubRunBuffers {
public:
class ScopedBuffers {
@ -43,23 +45,23 @@ public:
private:
SkSubRunBuffers* const fBuffers;
};
static ScopedBuffers SK_WARN_UNUSED_RESULT EnsureBuffers(const SkGlyphRunList& glyphRunList);
static ScopedBuffers SK_WARN_UNUSED_RESULT EnsureBuffers(const GlyphRunList& glyphRunList);
private:
SkDrawableGlyphBuffer fAccepted;
SkSourceGlyphBuffer fRejected;
};
class SkGlyphRun {
class GlyphRun {
public:
SkGlyphRun(const SkFont& font,
SkSpan<const SkPoint> positions,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters,
SkSpan<const SkVector> scaledRotations);
GlyphRun(const SkFont& font,
SkSpan<const SkPoint> positions,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters,
SkSpan<const SkVector> scaledRotations);
SkGlyphRun(const SkGlyphRun& glyphRun, const SkFont& font);
GlyphRun(const GlyphRun& glyphRun, const SkFont& font);
size_t runSize() const { return fSource.size(); }
SkSpan<const SkPoint> positions() const { return fSource.get<1>(); }
@ -84,22 +86,21 @@ private:
SkFont fFont;
};
class SkGlyphRunList {
SkSpan<const SkGlyphRun> fGlyphRuns;
class GlyphRunList {
SkSpan<const GlyphRun> fGlyphRuns;
public:
// Blob maybe null.
SkGlyphRunList(
const SkTextBlob* blob,
SkRect bounds,
SkPoint origin,
SkSpan<const SkGlyphRun> glyphRunList,
SkGlyphRunBuilder* builder);
GlyphRunList(const SkTextBlob* blob,
SkRect bounds,
SkPoint origin,
SkSpan<const GlyphRun> glyphRunList,
GlyphRunBuilder* builder);
SkGlyphRunList(const SkGlyphRun& glyphRun,
const SkRect& bounds,
SkPoint origin,
SkGlyphRunBuilder* builder);
GlyphRunList(const GlyphRun& glyphRun,
const SkRect& bounds,
SkPoint origin,
GlyphRunBuilder* builder);
uint64_t uniqueID() const;
bool anyRunsLCD() const;
void temporaryShuntBlobNotifyAddedToCache(uint32_t cacheID) const;
@ -108,14 +109,14 @@ public:
size_t runCount() const { return fGlyphRuns.size(); }
size_t totalGlyphCount() const {
size_t glyphCount = 0;
for (const SkGlyphRun& run : *this) {
for (const GlyphRun& run : *this) {
glyphCount += run.runSize();
}
return glyphCount;
}
bool hasRSXForm() const {
for (const SkGlyphRun& run : *this) {
for (const GlyphRun& run : *this) {
if (!run.scaledRotations().empty()) { return true; }
}
return false;
@ -126,7 +127,7 @@ public:
SkPoint origin() const { return fOrigin; }
SkRect sourceBounds() const { return fSourceBounds; }
const SkTextBlob* blob() const { return fOriginalTextBlob; }
SkGlyphRunBuilder* builder() const { return fBuilder; }
GlyphRunBuilder* builder() const { return fBuilder; }
SkSubRunBuffers* buffers() const;
auto begin() -> decltype(fGlyphRuns.begin()) { return fGlyphRuns.begin(); }
@ -143,20 +144,20 @@ private:
const SkTextBlob* fOriginalTextBlob{nullptr};
const SkRect fSourceBounds{SkRect::MakeEmpty()};
const SkPoint fOrigin = {0, 0};
SkGlyphRunBuilder* const fBuilder;
GlyphRunBuilder* const fBuilder;
};
class SkGlyphRunBuilder {
class GlyphRunBuilder {
public:
SkGlyphRunList makeGlyphRunList(
const SkGlyphRun& run, SkRect bounds, SkPoint origin);
const SkGlyphRunList& textToGlyphRunList(const SkFont& font,
const SkPaint& paint,
const void* bytes,
size_t byteLength,
SkPoint origin,
SkTextEncoding encoding = SkTextEncoding::kUTF8);
const SkGlyphRunList& blobToGlyphRunList(const SkTextBlob& blob, SkPoint origin);
GlyphRunList makeGlyphRunList(
const GlyphRun& run, SkRect bounds, SkPoint origin);
const GlyphRunList& textToGlyphRunList(const SkFont& font,
const SkPaint& paint,
const void* bytes,
size_t byteLength,
SkPoint origin,
SkTextEncoding encoding = SkTextEncoding::kUTF8);
const GlyphRunList& blobToGlyphRunList(const SkTextBlob& blob, SkPoint origin);
std::tuple<SkSpan<const SkPoint>, SkSpan<const SkVector>>
convertRSXForm(SkSpan<const SkRSXform> xforms);
@ -178,7 +179,7 @@ private:
SkSpan<const uint32_t> clusters,
SkSpan<const SkVector> scaledRotations);
const SkGlyphRunList& setGlyphRunList(
const GlyphRunList& setGlyphRunList(
const SkTextBlob* blob, const SkRect& bounds, SkPoint origin);
int fMaxTotalRunSize{0};
@ -186,8 +187,8 @@ private:
int fMaxScaledRotations{0};
SkAutoTMalloc<SkVector> fScaledRotations;
std::vector<SkGlyphRun> fGlyphRunListStorage;
std::optional<SkGlyphRunList> fGlyphRunList; // Defaults to no value;
std::vector<GlyphRun> fGlyphRunListStorage;
std::optional<GlyphRunList> fGlyphRunList; // Defaults to no value;
// Used as a temporary for preparing using utfN text. This implies that only one run of
// glyph ids will ever be needed because blobs are already glyph based.
@ -195,7 +196,7 @@ private:
SkSubRunBuffers fSubRunBuffers;
};
inline SkSubRunBuffers* SkGlyphRunList::buffers() const { return fBuilder->buffers(); }
inline SkSubRunBuffers* GlyphRunList::buffers() const { return fBuilder->buffers(); }
} // namespace sktext
#endif // SkGlyphRun_DEFINED

View File

@ -11,11 +11,11 @@
#include "src/core/SkDescriptor.h"
#include "src/core/SkDistanceFieldGen.h"
#include "src/core/SkGlyphBuffer.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkRectPriv.h"
#include "src/core/SkStrikeCache.h"
#include "src/gpu/AtlasTypes.h"
#include "src/text/GlyphRun.h"
#include "src/text/gpu/Glyph.h"
#include "src/text/gpu/GlyphVector.h"
#include "src/text/gpu/SubRunAllocator.h"
@ -2132,7 +2132,7 @@ SubRunContainerOwner SubRunContainer::MakeFromBufferInAlloc(SkReadBuffer& buffer
return container;
}
size_t SubRunContainer::EstimateAllocSize(const SkGlyphRunList& glyphRunList) {
size_t SubRunContainer::EstimateAllocSize(const GlyphRunList& glyphRunList) {
// The difference in alignment from the per-glyph data to the SubRun;
constexpr size_t alignDiff = alignof(DirectMaskSubRun) - alignof(DevicePosition);
constexpr size_t vertexDataToSubRunPadding = alignDiff > 0 ? alignDiff : 0;
@ -2145,7 +2145,7 @@ size_t SubRunContainer::EstimateAllocSize(const SkGlyphRunList& glyphRunList) {
}
std::tuple<bool, SubRunContainerOwner> SubRunContainer::MakeInAlloc(
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkMatrix& positionMatrix,
const SkPaint& runPaint,
SkStrikeDeviceInfo strikeDeviceInfo,

View File

@ -13,7 +13,6 @@
#include "src/core/SkDevice.h"
#include "src/text/gpu/SubRunAllocator.h"
class SkGlyphRunList;
class SkMatrix;
class SkMatrixProvider;
class SkPaint;
@ -22,9 +21,12 @@ class SkStrikeClient;
class SkStrikeForGPUCacheInterface;
class SkWriteBuffer;
namespace sktext::gpu {
class Glyph;
class StrikeCache;
namespace sktext {
class GlyphRunList;
namespace gpu {
class Glyph;
class StrikeCache;
}
}
#if SK_SUPPORT_GPU // Ganesh support
@ -205,7 +207,7 @@ public:
SubRunAllocator* alloc);
static std::tuple<bool, SubRunContainerOwner> MakeInAlloc(
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkMatrix& positionMatrix,
const SkPaint& runPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
@ -213,7 +215,7 @@ public:
sktext::gpu::SubRunAllocator* alloc,
const char* tag);
static size_t EstimateAllocSize(const SkGlyphRunList& glyphRunList);
static size_t EstimateAllocSize(const GlyphRunList& glyphRunList);
#if SK_SUPPORT_GPU
void draw(SkCanvas* canvas,

View File

@ -24,7 +24,6 @@
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkPaintPriv.h"
@ -32,6 +31,7 @@
#include "src/core/SkRectPriv.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkWriteBuffer.h"
#include "src/text/GlyphRun.h"
#include "src/text/gpu/SubRunAllocator.h"
#include "src/text/gpu/SubRunContainer.h"
@ -103,7 +103,7 @@ public:
~SlugImpl() override = default;
static sk_sp<SlugImpl> Make(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
@ -191,7 +191,7 @@ sk_sp<Slug> SlugImpl::MakeFromBuffer(SkReadBuffer& buffer, const SkStrikeClient*
}
sk_sp<SlugImpl> SlugImpl::Make(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
@ -228,7 +228,7 @@ sk_sp<SlugImpl> SlugImpl::Make(const SkMatrixProvider& viewMatrix,
namespace sktext::gpu {
// -- TextBlob::Key ------------------------------------------------------------------------------
auto TextBlob::Key::Make(const SkGlyphRunList& glyphRunList,
auto TextBlob::Key::Make(const GlyphRunList& glyphRunList,
const SkPaint& paint,
const SkMatrix& drawMatrix,
const SkStrikeDeviceInfo& strikeDevice) -> std::tuple<bool, Key> {
@ -340,7 +340,7 @@ void* TextBlob::operator new(size_t, void* p) { return p; }
TextBlob::~TextBlob() = default;
sk_sp<TextBlob> TextBlob::Make(const SkGlyphRunList& glyphRunList,
sk_sp<TextBlob> TextBlob::Make(const GlyphRunList& glyphRunList,
const SkPaint& paint,
const SkMatrix& positionMatrix,
SkStrikeDeviceInfo strikeDeviceInfo,
@ -452,7 +452,7 @@ sk_sp<Slug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* cli
#if SK_SUPPORT_GPU
namespace skgpu::v1 {
sk_sp<Slug>
Device::convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList,
Device::convertGlyphRunListToSlug(const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
return SlugImpl::Make(this->asMatrixProvider(),
@ -482,7 +482,7 @@ void Device::drawSlug(SkCanvas* canvas, const Slug* slug, const SkPaint& drawing
}
sk_sp<Slug> MakeSlug(const SkMatrixProvider& drawMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,

View File

@ -17,16 +17,18 @@
#include "src/core/SkTInternalLList.h"
#include "src/text/gpu/SubRunContainer.h"
class SkGlyphRunList;
class SkMatrixProvider;
class SkStrikeClient;
class SkSurfaceProps;
class SkTextBlob;
class SkTextBlobRunIterator;
namespace sktext::gpu {
class Glyph;
class StrikeCache;
namespace sktext {
class GlyphRunList;
namespace gpu {
class Glyph;
class StrikeCache;
}
}
#if SK_SUPPORT_GPU // Ganesh support
@ -60,7 +62,7 @@ public:
// Key is not used as part of a hash map, so the hash is never taken. It's only used in a
// list search using operator =().
struct Key {
static std::tuple<bool, Key> Make(const SkGlyphRunList& glyphRunList,
static std::tuple<bool, Key> Make(const GlyphRunList& glyphRunList,
const SkPaint& paint,
const SkMatrix& drawMatrix,
const SkStrikeDeviceInfo& strikeDevice);
@ -88,7 +90,7 @@ public:
SK_DECLARE_INTERNAL_LLIST_INTERFACE(TextBlob);
// Make a TextBlob and its sub runs.
static sk_sp<TextBlob> Make(const SkGlyphRunList& glyphRunList,
static sk_sp<TextBlob> Make(const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint,
const SkMatrix& positionMatrix,
SkStrikeDeviceInfo strikeDeviceInfo,
@ -155,7 +157,7 @@ private:
namespace skgpu::v1 {
sk_sp<sktext::gpu::Slug> MakeSlug(const SkMatrixProvider& drawMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,

View File

@ -7,8 +7,8 @@
#include "src/text/gpu/TextBlobRedrawCoordinator.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkStrikeCache.h"
#include "src/text/GlyphRun.h"
#if SK_SUPPORT_GPU
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
#endif
@ -32,7 +32,7 @@ TextBlobRedrawCoordinator::TextBlobRedrawCoordinator(uint32_t messageBusID)
void TextBlobRedrawCoordinator::drawGlyphRunList(SkCanvas* canvas,
const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkPaint& paint,
SkStrikeDeviceInfo strikeDeviceInfo,
skgpu::v1::SurfaceDrawContext* sdc) {
@ -46,7 +46,7 @@ void TextBlobRedrawCoordinator::drawGlyphRunList(SkCanvas* canvas,
#if defined(SK_GRAPHITE_ENABLED)
void TextBlobRedrawCoordinator::drawGlyphRunList(SkCanvas* canvas,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint,
SkStrikeDeviceInfo strikeDeviceInfo,
skgpu::graphite::Device* device) {
@ -58,7 +58,7 @@ void TextBlobRedrawCoordinator::drawGlyphRunList(SkCanvas* canvas,
#endif
sk_sp<TextBlob> TextBlobRedrawCoordinator::findOrCreateBlob(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkPaint& paint,
SkStrikeDeviceInfo strikeDeviceInfo) {
SkMatrix positionMatrix{viewMatrix.localToDevice()};
@ -93,7 +93,7 @@ sk_sp<TextBlob> TextBlobRedrawCoordinator::findOrCreateBlob(const SkMatrixProvid
}
sk_sp<TextBlob> TextBlobRedrawCoordinator::addOrReturnExisting(
const SkGlyphRunList& glyphRunList, sk_sp<TextBlob> blob) {
const GlyphRunList& glyphRunList, sk_sp<TextBlob> blob) {
SkAutoSpinlock lock{fSpinLock};
blob = this->internalAdd(std::move(blob));
glyphRunList.temporaryShuntBlobNotifyAddedToCache(fMessageBusID);

View File

@ -36,7 +36,7 @@ public:
void drawGlyphRunList(SkCanvas* canvas,
const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkPaint& paint,
SkStrikeDeviceInfo strikeDeviceInfo,
skgpu::v1::SurfaceDrawContext* sdc);
@ -44,7 +44,7 @@ public:
#if defined(SK_GRAPHITE_ENABLED)
void drawGlyphRunList(SkCanvas* canvas,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkPaint& paint,
SkStrikeDeviceInfo strikeDeviceInfo,
skgpu::graphite::Device* device);
@ -93,13 +93,13 @@ private:
};
sk_sp<TextBlob> findOrCreateBlob(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
const SkPaint& paint,
SkStrikeDeviceInfo strikeDeviceInfo);
// If not already in the cache, then add it else, return the text blob from the cache.
sk_sp<TextBlob> addOrReturnExisting(
const SkGlyphRunList& glyphRunList,
const GlyphRunList& glyphRunList,
sk_sp<TextBlob> blob) SK_EXCLUDES(fSpinLock);
sk_sp<TextBlob> find(const TextBlob::Key& key) SK_EXCLUDES(fSpinLock);

View File

@ -26,9 +26,12 @@
#include <utility>
namespace sktext {
class GlyphRunList;
}
class SkData;
class SkDrawable;
class SkGlyphRunList;
class SkImage;
class SkPaint;
class SkPath;
@ -313,7 +316,7 @@ void SkNWayCanvas::onDrawAtlas2(const SkImage* image, const SkRSXform xform[], c
}
}
void SkNWayCanvas::onDrawGlyphRunList(const SkGlyphRunList& list,
void SkNWayCanvas::onDrawGlyphRunList(const sktext::GlyphRunList& list,
const SkPaint &paint) {
Iter iter(fList);
while (iter.next()) {

View File

@ -18,7 +18,6 @@
class SkData;
class SkDrawable;
class SkGlyphRunList;
class SkImage;
class SkPath;
class SkPicture;
@ -207,7 +206,8 @@ void SkPaintFilterCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* m
}
}
void SkPaintFilterCanvas::onDrawGlyphRunList(const SkGlyphRunList& list, const SkPaint& paint) {
void SkPaintFilterCanvas::onDrawGlyphRunList(
const sktext::GlyphRunList& list, const SkPaint& paint) {
AutoPaintFilter apf(this, paint);
if (apf.shouldDraw()) {
this->SkNWayCanvas::onDrawGlyphRunList(list, apf.paint());

View File

@ -18,7 +18,7 @@
#include "include/core/SkSize.h"
#include "include/utils/SkNWayCanvas.h"
#include "src/core/SkDevice.h"
#include "src/core/SkGlyphRun.h"
#include "src/text/GlyphRun.h"
// You can only make template specializations of SkTestCanvas.
template <typename Key> class SkTestCanvas;
@ -29,7 +29,8 @@ template <>
class SkTestCanvas<SkSlugTestKey> : public SkCanvas {
public:
SkTestCanvas(SkCanvas* canvas);
void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void onDrawGlyphRunList(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
};
#endif // SkTestCanvas_DEFINED

View File

@ -39,7 +39,6 @@
#include "src/core/SkDraw.h"
#include "src/core/SkEndian.h"
#include "src/core/SkGeometry.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkRasterClip.h"
@ -50,6 +49,7 @@
#include "src/sfnt/SkSFNTHeader.h"
#include "src/sfnt/SkTTCFHeader.h"
#include "src/shaders/SkShaderBase.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkClipStackUtils.h"
#include "src/utils/win/SkHRESULT.h"
#include "src/utils/win/SkIStream.h"
@ -1898,7 +1898,7 @@ static bool text_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) {
}
void SkXPSDevice::onDrawGlyphRunList(SkCanvas*,
const SkGlyphRunList& glyphRunList,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& initailPaint,
const SkPaint& drawingPaint) {
SkASSERT(!glyphRunList.hasRSXForm());

View File

@ -30,8 +30,9 @@
#include "src/utils/win/SkAutoCoInitialize.h"
#include "src/utils/win/SkTScopedComPtr.h"
class SkGlyphRunList;
namespace sktext {
class GlyphRunList;
}
//#define SK_XPS_USE_DETERMINISTIC_IDS
/** \class SkXPSDevice
@ -93,7 +94,7 @@ protected:
const SkSamplingOptions&, const SkPaint& paint,
SkCanvas::SrcRectConstraint) override;
void onDrawGlyphRunList(
SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override;
SkCanvas*, const sktext::GlyphRunList&, const SkPaint&, const SkPaint&) override;
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override;

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "src/core/SkGlyphRun.h"
#include "src/text/GlyphRun.h"
#include "include/core/SkTextBlob.h"
#include "tests/Test.h"
@ -40,7 +40,7 @@ DEF_TEST(GlyphRunBlob, reporter) {
auto blob = blobBuilder.make();
SkGlyphRunBuilder runBuilder;
sktext::GlyphRunBuilder runBuilder;
SkPaint legacy_paint;
font.LEGACY_applyToPaint(&legacy_paint);
runBuilder.drawTextBlob(legacy_paint, *blob, SkPoint::Make(0, 0));

View File

@ -11,9 +11,9 @@
#include "include/core/SkSurface.h"
#include "include/core/SkTextBlob.h"
#include "src/core/SkDevice.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkSurfacePriv.h"
#include "src/gpu/ganesh/GrColorInfo.h"
#include "src/text/GlyphRun.h"
#include "src/text/gpu/TextBlob.h"
#include "tests/Test.h"
#include "tools/ToolUtils.h"
@ -336,7 +336,7 @@ DEF_TEST(KeyEqualityOnPerspective, r) {
auto runBuffer = builder.allocRun(font, 1, 0.0f, 0.0f);
runBuffer.glyphs[0] = 3;
auto blob = builder.make();
SkGlyphRunBuilder grBuilder;
sktext::GlyphRunBuilder grBuilder;
auto glyphRunList = grBuilder.blobToGlyphRunList(*blob, {100, 100});
SkPaint paint;

View File

@ -20,7 +20,6 @@
#include "include/effects/SkImageFilters.h"
#include "include/effects/SkPerlinNoiseShader.h"
#include "include/private/SkTo.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkSpecialImage.h"
@ -32,11 +31,12 @@
#include "src/pdf/SkPDFTypes.h"
#include "src/pdf/SkPDFUnion.h"
#include "src/pdf/SkPDFUtils.h"
#include "src/text/GlyphRun.h"
#include "tools/Resources.h"
#include "tools/ToolUtils.h"
#include <cstdlib>
#include <cmath>
#include <cstdlib>
#include <memory>
template <typename T>
@ -384,15 +384,15 @@ DEF_TEST(SkPDF_Primitives_Color, reporter) {
}
}
static SkGlyphRun make_run(size_t len, const SkGlyphID* glyphs, SkPoint* pos,
static sktext::GlyphRun make_run(size_t len, const SkGlyphID* glyphs, SkPoint* pos,
const SkFont& font, const uint32_t* clusters,
size_t utf8TextByteLength, const char* utf8Text) {
return SkGlyphRun(font,
SkSpan<const SkPoint>{pos, len},
SkSpan<const SkGlyphID>{glyphs, len},
SkSpan<const char>{utf8Text, utf8TextByteLength},
SkSpan<const uint32_t>{clusters, len},
SkSpan<const SkVector>{});
return sktext::GlyphRun(font,
SkSpan<const SkPoint>{pos, len},
SkSpan<const SkGlyphID>{glyphs, len},
SkSpan<const char>{utf8Text, utf8TextByteLength},
SkSpan<const uint32_t>{clusters, len},
SkSpan<const SkVector>{});
}
DEF_TEST(SkPDF_Clusterator, reporter) {
@ -404,7 +404,7 @@ DEF_TEST(SkPDF_Clusterator, reporter) {
SkPoint pos[len] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
const char text[] = "abcdefgh";
SkGlyphRun run = make_run(len, glyphs, pos, font, clusters, strlen(text), text);
sktext::GlyphRun run = make_run(len, glyphs, pos, font, clusters, strlen(text), text);
SkClusterator clusterator(run);
SkClusterator::Cluster expectations[] = {
{&text[3], 1, 0, 1},
@ -427,7 +427,7 @@ DEF_TEST(SkPDF_Clusterator, reporter) {
const SkGlyphID glyphs[len] = { 43, 167, 79, 79, 82, };
SkPoint pos[len] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
const char text[] = "Ha\xCC\x8A" "llo";
SkGlyphRun run = make_run(len, glyphs, pos, font, clusters, strlen(text), text);
sktext::GlyphRun run = make_run(len, glyphs, pos, font, clusters, strlen(text), text);
SkClusterator clusterator(run);
SkClusterator::Cluster expectations[] = {
{&text[0], 1, 0, 1},

View File

@ -8,10 +8,10 @@
#include "include/core/SkFont.h"
#include "include/core/SkTypeface.h"
#include "src/core/SkGlyphBuffer.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkScalerCache.h"
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkTaskGroup.h"
#include "src/text/GlyphRun.h"
#include "tests/Test.h"
#include "tools/ToolUtils.h"

View File

@ -19,8 +19,8 @@
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypeface.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkGlyphRun.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/text/GlyphRun.h"
#include "tools/fonts/RandomScalerContext.h"
#ifdef SK_BUILD_FOR_WIN

View File

@ -19,7 +19,6 @@
#include "include/utils/SkPaintFilterCanvas.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMD5.h"
#include "src/core/SkOSFile.h"
@ -36,6 +35,7 @@
#include "src/gpu/ganesh/GrPersistentCacheUtils.h"
#include "src/image/SkImage_Base.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkJSONWriter.h"
#include "src/utils/SkOSPath.h"
#include "src/utils/SkShaderUtils.h"
@ -79,7 +79,7 @@
#include "tools/viewer/RiveSlide.h"
#if defined(SK_ENABLE_SVG)
#include "modules/svg/include/SkSVGOpenTypeSVGDecoder.h"
#include "modules/svg/include/SkSVGOpenTypeSVGDecoder.h"
#endif
class CapturingShaderErrorHandler : public GrContextOptions::ShaderErrorHandler {
@ -1390,7 +1390,8 @@ public:
this->filterTextBlob(paint, blob, &cache), x, y, paint);
}
void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override {
void onDrawGlyphRunList(
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override {
sk_sp<SkTextBlob> cache;
sk_sp<SkTextBlob> blob = glyphRunList.makeBlob();
this->filterTextBlob(paint, blob.get(), &cache);
@ -1398,8 +1399,9 @@ public:
this->SkPaintFilterCanvas::onDrawGlyphRunList(glyphRunList, paint);
return;
}
SkGlyphRunBuilder builder;
const SkGlyphRunList& filtered = builder.blobToGlyphRunList(*cache, glyphRunList.origin());
sktext::GlyphRunBuilder builder;
const sktext::GlyphRunList& filtered =
builder.blobToGlyphRunList(*cache, glyphRunList.origin());
this->SkPaintFilterCanvas::onDrawGlyphRunList(filtered, paint);
}