[graphite] Move Slug to gpu shared

Bug: skia:13118
Change-Id: Id4afcfeeb9a5b44a0e2cb24b70c76a81ec5daaea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542300
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2022-05-20 15:01:58 -04:00 committed by SkCQ
parent 0275828111
commit e55e01640b
41 changed files with 360 additions and 306 deletions

View File

@ -862,6 +862,12 @@ optional("gpu_shared") {
deps = []
public_defines = []
if (skia_enable_gpu) {
public_defines += [ "SK_SUPPORT_GPU" ]
}
if (skia_enable_graphite) {
public_defines += [ "SK_GRAPHITE_ENABLED" ]
}
if (skia_use_direct3d) {
# Must be defined when 'skia_sksl_gpu_sources' is built, even if the rest of skia_use_direct3d

View File

@ -8192,7 +8192,7 @@ generated_cc_atom(
"//include/core:SkTypes_hdr",
"//include/gpu:GrContextOptions_hdr",
"//include/private:SkTDArray_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//tools:ToolUtils_hdr",
],
)

View File

@ -22,7 +22,7 @@
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/private/SkTDArray.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "tools/ToolUtils.h"
#if SK_SUPPORT_GPU
@ -61,7 +61,7 @@ protected:
p.setAntiAlias(true);
canvas->clipIRect(SkIRect::MakeSize(this->getISize()).makeInset(40, 50));
canvas->scale(1.3f, 1.3f);
sk_sp<GrSlug> slug = GrSlug::ConvertBlob(canvas, *blob, {10, 10}, p);
sk_sp<sktext::gpu::Slug> slug = sktext::gpu::Slug::ConvertBlob(canvas, *blob, {10, 10}, p);
if (slug == nullptr) {
return;
}

View File

@ -324,7 +324,6 @@ skia_gpu_sources = [
# text
"$_src/gpu/ganesh/text/GrAtlasManager.cpp",
"$_src/gpu/ganesh/text/GrAtlasManager.h",
"$_src/gpu/ganesh/text/GrSlug.cpp",
"$_src/gpu/ganesh/text/GrTextBlob.cpp",
"$_src/gpu/ganesh/text/GrTextBlob.h",
"$_src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.cpp",
@ -820,6 +819,7 @@ skia_shared_gpu_sources = [
"$_src/gpu/tessellate/WangsFormula.h",
# text
"$_include/private/chromium/Slug.h",
"$_src/text/gpu/DistanceFieldAdjustTable.cpp",
"$_src/text/gpu/DistanceFieldAdjustTable.h",
"$_src/text/gpu/Glyph.h",
@ -829,6 +829,7 @@ skia_shared_gpu_sources = [
"$_src/text/gpu/SDFMaskFilter.h",
"$_src/text/gpu/SDFTControl.cpp",
"$_src/text/gpu/SDFTControl.h",
"$_src/text/gpu/Slug.cpp",
"$_src/text/gpu/StrikeCache.cpp",
"$_src/text/gpu/StrikeCache.h",
"$_src/text/gpu/SubRunAllocator.cpp",

View File

@ -41,7 +41,6 @@
class AutoLayerForImageFilter;
class GrBackendRenderTarget;
class GrRecordingContext;
class GrSlug;
class SkBaseDevice;
class SkBitmap;
class SkData;
@ -67,8 +66,14 @@ class SkTextBlob;
class SkVertices;
namespace skgpu::graphite { class Recorder; }
namespace sktext::gpu { class Slug; }
namespace SkRecords { class Draw; }
// TODO:
// This is not ideal but Chrome is depending on a forward decl of GrSlug here.
// It should be removed once Chrome has migrated to sktext::gpu::Slug.
using GrSlug = sktext::gpu::Slug;
/** \class SkCanvas
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
SkCanvas contains a stack of SkMatrix and clip values.
@ -2270,15 +2275,15 @@ protected:
virtual void onDiscard();
#if SK_SUPPORT_GPU
#if (SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED)
/** Experimental
*/
virtual sk_sp<GrSlug> onConvertGlyphRunListToSlug(
virtual sk_sp<sktext::gpu::Slug> onConvertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList, const SkPaint& paint);
/** Experimental
*/
virtual void onDrawSlug(const GrSlug* slug);
virtual void onDrawSlug(const sktext::gpu::Slug* slug);
#endif
private:
@ -2420,17 +2425,18 @@ private:
SkCanvas& operator=(SkCanvas&&) = delete;
SkCanvas& operator=(const SkCanvas&) = delete;
#if SK_SUPPORT_GPU
friend class GrSlug;
#if (SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED)
friend class sktext::gpu::Slug;
/** Experimental
* Convert a SkTextBlob to a GrSlug using the current canvas state.
* Convert a SkTextBlob to a sktext::gpu::Slug using the current canvas state.
*/
sk_sp<GrSlug> convertBlobToSlug(const SkTextBlob& blob, SkPoint origin, const SkPaint& paint);
sk_sp<sktext::gpu::Slug> convertBlobToSlug(const SkTextBlob& blob, SkPoint origin,
const SkPaint& paint);
/** Experimental
* Draw an GrSlug given the current canvas state.
* Draw an sktext::gpu::Slug given the current canvas state.
*/
void drawSlug(const GrSlug* slug);
void drawSlug(const sktext::gpu::Slug* slug);
#endif
/** Experimental

View File

@ -252,7 +252,7 @@ struct SK_API GrContextOptions {
/**
* If true, then add 1 pixel padding to all glyph masks in the atlas to support bi-lerp
* rendering of all glyphs. This must be set to true to use GrSlug.
* rendering of all glyphs. This must be set to true to use Slugs.
*/
#if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG) || \
defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE) || \

View File

@ -8,11 +8,7 @@ generated_cc_atom(
name = "GrSlug_hdr",
hdrs = ["GrSlug.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkData_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkRefCnt_hdr",
],
deps = [":Slug_hdr"],
)
generated_cc_atom(
@ -25,3 +21,14 @@ generated_cc_atom(
"//include/utils:SkNoDrawCanvas_hdr",
],
)
generated_cc_atom(
name = "Slug_hdr",
hdrs = ["Slug.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkData_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkRefCnt_hdr",
],
)

View File

@ -8,71 +8,10 @@
#ifndef GrSlug_DEFINED
#define GrSlug_DEFINED
#include "include/core/SkData.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/private/chromium/Slug.h"
class SkCanvas;
class SkMatrix;
class SkPaint;
class SkTextBlob;
class SkReadBuffer;
class SkStrikeClient;
class SkWriteBuffer;
// TODO: Update Chrome to use sktext::gpu classes and remove these
using GrTextReferenceFrame = sktext::gpu::TextReferenceFrame;
using GrSlug = sktext::gpu::Slug;
// You can use GrSlug to simulate drawTextBlob by defining the following at compile time.
// SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG
// You can use GrSlug serialization to simulate drawTextBlob by defining the following:
// SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE
// For Skia, add this to your args.gn file.
// extra_cflags = ["-D", "SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG"]
// Internal infrastructure for using SubRuns.
class SK_API GrTextReferenceFrame : public SkRefCnt {
public:
~GrTextReferenceFrame() override;
virtual const SkMatrix& initialPositionMatrix() const = 0;
};
// GrSlug encapsulates an SkTextBlob at a specific origin, using a specific paint. It can be
// manipulated using matrix and clip changes to the canvas. If the canvas is transformed, then
// the GrSlug will also transform with smaller glyphs using bi-linear interpolation to render. You
// can think of a GrSlug as making a rubber stamp out of a SkTextBlob.
class SK_API GrSlug : public GrTextReferenceFrame {
public:
~GrSlug() override;
// Return nullptr if the blob would not draw. This is not because of clipping, but because of
// some paint optimization. The GrSlug is captured as if drawn using drawTextBlob.
static sk_sp<GrSlug> ConvertBlob(
SkCanvas* canvas, const SkTextBlob& blob, SkPoint origin, const SkPaint& paint);
// Serialize the slug.
sk_sp<SkData> serialize() const;
size_t serialize(void* buffer, size_t size) const;
// Set the client parameter to the appropriate SkStrikeClient when typeface ID translation
// is needed.
static sk_sp<GrSlug> Deserialize(
const void* data, size_t size, const SkStrikeClient* client = nullptr);
static sk_sp<GrSlug> MakeFromBuffer(SkReadBuffer& buffer);
// Draw the GrSlug obeying the canvas's mapping and clipping.
void draw(SkCanvas* canvas) const;
virtual SkRect sourceBounds() const = 0;
// The paint passed into ConvertBlob; this paint is used instead of the paint resulting from
// the call to aboutToDraw because when we call draw(), the initial paint is needed to call
// aboutToDraw again to get the layer right.
virtual const SkPaint& initialPaint() const = 0;
virtual void doFlatten(SkWriteBuffer&) const = 0;
uint32_t uniqueID() const { return fUniqueID; }
private:
static uint32_t NextUniqueID();
const uint32_t fUniqueID{NextUniqueID()};
};
#endif // GrSlug_DEFINED

View File

@ -15,7 +15,6 @@
#include "include/core/SkRefCnt.h"
#include "include/utils/SkNoDrawCanvas.h"
class GrSlug;
struct SkPackedGlyphID;
class SkAutoDescriptor;
class SkStrikeCache;
@ -23,6 +22,7 @@ class SkStrikeClientImpl;
class SkStrikeServer;
class SkStrikeServerImpl;
class SkTypeface;
namespace sktext::gpu { class Slug; }
using SkDiscardableHandleId = uint32_t;
// This class is not thread-safe.
@ -141,7 +141,7 @@ public:
// Given a buffer, unflatten into a slug making sure to do the typefaceID translation from
// renderer to GPU. Returns nullptr if there was a problem.
sk_sp<GrSlug> deserializeSlug(const void* data, size_t size) const;
sk_sp<sktext::gpu::Slug> deserializeSlug(const void* data, size_t size) const;
private:
std::unique_ptr<SkStrikeClientImpl> fImpl;

View File

@ -0,0 +1,83 @@
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef sktext_gpu_Slug_DEFINED
#define sktext_gpu_Slug_DEFINED
#include "include/core/SkData.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
class SkCanvas;
class SkMatrix;
class SkPaint;
class SkTextBlob;
class SkReadBuffer;
class SkStrikeClient;
class SkWriteBuffer;
namespace sktext::gpu {
// You can use Slug to simulate drawTextBlob by defining the following at compile time.
// SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG
// You can use Slug serialization to simulate drawTextBlob by defining the following:
// SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE
// For Skia, add this to your args.gn file.
// extra_cflags = ["-D", "SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG"]
// Internal infrastructure for using SubRuns.
class SK_API TextReferenceFrame : public SkRefCnt {
public:
~TextReferenceFrame() override;
virtual const SkMatrix& initialPositionMatrix() const = 0;
};
// Slug encapsulates an SkTextBlob at a specific origin, using a specific paint. It can be
// manipulated using matrix and clip changes to the canvas. If the canvas is transformed, then
// the Slug will also transform with smaller glyphs using bi-linear interpolation to render. You
// can think of a Slug as making a rubber stamp out of a SkTextBlob.
class SK_API Slug : public TextReferenceFrame {
public:
~Slug() override;
// Return nullptr if the blob would not draw. This is not because of clipping, but because of
// some paint optimization. The Slug is captured as if drawn using drawTextBlob.
static sk_sp<Slug> ConvertBlob(
SkCanvas* canvas, const SkTextBlob& blob, SkPoint origin, const SkPaint& paint);
// Serialize the slug.
sk_sp<SkData> serialize() const;
size_t serialize(void* buffer, size_t size) const;
// Set the client parameter to the appropriate SkStrikeClient when typeface ID translation
// is needed.
static sk_sp<Slug> Deserialize(
const void* data, size_t size, const SkStrikeClient* client = nullptr);
static sk_sp<Slug> MakeFromBuffer(SkReadBuffer& buffer);
// Draw the Slug obeying the canvas's mapping and clipping.
void draw(SkCanvas* canvas) const;
virtual SkRect sourceBounds() const = 0;
// The paint passed into ConvertBlob; this paint is used instead of the paint resulting from
// the call to aboutToDraw because when we call draw(), the initial paint is needed to call
// aboutToDraw again to get the layer right.
virtual const SkPaint& initialPaint() const = 0;
virtual void doFlatten(SkWriteBuffer&) const = 0;
uint32_t uniqueID() const { return fUniqueID; }
private:
static uint32_t NextUniqueID();
const uint32_t fUniqueID{NextUniqueID()};
};
} // namespace sktext::gpu
#endif // sktext_gpu_Slug_DEFINED

View File

@ -41,7 +41,9 @@ struct SkRSXform;
struct SkRect;
#if SK_SUPPORT_GPU
class GrSlug;
namespace sktext::gpu {
class Slug;
}
#endif
class SK_API SkNWayCanvas : public SkCanvasVirtualEnforcer<SkNoDrawCanvas> {
@ -71,7 +73,7 @@ protected:
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
#if SK_SUPPORT_GPU
void onDrawSlug(const GrSlug* slug) override;
void onDrawSlug(const sktext::gpu::Slug* slug) override;
#endif
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override;

View File

@ -1218,7 +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/GrSlug.cpp",
"src/gpu/ganesh/text/GrTextBlob.cpp",
"src/gpu/ganesh/text/GrTextBlob.h",
"src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.cpp",
@ -1652,6 +1651,7 @@ BASE_SRCS_ALL = [
"src/text/gpu/SDFMaskFilter.h",
"src/text/gpu/SDFTControl.cpp",
"src/text/gpu/SDFTControl.h",
"src/text/gpu/Slug.cpp",
"src/text/gpu/StrikeCache.cpp",
"src/text/gpu/StrikeCache.h",
"src/text/gpu/SubRunAllocator.cpp",

View File

@ -1032,7 +1032,7 @@ generated_cc_atom(
"//include/effects:SkRuntimeEffect_hdr",
"//include/gpu:GrDirectContext_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//include/utils:SkNoDrawCanvas_hdr",
"//src/gpu/ganesh:BaseDevice_hdr",
"//src/gpu/ganesh:GrRenderTargetProxy_hdr",
@ -1553,7 +1553,7 @@ generated_cc_atom(
"//include/core:SkShader_hdr",
"//include/core:SkVertices_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//src/image:SkImage_Base_hdr",
"//src/shaders:SkLocalMatrixShader_hdr",
"//src/utils:SkPatchUtils_hdr",
@ -3385,7 +3385,7 @@ generated_cc_atom(
"//include/core:SkStream_hdr",
"//include/core:SkTypeface_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
],
)
@ -3468,7 +3468,7 @@ generated_cc_atom(
"//include/core:SkTextBlob_hdr",
"//include/core:SkTypes_hdr",
"//include/private:SkTDArray_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//src/utils:SkPatchUtils_hdr",
],
)
@ -3514,7 +3514,7 @@ generated_cc_atom(
"//include/core:SkRSXform_hdr",
"//include/core:SkTextBlob_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//src/image:SkImage_Base_hdr",
"//src/utils:SkPatchUtils_hdr",
],
@ -3557,7 +3557,7 @@ generated_cc_atom(
"//include/core:SkPicture_hdr",
"//include/core:SkSerialProcs_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
],
)
@ -3976,7 +3976,7 @@ generated_cc_atom(
":SkRecordedDrawable_hdr",
"//include/core:SkMatrix_hdr",
"//include/core:SkPictureRecorder_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
],
)
@ -4008,7 +4008,7 @@ generated_cc_atom(
"//include/core:SkPicture_hdr",
"//include/core:SkSurface_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//src/utils:SkPatchUtils_hdr",
],
)
@ -4035,7 +4035,7 @@ generated_cc_atom(
"//include/core:SkString_hdr",
"//include/core:SkTextBlob_hdr",
"//include/core:SkVertices_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
],
)

View File

@ -53,7 +53,6 @@
#if SK_SUPPORT_GPU
#include "include/gpu/GrDirectContext.h"
#include "include/private/chromium/GrSlug.h"
#include "src/gpu/ganesh/BaseDevice.h"
#include "src/gpu/ganesh/SkGr.h"
#include "src/utils/SkTestCanvas.h"
@ -67,6 +66,10 @@
#include "src/gpu/graphite/Device.h"
#endif
#if (SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED)
#include "include/private/chromium/Slug.h"
#endif
#define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0)
#define RETURN_ON_FALSE(pred) do { if (!(pred)) return; } while (0)
@ -74,6 +77,8 @@
// and std::max() is constexpr only since the c++14 stdlib.
static_assert(std::max(3,4) == 4);
using Slug = sktext::gpu::Slug;
///////////////////////////////////////////////////////////////////////////////////////////////////
/*
@ -2337,15 +2342,15 @@ void SkCanvas::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPa
}
}
#if SK_SUPPORT_GPU
sk_sp<GrSlug> SkCanvas::convertBlobToSlug(
#if (SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED)
sk_sp<Slug> SkCanvas::convertBlobToSlug(
const SkTextBlob& blob, SkPoint origin, const SkPaint& paint) {
TRACE_EVENT0("skia", TRACE_FUNC);
auto glyphRunList = fScratchGlyphRunBuilder->blobToGlyphRunList(blob, origin);
return this->onConvertGlyphRunListToSlug(glyphRunList, paint);
}
sk_sp<GrSlug>
sk_sp<Slug>
SkCanvas::onConvertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
SkRect bounds = glyphRunList.sourceBounds();
if (bounds.isEmpty() || !bounds.isFinite() || paint.nothingToDraw()) {
@ -2358,14 +2363,14 @@ SkCanvas::onConvertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, const
return nullptr;
}
void SkCanvas::drawSlug(const GrSlug* slug) {
void SkCanvas::drawSlug(const Slug* slug) {
TRACE_EVENT0("skia", TRACE_FUNC);
if (slug) {
this->onDrawSlug(slug);
}
}
void SkCanvas::onDrawSlug(const GrSlug* slug) {
void SkCanvas::onDrawSlug(const Slug* slug) {
SkRect bounds = slug->sourceBounds();
if (this->internalQuickReject(bounds, slug->initialPaint())) {
return;
@ -2483,7 +2488,7 @@ void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
}
#if SK_SUPPORT_GPU && GR_TEST_UTILS
else {
auto slug = GrSlug::ConvertBlob(this, *blob, {x, y}, paint);
auto slug = Slug::ConvertBlob(this, *blob, {x, y}, paint);
slug->draw(this);
}
#endif

View File

@ -818,9 +818,9 @@ protected:
"Cache Diff");
}
sk_sp<GrSlug> convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override {
sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override {
// Full matrix for placing glyphs.
SkMatrix positionMatrix = this->localToDevice();
positionMatrix.preTranslate(glyphRunList.origin().x(), glyphRunList.origin().y());
@ -1200,7 +1200,7 @@ bool SkStrikeClient::translateTypefaceID(SkAutoDescriptor* descriptor) const {
}
#if SK_SUPPORT_GPU
sk_sp<GrSlug> SkStrikeClient::deserializeSlug(const void* data, size_t size) const {
return GrSlug::Deserialize(data, size, this);
sk_sp<sktext::gpu::Slug> SkStrikeClient::deserializeSlug(const void* data, size_t size) const {
return sktext::gpu::Slug::Deserialize(data, size, this);
}
#endif // SK_SUPPORT_GPU

View File

@ -34,7 +34,7 @@
#include "src/shaders/SkLocalMatrixShader.h"
#include "src/utils/SkPatchUtils.h"
#if SK_SUPPORT_GPU
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#endif
SkBaseDevice::SkBaseDevice(const SkImageInfo& info, const SkSurfaceProps& surfaceProps)
@ -486,16 +486,16 @@ void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas,
}
}
#if SK_SUPPORT_GPU
sk_sp<GrSlug> SkBaseDevice::convertGlyphRunListToSlug(
#if (SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED)
sk_sp<sktext::gpu::Slug> SkBaseDevice::convertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
return nullptr;
}
void SkBaseDevice::drawSlug(SkCanvas*, const GrSlug*, const SkPaint&) {
SK_ABORT("GrSlug drawing not supported.");
void SkBaseDevice::drawSlug(SkCanvas*, const sktext::gpu::Slug*, const SkPaint&) {
SK_ABORT("Slug drawing not supported.");
}
#endif

View File

@ -336,13 +336,13 @@ protected:
const SkPaint& initialPaint,
const SkPaint& drawingPaint) = 0;
// GrSlug handling routines.
#if SK_SUPPORT_GPU
virtual sk_sp<GrSlug> convertGlyphRunListToSlug(
// Slug handling routines.
#if (SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED)
virtual sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint);
virtual void drawSlug(SkCanvas*, const GrSlug* slug, const SkPaint& drawingPaint);
virtual void drawSlug(SkCanvas*, const sktext::gpu::Slug* slug, const SkPaint& drawingPaint);
#endif
/**
@ -572,7 +572,7 @@ protected:
void drawFilteredImage(const skif::Mapping&, SkSpecialImage* src, const SkImageFilter*,
const SkSamplingOptions&, const SkPaint&) override {}
#if SK_SUPPORT_GPU
void drawSlug(SkCanvas*, const GrSlug*, const SkPaint&) override {}
void drawSlug(SkCanvas*, const sktext::gpu::Slug*, const SkPaint&) override {}
#endif
void onDrawGlyphRunList(

View File

@ -22,7 +22,7 @@
#include <atomic>
#if SK_SUPPORT_GPU
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#endif
// When we read/write the SkPictInfo via a stream, we have a sentinel byte right after the info.

View File

@ -21,7 +21,7 @@
#include <new>
#if SK_SUPPORT_GPU
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#endif
template <typename T> int SafeCount(const T* obj) {
@ -455,7 +455,7 @@ void SkPictureData::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t
break;
case SK_PICT_SLUG_BUFFER_TAG:
#if SK_SUPPORT_GPU
new_array_from_buffer(buffer, size, fSlugs, GrSlug::MakeFromBuffer);
new_array_from_buffer(buffer, size, fSlugs, sktext::gpu::Slug::MakeFromBuffer);
#endif
break;
case SK_PICT_VERTICES_BUFFER_TAG:

View File

@ -131,7 +131,7 @@ public:
}
#if SK_SUPPORT_GPU
const GrSlug* getSlug(SkReadBuffer* reader) const {
const sktext::gpu::Slug* getSlug(SkReadBuffer* reader) const {
return read_index_base_1_or_null(reader, fSlugs);
}
#endif
@ -162,7 +162,7 @@ private:
SkTArray<sk_sp<const SkVertices>> fVertices;
SkTArray<sk_sp<const SkImage>> fImages;
#if SK_SUPPORT_GPU
SkTArray<sk_sp<const GrSlug>> fSlugs;
SkTArray<sk_sp<const sktext::gpu::Slug>> fSlugs;
#endif

View File

@ -10,7 +10,7 @@
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypes.h"
#include "include/private/SkTDArray.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkDrawShadowInfo.h"
#include "src/core/SkFontPriv.h"
@ -606,7 +606,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
} break;
case DRAW_SLUG: {
#if SK_SUPPORT_GPU
const GrSlug* slug = fPictureData->getSlug(reader);
const sktext::gpu::Slug* slug = fPictureData->getSlug(reader);
BREAK_ON_READ_ERROR(reader);
slug->draw(canvas);

View File

@ -20,7 +20,7 @@
#include "src/utils/SkPatchUtils.h"
#if SK_SUPPORT_GPU
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#endif
#define HEAP_BLOCK_SIZE 4096
@ -581,7 +581,7 @@ void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala
}
#if SK_SUPPORT_GPU
void SkPictureRecord::onDrawSlug(const GrSlug* slug) {
void SkPictureRecord::onDrawSlug(const sktext::gpu::Slug* slug) {
// op + slug id
size_t size = 2 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_SLUG, &size);
@ -936,7 +936,7 @@ void SkPictureRecord::addTextBlob(const SkTextBlob* blob) {
}
#if SK_SUPPORT_GPU
void SkPictureRecord::addSlug(const GrSlug* slug) {
void SkPictureRecord::addSlug(const sktext::gpu::Slug* slug) {
// follow the convention of recording a 1-based index
this->addInt(find_or_append(fSlugs, slug) + 1);
}

View File

@ -48,7 +48,7 @@ public:
}
#if SK_SUPPORT_GPU
const SkTArray<sk_sp<const GrSlug>>& getSlugs() const {
const SkTArray<sk_sp<const sktext::gpu::Slug>>& getSlugs() const {
return fSlugs;
}
#endif
@ -150,7 +150,7 @@ private:
void addSampling(const SkSamplingOptions&);
void addText(const void* text, size_t byteLength);
void addTextBlob(const SkTextBlob* blob);
void addSlug(const GrSlug* slug);
void addSlug(const sktext::gpu::Slug* slug);
void addVertices(const SkVertices*);
int find(const SkBitmap& bitmap);
@ -180,7 +180,7 @@ protected:
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
#if SK_SUPPORT_GPU
void onDrawSlug(const GrSlug* slug) override;
void onDrawSlug(const sktext::gpu::Slug* slug) override;
#endif
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override;
@ -256,7 +256,7 @@ private:
SkTArray<sk_sp<const SkTextBlob>> fTextBlobs;
SkTArray<sk_sp<const SkVertices>> fVertices;
#if SK_SUPPORT_GPU
SkTArray<sk_sp<const GrSlug>> fSlugs;
SkTArray<sk_sp<const sktext::gpu::Slug>> fSlugs;
#endif
uint32_t fRecordFlags;

View File

@ -14,7 +14,7 @@
#include "src/core/SkRecordedDrawable.h"
#if SK_SUPPORT_GPU
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#endif
size_t SkRecordedDrawable::onApproximateBytesUsed() {

View File

@ -11,7 +11,7 @@
#include "include/core/SkPicture.h"
#include "include/core/SkSurface.h"
#include "include/private/SkTo.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkBigPicture.h"
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkGlyphRun.h"
@ -236,7 +236,7 @@ void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
}
#if SK_SUPPORT_GPU
void SkRecorder::onDrawSlug(const GrSlug* slug) {
void SkRecorder::onDrawSlug(const sktext::gpu::Slug* slug) {
this->append<SkRecords::DrawSlug>(sk_ref_sp(slug));
}
#endif

View File

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

View File

@ -27,7 +27,7 @@
#include "src/core/SkDrawShadowInfo.h"
#if SK_SUPPORT_GPU
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#endif
namespace SkRecords {
@ -300,7 +300,7 @@ RECORD(DrawTextBlob, kDraw_Tag|kHasText_Tag|kHasPaint_Tag,
SkScalar y);
#if SK_SUPPORT_GPU
RECORD(DrawSlug, kDraw_Tag|kHasText_Tag,
sk_sp<const GrSlug> slug);
sk_sp<const sktext::gpu::Slug> slug);
#else
RECORD(DrawSlug, 0)
#endif

View File

@ -20,6 +20,7 @@ cc_library(
"//src/text/gpu:GlyphVector_src",
"//src/text/gpu:SDFMaskFilter_src",
"//src/text/gpu:SDFTControl_src",
"//src/text/gpu:Slug_src",
"//src/text/gpu:StrikeCache_src",
"//src/text/gpu:SubRunAllocator_src",
],

View File

@ -188,7 +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:GrSlug_src",
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_src",
"//src/gpu/ganesh/text:GrTextBlob_src",
],

View File

@ -42,18 +42,6 @@ generated_cc_atom(
],
)
generated_cc_atom(
name = "GrSlug_src",
srcs = ["GrSlug.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkCanvas_hdr",
"//include/private/chromium:GrSlug_hdr",
"//src/core:SkReadBuffer_hdr",
"//src/core:SkWriteBuffer_hdr",
],
)
generated_cc_atom(
name = "GrTextBlob_hdr",
hdrs = ["GrTextBlob.h"],
@ -61,7 +49,7 @@ generated_cc_atom(
deps = [
"//include/core:SkPoint3_hdr",
"//include/core:SkRefCnt_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//src/core:SkDevice_hdr",
"//src/core:SkGlyphRunPainter_hdr",
"//src/core:SkIPoint16_hdr",
@ -88,8 +76,8 @@ generated_cc_atom(
"//include/core:SkScalar_hdr",
"//include/gpu:GrRecordingContext_hdr",
"//include/private:SkTemplates_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
"//include/private/chromium:Slug_hdr",
"//src/core:SkEnumerate_hdr",
"//src/core:SkFontPriv_hdr",
"//src/core:SkGlyph_hdr",

View File

@ -9,8 +9,8 @@
#include "include/core/SkScalar.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/private/SkTemplates.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkEnumerate.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyph.h"
@ -46,13 +46,15 @@ using MaskFormat = skgpu::MaskFormat;
using Glyph = sktext::gpu::Glyph;
using GlyphVector = sktext::gpu::GlyphVector;
using SDFTMatrixRange = sktext::gpu::SDFTMatrixRange;
using Slug = sktext::gpu::Slug;
using StrikeCache = sktext::gpu::StrikeCache;
using SubRunAllocator = sktext::gpu::SubRunAllocator;
using TextReferenceFrame = sktext::gpu::TextReferenceFrame;
// -- GPU Text -------------------------------------------------------------------------------------
// There are three broad types of SubRun implementations for drawing text using the GPU.
// GrTextBlob (runs with no postfix) - these runs support drawing for GrTextBlobs.
// GrSlug (Slug postfix) - these runs support drawing of GrSlugs.
// sktext::gpu::Slug (Slug postfix) - these runs support drawing of Slugs.
//
// Naming conventions
// * drawMatrix - the CTM from the canvas.
@ -61,7 +63,7 @@ using SubRunAllocator = sktext::gpu::SubRunAllocator;
// positionMatrix = drawMatrix * TranslationMatrix(drawOrigin.x, drawOrigin.y);
//
// Note:
// In order to use GrSlugs, you need to set the fSupportBilerpFromGlyphAtlas on GrContextOptions.
// In order to use Slugs, you need to set the fSupportBilerpFromGlyphAtlas on GrContextOptions.
enum GrSubRun::SubRunType : int {
kBad = 0, // Make this 0 to line up with errors from readInt.
@ -698,7 +700,7 @@ public:
return true;
}
const GrAtlasSubRun* testingOnly_atlasSubRun() const override { return nullptr; }
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client);
@ -719,7 +721,7 @@ void PathSubRun::doFlatten(SkWriteBuffer& buffer) const {
fPathDrawing.flatten(buffer);
}
GrSubRunOwner PathSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner PathSubRun::MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
@ -915,7 +917,7 @@ public:
DrawableSubRun(DrawableOpSubmitter&& drawingDrawing)
: fDrawingDrawing(std::move(drawingDrawing)) {}
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client);
@ -951,10 +953,10 @@ void DrawableSubRun::doFlatten(SkWriteBuffer& buffer) const {
fDrawingDrawing.flatten(buffer);
}
GrSubRunOwner DrawableSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
GrSubRunOwner DrawableSubRun::MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
auto drawableOpSubmitter = DrawableOpSubmitter::MakeFromBuffer(buffer, alloc, client);
if (!buffer.validate(drawableOpSubmitter.has_value())) { return nullptr; }
return alloc->makeUnique<DrawableSubRun>(std::move(*drawableOpSubmitter));
@ -1084,20 +1086,20 @@ void generalized_direct_2D(SkZip<Quad, const Glyph*, const VertexData> quadData,
// -- DirectMaskSubRun -------------------------------------------------------------------------
class DirectMaskSubRun final : public GrSubRun, public GrAtlasSubRun {
public:
DirectMaskSubRun(const GrTextReferenceFrame* referenceFrame,
DirectMaskSubRun(const TextReferenceFrame* referenceFrame,
MaskFormat format,
SkGlyphRect deviceBounds,
SkSpan<const DevicePosition> devicePositions,
GlyphVector&& glyphs,
bool glyphsOutOfBounds);
static GrSubRunOwner Make(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner Make(const TextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
MaskFormat format,
SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client);
@ -1146,7 +1148,7 @@ private:
// and this operation should be dropped.
std::tuple<bool, SkRect> deviceRectAndCheckTransform(const SkMatrix& positionMatrix) const;
const GrTextReferenceFrame* const fReferenceFrame;
const TextReferenceFrame* const fReferenceFrame;
const MaskFormat fMaskFormat;
// The vertex bounds in device space. The bounds are the joined rectangles of all the glyphs.
@ -1159,7 +1161,7 @@ private:
mutable GlyphVector fGlyphs;
};
DirectMaskSubRun::DirectMaskSubRun(const GrTextReferenceFrame* referenceFrame,
DirectMaskSubRun::DirectMaskSubRun(const TextReferenceFrame* referenceFrame,
MaskFormat format,
SkGlyphRect deviceBounds,
SkSpan<const DevicePosition> devicePositions,
@ -1172,7 +1174,7 @@ DirectMaskSubRun::DirectMaskSubRun(const GrTextReferenceFrame* referenceFrame,
, fSomeGlyphsExcluded{glyphsOutOfBounds}
, fGlyphs{std::move(glyphs)} { }
GrSubRunOwner DirectMaskSubRun::Make(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner DirectMaskSubRun::Make(const TextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
MaskFormat format,
@ -1231,7 +1233,7 @@ bool DirectMaskSubRun::canReuse(const SkPaint& paint, const SkMatrix& positionMa
return reuse;
}
GrSubRunOwner DirectMaskSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner DirectMaskSubRun::MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
@ -1523,18 +1525,18 @@ std::tuple<bool, SkRect> DirectMaskSubRun::deviceRectAndCheckTransform(
// -- TransformedMaskSubRun ------------------------------------------------------------------------
class TransformedMaskSubRun final : public GrSubRun, public GrAtlasSubRun {
public:
TransformedMaskSubRun(const GrTextReferenceFrame* referenceFrame,
TransformedMaskSubRun(const TextReferenceFrame* referenceFrame,
TransformedMaskVertexFiller&& vertexFiller,
GlyphVector&& glyphs);
static GrSubRunOwner Make(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner Make(const TextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
MaskFormat maskType,
SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client);
@ -1580,7 +1582,7 @@ private:
// The rectangle that surrounds all the glyph bounding boxes in device space.
SkRect deviceRect(const SkMatrix& drawMatrix, SkPoint drawOrigin) const;
const GrTextReferenceFrame* const fReferenceFrame;
const TextReferenceFrame* const fReferenceFrame;
const TransformedMaskVertexFiller fVertexFiller;
@ -1589,14 +1591,14 @@ private:
mutable GlyphVector fGlyphs;
};
TransformedMaskSubRun::TransformedMaskSubRun(const GrTextReferenceFrame* referenceFrame,
TransformedMaskSubRun::TransformedMaskSubRun(const TextReferenceFrame* referenceFrame,
TransformedMaskVertexFiller&& vertexFiller,
GlyphVector&& glyphs)
: fReferenceFrame{referenceFrame}
, fVertexFiller{std::move(vertexFiller)}
, fGlyphs{std::move(glyphs)} { }
GrSubRunOwner TransformedMaskSubRun::Make(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner TransformedMaskSubRun::Make(const TextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
@ -1611,7 +1613,7 @@ GrSubRunOwner TransformedMaskSubRun::Make(const GrTextReferenceFrame* referenceF
referenceFrame, std::move(vertexFiller), std::move(glyphVector));
}
GrSubRunOwner TransformedMaskSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner TransformedMaskSubRun::MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
@ -1729,14 +1731,14 @@ const GrAtlasSubRun* TransformedMaskSubRun::testingOnly_atlasSubRun() const {
// -- SDFTSubRun -----------------------------------------------------------------------------------
class SDFTSubRun final : public GrSubRun, public GrAtlasSubRun {
public:
SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
SDFTSubRun(const TextReferenceFrame* referenceFrame,
bool useLCDText,
bool antiAliased,
const SDFTMatrixRange& matrixRange,
TransformedMaskVertexFiller&& vertexFiller,
GlyphVector&& glyphs);
static GrSubRunOwner Make(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner Make(const TextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
sk_sp<SkStrike>&& strike,
@ -1744,7 +1746,7 @@ public:
const SDFTMatrixRange& matrixRange,
SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client);
@ -1790,7 +1792,7 @@ private:
// The rectangle that surrounds all the glyph bounding boxes in device space.
SkRect deviceRect(const SkMatrix& drawMatrix, SkPoint drawOrigin) const;
const GrTextReferenceFrame* const fReferenceFrame;
const TextReferenceFrame* const fReferenceFrame;
const bool fUseLCDText;
const bool fAntiAliased;
const sktext::gpu::SDFTMatrixRange fMatrixRange;
@ -1802,7 +1804,7 @@ private:
mutable GlyphVector fGlyphs;
};
SDFTSubRun::SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
SDFTSubRun::SDFTSubRun(const TextReferenceFrame* referenceFrame,
bool useLCDText,
bool antiAliased,
const SDFTMatrixRange& matrixRange,
@ -1821,7 +1823,7 @@ bool has_some_antialiasing(const SkFont& font ) {
|| edging == SkFont::Edging::kSubpixelAntiAlias;
}
GrSubRunOwner SDFTSubRun::Make(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner SDFTSubRun::Make(const TextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
sk_sp<SkStrike>&& strike,
@ -1846,7 +1848,7 @@ GrSubRunOwner SDFTSubRun::Make(const GrTextReferenceFrame* referenceFrame,
std::move(glyphVector));
}
GrSubRunOwner SDFTSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner SDFTSubRun::MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
@ -2322,24 +2324,24 @@ void GrTextBlob::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accept
}
namespace {
// -- Slug -----------------------------------------------------------------------------------------
class Slug final : public GrSlug, public SkGlyphRunPainterInterface {
// -- SlugImpl ------------------------------------------------------------------------------------
class SlugImpl final : public Slug, public SkGlyphRunPainterInterface {
public:
Slug(SubRunAllocator&& alloc,
SkRect sourceBounds,
const SkPaint& paint,
const SkMatrix& positionMatrix,
SkPoint origin);
~Slug() override = default;
SlugImpl(SubRunAllocator&& alloc,
SkRect sourceBounds,
const SkPaint& paint,
const SkMatrix& positionMatrix,
SkPoint origin);
~SlugImpl() override = default;
static sk_sp<Slug> Make(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache);
static sk_sp<GrSlug> MakeFromBuffer(SkReadBuffer& buffer,
const SkStrikeClient* client);
static sk_sp<SlugImpl> Make(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache);
static sk_sp<Slug> MakeFromBuffer(SkReadBuffer& buffer,
const SkStrikeClient* client);
void surfaceDraw(SkCanvas*,
const GrClip* clip,
@ -2399,25 +2401,25 @@ private:
GrSubRunList fSubRuns;
};
Slug::Slug(SubRunAllocator&& alloc,
SkRect sourceBounds,
const SkPaint& initialPaint,
const SkMatrix& positionMatrix,
SkPoint origin)
SlugImpl::SlugImpl(SubRunAllocator&& alloc,
SkRect sourceBounds,
const SkPaint& initialPaint,
const SkMatrix& positionMatrix,
SkPoint origin)
: fAlloc {std::move(alloc)}
, fSourceBounds{sourceBounds}
, fInitialPaint{initialPaint}
, fInitialPositionMatrix{positionMatrix}
, fOrigin{origin} {}
void Slug::surfaceDraw(SkCanvas* canvas, const GrClip* clip, const SkMatrixProvider& viewMatrix,
const SkPaint& drawingPaint, skgpu::v1::SurfaceDrawContext* sdc) const {
void SlugImpl::surfaceDraw(SkCanvas* canvas, const GrClip* clip, const SkMatrixProvider& viewMatrix,
const SkPaint& drawingPaint, skgpu::v1::SurfaceDrawContext* sdc) const {
for (const GrSubRun& subRun : fSubRuns) {
subRun.draw(canvas, clip, viewMatrix, fOrigin, drawingPaint, sdc);
}
}
void Slug::doFlatten(SkWriteBuffer& buffer) const {
void SlugImpl::doFlatten(SkWriteBuffer& buffer) const {
buffer.writeRect(fSourceBounds);
SkPaintPriv::Flatten(fInitialPaint, buffer);
buffer.writeMatrix(fInitialPositionMatrix);
@ -2430,7 +2432,7 @@ void Slug::doFlatten(SkWriteBuffer& buffer) const {
}
}
sk_sp<GrSlug> Slug::MakeFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client) {
sk_sp<Slug> SlugImpl::MakeFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client) {
SkRect sourceBounds = buffer.readRect();
SkASSERT(!sourceBounds.isEmpty());
if (!buffer.validate(!sourceBounds.isEmpty())) { return nullptr; }
@ -2451,9 +2453,9 @@ sk_sp<GrSlug> Slug::MakeFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* c
}
auto [initializer, _, alloc] =
SubRunAllocator::AllocateClassMemoryAndArena<Slug>(subRunsSizeHint);
SubRunAllocator::AllocateClassMemoryAndArena<SlugImpl>(subRunsSizeHint);
sk_sp<Slug> slug = sk_sp<Slug>(
sk_sp<SlugImpl> slug = sk_sp<SlugImpl>(
initializer.initialize(std::move(alloc), sourceBounds, paint, positionMatrix, origin));
for (int i = 0; i < subRunCount; ++i) {
@ -2471,7 +2473,7 @@ sk_sp<GrSlug> Slug::MakeFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* c
return std::move(slug);
}
void Slug::processDeviceMasks(
void SlugImpl::processDeviceMasks(
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
MaskFormat format,
@ -2486,12 +2488,12 @@ void Slug::processDeviceMasks(
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
sk_sp<Slug> Slug::Make(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache) {
sk_sp<SlugImpl> SlugImpl::Make(const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache) {
// 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;
@ -2504,12 +2506,12 @@ sk_sp<Slug> Slug::Make(const SkMatrixProvider& viewMatrix,
+ glyphRunList.runCount() * (sizeof(DirectMaskSubRun) + vertexDataToSubRunPadding);
auto [initializer, _, alloc] =
SubRunAllocator::AllocateClassMemoryAndArena<Slug>(subRunSizeHint);
SubRunAllocator::AllocateClassMemoryAndArena<SlugImpl>(subRunSizeHint);
const SkMatrix positionMatrix =
position_matrix(viewMatrix.localToDevice(), glyphRunList.origin());
sk_sp<Slug> slug = sk_sp<Slug>(initializer.initialize(
sk_sp<SlugImpl> slug = sk_sp<SlugImpl>(initializer.initialize(
std::move(alloc), glyphRunList.sourceBounds(), initialPaint, positionMatrix,
glyphRunList.origin()));
@ -2524,11 +2526,11 @@ sk_sp<Slug> Slug::Make(const SkMatrixProvider& viewMatrix,
return slug;
}
void Slug::processSourcePaths(const SkZip<SkGlyphVariant,
SkPoint>& accepted,
const SkFont& runFont,
const SkDescriptor& descriptor,
SkScalar strikeToSourceScale) {
void SlugImpl::processSourcePaths(const SkZip<SkGlyphVariant,
SkPoint>& accepted,
const SkFont& runFont,
const SkDescriptor& descriptor,
SkScalar strikeToSourceScale) {
fSubRuns.append(PathSubRun::Make(accepted,
has_some_antialiasing(runFont),
strikeToSourceScale,
@ -2536,26 +2538,26 @@ void Slug::processSourcePaths(const SkZip<SkGlyphVariant,
&fAlloc));
}
void Slug::processSourceDrawables(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
const SkDescriptor& descriptor,
SkScalar strikeToSourceScale) {
void SlugImpl::processSourceDrawables(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
const SkDescriptor& descriptor,
SkScalar strikeToSourceScale) {
fSubRuns.append(make_drawable_sub_run<DrawableSubRun>(
accepted, std::move(strike), strikeToSourceScale, descriptor, &fAlloc));
}
void Slug::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,
const SDFTMatrixRange& matrixRange) {
void SlugImpl::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,
const SDFTMatrixRange& matrixRange) {
fSubRuns.append(SDFTSubRun::Make(
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
}
void Slug::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) {
void SlugImpl::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
MaskFormat format,
@ -2572,43 +2574,43 @@ void Slug::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
} // namespace
namespace skgpu::v1 {
sk_sp<GrSlug>
sk_sp<Slug>
Device::convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) {
return Slug::Make(this->asMatrixProvider(),
glyphRunList,
initialPaint,
drawingPaint,
this->strikeDeviceInfo(),
SkStrikeCache::GlobalStrikeCache());
return SlugImpl::Make(this->asMatrixProvider(),
glyphRunList,
initialPaint,
drawingPaint,
this->strikeDeviceInfo(),
SkStrikeCache::GlobalStrikeCache());
}
void Device::drawSlug(SkCanvas* canvas, const GrSlug* grSlug, const SkPaint& drawingPaint) {
const Slug* slug = static_cast<const Slug*>(grSlug);
void Device::drawSlug(SkCanvas* canvas, const Slug* slug, const SkPaint& drawingPaint) {
const SlugImpl* slugImpl = static_cast<const SlugImpl*>(slug);
auto matrixProvider = this->asMatrixProvider();
#if defined(SK_DEBUG)
if (!fContext->priv().options().fSupportBilerpFromGlyphAtlas) {
// We can draw a slug if the atlas has padding or if the creation matrix and the
// drawing matrix are the same. If they are the same, then the Slug will use the direct
// drawing code and not use bi-lerp.
SkMatrix slugMatrix = slug->initialPositionMatrix();
SkMatrix slugMatrix = slugImpl->initialPositionMatrix();
SkMatrix positionMatrix = matrixProvider.localToDevice();
positionMatrix.preTranslate(slug->origin().x(), slug->origin().y());
positionMatrix.preTranslate(slugImpl->origin().x(), slugImpl->origin().y());
SkASSERT(slugMatrix == positionMatrix);
}
#endif
slug->surfaceDraw(
slugImpl->surfaceDraw(
canvas, this->clip(), matrixProvider, drawingPaint, fSurfaceDrawContext.get());
}
sk_sp<GrSlug> MakeSlug(const SkMatrixProvider& drawMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache) {
return Slug::Make(
sk_sp<Slug> MakeSlug(const SkMatrixProvider& drawMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache) {
return SlugImpl::Make(
drawMatrix, glyphRunList, initialPaint, drawingPaint, strikeDeviceInfo, strikeCache);
}
} // namespace skgpu::v1
@ -2619,11 +2621,11 @@ void GrSubRun::flatten(SkWriteBuffer& buffer) const {
this->doFlatten(buffer);
}
GrSubRunOwner GrSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
GrSubRunOwner GrSubRun::MakeFromBuffer(const TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
SubRunAllocator* alloc,
const SkStrikeClient* client) {
using Maker = GrSubRunOwner (*)(const GrTextReferenceFrame*,
using Maker = GrSubRunOwner (*)(const TextReferenceFrame*,
SkReadBuffer&,
SubRunAllocator*,
const SkStrikeClient*);
@ -2646,6 +2648,6 @@ GrSubRunOwner GrSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFram
return maker(referenceFrame, buffer, alloc, client);
}
sk_sp<GrSlug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client) {
return Slug::MakeFromBuffer(buffer, client);
sk_sp<Slug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client) {
return SlugImpl::MakeFromBuffer(buffer, client);
}

View File

@ -13,7 +13,7 @@
#include "include/core/SkPoint3.h"
#include "include/core/SkRefCnt.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkDevice.h"
#include "src/core/SkGlyphRunPainter.h"
#include "src/core/SkIPoint16.h"
@ -110,7 +110,7 @@ public:
virtual const GrBlobSubRun* blobCast() const;
void flatten(SkWriteBuffer& buffer) const;
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
static GrSubRunOwner MakeFromBuffer(const sktext::gpu::TextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
sktext::gpu::SubRunAllocator* alloc,
const SkStrikeClient* client);
@ -190,7 +190,8 @@ private:
// with.
//
//
class GrTextBlob final : public GrTextReferenceFrame, public SkGlyphRunPainterInterface {
class GrTextBlob final : public sktext::gpu::TextReferenceFrame,
public SkGlyphRunPainterInterface {
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 =().
@ -304,11 +305,11 @@ private:
};
namespace skgpu::v1 {
sk_sp<GrSlug> MakeSlug(const SkMatrixProvider& drawMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache);
sk_sp<sktext::gpu::Slug> MakeSlug(const SkMatrixProvider& drawMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint,
SkStrikeDeviceInfo strikeDeviceInfo,
SkStrikeForGPUCacheInterface* strikeCache);
} // namespace skgpu::v1
#endif // GrTextBlob_DEFINED

View File

@ -101,8 +101,8 @@ generated_cc_atom(
"//include/gpu:GrRecordingContext_hdr",
"//include/private:SkShadowFlags_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
"//include/private/chromium:Slug_hdr",
"//src/core:SkCanvasPriv_hdr",
"//src/core:SkClipStack_hdr",
"//src/core:SkDraw_hdr",

View File

@ -18,7 +18,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "include/private/SkShadowFlags.h"
#include "include/private/SkTo.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkClipStack.h"
#include "src/core/SkDraw.h"
@ -979,7 +979,7 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas,
}
return;
}
auto srcSlug = GrSlug::ConvertBlob(
auto srcSlug = Slug::ConvertBlob(
canvas, *glyphRunList.blob(), glyphRunList.origin(), initialPaint);
// There is nothing to draw.
@ -989,7 +989,7 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas,
auto dstSlugData = srcSlug->serialize();
auto dstSlug = GrSlug::Deserialize(dstSlugData->data(), dstSlugData->size());
auto dstSlug = Slug::Deserialize(dstSlugData->data(), dstSlugData->size());
SkASSERT(dstSlug != nullptr);
if (dstSlug != nullptr) {
this->drawSlug(canvas, dstSlug.get(), drawingPaint);
@ -1082,7 +1082,7 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlugAndStrike(
);
analysisCanvas->setMatrix(canvas->getTotalMatrix());
auto srcSlug = GrSlug::ConvertBlob(analysisCanvas.get(),
auto srcSlug = Slug::ConvertBlob(analysisCanvas.get(),
*glyphRunList.blob(),
glyphRunList.origin(),
initialPaint);

View File

@ -162,12 +162,12 @@ protected:
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;
sk_sp<GrSlug> convertGlyphRunListToSlug(
sk_sp<sktext::gpu::Slug> convertGlyphRunListToSlug(
const SkGlyphRunList& glyphRunList,
const SkPaint& initialPaint,
const SkPaint& drawingPaint) override;
void drawSlug(SkCanvas*, const GrSlug* slug, const SkPaint& drawingPaint) override;
void drawSlug(SkCanvas*, const sktext::gpu::Slug* slug, const SkPaint& drawingPaint) override;
void onClipRect(const SkRect& rect, SkClipOp op, bool aa) override {
SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference);

View File

@ -154,3 +154,15 @@ generated_cc_atom(
"//src/core:SkReadBuffer_hdr",
],
)
generated_cc_atom(
name = "Slug_src",
srcs = ["Slug.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkCanvas_hdr",
"//include/private/chromium:Slug_hdr",
"//src/core:SkReadBuffer_hdr",
"//src/core:SkWriteBuffer_hdr",
],
)

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "include/core/SkCanvas.h"
#include "src/core/SkReadBuffer.h"
@ -13,21 +13,26 @@
#include <atomic>
GrTextReferenceFrame::~GrTextReferenceFrame() = default;
namespace sktext::gpu { class Slug; }
sk_sp<sktext::gpu::Slug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client);
GrSlug::~GrSlug() = default;
sk_sp<GrSlug> GrSlug::ConvertBlob(
namespace sktext::gpu {
TextReferenceFrame::~TextReferenceFrame() = default;
Slug::~Slug() = default;
sk_sp<Slug> Slug::ConvertBlob(
SkCanvas* canvas, const SkTextBlob& blob, SkPoint origin, const SkPaint& paint) {
return canvas->convertBlobToSlug(blob, origin, paint);
}
sk_sp<SkData> GrSlug::serialize() const {
sk_sp<SkData> Slug::serialize() const {
SkBinaryWriteBuffer buffer;
this->doFlatten(buffer);
return buffer.snapshotAsData();
}
size_t GrSlug::serialize(void* buffer, size_t size) const {
size_t Slug::serialize(void* buffer, size_t size) const {
SkBinaryWriteBuffer writeBuffer{buffer, size};
this->doFlatten(writeBuffer);
@ -38,26 +43,25 @@ size_t GrSlug::serialize(void* buffer, size_t size) const {
return writeBuffer.usingInitialStorage() ? writeBuffer.bytesWritten() : 0u;
}
sk_sp<GrSlug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client);
sk_sp<GrSlug> GrSlug::MakeFromBuffer(SkReadBuffer& buffer) {
sk_sp<Slug> Slug::MakeFromBuffer(SkReadBuffer& buffer) {
return SkMakeSlugFromBuffer(buffer, nullptr);
}
sk_sp<GrSlug> GrSlug::Deserialize(const void* data, size_t size, const SkStrikeClient* client) {
sk_sp<Slug> Slug::Deserialize(const void* data, size_t size, const SkStrikeClient* client) {
SkReadBuffer buffer{data, size};
return SkMakeSlugFromBuffer(buffer, client);
}
void GrSlug::draw(SkCanvas* canvas) const {
void Slug::draw(SkCanvas* canvas) const {
canvas->drawSlug(this);
}
uint32_t GrSlug::NextUniqueID() {
uint32_t Slug::NextUniqueID() {
static std::atomic<uint32_t> nextUnique = 1;
return nextUnique++;
}
// Most of GrSlug's implementation is in GrTextBlob.cpp to share common code.
// Most of Slug's implementation is in GrTextBlob.cpp to share common code.
} // namespace sktext::gpu

View File

@ -39,10 +39,6 @@ class SkTextBlob;
class SkVertices;
struct SkDrawShadowRec;
#if SK_SUPPORT_GPU
class GrSlug;
#endif
SkNWayCanvas::SkNWayCanvas(int width, int height) : INHERITED(width, height) {}
SkNWayCanvas::~SkNWayCanvas() {
@ -334,7 +330,7 @@ void SkNWayCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y
}
#if SK_SUPPORT_GPU
void SkNWayCanvas::onDrawSlug(const GrSlug* slug) {
void SkNWayCanvas::onDrawSlug(const sktext::gpu::Slug* slug) {
Iter iter(fList);
while (iter.next()) {
iter->drawSlug(slug);

View File

@ -2582,7 +2582,7 @@ generated_cc_atom(
deps = [
":Test_hdr",
"//include/core:SkTextBlob_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:Slug_hdr",
"//src/gpu/ganesh:GrDirectContextPriv_hdr",
"//tools:ToolUtils_hdr",
],
@ -5602,8 +5602,8 @@ generated_cc_atom(
"//include/core:SkTextBlob_hdr",
"//include/gpu:GrDirectContext_hdr",
"//include/private:SkMutex_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
"//include/private/chromium:Slug_hdr",
"//src/core:SkDraw_hdr",
"//src/core:SkFontPriv_hdr",
"//src/core:SkReadBuffer_hdr",

View File

@ -6,7 +6,7 @@
*/
#include "include/core/SkTextBlob.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/Slug.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "tests/Test.h"
#include "tools/ToolUtils.h"
@ -40,7 +40,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrSlug_empty, reporter, ctxInfo) {
SkPaint p;
p.setAntiAlias(true);
sk_sp<GrSlug> slug = GrSlug::ConvertBlob(canvas, *blob, {10, 10}, p);
sk_sp<sktext::gpu::Slug> slug = sktext::gpu::Slug::ConvertBlob(canvas, *blob, {10, 10}, p);
REPORTER_ASSERT(reporter, slug == nullptr);
}

View File

@ -11,8 +11,8 @@
#include "include/core/SkTextBlob.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkMutex.h"
#include "include/private/chromium/GrSlug.h"
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkDraw.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkReadBuffer.h"
@ -34,6 +34,8 @@
// text blobs in the GPU stack.
#if !defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_STRIKE_SERIALIZE)
using Slug = sktext::gpu::Slug;
class DiscardableManager : public SkStrikeServer::DiscardableHandleManager,
public SkStrikeClient::DiscardableHandleManager {
public:
@ -200,7 +202,7 @@ SkBitmap RasterBlobThroughSlug(sk_sp<SkTextBlob> blob, int width, int height, co
surface->getCanvas()->concat(*matrix);
}
auto canvas = surface->getCanvas();
auto slug = GrSlug::ConvertBlob(canvas, *blob, {x, height/2.0f}, paint);
auto slug = Slug::ConvertBlob(canvas, *blob, {x, height/2.0f}, paint);
slug->draw(canvas);
SkBitmap bitmap;
bitmap.allocN32Pixels(width, height);
@ -208,7 +210,7 @@ SkBitmap RasterBlobThroughSlug(sk_sp<SkTextBlob> blob, int width, int height, co
return bitmap;
}
SkBitmap RasterSlug(sk_sp<GrSlug> slug, int width, int height, const SkPaint& paint,
SkBitmap RasterSlug(sk_sp<Slug> slug, int width, int height, const SkPaint& paint,
GrRecordingContext* rContext, const SkMatrix* matrix = nullptr,
SkScalar x = 0) {
auto surface = MakeSurface(width, height, rContext);
@ -300,7 +302,7 @@ DEF_GPUTEST_FOR_CONTEXTS(SkRemoteGlyphCache_StrikeSerializationSlug,
10, 10, props, nullptr, dContext->supportsDistanceFieldText());
// Generate strike updates.
(void)GrSlug::ConvertBlob(analysisCanvas.get(), *serverBlob, {0, 0}, paint);
(void)Slug::ConvertBlob(analysisCanvas.get(), *serverBlob, {0, 0}, paint);
std::vector<uint8_t> serverStrikeData;
server.writeStrikeData(&serverStrikeData);
@ -340,7 +342,7 @@ DEF_GPUTEST_FOR_CONTEXTS(SkRemoteGlyphCache_SlugSerialization,
10, 10, props, nullptr, dContext->supportsDistanceFieldText());
// Generate strike updates.
auto srcSlug = GrSlug::ConvertBlob(analysisCanvas.get(), *serverBlob, {0.3f, 0}, paint);
auto srcSlug = Slug::ConvertBlob(analysisCanvas.get(), *serverBlob, {0.3f, 0}, paint);
auto dstSlugData = srcSlug->serialize();
std::vector<uint8_t> serverStrikeData;