Move more GPU text classes to sktext::gpu namespace.
Moves GlyphVector, TextStrike, StrikeCache, and SubRunAllocator.
Bug: skia:13118
Change-Id: Ifa4957b5cff280f44606dc62bfd30f6a03063c07
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/536102
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/bench/GlyphQuadFillBench.cpp b/bench/GlyphQuadFillBench.cpp
index 9726b0d..0892a6f 100644
--- a/bench/GlyphQuadFillBench.cpp
+++ b/bench/GlyphQuadFillBench.cpp
@@ -15,8 +15,8 @@
#include "src/core/SkUtils.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/SkGr.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
#include "src/gpu/ganesh/text/GrTextBlob.h"
+#include "src/text/gpu/StrikeCache.h"
#include "src/utils/SkUTF.h"
// From Project Guttenberg. This is UTF-8 text.
@@ -77,7 +77,7 @@
private:
sk_sp<GrTextBlob> fBlob;
- GrStrikeCache fCache;
+ sktext::gpu::StrikeCache fCache;
std::unique_ptr<char[]> fVertices;
};
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 346e71a..53f5fa7 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -191,8 +191,6 @@
"$_src/gpu/ganesh/GrStencilSettings.h",
"$_src/gpu/ganesh/GrStyle.cpp",
"$_src/gpu/ganesh/GrStyle.h",
- "$_src/gpu/ganesh/GrSubRunAllocator.cpp",
- "$_src/gpu/ganesh/GrSubRunAllocator.h",
"$_src/gpu/ganesh/GrSurface.cpp",
"$_src/gpu/ganesh/GrSurface.h",
"$_src/gpu/ganesh/GrSurfaceInfo.cpp",
@@ -325,20 +323,17 @@
"$_src/gpu/ganesh/text/GrAtlasManager.h",
"$_src/gpu/ganesh/text/GrDistanceFieldAdjustTable.cpp",
"$_src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h",
- "$_src/gpu/ganesh/text/GrGlyphVector.cpp",
- "$_src/gpu/ganesh/text/GrGlyphVector.h",
"$_src/gpu/ganesh/text/GrSDFMaskFilter.cpp",
"$_src/gpu/ganesh/text/GrSDFMaskFilter.h",
"$_src/gpu/ganesh/text/GrSDFTControl.cpp",
"$_src/gpu/ganesh/text/GrSDFTControl.h",
"$_src/gpu/ganesh/text/GrSlug.cpp",
- "$_src/gpu/ganesh/text/GrStrikeCache.cpp",
- "$_src/gpu/ganesh/text/GrStrikeCache.h",
"$_src/gpu/ganesh/text/GrTextBlob.cpp",
"$_src/gpu/ganesh/text/GrTextBlob.h",
"$_src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.cpp",
"$_src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.h",
- "$_src/text/gpu/Glyph.h",
+ "$_src/text/gpu/GlyphVector.cpp",
+ "$_src/text/gpu/GlyphVector.h",
# GLSL
"$_src/gpu/ganesh/glsl/GrGLSL.cpp",
@@ -832,4 +827,11 @@
"$_src/gpu/tessellate/Tessellation.cpp",
"$_src/gpu/tessellate/Tessellation.h",
"$_src/gpu/tessellate/WangsFormula.h",
+
+ # text
+ "$_src/text/gpu/Glyph.h",
+ "$_src/text/gpu/StrikeCache.cpp",
+ "$_src/text/gpu/StrikeCache.h",
+ "$_src/text/gpu/SubRunAllocator.cpp",
+ "$_src/text/gpu/SubRunAllocator.h",
]
diff --git a/include/gpu/GrDirectContext.h b/include/gpu/GrDirectContext.h
index 1d7b533..fe216e2 100644
--- a/include/gpu/GrDirectContext.h
+++ b/include/gpu/GrDirectContext.h
@@ -29,7 +29,6 @@
class GrPath;
class GrResourceCache;
class GrResourceProvider;
-class GrStrikeCache;
class GrSurfaceProxy;
class GrTextureProxy;
struct GrVkBackendContext;
@@ -46,6 +45,10 @@
namespace v1 { class SmallPathAtlasMgr; }
}
+namespace sktext::gpu {
+class StrikeCache;
+}
+
class SK_API GrDirectContext : public GrRecordingContext {
public:
#ifdef SK_GL
@@ -856,11 +859,11 @@
// after all of its users. Clients of fTaskGroup will generally want to ensure that they call
// wait() on it as they are being destroyed, to avoid the possibility of pending tasks being
// invoked after objects they depend upon have already been destroyed.
- std::unique_ptr<SkTaskGroup> fTaskGroup;
- std::unique_ptr<GrStrikeCache> fStrikeCache;
- sk_sp<GrGpu> fGpu;
- std::unique_ptr<GrResourceCache> fResourceCache;
- std::unique_ptr<GrResourceProvider> fResourceProvider;
+ std::unique_ptr<SkTaskGroup> fTaskGroup;
+ std::unique_ptr<sktext::gpu::StrikeCache> fStrikeCache;
+ sk_sp<GrGpu> fGpu;
+ std::unique_ptr<GrResourceCache> fResourceCache;
+ std::unique_ptr<GrResourceProvider> fResourceProvider;
bool fDidTestPMConversions;
// true if the PM/UPM conversion succeeded; false otherwise
diff --git a/include/gpu/GrRecordingContext.h b/include/gpu/GrRecordingContext.h
index b948a78..8b8b4fe 100644
--- a/include/gpu/GrRecordingContext.h
+++ b/include/gpu/GrRecordingContext.h
@@ -26,13 +26,16 @@
class GrProgramInfo;
class GrProxyProvider;
class GrRecordingContextPriv;
-class GrSubRunAllocator;
class GrSurfaceProxy;
class GrTextBlobRedrawCoordinator;
class GrThreadSafeCache;
class SkArenaAlloc;
class SkJSONWriter;
+namespace sktext::gpu {
+class SubRunAllocator;
+}
+
#if GR_TEST_UTILS
class SkString;
#endif
@@ -102,17 +105,19 @@
// GrRecordingContext. Arenas does not maintain ownership of the pools it groups together.
class Arenas {
public:
- Arenas(SkArenaAlloc*, GrSubRunAllocator*);
+ Arenas(SkArenaAlloc*, sktext::gpu::SubRunAllocator*);
// For storing pipelines and other complex data as-needed by ops
SkArenaAlloc* recordTimeAllocator() { return fRecordTimeAllocator; }
// For storing GrTextBlob SubRuns
- GrSubRunAllocator* recordTimeSubRunAllocator() { return fRecordTimeSubRunAllocator; }
+ sktext::gpu::SubRunAllocator* recordTimeSubRunAllocator() {
+ return fRecordTimeSubRunAllocator;
+ }
private:
SkArenaAlloc* fRecordTimeAllocator;
- GrSubRunAllocator* fRecordTimeSubRunAllocator;
+ sktext::gpu::SubRunAllocator* fRecordTimeSubRunAllocator;
};
protected:
@@ -133,7 +138,7 @@
private:
bool fDDLRecording;
std::unique_ptr<SkArenaAlloc> fRecordTimeAllocator;
- std::unique_ptr<GrSubRunAllocator> fRecordTimeSubRunAllocator;
+ std::unique_ptr<sktext::gpu::SubRunAllocator> fRecordTimeSubRunAllocator;
};
GrRecordingContext(sk_sp<GrContextThreadSafeProxy>, bool ddlRecording);
diff --git a/public.bzl b/public.bzl
index 8385dfb..faed2fc 100644
--- a/public.bzl
+++ b/public.bzl
@@ -976,8 +976,6 @@
"src/gpu/ganesh/GrStencilSettings.h",
"src/gpu/ganesh/GrStyle.cpp",
"src/gpu/ganesh/GrStyle.h",
- "src/gpu/ganesh/GrSubRunAllocator.cpp",
- "src/gpu/ganesh/GrSubRunAllocator.h",
"src/gpu/ganesh/GrSurface.cpp",
"src/gpu/ganesh/GrSurface.h",
"src/gpu/ganesh/GrSurfaceInfo.cpp",
@@ -1221,15 +1219,11 @@
"src/gpu/ganesh/text/GrAtlasManager.h",
"src/gpu/ganesh/text/GrDistanceFieldAdjustTable.cpp",
"src/gpu/ganesh/text/GrDistanceFieldAdjustTable.h",
- "src/gpu/ganesh/text/GrGlyphVector.cpp",
- "src/gpu/ganesh/text/GrGlyphVector.h",
"src/gpu/ganesh/text/GrSDFMaskFilter.cpp",
"src/gpu/ganesh/text/GrSDFMaskFilter.h",
"src/gpu/ganesh/text/GrSDFTControl.cpp",
"src/gpu/ganesh/text/GrSDFTControl.h",
"src/gpu/ganesh/text/GrSlug.cpp",
- "src/gpu/ganesh/text/GrStrikeCache.cpp",
- "src/gpu/ganesh/text/GrStrikeCache.h",
"src/gpu/ganesh/text/GrTextBlob.cpp",
"src/gpu/ganesh/text/GrTextBlob.h",
"src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.cpp",
@@ -1657,6 +1651,12 @@
"src/sksl/transform/SkSLProgramWriter.h",
"src/sksl/transform/SkSLTransform.h",
"src/text/gpu/Glyph.h",
+ "src/text/gpu/GlyphVector.cpp",
+ "src/text/gpu/GlyphVector.h",
+ "src/text/gpu/StrikeCache.cpp",
+ "src/text/gpu/StrikeCache.h",
+ "src/text/gpu/SubRunAllocator.cpp",
+ "src/text/gpu/SubRunAllocator.h",
"src/utils/SkAnimCodecPlayer.cpp",
"src/utils/SkBase64.cpp",
"src/utils/SkBitSet.h",
diff --git a/src/core/BUILD.bazel b/src/core/BUILD.bazel
index 1ccb204..3654d0d 100644
--- a/src/core/BUILD.bazel
+++ b/src/core/BUILD.bazel
@@ -4691,7 +4691,7 @@
"//include/core:SkTypeface_hdr",
"//include/private:SkMutex_hdr",
"//include/private:SkTemplates_hdr",
- "//src/gpu/ganesh/text:GrStrikeCache_hdr",
+ "//src/text/gpu:StrikeCache_hdr",
],
)
@@ -4743,7 +4743,7 @@
"//include/core:SkGraphics_hdr",
"//src/gpu/ganesh/text:GrSDFMaskFilter_hdr",
"//src/gpu/ganesh/text:GrSDFTControl_hdr",
- "//src/gpu/ganesh/text:GrStrikeCache_hdr",
+ "//src/text/gpu:StrikeCache_hdr",
],
)
diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp
index 94cb4d8..62c4c75 100644
--- a/src/core/SkStrikeCache.cpp
+++ b/src/core/SkStrikeCache.cpp
@@ -19,7 +19,7 @@
#include "src/core/SkScalerCache.h"
#if SK_SUPPORT_GPU
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
+#include "src/text/gpu/StrikeCache.h"
#endif
bool gSkUseThreadLocalStrikeCaches_IAcknowledgeThisIsIncrediblyExperimental = false;
@@ -345,8 +345,9 @@
}
#if SK_SUPPORT_GPU
- sk_sp<GrTextStrike> SkStrike::findOrCreateGrStrike(GrStrikeCache* grStrikeCache) const {
- return grStrikeCache->findOrCreateStrike(fStrikeSpec);
+ sk_sp<sktext::gpu::TextStrike> SkStrike::findOrCreateTextStrike(
+ sktext::gpu::StrikeCache* gpuStrikeCache) const {
+ return gpuStrikeCache->findOrCreateStrike(fStrikeSpec);
}
#endif
diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h
index b2afd7a..be26b9a 100644
--- a/src/core/SkStrikeCache.h
+++ b/src/core/SkStrikeCache.h
@@ -132,7 +132,8 @@
}
#if SK_SUPPORT_GPU
- sk_sp<GrTextStrike> findOrCreateGrStrike(GrStrikeCache* grStrikeCache) const;
+ sk_sp<sktext::gpu::TextStrike> findOrCreateTextStrike(
+ sktext::gpu::StrikeCache* gpuStrikeCache) const;
#endif
void prepareForMaskDrawing(
diff --git a/src/core/SkStrikeSpec.cpp b/src/core/SkStrikeSpec.cpp
index b854f19..fe80337 100644
--- a/src/core/SkStrikeSpec.cpp
+++ b/src/core/SkStrikeSpec.cpp
@@ -16,7 +16,7 @@
#if SK_SUPPORT_GPU
#include "src/gpu/ganesh/text/GrSDFMaskFilter.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
+#include "src/text/gpu/StrikeCache.h"
#endif
SkStrikeSpec::SkStrikeSpec(const SkDescriptor& descriptor, sk_sp<SkTypeface> typeface)
@@ -189,7 +189,8 @@
return std::make_tuple(std::move(strikeSpec), strikeToSourceScale, matrixRange);
}
-sk_sp<GrTextStrike> SkStrikeSpec::findOrCreateGrStrike(GrStrikeCache* cache) const {
+sk_sp<sktext::gpu::TextStrike> SkStrikeSpec::findOrCreateTextStrike(
+ sktext::gpu::StrikeCache* cache) const {
return cache->findOrCreateStrike(*this);
}
#endif
diff --git a/src/core/SkStrikeSpec.h b/src/core/SkStrikeSpec.h
index 18a0449..030f52c 100644
--- a/src/core/SkStrikeSpec.h
+++ b/src/core/SkStrikeSpec.h
@@ -17,8 +17,10 @@
#if SK_SUPPORT_GPU
#include "src/gpu/ganesh/text/GrSDFTControl.h"
-class GrStrikeCache;
-class GrTextStrike;
+namespace sktext::gpu {
+class StrikeCache;
+class TextStrike;
+}
#endif
class SkFont;
@@ -78,7 +80,7 @@
const SkMatrix& deviceMatrix,
const GrSDFTControl& control);
- sk_sp<GrTextStrike> findOrCreateGrStrike(GrStrikeCache* cache) const;
+ sk_sp<sktext::gpu::TextStrike> findOrCreateTextStrike(sktext::gpu::StrikeCache* cache) const;
#endif
SkScopedStrikeForGPU findOrCreateScopedStrike(SkStrikeForGPUCacheInterface* cache) const;
diff --git a/src/gpu/BUILD.bazel b/src/gpu/BUILD.bazel
index acffc5b..68f27c2 100644
--- a/src/gpu/BUILD.bazel
+++ b/src/gpu/BUILD.bazel
@@ -16,6 +16,9 @@
":Swizzle_src",
"//src/gpu/tessellate:FixedCountBufferUtils_src",
"//src/gpu/tessellate:Tessellation_src",
+ "//src/text/gpu:GlyphVector_src",
+ "//src/text/gpu:StrikeCache_src",
+ "//src/text/gpu:SubRunAllocator_src",
],
)
diff --git a/src/gpu/ganesh/BUILD.bazel b/src/gpu/ganesh/BUILD.bazel
index 6c99640..36b1a00 100644
--- a/src/gpu/ganesh/BUILD.bazel
+++ b/src/gpu/ganesh/BUILD.bazel
@@ -82,7 +82,6 @@
":GrStagingBufferManager_src",
":GrStencilSettings_src",
":GrStyle_src",
- ":GrSubRunAllocator_src",
":GrSurfaceInfo_src",
":GrSurfaceProxy_src",
":GrSurface_src",
@@ -190,11 +189,9 @@
"//src/gpu/ganesh/tessellate/shaders:GrTessellationShader_src",
"//src/gpu/ganesh/text:GrAtlasManager_src",
"//src/gpu/ganesh/text:GrDistanceFieldAdjustTable_src",
- "//src/gpu/ganesh/text:GrGlyphVector_src",
"//src/gpu/ganesh/text:GrSDFMaskFilter_src",
"//src/gpu/ganesh/text:GrSDFTControl_src",
"//src/gpu/ganesh/text:GrSlug_src",
- "//src/gpu/ganesh/text:GrStrikeCache_src",
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_src",
"//src/gpu/ganesh/text:GrTextBlob_src",
],
@@ -1148,9 +1145,9 @@
"//src/gpu/ganesh/mtl:GrMtlTrampoline_hdr",
"//src/gpu/ganesh/ops:SmallPathAtlasMgr_hdr",
"//src/gpu/ganesh/text:GrAtlasManager_hdr",
- "//src/gpu/ganesh/text:GrStrikeCache_hdr",
"//src/gpu/ganesh/vk:GrVkGpu_hdr",
"//src/image:SkImage_GpuBase_hdr",
+ "//src/text/gpu:StrikeCache_hdr",
"//src/utils:SkJSONWriter_hdr",
"//src/utils:SkShaderUtils_hdr",
],
@@ -2248,11 +2245,11 @@
deps = [
":GrCaps_hdr",
":GrNativeRect_hdr",
- ":GrSubRunAllocator_hdr",
":GrSurfaceProxy_hdr",
"//include/private/gpu/ganesh:GrTypesPriv_hdr",
"//src/core:SkArenaAlloc_hdr",
"//src/gpu:Swizzle_hdr",
+ "//src/text/gpu:SubRunAllocator_hdr",
],
)
@@ -2715,28 +2712,6 @@
)
generated_cc_atom(
- name = "GrSubRunAllocator_hdr",
- hdrs = ["GrSubRunAllocator.h"],
- visibility = ["//:__subpackages__"],
- deps = [
- "//include/core:SkMath_hdr",
- "//include/core:SkSpan_hdr",
- "//include/private:SkTemplates_hdr",
- "//src/core:SkArenaAlloc_hdr",
- ],
-)
-
-generated_cc_atom(
- name = "GrSubRunAllocator_src",
- srcs = ["GrSubRunAllocator.cpp"],
- visibility = ["//:__subpackages__"],
- deps = [
- ":GrSubRunAllocator_hdr",
- "//include/core:SkMath_hdr",
- ],
-)
-
-generated_cc_atom(
name = "GrSurfaceInfo_src",
srcs = ["GrSurfaceInfo.cpp"],
visibility = ["//:__subpackages__"],
diff --git a/src/gpu/ganesh/GrDirectContext.cpp b/src/gpu/ganesh/GrDirectContext.cpp
index 4e9fca4..874dba1 100644
--- a/src/gpu/ganesh/GrDirectContext.cpp
+++ b/src/gpu/ganesh/GrDirectContext.cpp
@@ -27,8 +27,8 @@
#include "src/gpu/ganesh/effects/GrSkSLFP.h"
#include "src/gpu/ganesh/mock/GrMockGpu.h"
#include "src/gpu/ganesh/text/GrAtlasManager.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
#include "src/image/SkImage_GpuBase.h"
+#include "src/text/gpu/StrikeCache.h"
#include "src/utils/SkShaderUtils.h"
#if SK_GPU_V1
#include "src/gpu/ganesh/ops/SmallPathAtlasMgr.h"
@@ -69,6 +69,8 @@
#define ASSERT_SINGLE_OWNER SKGPU_ASSERT_SINGLE_OWNER(this->singleOwner())
+using StrikeCache = sktext::gpu::StrikeCache;
+
GrDirectContext::DirectContextID GrDirectContext::DirectContextID::Next() {
static std::atomic<uint32_t> nextID{1};
uint32_t id;
@@ -226,7 +228,7 @@
SkASSERT(this->getTextBlobRedrawCoordinator());
SkASSERT(this->threadSafeCache());
- fStrikeCache = std::make_unique<GrStrikeCache>();
+ fStrikeCache = std::make_unique<StrikeCache>();
fResourceCache = std::make_unique<GrResourceCache>(this->singleOwner(),
this->directContextID(),
this->contextID());
diff --git a/src/gpu/ganesh/GrDirectContextPriv.h b/src/gpu/ganesh/GrDirectContextPriv.h
index f4d8af0..570997d 100644
--- a/src/gpu/ganesh/GrDirectContextPriv.h
+++ b/src/gpu/ganesh/GrDirectContextPriv.h
@@ -36,7 +36,7 @@
GrDirectContext* context() { return static_cast<GrDirectContext*>(fContext); }
const GrDirectContext* context() const { return static_cast<const GrDirectContext*>(fContext); }
- GrStrikeCache* getGrStrikeCache() { return this->context()->fStrikeCache.get(); }
+ sktext::gpu::StrikeCache* getStrikeCache() { return this->context()->fStrikeCache.get(); }
/**
* Finalizes all pending reads and writes to the surfaces and also performs an MSAA resolves
diff --git a/src/gpu/ganesh/GrMeshDrawTarget.h b/src/gpu/ganesh/GrMeshDrawTarget.h
index a5da44b..75be65d 100644
--- a/src/gpu/ganesh/GrMeshDrawTarget.h
+++ b/src/gpu/ganesh/GrMeshDrawTarget.h
@@ -12,7 +12,6 @@
#include "src/gpu/ganesh/GrSimpleMesh.h"
class GrAtlasManager;
-class GrStrikeCache;
class GrThreadSafeCache;
namespace skgpu {
@@ -22,6 +21,10 @@
struct VertexWriter;
} // namespace skgpu
+namespace sktext::gpu {
+class StrikeCache;
+}
+
/*
* Abstract interface that supports creating vertices, indices, and meshes, as well as
* invoking GPU draw operations.
@@ -139,7 +142,7 @@
virtual GrResourceProvider* resourceProvider() const = 0;
uint32_t contextUniqueID() const;
- virtual GrStrikeCache* strikeCache() const = 0;
+ virtual sktext::gpu::StrikeCache* strikeCache() const = 0;
virtual GrAtlasManager* atlasManager() const = 0;
virtual skgpu::v1::SmallPathAtlasMgr* smallPathAtlasManager() const = 0;
diff --git a/src/gpu/ganesh/GrOpFlushState.cpp b/src/gpu/ganesh/GrOpFlushState.cpp
index 7ca9345..d9df81d 100644
--- a/src/gpu/ganesh/GrOpFlushState.cpp
+++ b/src/gpu/ganesh/GrOpFlushState.cpp
@@ -213,8 +213,8 @@
return fOpArgs->appliedClip() ? std::move(*fOpArgs->appliedClip()) : GrAppliedClip::Disabled();
}
-GrStrikeCache* GrOpFlushState::strikeCache() const {
- return fGpu->getContext()->priv().getGrStrikeCache();
+sktext::gpu::StrikeCache* GrOpFlushState::strikeCache() const {
+ return fGpu->getContext()->priv().getStrikeCache();
}
GrAtlasManager* GrOpFlushState::atlasManager() const {
diff --git a/src/gpu/ganesh/GrOpFlushState.h b/src/gpu/ganesh/GrOpFlushState.h
index 1914aaa..de42481 100644
--- a/src/gpu/ganesh/GrOpFlushState.h
+++ b/src/gpu/ganesh/GrOpFlushState.h
@@ -179,7 +179,7 @@
GrThreadSafeCache* threadSafeCache() const final;
GrResourceProvider* resourceProvider() const final { return fResourceProvider; }
- GrStrikeCache* strikeCache() const final;
+ sktext::gpu::StrikeCache* strikeCache() const final;
// At this point we know we're flushing so full access to the GrAtlasManager and
// SmallPathAtlasMgr is required (and permissible).
diff --git a/src/gpu/ganesh/GrRecordingContext.cpp b/src/gpu/ganesh/GrRecordingContext.cpp
index 6a2ff64..1949802 100644
--- a/src/gpu/ganesh/GrRecordingContext.cpp
+++ b/src/gpu/ganesh/GrRecordingContext.cpp
@@ -101,7 +101,7 @@
}
GrRecordingContext::Arenas::Arenas(SkArenaAlloc* recordTimeAllocator,
- GrSubRunAllocator* subRunAllocator)
+ sktext::gpu::SubRunAllocator* subRunAllocator)
: fRecordTimeAllocator(recordTimeAllocator)
, fRecordTimeSubRunAllocator(subRunAllocator) {
// OwnedArenas should instantiate these before passing the bare pointer off to this struct.
@@ -127,7 +127,7 @@
}
if (!fRecordTimeSubRunAllocator) {
- fRecordTimeSubRunAllocator = std::make_unique<GrSubRunAllocator>();
+ fRecordTimeSubRunAllocator = std::make_unique<sktext::gpu::SubRunAllocator>();
}
return {fRecordTimeAllocator.get(), fRecordTimeSubRunAllocator.get()};
diff --git a/src/gpu/ganesh/GrRecordingContextPriv.h b/src/gpu/ganesh/GrRecordingContextPriv.h
index 930f105..e59bb05 100644
--- a/src/gpu/ganesh/GrRecordingContextPriv.h
+++ b/src/gpu/ganesh/GrRecordingContextPriv.h
@@ -39,7 +39,7 @@
GrDrawingManager* drawingManager() { return this->context()->drawingManager(); }
SkArenaAlloc* recordTimeAllocator() { return this->context()->arenas().recordTimeAllocator(); }
- GrSubRunAllocator* recordTimeSubRunAllocator() {
+ sktext::gpu::SubRunAllocator* recordTimeSubRunAllocator() {
return this->context()->arenas().recordTimeSubRunAllocator();
}
GrRecordingContext::Arenas arenas() { return this->context()->arenas(); }
diff --git a/src/gpu/ganesh/GrRenderTargetProxy.h b/src/gpu/ganesh/GrRenderTargetProxy.h
index 31e2b8a..bd962c5 100644
--- a/src/gpu/ganesh/GrRenderTargetProxy.h
+++ b/src/gpu/ganesh/GrRenderTargetProxy.h
@@ -13,8 +13,8 @@
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrNativeRect.h"
-#include "src/gpu/ganesh/GrSubRunAllocator.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
+#include "src/text/gpu/SubRunAllocator.h"
class GrResourceProvider;
@@ -32,13 +32,13 @@
void flush() {
SkDEBUGCODE(fIsFlushed = true;)
}
- GrSubRunAllocator* subRunAlloc() { return &fSubRunAllocator; }
+ sktext::gpu::SubRunAllocator* subRunAlloc() { return &fSubRunAllocator; }
private:
SkArenaAlloc fArenaAlloc{1024};
// An allocator specifically designed to minimize the overhead of sub runs. It provides a
// different dtor semantics than SkArenaAlloc.
- GrSubRunAllocator fSubRunAllocator{1024};
+ sktext::gpu::SubRunAllocator fSubRunAllocator{1024};
SkDEBUGCODE(bool fIsFlushed = false;)
};
diff --git a/src/gpu/ganesh/mock/GrMockOpTarget.h b/src/gpu/ganesh/mock/GrMockOpTarget.h
index 3f9714a..15a617e 100644
--- a/src/gpu/ganesh/mock/GrMockOpTarget.h
+++ b/src/gpu/ganesh/mock/GrMockOpTarget.h
@@ -108,7 +108,7 @@
UNIMPL(const GrSurfaceProxyView& writeView() const)
UNIMPL(const GrAppliedClip* appliedClip() const)
UNIMPL(bool usesMSAASurface() const)
- UNIMPL(GrStrikeCache* strikeCache() const)
+ UNIMPL(sktext::gpu::StrikeCache* strikeCache() const)
UNIMPL(GrAtlasManager* atlasManager() const)
UNIMPL(SkTArray<GrSurfaceProxy*, true>* sampledProxyArray())
UNIMPL(GrDeferredUploadTarget* deferredUploadTarget())
diff --git a/src/gpu/ganesh/ops/GrMeshDrawOp.h b/src/gpu/ganesh/ops/GrMeshDrawOp.h
index 297e1af..5fde598 100644
--- a/src/gpu/ganesh/ops/GrMeshDrawOp.h
+++ b/src/gpu/ganesh/ops/GrMeshDrawOp.h
@@ -19,7 +19,6 @@
class GrMeshDrawTarget;
class GrOpFlushState;
struct GrSimpleMesh;
-class GrStrikeCache;
/**
* Base class for mesh-drawing GrDrawOps.
diff --git a/src/gpu/ganesh/text/BUILD.bazel b/src/gpu/ganesh/text/BUILD.bazel
index 6d3e78d..d517139 100644
--- a/src/gpu/ganesh/text/BUILD.bazel
+++ b/src/gpu/ganesh/text/BUILD.bazel
@@ -22,7 +22,6 @@
visibility = ["//:__subpackages__"],
deps = [
":GrAtlasManager_hdr",
- ":GrStrikeCache_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkColorSpace_hdr",
"//include/core:SkImageEncoder_hdr",
@@ -37,6 +36,7 @@
"//src/gpu/ganesh:GrTextureProxy_hdr",
"//src/gpu/ganesh:SurfaceContext_hdr",
"//src/text/gpu:Glyph_hdr",
+ "//src/text/gpu:StrikeCache_hdr",
],
)
@@ -120,29 +120,6 @@
)
generated_cc_atom(
- name = "GrStrikeCache_hdr",
- hdrs = ["GrStrikeCache.h"],
- visibility = ["//:__subpackages__"],
- deps = [
- "//include/private:SkTHash_hdr",
- "//src/core:SkArenaAlloc_hdr",
- "//src/core:SkStrikeSpec_hdr",
- ],
-)
-
-generated_cc_atom(
- name = "GrStrikeCache_src",
- srcs = ["GrStrikeCache.cpp"],
- visibility = ["//:__subpackages__"],
- deps = [
- ":GrStrikeCache_hdr",
- "//src/core:SkArenaAlloc_hdr",
- "//src/core:SkStrikeSpec_hdr",
- "//src/text/gpu:Glyph_hdr",
- ],
-)
-
-generated_cc_atom(
name = "GrTextBlob_hdr",
hdrs = ["GrTextBlob.h"],
visibility = ["//:__subpackages__"],
@@ -159,8 +136,8 @@
"//src/core:SkTInternalLList_hdr",
"//src/core:SkTLazy_hdr",
"//src/gpu/ganesh:GrColor_hdr",
- "//src/gpu/ganesh:GrSubRunAllocator_hdr",
"//src/gpu/ganesh/ops:GrOp_hdr",
+ "//src/text/gpu:SubRunAllocator_hdr",
],
)
@@ -170,9 +147,7 @@
visibility = ["//:__subpackages__"],
deps = [
":GrAtlasManager_hdr",
- ":GrGlyphVector_hdr",
":GrSDFTControl_hdr",
- ":GrStrikeCache_hdr",
":GrTextBlob_hdr",
"//include/core:SkColorFilter_hdr",
"//include/core:SkScalar_hdr",
@@ -194,14 +169,16 @@
"//src/gpu/ganesh:GrMeshDrawTarget_hdr",
"//src/gpu/ganesh:GrRecordingContextPriv_hdr",
"//src/gpu/ganesh:GrStyle_hdr",
- "//src/gpu/ganesh:GrSubRunAllocator_hdr",
"//src/gpu/ganesh:SkGr_hdr",
"//src/gpu/ganesh/effects:GrDistanceFieldGeoProc_hdr",
"//src/gpu/ganesh/geometry:GrStyledShape_hdr",
"//src/gpu/ganesh/ops:AtlasTextOp_hdr",
"//src/gpu/ganesh/v1:Device_v1_hdr",
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
+ "//src/text/gpu:GlyphVector_hdr",
"//src/text/gpu:Glyph_hdr",
+ "//src/text/gpu:StrikeCache_hdr",
+ "//src/text/gpu:SubRunAllocator_hdr",
],
)
@@ -229,34 +206,3 @@
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
],
)
-
-generated_cc_atom(
- name = "GrGlyphVector_hdr",
- hdrs = ["GrGlyphVector.h"],
- visibility = ["//:__subpackages__"],
- deps = [
- ":GrStrikeCache_hdr",
- "//include/core:SkSpan_hdr",
- "//src/core:SkGlyphBuffer_hdr",
- "//src/core:SkGlyph_hdr",
- "//src/gpu/ganesh:GrDrawOpAtlas_hdr",
- "//src/gpu/ganesh:GrMeshDrawTarget_hdr",
- "//src/gpu/ganesh:GrSubRunAllocator_hdr",
- "//src/text/gpu:Glyph_hdr",
- ],
-)
-
-generated_cc_atom(
- name = "GrGlyphVector_src",
- srcs = ["GrGlyphVector.cpp"],
- visibility = ["//:__subpackages__"],
- deps = [
- ":GrAtlasManager_hdr",
- ":GrGlyphVector_hdr",
- "//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
- "//src/core:SkReadBuffer_hdr",
- "//src/core:SkStrikeCache_hdr",
- "//src/core:SkStrikeSpec_hdr",
- "//src/core:SkWriteBuffer_hdr",
- ],
-)
diff --git a/src/gpu/ganesh/text/GrAtlasManager.cpp b/src/gpu/ganesh/text/GrAtlasManager.cpp
index 4f3fbfe..431f8cf 100644
--- a/src/gpu/ganesh/text/GrAtlasManager.cpp
+++ b/src/gpu/ganesh/text/GrAtlasManager.cpp
@@ -12,8 +12,9 @@
#include "src/core/SkAutoMalloc.h"
#include "src/core/SkDistanceFieldGen.h"
#include "src/gpu/ganesh/GrImageInfo.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
#include "src/text/gpu/Glyph.h"
+#include "src/text/gpu/StrikeCache.h"
+
using Glyph = sktext::gpu::Glyph;
using MaskFormat = skgpu::MaskFormat;
diff --git a/src/gpu/ganesh/text/GrAtlasManager.h b/src/gpu/ganesh/text/GrAtlasManager.h
index 4e8ead5..3acaac8 100644
--- a/src/gpu/ganesh/text/GrAtlasManager.h
+++ b/src/gpu/ganesh/text/GrAtlasManager.h
@@ -36,7 +36,7 @@
~GrAtlasManager() override;
// if getViews returns nullptr, the client must not try to use other functions on the
- // GrStrikeCache which use the atlas. This function *must* be called first, before other
+ // StrikeCache which use the atlas. This function *must* be called first, before other
// functions which use the atlas. Note that we can have proxies available but none active
// (i.e., none instantiated).
const GrSurfaceProxyView* getViews(skgpu::MaskFormat format, unsigned int* numActiveProxies) {
@@ -120,7 +120,7 @@
bool initAtlas(skgpu::MaskFormat);
// Change an expected 565 mask format to 8888 if 565 is not supported (will happen when using
// Metal on macOS). The actual conversion of the data is handled in get_packed_glyph_image() in
- // GrStrikeCache.cpp
+ // StrikeCache.cpp
skgpu::MaskFormat resolveMaskFormat(skgpu::MaskFormat format) const {
if (skgpu::MaskFormat::kA565 == format &&
!fProxyProvider->caps()->getDefaultBackendFormat(GrColorType::kBGR_565,
diff --git a/src/gpu/ganesh/text/GrGlyphVector.h b/src/gpu/ganesh/text/GrGlyphVector.h
deleted file mode 100644
index 82916c7..0000000
--- a/src/gpu/ganesh/text/GrGlyphVector.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGlyphVector_DEFINED
-#define GrGlyphVector_DEFINED
-
-#include "include/core/SkSpan.h"
-#include "src/core/SkGlyph.h"
-#include "src/core/SkGlyphBuffer.h"
-#include "src/gpu/ganesh/GrDrawOpAtlas.h"
-#include "src/gpu/ganesh/GrMeshDrawTarget.h"
-#include "src/gpu/ganesh/GrSubRunAllocator.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
-#include "src/text/gpu/Glyph.h"
-
-class SkStrikeClient;
-
-// -- GlyphVector ----------------------------------------------------------------------------------
-// GlyphVector provides a way to delay the lookup of sktext::gpu::Glyphs until the code is running
-// on the GPU in single threaded mode. The GlyphVector is created in a multi-threaded environment,
-// but the GrStrikeCache is only single threaded (and must be single threaded because of the atlas).
-class GrGlyphVector {
-public:
- union Variant {
- // Initially, filled with packed id, but changed to Glyph* in the onPrepare stage.
- SkPackedGlyphID packedGlyphID;
- sktext::gpu::Glyph* glyph;
- // Add ctors to help SkArenaAlloc create arrays.
- Variant() : glyph{nullptr} {}
- Variant(SkPackedGlyphID id) : packedGlyphID{id} {}
- };
-
- GrGlyphVector(sk_sp<SkStrike>&& strike, SkSpan<Variant> glyphs);
-
- static GrGlyphVector Make(
- sk_sp<SkStrike>&& strike, SkSpan<SkGlyphVariant> glyphs, GrSubRunAllocator* alloc);
- SkSpan<const sktext::gpu::Glyph*> glyphs() const;
-
- static std::optional<GrGlyphVector> MakeFromBuffer(SkReadBuffer& buffer,
- const SkStrikeClient* strikeClient,
- GrSubRunAllocator* alloc);
- void flatten(SkWriteBuffer& buffer);
-
- // This doesn't need to include sizeof(GrGlyphVector) because this is embedded in each of
- // the sub runs.
- int unflattenSize() const { return GlyphVectorSize(fGlyphs.size()); }
-
- void packedGlyphIDToGlyph(GrStrikeCache* cache);
-
- std::tuple<bool, int> regenerateAtlas(
- int begin, int end,
- skgpu::MaskFormat maskFormat,
- int srcPadding,
- GrMeshDrawTarget *);
-
- static size_t GlyphVectorSize(size_t count) {
- return sizeof(Variant) * count;
- }
-
-private:
- friend class TestingPeer;
- sk_sp<SkStrike> fStrike;
- SkSpan<Variant> fGlyphs;
- sk_sp<GrTextStrike> fGrStrike{nullptr};
- uint64_t fAtlasGeneration{skgpu::AtlasGenerationCounter::kInvalidGeneration};
- GrDrawOpAtlas::BulkUseTokenUpdater fBulkUseToken;
-};
-#endif // GrGlyphVector_DEFINED
diff --git a/src/gpu/ganesh/text/GrStrikeCache.cpp b/src/gpu/ganesh/text/GrStrikeCache.cpp
deleted file mode 100644
index 942cbeb..0000000
--- a/src/gpu/ganesh/text/GrStrikeCache.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "src/core/SkArenaAlloc.h"
-#include "src/core/SkStrikeSpec.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
-#include "src/text/gpu/Glyph.h"
-
-using Glyph = sktext::gpu::Glyph;
-
-GrStrikeCache::~GrStrikeCache() {
- this->freeAll();
-}
-
-void GrStrikeCache::freeAll() {
- fCache.reset();
-}
-
-sk_sp<GrTextStrike> GrStrikeCache::findOrCreateStrike(const SkStrikeSpec& strikeSpec) {
- if (sk_sp<GrTextStrike>* cached = fCache.find(strikeSpec.descriptor())) {
- return *cached;
- }
- return this->generateStrike(strikeSpec);
-}
-
-sk_sp<GrTextStrike> GrStrikeCache::generateStrike(const SkStrikeSpec& strikeSpec) {
- sk_sp<GrTextStrike> strike = sk_make_sp<GrTextStrike>(strikeSpec);
- fCache.set(strike);
- return strike;
-}
-
-const SkDescriptor& GrStrikeCache::HashTraits::GetKey(const sk_sp<GrTextStrike>& strike) {
- return strike->fStrikeSpec.descriptor();
-}
-
-uint32_t GrStrikeCache::HashTraits::Hash(const SkDescriptor& descriptor) {
- return descriptor.getChecksum();
-}
-
-GrTextStrike::GrTextStrike(const SkStrikeSpec& strikeSpec) : fStrikeSpec{strikeSpec} {}
-
-Glyph* GrTextStrike::getGlyph(SkPackedGlyphID packedGlyphID) {
- Glyph* glyph = fCache.findOrNull(packedGlyphID);
- if (glyph == nullptr) {
- glyph = fAlloc.make<Glyph>(packedGlyphID);
- fCache.set(glyph);
- }
- return glyph;
-}
-
-const SkPackedGlyphID& GrTextStrike::HashTraits::GetKey(const Glyph* glyph) {
- return glyph->fPackedID;
-}
-
-uint32_t GrTextStrike::HashTraits::Hash(SkPackedGlyphID key) {
- return key.hash();
-}
-
diff --git a/src/gpu/ganesh/text/GrStrikeCache.h b/src/gpu/ganesh/text/GrStrikeCache.h
deleted file mode 100644
index 1c940ba..0000000
--- a/src/gpu/ganesh/text/GrStrikeCache.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrStrikeCache_DEFINED
-#define GrStrikeCache_DEFINED
-
-#include "include/private/SkTHash.h"
-#include "src/core/SkArenaAlloc.h"
-#include "src/core/SkStrikeSpec.h"
-
-class GrStrikeCache;
-
-namespace sktext::gpu {
-class Glyph;
-}
-
-
-// The GrTextStrike manages an SkArenaAlloc for Glyphs. The SkStrike is what actually creates
-// the mask. The GrTextStrike may outlive the generating SkStrike. However, it retains a copy
-// of it's SkDescriptor as a key to access (or regenerate) the SkStrike. GrTextStrikes are
-// created by and owned by a GrStrikeCache.
-class GrTextStrike : public SkNVRefCnt<GrTextStrike> {
-public:
- GrTextStrike(const SkStrikeSpec& strikeSpec);
-
- sktext::gpu::Glyph* getGlyph(SkPackedGlyphID);
- const SkStrikeSpec& strikeSpec() const { return fStrikeSpec; }
-
-private:
- // Key for retrieving the SkStrike for creating new atlas data.
- const SkStrikeSpec fStrikeSpec;
-
- struct HashTraits {
- static const SkPackedGlyphID& GetKey(const sktext::gpu::Glyph* glyph);
- static uint32_t Hash(SkPackedGlyphID key);
- };
- // Map SkPackedGlyphID -> Glyph*.
- SkTHashTable<sktext::gpu::Glyph*, SkPackedGlyphID, HashTraits> fCache;
-
- // Store for the glyph information.
- SkArenaAlloc fAlloc{512};
-
- friend class GrStrikeCache;
-};
-
-// GrStrikeCache manages strikes which are indexed by a SkStrike. These strikes can then be
-// used to generate individual Glyph Masks.
-class GrStrikeCache {
-public:
- ~GrStrikeCache();
-
- // The user of the cache may hold a long-lived ref to the returned strike.
- sk_sp<GrTextStrike> findOrCreateStrike(const SkStrikeSpec& strikeSpec);
-
- void freeAll();
-
-private:
- sk_sp<GrTextStrike> generateStrike(const SkStrikeSpec& strikeSpec);
-
- struct HashTraits {
- static const SkDescriptor& GetKey(const sk_sp<GrTextStrike>& strike);
- static uint32_t Hash(const SkDescriptor& strikeSpec);
- };
-
- using StrikeHash = SkTHashTable<sk_sp<GrTextStrike>, const SkDescriptor&, HashTraits>;
-
- StrikeHash fCache;
-};
-
-#endif // GrStrikeCache_DEFINED
diff --git a/src/gpu/ganesh/text/GrTextBlob.cpp b/src/gpu/ganesh/text/GrTextBlob.cpp
index 63ccb0b..a06dd18 100644
--- a/src/gpu/ganesh/text/GrTextBlob.cpp
+++ b/src/gpu/ganesh/text/GrTextBlob.cpp
@@ -24,17 +24,17 @@
#include "src/gpu/ganesh/GrMeshDrawTarget.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrStyle.h"
-#include "src/gpu/ganesh/GrSubRunAllocator.h"
#include "src/gpu/ganesh/SkGr.h"
#include "src/gpu/ganesh/effects/GrDistanceFieldGeoProc.h"
#include "src/gpu/ganesh/geometry/GrStyledShape.h"
#include "src/gpu/ganesh/text/GrAtlasManager.h"
-#include "src/gpu/ganesh/text/GrGlyphVector.h"
#include "src/gpu/ganesh/text/GrSDFTControl.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
#include "src/gpu/ganesh/text/GrTextBlob.h"
#include "src/text/gpu/Glyph.h"
+#include "src/text/gpu/GlyphVector.h"
+#include "src/text/gpu/StrikeCache.h"
+#include "src/text/gpu/SubRunAllocator.h"
#include "src/gpu/ganesh/GrBlurUtils.h"
#include "src/gpu/ganesh/ops/AtlasTextOp.h"
@@ -42,9 +42,13 @@
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
using AtlasTextOp = skgpu::v1::AtlasTextOp;
-using Glyph = sktext::gpu::Glyph;
using MaskFormat = skgpu::MaskFormat;
+using Glyph = sktext::gpu::Glyph;
+using GlyphVector = sktext::gpu::GlyphVector;
+using StrikeCache = sktext::gpu::StrikeCache;
+using SubRunAllocator = sktext::gpu::SubRunAllocator;
+
// -- 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.
@@ -101,10 +105,10 @@
int dstPadding,
SkScalar strikeToSourceScale,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
- GrSubRunAllocator* alloc);
+ SubRunAllocator* alloc);
static std::optional<TransformedMaskVertexFiller> MakeFromBuffer(
- SkReadBuffer& buffer, GrSubRunAllocator* alloc);
+ SkReadBuffer& buffer, SubRunAllocator* alloc);
int unflattenSize() const;
void flatten(SkWriteBuffer& buffer) const;
@@ -208,7 +212,7 @@
int dstPadding,
SkScalar strikeToSourceScale,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
SkRect sourceBounds = SkRectPriv::MakeLargestInverted();
SkSpan<PositionAndExtent> positionAndExtent = alloc->makePODArray<PositionAndExtent>(
accepted,
@@ -235,7 +239,7 @@
}
std::optional<TransformedMaskVertexFiller> TransformedMaskVertexFiller::MakeFromBuffer(
- SkReadBuffer& buffer, GrSubRunAllocator* alloc) {
+ SkReadBuffer& buffer, SubRunAllocator* alloc) {
int checkingMaskType = buffer.readInt();
if (!buffer.validate(0 <= checkingMaskType && checkingMaskType < skgpu::kMaskFormatCount)) {
return {};
@@ -468,19 +472,19 @@
SkScalar strikeToSourceScale,
SkSpan<SkPoint> positions,
SkSpan<SkGlyphID> glyphIDs,
- std::unique_ptr<SkPath[], GrSubRunAllocator::ArrayDestroyer> paths,
+ std::unique_ptr<SkPath[], SubRunAllocator::ArrayDestroyer> paths,
const SkDescriptor& descriptor);
static PathOpSubmitter Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
bool isAntiAliased,
SkScalar strikeToSourceScale,
const SkDescriptor& descriptor,
- GrSubRunAllocator* alloc);
+ SubRunAllocator* alloc);
int unflattenSize() const;
void flatten(SkWriteBuffer& buffer) const;
static std::optional<PathOpSubmitter> MakeFromBuffer(SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
void submitOps(SkCanvas*,
@@ -495,7 +499,7 @@
const SkScalar fStrikeToSourceScale;
const SkSpan<const SkPoint> fPositions;
const SkSpan<const SkGlyphID> fGlyphIDs;
- std::unique_ptr<SkPath[], GrSubRunAllocator::ArrayDestroyer> fPaths;
+ std::unique_ptr<SkPath[], SubRunAllocator::ArrayDestroyer> fPaths;
const SkAutoDescriptor fDescriptor;
};
@@ -517,7 +521,7 @@
}
std::optional<PathOpSubmitter> PathOpSubmitter::MakeFromBuffer(SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client) {
bool isAntiAlias = buffer.readInt();
SkScalar strikeToSourceScale = buffer.readScalar();
@@ -572,7 +576,7 @@
SkScalar strikeToSourceScale,
SkSpan<SkPoint> positions,
SkSpan<SkGlyphID> glyphIDs,
- std::unique_ptr<SkPath[], GrSubRunAllocator::ArrayDestroyer> paths,
+ std::unique_ptr<SkPath[], SubRunAllocator::ArrayDestroyer> paths,
const SkDescriptor& descriptor)
: fIsAntiAliased{isAntiAliased}
, fStrikeToSourceScale{strikeToSourceScale}
@@ -587,7 +591,7 @@
bool isAntiAliased,
SkScalar strikeToSourceScale,
const SkDescriptor& descriptor,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
int glyphCount = SkCount(accepted);
SkPoint* positions = alloc->makePODArray<SkPoint>(glyphCount);
SkGlyphID* glyphIDs = alloc->makePODArray<SkGlyphID>(glyphCount);
@@ -673,7 +677,7 @@
bool isAntiAliased,
SkScalar strikeToSourceScale,
const SkDescriptor& descriptor,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
return alloc->makeUnique<PathSubRun>(
PathOpSubmitter::Make(
accepted, isAntiAliased, strikeToSourceScale, descriptor, alloc));
@@ -696,7 +700,7 @@
const GrAtlasSubRun* testingOnly_atlasSubRun() const override { return nullptr; }
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
protected:
@@ -717,7 +721,7 @@
GrSubRunOwner PathSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client) {
auto pathOpSubmitter = PathOpSubmitter::MakeFromBuffer(buffer, alloc, client);
if (!buffer.validate(pathOpSubmitter.has_value())) { return nullptr; }
@@ -732,18 +736,18 @@
SkSpan<SkPoint> positions,
SkSpan<SkGlyphID> glyphIDs,
std::unique_ptr<sk_sp<SkDrawable>[],
- GrSubRunAllocator::ArrayDestroyer> drawableData,
+ SubRunAllocator::ArrayDestroyer> drawableData,
const SkDescriptor& descriptor);
static DrawableOpSubmitter Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
SkScalar strikeToSourceScale,
const SkDescriptor& descriptor,
- GrSubRunAllocator* alloc);
+ SubRunAllocator* alloc);
int unflattenSize() const;
void flatten(SkWriteBuffer& buffer) const;
static std::optional<DrawableOpSubmitter> MakeFromBuffer(SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
void submitOps(SkCanvas*,
@@ -757,7 +761,7 @@
const SkScalar fStrikeToSourceScale;
const SkSpan<SkPoint> fPositions;
const SkSpan<SkGlyphID> fGlyphIDs;
- std::unique_ptr<sk_sp<SkDrawable>[], GrSubRunAllocator::ArrayDestroyer> fDrawables;
+ std::unique_ptr<sk_sp<SkDrawable>[], SubRunAllocator::ArrayDestroyer> fDrawables;
const SkAutoDescriptor fDescriptor;
};
@@ -780,7 +784,7 @@
}
std::optional<DrawableOpSubmitter> DrawableOpSubmitter::MakeFromBuffer(
- SkReadBuffer& buffer, GrSubRunAllocator* alloc, const SkStrikeClient* client) {
+ SkReadBuffer& buffer, SubRunAllocator* alloc, const SkStrikeClient* client) {
SkScalar strikeToSourceScale = buffer.readScalar();
int glyphCount = buffer.readInt();
@@ -830,7 +834,7 @@
SkSpan<SkPoint> positions,
SkSpan<SkGlyphID> glyphIDs,
std::unique_ptr<sk_sp<SkDrawable>[],
- GrSubRunAllocator::ArrayDestroyer> drawables,
+ SubRunAllocator::ArrayDestroyer> drawables,
const SkDescriptor& descriptor)
: fStrikeToSourceScale{strikeToSourceScale}
, fPositions{positions}
@@ -843,7 +847,7 @@
DrawableOpSubmitter DrawableOpSubmitter::Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
SkScalar strikeToSourceScale,
const SkDescriptor& descriptor,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
int glyphCount = SkCount(accepted);
SkPoint* positions = alloc->makePODArray<SkPoint>(glyphCount);
SkGlyphID* glyphIDs = alloc->makePODArray<SkGlyphID>(glyphCount);
@@ -892,7 +896,7 @@
GrSubRunOwner make_drawable_sub_run(const SkZip<SkGlyphVariant, SkPoint>& drawables,
SkScalar strikeToSourceScale,
const SkDescriptor& descriptor,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
return alloc->makeUnique<SubRun>(
DrawableOpSubmitter::Make(drawables, strikeToSourceScale, descriptor, alloc));
}
@@ -905,7 +909,7 @@
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
void draw(SkCanvas* canvas,
@@ -941,7 +945,7 @@
GrSubRunOwner DrawableSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client) {
auto drawableOpSubmitter = DrawableOpSubmitter::MakeFromBuffer(buffer, alloc, client);
if (!buffer.validate(drawableOpSubmitter.has_value())) { return nullptr; }
@@ -1076,18 +1080,18 @@
MaskFormat format,
SkGlyphRect deviceBounds,
SkSpan<const DevicePosition> devicePositions,
- GrGlyphVector&& glyphs,
+ GlyphVector&& glyphs,
bool glyphsOutOfBounds);
static GrSubRunOwner Make(const GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
MaskFormat format,
- GrSubRunAllocator* alloc);
+ SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
void draw(SkCanvas*,
@@ -1110,7 +1114,7 @@
const SkPaint&,
skgpu::v1::SurfaceDrawContext*) const override;
- void testingOnly_packedGlyphIDToGlyph(GrStrikeCache *cache) const override;
+ void testingOnly_packedGlyphIDToGlyph(StrikeCache *cache) const override;
std::tuple<bool, int>
regenerateAtlas(int begin, int end, GrMeshDrawTarget*) const override;
@@ -1144,15 +1148,15 @@
// The regenerateAtlas method mutates fGlyphs. It should be called from onPrepare which must
// be single threaded.
- mutable GrGlyphVector fGlyphs;
+ mutable GlyphVector fGlyphs;
};
DirectMaskSubRun::DirectMaskSubRun(const GrTextReferenceFrame* referenceFrame,
- MaskFormat format,
- SkGlyphRect deviceBounds,
- SkSpan<const DevicePosition> devicePositions,
- GrGlyphVector&& glyphs,
- bool glyphsOutOfBounds)
+ MaskFormat format,
+ SkGlyphRect deviceBounds,
+ SkSpan<const DevicePosition> devicePositions,
+ GlyphVector&& glyphs,
+ bool glyphsOutOfBounds)
: fReferenceFrame{referenceFrame}
, fMaskFormat{format}
, fGlyphDeviceBounds{deviceBounds}
@@ -1161,12 +1165,12 @@
, fGlyphs{std::move(glyphs)} { }
GrSubRunOwner DirectMaskSubRun::Make(const GrTextReferenceFrame* referenceFrame,
- const SkZip<SkGlyphVariant, SkPoint>& accepted,
- sk_sp<SkStrike>&& strike,
- MaskFormat format,
- GrSubRunAllocator* alloc) {
+ const SkZip<SkGlyphVariant, SkPoint>& accepted,
+ sk_sp<SkStrike>&& strike,
+ MaskFormat format,
+ SubRunAllocator* alloc) {
auto glyphLeftTop = alloc->makePODArray<DevicePosition>(accepted.size());
- auto glyphIDs = alloc->makePODArray<GrGlyphVector::Variant>(accepted.size());
+ auto glyphIDs = alloc->makePODArray<GlyphVector::Variant>(accepted.size());
// Because this is the direct case, the maximum width or height is the size that fits in the
// atlas. This boundary is checked below to ensure that the call to SkGlyphRect below will
@@ -1202,7 +1206,7 @@
SkSpan<const DevicePosition> leftTop{glyphLeftTop, goodPosCount};
return alloc->makeUnique<DirectMaskSubRun>(
referenceFrame, format, runBounds, leftTop,
- GrGlyphVector{std::move(strike), {glyphIDs, goodPosCount}},
+ GlyphVector{std::move(strike), {glyphIDs, goodPosCount}},
glyphsExcluded);
}
@@ -1220,9 +1224,9 @@
}
GrSubRunOwner DirectMaskSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
- SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
- const SkStrikeClient* client) {
+ SkReadBuffer& buffer,
+ SubRunAllocator* alloc,
+ const SkStrikeClient* client) {
MaskFormat maskType = (MaskFormat)buffer.readInt();
SkGlyphRect runBounds;
pun_read(buffer, &runBounds);
@@ -1236,7 +1240,7 @@
}
SkSpan<DevicePosition> positions(positionsData, glyphCount);
- auto glyphVector = GrGlyphVector::MakeFromBuffer(buffer, client, alloc);
+ auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
if (!buffer.validate(glyphVector.has_value())) { return nullptr; }
if (!buffer.validate(SkCount(glyphVector->glyphs()) == glyphCount)) { return nullptr; }
SkASSERT(buffer.isValid());
@@ -1360,7 +1364,7 @@
return {clip, std::move(op)};
}
-void DirectMaskSubRun::testingOnly_packedGlyphIDToGlyph(GrStrikeCache *cache) const {
+void DirectMaskSubRun::testingOnly_packedGlyphIDToGlyph(StrikeCache *cache) const {
fGlyphs.packedGlyphIDToGlyph(cache);
}
@@ -1513,18 +1517,18 @@
public:
TransformedMaskSubRun(const GrTextReferenceFrame* referenceFrame,
TransformedMaskVertexFiller&& vertexFiller,
- GrGlyphVector&& glyphs);
+ GlyphVector&& glyphs);
static GrSubRunOwner Make(const GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
MaskFormat maskType,
- GrSubRunAllocator* alloc);
+ SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
void draw(SkCanvas*,
@@ -1547,7 +1551,7 @@
const GrAtlasSubRun* testingOnly_atlasSubRun() const override;
- void testingOnly_packedGlyphIDToGlyph(GrStrikeCache *cache) const override;
+ void testingOnly_packedGlyphIDToGlyph(StrikeCache *cache) const override;
std::tuple<bool, int> regenerateAtlas(int begin, int end, GrMeshDrawTarget*) const override;
@@ -1574,12 +1578,12 @@
// The regenerateAtlas method mutates fGlyphs. It should be called from onPrepare which must
// be single threaded.
- mutable GrGlyphVector fGlyphs;
+ mutable GlyphVector fGlyphs;
};
TransformedMaskSubRun::TransformedMaskSubRun(const GrTextReferenceFrame* referenceFrame,
TransformedMaskVertexFiller&& vertexFiller,
- GrGlyphVector&& glyphs)
+ GlyphVector&& glyphs)
: fReferenceFrame{referenceFrame}
, fVertexFiller{std::move(vertexFiller)}
, fGlyphs{std::move(glyphs)} { }
@@ -1589,11 +1593,11 @@
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
MaskFormat maskType,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
auto vertexFiller = TransformedMaskVertexFiller::Make(
maskType, 0, strikeToSourceScale, accepted, alloc);
- auto glyphVector = GrGlyphVector::Make(std::move(strike), accepted.get<0>(), alloc);
+ auto glyphVector = GlyphVector::Make(std::move(strike), accepted.get<0>(), alloc);
return alloc->makeUnique<TransformedMaskSubRun>(
referenceFrame, std::move(vertexFiller), std::move(glyphVector));
@@ -1601,12 +1605,12 @@
GrSubRunOwner TransformedMaskSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client) {
auto vertexFiller = TransformedMaskVertexFiller::MakeFromBuffer(buffer, alloc);
if (!buffer.validate(vertexFiller.has_value())) { return {}; }
- auto glyphVector = GrGlyphVector::MakeFromBuffer(buffer, client, alloc);
+ auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
if (!buffer.validate(glyphVector.has_value())) { return {}; }
if (!buffer.validate(SkCount(glyphVector->glyphs()) == vertexFiller->count())) { return {}; }
return alloc->makeUnique<TransformedMaskSubRun>(
@@ -1676,7 +1680,7 @@
return true;
}
-void TransformedMaskSubRun::testingOnly_packedGlyphIDToGlyph(GrStrikeCache *cache) const {
+void TransformedMaskSubRun::testingOnly_packedGlyphIDToGlyph(StrikeCache *cache) const {
fGlyphs.packedGlyphIDToGlyph(cache);
}
@@ -1722,7 +1726,7 @@
bool antiAliased,
const GrSDFTMatrixRange& matrixRange,
TransformedMaskVertexFiller&& vertexFiller,
- GrGlyphVector&& glyphs);
+ GlyphVector&& glyphs);
static GrSubRunOwner Make(const GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
@@ -1730,11 +1734,11 @@
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const GrSDFTMatrixRange& matrixRange,
- GrSubRunAllocator* alloc);
+ SubRunAllocator* alloc);
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client);
void draw(SkCanvas*,
@@ -1757,7 +1761,7 @@
const GrAtlasSubRun* testingOnly_atlasSubRun() const override;
- void testingOnly_packedGlyphIDToGlyph(GrStrikeCache *cache) const override;
+ void testingOnly_packedGlyphIDToGlyph(StrikeCache *cache) const override;
std::tuple<bool, int> regenerateAtlas(int begin, int end, GrMeshDrawTarget*) const override;
@@ -1787,7 +1791,7 @@
// The regenerateAtlas method mutates fGlyphs. It should be called from onPrepare which must
// be single threaded.
- mutable GrGlyphVector fGlyphs;
+ mutable GlyphVector fGlyphs;
};
SDFTSubRun::SDFTSubRun(const GrTextReferenceFrame* referenceFrame,
@@ -1795,7 +1799,7 @@
bool antiAliased,
const GrSDFTMatrixRange& matrixRange,
TransformedMaskVertexFiller&& vertexFiller,
- GrGlyphVector&& glyphs)
+ GlyphVector&& glyphs)
: fReferenceFrame{referenceFrame}
, fUseLCDText{useLCDText}
, fAntiAliased{antiAliased}
@@ -1815,7 +1819,7 @@
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const GrSDFTMatrixRange& matrixRange,
- GrSubRunAllocator* alloc) {
+ SubRunAllocator* alloc) {
auto vertexFiller = TransformedMaskVertexFiller::Make(
MaskFormat::kA8,
SK_DistanceFieldInset,
@@ -1823,7 +1827,7 @@
accepted,
alloc);
- auto glyphVector = GrGlyphVector::Make(std::move(strike), accepted.get<0>(), alloc);
+ auto glyphVector = GlyphVector::Make(std::move(strike), accepted.get<0>(), alloc);
return alloc->makeUnique<SDFTSubRun>(
referenceFrame,
@@ -1836,14 +1840,14 @@
GrSubRunOwner SDFTSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client) {
int useLCD = buffer.readInt();
int isAntiAliased = buffer.readInt();
GrSDFTMatrixRange matrixRange = GrSDFTMatrixRange::MakeFromBuffer(buffer);
auto vertexFiller = TransformedMaskVertexFiller::MakeFromBuffer(buffer, alloc);
if (!buffer.validate(vertexFiller.has_value())) { return {}; }
- auto glyphVector = GrGlyphVector::MakeFromBuffer(buffer, client, alloc);
+ auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
if (!buffer.validate(glyphVector.has_value())) { return {}; }
if (!buffer.validate(SkCount(glyphVector->glyphs()) == vertexFiller->count())) { return {}; }
return alloc->makeUnique<SDFTSubRun>(referenceFrame,
@@ -1950,7 +1954,7 @@
return fMatrixRange.matrixInRange(positionMatrix);
}
-void SDFTSubRun::testingOnly_packedGlyphIDToGlyph(GrStrikeCache *cache) const {
+void SDFTSubRun::testingOnly_packedGlyphIDToGlyph(StrikeCache *cache) const {
fGlyphs.packedGlyphIDToGlyph(cache);
}
@@ -2175,11 +2179,11 @@
// The neededForSubRun is optimized for DirectMaskSubRun which is by far the most common case.
size_t subRunSizeHint =
totalGlyphCount * sizeof(DevicePosition)
- + GrGlyphVector::GlyphVectorSize(totalGlyphCount)
+ + GlyphVector::GlyphVectorSize(totalGlyphCount)
+ glyphRunList.runCount() * (sizeof(DirectMaskSubRun) + vertexDataToSubRunPadding);
auto [initializer, totalMemoryAllocated, alloc] =
- GrSubRunAllocator::AllocateClassMemoryAndArena<GrTextBlob>(subRunSizeHint);
+ SubRunAllocator::AllocateClassMemoryAndArena<GrTextBlob>(subRunSizeHint);
SkColor initialLuminance = SkPaintPriv::ComputeLuminanceColor(paint);
sk_sp<GrTextBlob> blob = sk_sp<GrTextBlob>(initializer.initialize(
std::move(alloc), totalMemoryAllocated, positionMatrix, initialLuminance));
@@ -2252,7 +2256,7 @@
return fSubRunList.front().testingOnly_atlasSubRun();
}
-GrTextBlob::GrTextBlob(GrSubRunAllocator&& alloc,
+GrTextBlob::GrTextBlob(SubRunAllocator&& alloc,
int totalMemorySize,
const SkMatrix& positionMatrix,
SkColor initialLuminance)
@@ -2324,7 +2328,7 @@
// -- Slug -----------------------------------------------------------------------------------------
class Slug final : public GrSlug, public SkGlyphRunPainterInterface {
public:
- Slug(GrSubRunAllocator&& alloc,
+ Slug(SubRunAllocator&& alloc,
SkRect sourceBounds,
const SkPaint& paint,
const SkMatrix& positionMatrix,
@@ -2390,7 +2394,7 @@
private:
// The allocator must come first because it needs to be destroyed last. Other fields of this
// structure may have pointers into it.
- GrSubRunAllocator fAlloc;
+ SubRunAllocator fAlloc;
const SkRect fSourceBounds;
const SkPaint fInitialPaint;
const SkMatrix fInitialPositionMatrix;
@@ -2398,7 +2402,7 @@
GrSubRunList fSubRuns;
};
-Slug::Slug(GrSubRunAllocator&& alloc,
+Slug::Slug(SubRunAllocator&& alloc,
SkRect sourceBounds,
const SkPaint& initialPaint,
const SkMatrix& positionMatrix,
@@ -2450,7 +2454,7 @@
}
auto [initializer, _, alloc] =
- GrSubRunAllocator::AllocateClassMemoryAndArena<Slug>(subRunsSizeHint);
+ SubRunAllocator::AllocateClassMemoryAndArena<Slug>(subRunsSizeHint);
sk_sp<Slug> slug = sk_sp<Slug>(
initializer.initialize(std::move(alloc), sourceBounds, paint, positionMatrix, origin));
@@ -2499,11 +2503,11 @@
// common case.
size_t subRunSizeHint =
totalGlyphCount * sizeof(DevicePosition)
- + GrGlyphVector::GlyphVectorSize(totalGlyphCount)
+ + GlyphVector::GlyphVectorSize(totalGlyphCount)
+ glyphRunList.runCount() * (sizeof(DirectMaskSubRun) + vertexDataToSubRunPadding);
auto [initializer, _, alloc] =
- GrSubRunAllocator::AllocateClassMemoryAndArena<Slug>(subRunSizeHint);
+ SubRunAllocator::AllocateClassMemoryAndArena<Slug>(subRunSizeHint);
const SkMatrix positionMatrix =
position_matrix(viewMatrix.localToDevice(), glyphRunList.origin());
@@ -2630,11 +2634,11 @@
GrSubRunOwner GrSubRun::MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ SubRunAllocator* alloc,
const SkStrikeClient* client) {
using Maker = GrSubRunOwner (*)(const GrTextReferenceFrame*,
SkReadBuffer&,
- GrSubRunAllocator*,
+ SubRunAllocator*,
const SkStrikeClient*);
static Maker makers[kSubRunTypeCount] = {
diff --git a/src/gpu/ganesh/text/GrTextBlob.h b/src/gpu/ganesh/text/GrTextBlob.h
index 2510fc0..9a69986 100644
--- a/src/gpu/ganesh/text/GrTextBlob.h
+++ b/src/gpu/ganesh/text/GrTextBlob.h
@@ -23,13 +23,12 @@
#include "src/core/SkTInternalLList.h"
#include "src/core/SkTLazy.h"
#include "src/gpu/ganesh/GrColor.h"
-#include "src/gpu/ganesh/GrSubRunAllocator.h"
#include "src/gpu/ganesh/ops/GrOp.h"
+#include "src/text/gpu/SubRunAllocator.h"
class GrAtlasManager;
class GrDeferredUploadTarget;
class GrMeshDrawTarget;
-class GrStrikeCache;
class GrSubRun;
class SkMatrixProvider;
@@ -40,6 +39,7 @@
namespace sktext::gpu {
class Glyph;
+class StrikeCache;
}
namespace skgpu::v1 { class SurfaceDrawContext; }
@@ -59,7 +59,7 @@
// can fit in the atlas; the sizes between direct SubRun, and path SubRun. The destination
// rectangles are in source space.
class GrAtlasSubRun;
-using GrAtlasSubRunOwner = std::unique_ptr<GrAtlasSubRun, GrSubRunAllocator::Destroyer>;
+using GrAtlasSubRunOwner = std::unique_ptr<GrAtlasSubRun, sktext::gpu::SubRunAllocator::Destroyer>;
class GrAtlasSubRun {
public:
virtual ~GrAtlasSubRun() = default;
@@ -82,7 +82,7 @@
SkPoint drawOrigin,
SkIRect clip) const = 0;
- virtual void testingOnly_packedGlyphIDToGlyph(GrStrikeCache* cache) const = 0;
+ virtual void testingOnly_packedGlyphIDToGlyph(sktext::gpu::StrikeCache* cache) const = 0;
// This call is not thread safe. It should only be called from GrDrawOp::onPrepare which
// is single threaded.
@@ -94,7 +94,7 @@
// GrSubRun defines the most basic functionality of a SubRun; the ability to draw, and the
// ability to be in a list.
class GrSubRun;
-using GrSubRunOwner = std::unique_ptr<GrSubRun, GrSubRunAllocator::Destroyer>;
+using GrSubRunOwner = std::unique_ptr<GrSubRun, sktext::gpu::SubRunAllocator::Destroyer>;
class GrBlobSubRun;
class GrSubRun {
public:
@@ -111,7 +111,7 @@
void flatten(SkWriteBuffer& buffer) const;
static GrSubRunOwner MakeFromBuffer(const GrTextReferenceFrame* referenceFrame,
SkReadBuffer& buffer,
- GrSubRunAllocator* alloc,
+ sktext::gpu::SubRunAllocator* alloc,
const SkStrikeClient* client);
// Size hint for unflattening this run. If this is accurate, it will help with the allocation
@@ -230,7 +230,7 @@
const GrSDFTControl& control,
SkGlyphRunListPainter* painter);
- GrTextBlob(GrSubRunAllocator&& alloc,
+ GrTextBlob(sktext::gpu::SubRunAllocator&& alloc,
int totalMemorySize,
const SkMatrix& positionMatrix,
SkColor initialLuminance);
@@ -285,7 +285,7 @@
// The allocator must come first because it needs to be destroyed last. Other fields of this
// structure may have pointers into it.
- GrSubRunAllocator fAlloc;
+ sktext::gpu::SubRunAllocator fAlloc;
// Owner and list of the SubRun.
GrSubRunList fSubRunList;
diff --git a/src/gpu/ganesh/v1/SurfaceFillContext_v1.h b/src/gpu/ganesh/v1/SurfaceFillContext_v1.h
index 85ec253..d0fd036 100644
--- a/src/gpu/ganesh/v1/SurfaceFillContext_v1.h
+++ b/src/gpu/ganesh/v1/SurfaceFillContext_v1.h
@@ -53,7 +53,7 @@
bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
SkArenaAlloc* arenaAlloc() { return this->arenas()->arenaAlloc(); }
- GrSubRunAllocator* subRunAlloc() { return this->arenas()->subRunAlloc(); }
+ sktext::gpu::SubRunAllocator* subRunAlloc() { return this->arenas()->subRunAlloc(); }
#if GR_TEST_UTILS
OpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); }
diff --git a/src/text/gpu/BUILD.bazel b/src/text/gpu/BUILD.bazel
index 8334626..8907020 100644
--- a/src/text/gpu/BUILD.bazel
+++ b/src/text/gpu/BUILD.bazel
@@ -5,6 +5,37 @@
exports_files_legacy()
generated_cc_atom(
+ name = "GlyphVector_hdr",
+ hdrs = ["GlyphVector.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":Glyph_hdr",
+ ":StrikeCache_hdr",
+ ":SubRunAllocator_hdr",
+ "//include/core:SkSpan_hdr",
+ "//src/core:SkGlyphBuffer_hdr",
+ "//src/core:SkGlyph_hdr",
+ "//src/gpu/ganesh:GrDrawOpAtlas_hdr",
+ "//src/gpu/ganesh:GrMeshDrawTarget_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "GlyphVector_src",
+ srcs = ["GlyphVector.cpp"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":GlyphVector_hdr",
+ "//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
+ "//src/core:SkReadBuffer_hdr",
+ "//src/core:SkStrikeCache_hdr",
+ "//src/core:SkStrikeSpec_hdr",
+ "//src/core:SkWriteBuffer_hdr",
+ "//src/gpu/ganesh/text:GrAtlasManager_hdr",
+ ],
+)
+
+generated_cc_atom(
name = "Glyph_hdr",
hdrs = ["Glyph.h"],
visibility = ["//:__subpackages__"],
@@ -14,3 +45,48 @@
"//src/gpu:AtlasTypes_hdr",
],
)
+
+generated_cc_atom(
+ name = "StrikeCache_hdr",
+ hdrs = ["StrikeCache.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/private:SkTHash_hdr",
+ "//src/core:SkArenaAlloc_hdr",
+ "//src/core:SkStrikeSpec_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "StrikeCache_src",
+ srcs = ["StrikeCache.cpp"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":Glyph_hdr",
+ ":StrikeCache_hdr",
+ "//src/core:SkArenaAlloc_hdr",
+ "//src/core:SkStrikeSpec_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SubRunAllocator_hdr",
+ hdrs = ["SubRunAllocator.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkMath_hdr",
+ "//include/core:SkSpan_hdr",
+ "//include/private:SkTemplates_hdr",
+ "//src/core:SkArenaAlloc_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "SubRunAllocator_src",
+ srcs = ["SubRunAllocator.cpp"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":SubRunAllocator_hdr",
+ "//include/core:SkMath_hdr",
+ ],
+)
diff --git a/src/text/gpu/Glyph.h b/src/text/gpu/Glyph.h
index b4f03d4..2c6f828 100644
--- a/src/text/gpu/Glyph.h
+++ b/src/text/gpu/Glyph.h
@@ -13,6 +13,7 @@
#include "src/gpu/AtlasTypes.h"
namespace sktext::gpu {
+
class Glyph {
public:
static skgpu::MaskFormat FormatFromSkGlyph(SkMask::Format format) {
@@ -39,6 +40,6 @@
skgpu::AtlasLocator fAtlasLocator;
};
-}
+} // namespace sktext::gpu
-#endif
+#endif // sktext_gpu_Glyph_DEFINED
diff --git a/src/gpu/ganesh/text/GrGlyphVector.cpp b/src/text/gpu/GlyphVector.cpp
similarity index 74%
rename from src/gpu/ganesh/text/GrGlyphVector.cpp
rename to src/text/gpu/GlyphVector.cpp
index 110b129..75172d2 100644
--- a/src/gpu/ganesh/text/GrGlyphVector.cpp
+++ b/src/text/gpu/GlyphVector.cpp
@@ -5,27 +5,30 @@
* found in the LICENSE file.
*/
-#include "src/gpu/ganesh/text/GrGlyphVector.h"
+#include "src/text/gpu/GlyphVector.h"
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkWriteBuffer.h"
+#if SK_SUPPORT_GPU
#include "src/gpu/ganesh/text/GrAtlasManager.h"
+#endif
-using Glyph = sktext::gpu::Glyph;
using MaskFormat = skgpu::MaskFormat;
-GrGlyphVector::GrGlyphVector(sk_sp<SkStrike>&& strike, SkSpan<Variant> glyphs)
- : fStrike{std::move(strike)}
+namespace sktext::gpu {
+
+GlyphVector::GlyphVector(sk_sp<SkStrike>&& strike, SkSpan<Variant> glyphs)
+ : fSkStrike{std::move(strike)}
, fGlyphs{glyphs} {
- SkASSERT(fStrike != nullptr);
+ SkASSERT(fSkStrike != nullptr);
SkASSERT(fGlyphs.size() > 0);
}
-GrGlyphVector GrGlyphVector::Make(
- sk_sp<SkStrike>&& strike, SkSpan<SkGlyphVariant> glyphs, GrSubRunAllocator* alloc) {
+GlyphVector GlyphVector::Make(
+ sk_sp<SkStrike>&& strike, SkSpan<SkGlyphVariant> glyphs, SubRunAllocator* alloc) {
SkASSERT(strike != nullptr);
SkASSERT(glyphs.size() > 0);
Variant* variants = alloc->makePODArray<Variant>(glyphs.size());
@@ -33,12 +36,12 @@
variants[i] = gv.glyph()->getPackedID();
}
- return GrGlyphVector{std::move(strike), SkMakeSpan(variants, glyphs.size())};
+ return GlyphVector{std::move(strike), SkMakeSpan(variants, glyphs.size())};
}
-std::optional<GrGlyphVector> GrGlyphVector::MakeFromBuffer(SkReadBuffer& buffer,
- const SkStrikeClient* client,
- GrSubRunAllocator* alloc) {
+std::optional<GlyphVector> GlyphVector::MakeFromBuffer(SkReadBuffer& buffer,
+ const SkStrikeClient* client,
+ SubRunAllocator* alloc) {
auto descriptor = SkAutoDescriptor::MakeFromBuffer(buffer);
if (!buffer.validate(descriptor.has_value())) { return {}; }
@@ -65,15 +68,15 @@
for (int i = 0; i < glyphCount; i++) {
variants[i].packedGlyphID = SkPackedGlyphID(buffer.readUInt());
}
- return {GrGlyphVector{std::move(strike), SkMakeSpan(variants, glyphCount)}};
+ return {GlyphVector{std::move(strike), SkMakeSpan(variants, glyphCount)}};
}
-void GrGlyphVector::flatten(SkWriteBuffer& buffer) {
+void GlyphVector::flatten(SkWriteBuffer& buffer) {
// There should never be a glyph vector with zero glyphs.
SkASSERT(fGlyphs.size() != 0);
- if (!fStrike) { SK_ABORT("Can't flatten with already drawn."); }
+ if (!fSkStrike) { SK_ABORT("Can't flatten with already drawn."); }
- fStrike->getDescriptor().flatten(buffer);
+ fSkStrike->getDescriptor().flatten(buffer);
// Write out the span of packedGlyphIDs.
buffer.write32(SkTo<int32_t>(fGlyphs.size()));
@@ -82,33 +85,34 @@
}
}
-SkSpan<const Glyph*> GrGlyphVector::glyphs() const {
+SkSpan<const Glyph*> GlyphVector::glyphs() const {
return SkMakeSpan(reinterpret_cast<const Glyph**>(fGlyphs.data()), fGlyphs.size());
}
// packedGlyphIDToGlyph must be run in single-threaded mode.
-// If fStrike != nullptr then the conversion to Glyph* has not happened.
-void GrGlyphVector::packedGlyphIDToGlyph(GrStrikeCache* cache) {
- if (fStrike != nullptr) {
- fGrStrike = cache->findOrCreateStrike(fStrike->strikeSpec());
+// If fSkStrike != nullptr then the conversion to Glyph* has not happened.
+void GlyphVector::packedGlyphIDToGlyph(StrikeCache* cache) {
+ if (fSkStrike != nullptr) {
+ fTextStrike = cache->findOrCreateStrike(fSkStrike->strikeSpec());
for (auto& variant : fGlyphs) {
- variant.glyph = fGrStrike->getGlyph(variant.packedGlyphID);
+ variant.glyph = fTextStrike->getGlyph(variant.packedGlyphID);
}
// This must be pinned for the Atlas filling to work.
// TODO(herb): re-enable after the cut on 20220414
- // fStrike->verifyPinnedStrike();
+ // fSkStrike->verifyPinnedStrike();
// Drop the ref on the strike that was taken in the SkGlyphRunPainter process* methods.
- fStrike = nullptr;
+ fSkStrike = nullptr;
}
}
-std::tuple<bool, int> GrGlyphVector::regenerateAtlas(int begin, int end,
- MaskFormat maskFormat,
- int srcPadding,
- GrMeshDrawTarget* target) {
+#if SK_SUPPORT_GPU
+std::tuple<bool, int> GlyphVector::regenerateAtlas(int begin, int end,
+ MaskFormat maskFormat,
+ int srcPadding,
+ GrMeshDrawTarget* target) {
GrAtlasManager* atlasManager = target->atlasManager();
GrDeferredUploadTarget* uploadTarget = target->deferredUploadTarget();
@@ -121,7 +125,7 @@
// is set to kInvalidAtlasGeneration) or the atlas has changed in subsequent calls..
fBulkUseToken.reset();
- SkBulkGlyphMetricsAndImages metricsAndImages{fGrStrike->strikeSpec()};
+ SkBulkGlyphMetricsAndImages metricsAndImages{fTextStrike->strikeSpec()};
// Update the atlas information in the GrStrike.
auto tokenTracker = uploadTarget->tokenTracker();
@@ -129,7 +133,7 @@
int glyphsPlacedInAtlas = 0;
bool success = true;
for (const Variant& variant : glyphs) {
- sktext::gpu::Glyph* gpuGlyph = variant.glyph;
+ Glyph* gpuGlyph = variant.glyph;
SkASSERT(gpuGlyph != nullptr);
if (!atlasManager->hasGlyph(maskFormat, gpuGlyph)) {
@@ -167,4 +171,6 @@
return {true, end - begin};
}
}
+#endif
+} // namespace sktext::gpu
diff --git a/src/text/gpu/GlyphVector.h b/src/text/gpu/GlyphVector.h
new file mode 100644
index 0000000..3ff4553
--- /dev/null
+++ b/src/text/gpu/GlyphVector.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2022 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_GlyphVector_DEFINED
+#define sktext_gpu_GlyphVector_DEFINED
+
+#include "include/core/SkSpan.h"
+#include "src/core/SkGlyph.h"
+#include "src/core/SkGlyphBuffer.h"
+#if SK_SUPPORT_GPU
+#include "src/gpu/ganesh/GrDrawOpAtlas.h"
+#include "src/gpu/ganesh/GrMeshDrawTarget.h"
+#endif
+#include "src/text/gpu/Glyph.h"
+#include "src/text/gpu/StrikeCache.h"
+#include "src/text/gpu/SubRunAllocator.h"
+
+class SkStrikeClient;
+
+namespace sktext::gpu {
+
+// -- GlyphVector ----------------------------------------------------------------------------------
+// GlyphVector provides a way to delay the lookup of Glyphs until the code is running on the GPU
+// in single threaded mode. The GlyphVector is created in a multi-threaded environment, but the
+// StrikeCache is only single threaded (and must be single threaded because of the atlas).
+class GlyphVector {
+public:
+ union Variant {
+ // Initially, filled with packed id, but changed to Glyph* in the onPrepare stage.
+ SkPackedGlyphID packedGlyphID;
+ Glyph* glyph;
+ // Add ctors to help SkArenaAlloc create arrays.
+ Variant() : glyph{nullptr} {}
+ Variant(SkPackedGlyphID id) : packedGlyphID{id} {}
+ };
+
+ GlyphVector(sk_sp<SkStrike>&& strike, SkSpan<Variant> glyphs);
+
+ static GlyphVector Make(
+ sk_sp<SkStrike>&& strike, SkSpan<SkGlyphVariant> glyphs, SubRunAllocator* alloc);
+ SkSpan<const Glyph*> glyphs() const;
+
+ static std::optional<GlyphVector> MakeFromBuffer(SkReadBuffer& buffer,
+ const SkStrikeClient* strikeClient,
+ SubRunAllocator* alloc);
+ void flatten(SkWriteBuffer& buffer);
+
+ // This doesn't need to include sizeof(GlyphVector) because this is embedded in each of
+ // the sub runs.
+ int unflattenSize() const { return GlyphVectorSize(fGlyphs.size()); }
+
+ void packedGlyphIDToGlyph(StrikeCache* cache);
+
+#if SK_SUPPORT_GPU
+ std::tuple<bool, int> regenerateAtlas(
+ int begin, int end,
+ skgpu::MaskFormat maskFormat,
+ int srcPadding,
+ GrMeshDrawTarget *);
+#endif
+
+ static size_t GlyphVectorSize(size_t count) {
+ return sizeof(Variant) * count;
+ }
+
+private:
+ friend class TestingPeer;
+ sk_sp<SkStrike> fSkStrike;
+ SkSpan<Variant> fGlyphs;
+ sk_sp<TextStrike> fTextStrike{nullptr};
+ uint64_t fAtlasGeneration{skgpu::AtlasGenerationCounter::kInvalidGeneration};
+#if SK_SUPPORT_GPU
+ GrDrawOpAtlas::BulkUseTokenUpdater fBulkUseToken;
+#endif
+};
+
+} // namespace sktext::gpu
+
+#endif // sktext_gpu_GlyphVector_DEFINED
diff --git a/src/text/gpu/StrikeCache.cpp b/src/text/gpu/StrikeCache.cpp
new file mode 100644
index 0000000..2415eda
--- /dev/null
+++ b/src/text/gpu/StrikeCache.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/core/SkArenaAlloc.h"
+#include "src/core/SkStrikeSpec.h"
+#include "src/text/gpu/Glyph.h"
+#include "src/text/gpu/StrikeCache.h"
+
+namespace sktext::gpu {
+
+StrikeCache::~StrikeCache() {
+ this->freeAll();
+}
+
+void StrikeCache::freeAll() {
+ fCache.reset();
+}
+
+sk_sp<TextStrike> StrikeCache::findOrCreateStrike(const SkStrikeSpec& strikeSpec) {
+ if (sk_sp<TextStrike>* cached = fCache.find(strikeSpec.descriptor())) {
+ return *cached;
+ }
+ return this->generateStrike(strikeSpec);
+}
+
+sk_sp<TextStrike> StrikeCache::generateStrike(const SkStrikeSpec& strikeSpec) {
+ sk_sp<TextStrike> strike = sk_make_sp<TextStrike>(strikeSpec);
+ fCache.set(strike);
+ return strike;
+}
+
+const SkDescriptor& StrikeCache::HashTraits::GetKey(const sk_sp<TextStrike>& strike) {
+ return strike->fStrikeSpec.descriptor();
+}
+
+uint32_t StrikeCache::HashTraits::Hash(const SkDescriptor& descriptor) {
+ return descriptor.getChecksum();
+}
+
+TextStrike::TextStrike(const SkStrikeSpec& strikeSpec) : fStrikeSpec{strikeSpec} {}
+
+Glyph* TextStrike::getGlyph(SkPackedGlyphID packedGlyphID) {
+ Glyph* glyph = fCache.findOrNull(packedGlyphID);
+ if (glyph == nullptr) {
+ glyph = fAlloc.make<Glyph>(packedGlyphID);
+ fCache.set(glyph);
+ }
+ return glyph;
+}
+
+const SkPackedGlyphID& TextStrike::HashTraits::GetKey(const Glyph* glyph) {
+ return glyph->fPackedID;
+}
+
+uint32_t TextStrike::HashTraits::Hash(SkPackedGlyphID key) {
+ return key.hash();
+}
+
+} // namespace sktext::gpu
diff --git a/src/text/gpu/StrikeCache.h b/src/text/gpu/StrikeCache.h
new file mode 100644
index 0000000..3604bd2
--- /dev/null
+++ b/src/text/gpu/StrikeCache.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef sktext_gpu_StrikeCache_DEFINED
+#define sktext_gpu_StrikeCache_DEFINED
+
+#include "include/private/SkTHash.h"
+#include "src/core/SkArenaAlloc.h"
+#include "src/core/SkStrikeSpec.h"
+
+namespace sktext::gpu {
+
+class Glyph;
+class StrikeCache;
+
+// The TextStrike manages an SkArenaAlloc for Glyphs. The SkStrike is what actually creates
+// the mask. The TextStrike may outlive the generating SkStrike. However, it retains a copy
+// of it's SkDescriptor as a key to access (or regenerate) the SkStrike. TextStrikes are
+// created by and owned by a StrikeCache.
+class TextStrike : public SkNVRefCnt<TextStrike> {
+public:
+ TextStrike(const SkStrikeSpec& strikeSpec);
+
+ Glyph* getGlyph(SkPackedGlyphID);
+ const SkStrikeSpec& strikeSpec() const { return fStrikeSpec; }
+
+private:
+ // Key for retrieving the SkStrike for creating new atlas data.
+ const SkStrikeSpec fStrikeSpec;
+
+ struct HashTraits {
+ static const SkPackedGlyphID& GetKey(const Glyph* glyph);
+ static uint32_t Hash(SkPackedGlyphID key);
+ };
+ // Map SkPackedGlyphID -> Glyph*.
+ SkTHashTable<Glyph*, SkPackedGlyphID, HashTraits> fCache;
+
+ // Store for the glyph information.
+ SkArenaAlloc fAlloc{512};
+
+ friend class StrikeCache;
+};
+
+// StrikeCache manages strikes which are indexed by a SkStrike. These strikes can then be
+// used to generate individual Glyph Masks.
+class StrikeCache {
+public:
+ ~StrikeCache();
+
+ // The user of the cache may hold a long-lived ref to the returned strike.
+ sk_sp<TextStrike> findOrCreateStrike(const SkStrikeSpec& strikeSpec);
+
+ void freeAll();
+
+private:
+ sk_sp<TextStrike> generateStrike(const SkStrikeSpec& strikeSpec);
+
+ struct HashTraits {
+ static const SkDescriptor& GetKey(const sk_sp<TextStrike>& strike);
+ static uint32_t Hash(const SkDescriptor& strikeSpec);
+ };
+
+ using StrikeHash = SkTHashTable<sk_sp<TextStrike>, const SkDescriptor&, HashTraits>;
+
+ StrikeHash fCache;
+};
+
+} // namespace sktext::gpu
+
+#endif // sktext_gpu_StrikeCache_DEFINED
diff --git a/src/gpu/ganesh/GrSubRunAllocator.cpp b/src/text/gpu/SubRunAllocator.cpp
similarity index 67%
rename from src/gpu/ganesh/GrSubRunAllocator.cpp
rename to src/text/gpu/SubRunAllocator.cpp
index 4bde829..1dec604 100644
--- a/src/gpu/ganesh/GrSubRunAllocator.cpp
+++ b/src/text/gpu/SubRunAllocator.cpp
@@ -6,15 +6,17 @@
*/
#include "include/core/SkMath.h"
-#include "src/gpu/ganesh/GrSubRunAllocator.h"
+#include "src/text/gpu/SubRunAllocator.h"
#include <cstddef>
#include <memory>
#include <new>
#include <utility>
-// -- GrBagOfBytes ---------------------------------------------------------------------------------
-GrBagOfBytes::GrBagOfBytes(char* bytes, size_t size, size_t firstHeapAllocation)
+namespace sktext::gpu {
+
+// -- BagOfBytes ---------------------------------------------------------------------------------
+BagOfBytes::BagOfBytes(char* bytes, size_t size, size_t firstHeapAllocation)
: fFibProgression(size, firstHeapAllocation) {
SkASSERT_RELEASE(size < kMaxByteSize);
SkASSERT_RELEASE(firstHeapAllocation < kMaxByteSize);
@@ -27,10 +29,10 @@
}
}
-GrBagOfBytes::GrBagOfBytes(size_t firstHeapAllocation)
- : GrBagOfBytes(nullptr, 0, firstHeapAllocation) {}
+BagOfBytes::BagOfBytes(size_t firstHeapAllocation)
+ : BagOfBytes(nullptr, 0, firstHeapAllocation) {}
-GrBagOfBytes::~GrBagOfBytes() {
+BagOfBytes::~BagOfBytes() {
Block* cursor = reinterpret_cast<Block*>(fEndByte);
while (cursor != nullptr) {
char* toDelete = cursor->fBlockStart;
@@ -39,11 +41,11 @@
}
}
-GrBagOfBytes::Block::Block(char* previous, char* startOfBlock)
+BagOfBytes::Block::Block(char* previous, char* startOfBlock)
: fBlockStart{startOfBlock}
, fPrevious{reinterpret_cast<Block*>(previous)} {}
-void* GrBagOfBytes::alignedBytes(int size, int alignment) {
+void* BagOfBytes::alignedBytes(int size, int alignment) {
SkASSERT_RELEASE(0 < size && size < kMaxByteSize);
SkASSERT_RELEASE(0 < alignment && alignment <= kMaxAlignment);
SkASSERT_RELEASE(SkIsPow2(alignment));
@@ -51,7 +53,7 @@
return this->allocateBytes(size, alignment);
}
-void GrBagOfBytes::setupBytesAndCapacity(char* bytes, int size) {
+void BagOfBytes::setupBytesAndCapacity(char* bytes, int size) {
// endByte must be aligned to the maximum alignment to allow tracking alignment using capacity;
// capacity and endByte are both aligned to max alignment.
intptr_t endByte = reinterpret_cast<intptr_t>(bytes + size - sizeof(Block)) & -kMaxAlignment;
@@ -59,7 +61,7 @@
fCapacity = fEndByte - bytes;
}
-void GrBagOfBytes::needMoreBytes(int requestedSize, int alignment) {
+void BagOfBytes::needMoreBytes(int requestedSize, int alignment) {
int nextBlockSize = fFibProgression.nextBlockSize();
const int size = PlatformMinimumSizeWithOverhead(
std::max(requestedSize, nextBlockSize), kAllocationAlignment);
@@ -76,16 +78,18 @@
SkASSERT(fCapacity >= requestedSize);
}
-// -- GrSubRunAllocator ----------------------------------------------------------------------------
-GrSubRunAllocator::GrSubRunAllocator(char* bytes, int size, int firstHeapAllocation)
+// -- SubRunAllocator ----------------------------------------------------------------------------
+SubRunAllocator::SubRunAllocator(char* bytes, int size, int firstHeapAllocation)
: fAlloc{bytes, SkTo<size_t>(size), SkTo<size_t>(firstHeapAllocation)} {
- SkASSERT_RELEASE(SkTFitsIn<size_t>(size));
- SkASSERT_RELEASE(SkTFitsIn<size_t>(firstHeapAllocation));
+ SkASSERT_RELEASE(SkTFitsIn<size_t>(size));
+ SkASSERT_RELEASE(SkTFitsIn<size_t>(firstHeapAllocation));
}
-GrSubRunAllocator::GrSubRunAllocator(int firstHeapAllocation)
- : GrSubRunAllocator(nullptr, 0, firstHeapAllocation) { }
+SubRunAllocator::SubRunAllocator(int firstHeapAllocation)
+ : SubRunAllocator(nullptr, 0, firstHeapAllocation) { }
-void* GrSubRunAllocator::alignedBytes(int unsafeSize, int unsafeAlignment) {
+void* SubRunAllocator::alignedBytes(int unsafeSize, int unsafeAlignment) {
return fAlloc.alignedBytes(unsafeSize, unsafeAlignment);
}
+
+} // namespace sktext::gpu
diff --git a/src/gpu/ganesh/GrSubRunAllocator.h b/src/text/gpu/SubRunAllocator.h
similarity index 87%
rename from src/gpu/ganesh/GrSubRunAllocator.h
rename to src/text/gpu/SubRunAllocator.h
index 83767fe..a3b5f14 100644
--- a/src/gpu/ganesh/GrSubRunAllocator.h
+++ b/src/text/gpu/SubRunAllocator.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrSubRunAllocator_DEFINED
-#define GrSubRunAllocator_DEFINED
+#ifndef sktext_gpu_SubRunAllocator_DEFINED
+#define sktext_gpu_SubRunAllocator_DEFINED
#include "include/core/SkMath.h"
#include "include/core/SkSpan.h"
@@ -19,24 +19,26 @@
#include <tuple>
#include <utility>
-// GrBagOfBytes parcels out bytes with a given size and alignment.
-class GrBagOfBytes {
+namespace sktext::gpu {
+
+// BagOfBytes parcels out bytes with a given size and alignment.
+class BagOfBytes {
public:
- GrBagOfBytes(char* block, size_t blockSize, size_t firstHeapAllocation);
- explicit GrBagOfBytes(size_t firstHeapAllocation = 0);
- GrBagOfBytes(const GrBagOfBytes&) = delete;
- GrBagOfBytes& operator=(const GrBagOfBytes&) = delete;
- GrBagOfBytes(GrBagOfBytes&& that)
+ BagOfBytes(char* block, size_t blockSize, size_t firstHeapAllocation);
+ explicit BagOfBytes(size_t firstHeapAllocation = 0);
+ BagOfBytes(const BagOfBytes&) = delete;
+ BagOfBytes& operator=(const BagOfBytes&) = delete;
+ BagOfBytes(BagOfBytes&& that)
: fEndByte{std::exchange(that.fEndByte, nullptr)}
, fCapacity{that.fCapacity}
, fFibProgression{that.fFibProgression} {}
- GrBagOfBytes& operator=(GrBagOfBytes&& that) {
- this->~GrBagOfBytes();
- new (this) GrBagOfBytes{std::move(that)};
+ BagOfBytes& operator=(BagOfBytes&& that) {
+ this->~BagOfBytes();
+ new (this) BagOfBytes{std::move(that)};
return *this;
}
- ~GrBagOfBytes();
+ ~BagOfBytes();
// Given a requestedSize round up to the smallest size that accounts for all the per block
// overhead and alignment. It crashes if requestedSize is negative or too big.
@@ -166,9 +168,9 @@
};
template <typename T>
-class GrSubRunInitializer {
+class SubRunInitializer {
public:
- GrSubRunInitializer(void* memory) : fMemory{memory} { SkASSERT(memory != nullptr); }
+ SubRunInitializer(void* memory) : fMemory{memory} { SkASSERT(memory != nullptr); }
template <typename... Args>
T* initialize(Args&&... args) {
// Warn on more than one initialization.
@@ -185,7 +187,7 @@
// unique_ptrs returned, are to assist in assuring the object's destructor is called.
// A note on zero length arrays: according to the standard a pointer must be returned, and it
// can't be a nullptr. In such a case, SkArena allocates one byte, but does not initialize it.
-class GrSubRunAllocator {
+class SubRunAllocator {
public:
struct Destroyer {
template <typename T>
@@ -203,26 +205,26 @@
template<class T>
inline static constexpr bool HasNoDestructor = std::is_trivially_destructible<T>::value;
- GrSubRunAllocator(char* block, int blockSize, int firstHeapAllocation);
- explicit GrSubRunAllocator(int firstHeapAllocation = 0);
- GrSubRunAllocator(const GrSubRunAllocator&) = delete;
- GrSubRunAllocator& operator=(const GrSubRunAllocator&) = delete;
- GrSubRunAllocator(GrSubRunAllocator&&) = default;
- GrSubRunAllocator& operator=(GrSubRunAllocator&&) = default;
+ SubRunAllocator(char* block, int blockSize, int firstHeapAllocation);
+ explicit SubRunAllocator(int firstHeapAllocation = 0);
+ SubRunAllocator(const SubRunAllocator&) = delete;
+ SubRunAllocator& operator=(const SubRunAllocator&) = delete;
+ SubRunAllocator(SubRunAllocator&&) = default;
+ SubRunAllocator& operator=(SubRunAllocator&&) = default;
template <typename T>
- static std::tuple<GrSubRunInitializer<T>, int, GrSubRunAllocator>
+ static std::tuple<SubRunInitializer<T>, int, SubRunAllocator>
AllocateClassMemoryAndArena(int allocSizeHint) {
SkASSERT_RELEASE(allocSizeHint >= 0);
// Round the size after the object the optimal amount.
- int extraSize = GrBagOfBytes::PlatformMinimumSizeWithOverhead(allocSizeHint, alignof(T));
+ int extraSize = BagOfBytes::PlatformMinimumSizeWithOverhead(allocSizeHint, alignof(T));
// Don't overflow or die.
SkASSERT_RELEASE(INT_MAX - SkTo<int>(sizeof(T)) > extraSize);
int totalMemorySize = sizeof(T) + extraSize;
void* memory = ::operator new (totalMemorySize);
- GrSubRunAllocator alloc{SkTAddOffset<char>(memory, sizeof(T)), extraSize, extraSize/2};
+ SubRunAllocator alloc{SkTAddOffset<char>(memory, sizeof(T)), extraSize, extraSize/2};
return {memory, totalMemorySize, std::move(alloc)};
}
@@ -278,6 +280,9 @@
void* alignedBytes(int size, int alignment);
private:
- GrBagOfBytes fAlloc;
+ BagOfBytes fAlloc;
};
-#endif // GrSubRunAllocator_DEFINED
+
+} // namespace sktext::gpu
+
+#endif // sktext_gpu_SubRunAllocator_DEFINED
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
index 63e2414..1688aeb 100644
--- a/tests/BUILD.bazel
+++ b/tests/BUILD.bazel
@@ -7201,8 +7201,8 @@
"//src/core:SkStrikeSpec_hdr",
"//src/core:SkWriteBuffer_hdr",
"//src/gpu/ganesh:GrResourceProvider_hdr",
- "//src/gpu/ganesh:GrSubRunAllocator_hdr",
- "//src/gpu/ganesh/text:GrGlyphVector_hdr",
+ "//src/text/gpu:GlyphVector_hdr",
+ "//src/text/gpu:SubRunAllocator_hdr",
],
)
diff --git a/tests/GrGlyphVectorTest.cpp b/tests/GrGlyphVectorTest.cpp
index 5dbd11b..3a2f0b8 100644
--- a/tests/GrGlyphVectorTest.cpp
+++ b/tests/GrGlyphVectorTest.cpp
@@ -7,31 +7,36 @@
#include "src/core/SkGlyph.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
-#include "src/gpu/ganesh/text/GrGlyphVector.h"
#include "src/core/SkGlyphBuffer.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkWriteBuffer.h"
-#include "src/gpu/ganesh/GrSubRunAllocator.h"
+#include "src/text/gpu/GlyphVector.h"
+#include "src/text/gpu/SubRunAllocator.h"
#include "tests/Test.h"
+using GlyphVector = sktext::gpu::GlyphVector;
+using SubRunAllocator = sktext::gpu::SubRunAllocator;
+
+namespace sktext::gpu {
+
class TestingPeer {
public:
- static const SkDescriptor& GetDescriptor(const GrGlyphVector& v) {
- return v.fStrike->getDescriptor();
+ static const SkDescriptor& GetDescriptor(const GlyphVector& v) {
+ return v.fSkStrike->getDescriptor();
}
- static SkSpan<GrGlyphVector::Variant> GetGlyphs(const GrGlyphVector& v) {
+ static SkSpan<GlyphVector::Variant> GetGlyphs(const GlyphVector& v) {
return v.fGlyphs;
}
};
-DEF_TEST(GrGlyphVector_Serialization, r) {
+DEF_TEST(GlyphVector_Serialization, r) {
SkFont font;
auto [strikeSpec, _] = SkStrikeSpec::MakeCanonicalized(font);
- GrSubRunAllocator alloc;
+ SubRunAllocator alloc;
SkBulkGlyphMetricsAndImages glyphFinder{strikeSpec};
const int N = 10;
@@ -40,7 +45,7 @@
glyphs[i] = glyphFinder.glyph(SkPackedGlyphID(SkTo<SkGlyphID>(i + 1)));
}
- GrGlyphVector src = GrGlyphVector::Make(
+ GlyphVector src = GlyphVector::Make(
strikeSpec.findOrCreateStrike(), SkMakeSpan(glyphs, N), &alloc);
SkBinaryWriteBuffer wBuffer;
@@ -48,7 +53,7 @@
auto data = wBuffer.snapshotAsData();
SkReadBuffer rBuffer{data->data(), data->size()};
- auto dst = GrGlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
+ auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
REPORTER_ASSERT(r, dst.has_value());
REPORTER_ASSERT(r, TestingPeer::GetDescriptor(src) == TestingPeer::GetDescriptor(*dst));
@@ -59,7 +64,7 @@
}
}
-DEF_TEST(GrGlyphVector_BadLengths, r) {
+DEF_TEST(GlyphVector_BadLengths, r) {
{
SkFont font;
auto [strikeSpec, _] = SkStrikeSpec::MakeCanonicalized(font);
@@ -70,8 +75,8 @@
wBuffer.write32(0); // length
auto data = wBuffer.snapshotAsData();
SkReadBuffer rBuffer{data->data(), data->size()};
- GrSubRunAllocator alloc;
- auto dst = GrGlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
+ SubRunAllocator alloc;
+ auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
REPORTER_ASSERT(r, !dst.has_value());
}
@@ -88,8 +93,8 @@
wBuffer.writeUInt(12); // random data
auto data = wBuffer.snapshotAsData();
SkReadBuffer rBuffer{data->data(), data->size()};
- GrSubRunAllocator alloc;
- auto dst = GrGlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
+ SubRunAllocator alloc;
+ auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
REPORTER_ASSERT(r, !dst.has_value());
}
@@ -106,8 +111,10 @@
wBuffer.writeUInt(12); // random data
auto data = wBuffer.snapshotAsData();
SkReadBuffer rBuffer{data->data(), data->size()};
- GrSubRunAllocator alloc;
- auto dst = GrGlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
+ SubRunAllocator alloc;
+ auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
REPORTER_ASSERT(r, !dst.has_value());
}
}
+
+} // namespace sktext::gpu
diff --git a/tests/GrTextBlobTest.cpp b/tests/GrTextBlobTest.cpp
index 11066e7..d90db0e 100644
--- a/tests/GrTextBlobTest.cpp
+++ b/tests/GrTextBlobTest.cpp
@@ -14,6 +14,9 @@
#include "tests/Test.h"
#include "tools/ToolUtils.h"
+using BagOfBytes = sktext::gpu::BagOfBytes;
+using SubRunAllocator = sktext::gpu::SubRunAllocator;
+
SkBitmap rasterize_blob(SkTextBlob* blob,
const SkPaint& paint,
GrRecordingContext* rContext,
@@ -143,34 +146,34 @@
}
}
-DEF_TEST(GrBagOfBytesBasic, r) {
+DEF_TEST(BagOfBytesBasic, r) {
const int k4K = 1 << 12;
{
// GrBagOfBytes::MinimumSizeWithOverhead(-1); // This should fail
- GrBagOfBytes::PlatformMinimumSizeWithOverhead(0, 16);
- GrBagOfBytes::PlatformMinimumSizeWithOverhead(
+ BagOfBytes::PlatformMinimumSizeWithOverhead(0, 16);
+ BagOfBytes::PlatformMinimumSizeWithOverhead(
std::numeric_limits<int>::max() - k4K - 1, 16);
// GrBagOfBytes::MinimumSizeWithOverhead(std::numeric_limits<int>::max() - k4K); // Fail
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(0, 1, 16, 16) == 31);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(1, 1, 16, 16) == 32);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(63, 1, 16, 16) == 94);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(0, 8, 16, 16) == 24);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(1, 8, 16, 16) == 32);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(63, 8, 16, 16) == 88);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(0, 16, 16, 16) == 16);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(1, 16, 16, 16) == 32);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(63, 16, 16, 16) == 80);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(0, 1, 16, 16) == 31);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(1, 1, 16, 16) == 32);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(63, 1, 16, 16) == 94);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(0, 8, 16, 16) == 24);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(1, 8, 16, 16) == 32);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(63, 8, 16, 16) == 88);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(0, 16, 16, 16) == 16);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(1, 16, 16, 16) == 32);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(63, 16, 16, 16) == 80);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(0, 1, 8, 16) == 23);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(1, 1, 8, 16) == 24);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(63, 1, 8, 16) == 86);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(0, 8, 8, 16) == 16);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(1, 8, 8, 16) == 24);
- REPORTER_ASSERT(r, GrBagOfBytes::MinimumSizeWithOverhead(63, 8, 8, 16) == 80);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(0, 1, 8, 16) == 23);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(1, 1, 8, 16) == 24);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(63, 1, 8, 16) == 86);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(0, 8, 8, 16) == 16);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(1, 8, 8, 16) == 24);
+ REPORTER_ASSERT(r, BagOfBytes::MinimumSizeWithOverhead(63, 8, 8, 16) == 80);
}
{
- GrBagOfBytes bob;
+ BagOfBytes bob;
// bob.alignedBytes(0, 1); // This should fail
// bob.alignedBytes(1, 0); // This should fail
// bob.alignedBytes(1, 3); // This should fail
@@ -189,7 +192,7 @@
// Force multiple block allocation
{
- GrBagOfBytes bob;
+ BagOfBytes bob;
const int k64K = 1 << 16;
// By default allocation block sizes start at 1K and go up with fib. This should allocate
// 10 individual blocks.
@@ -200,20 +203,20 @@
}
// Helper for defining allocators with inline/reserved storage.
-// For argument declarations, stick to the base type (GrSubRunAllocator).
+// For argument declarations, stick to the base type (SubRunAllocator).
// Note: Inheriting from the storage first means the storage will outlive the
-// GrSubRunAllocator, letting ~GrSubRunAllocator read it as it calls destructors.
+// SubRunAllocator, letting ~SubRunAllocator read it as it calls destructors.
// (This is mostly only relevant for strict tools like MSAN.)
template <size_t inlineSize>
-class GrSTSubRunAllocator : private GrBagOfBytes::Storage<inlineSize>, public GrSubRunAllocator {
+class GrSTSubRunAllocator : private BagOfBytes::Storage<inlineSize>, public SubRunAllocator {
public:
explicit GrSTSubRunAllocator(int firstHeapAllocation =
- GrBagOfBytes::PlatformMinimumSizeWithOverhead(inlineSize, 1))
- : GrSubRunAllocator{this->data(), SkTo<int>(this->size()), firstHeapAllocation} {}
+ BagOfBytes::PlatformMinimumSizeWithOverhead(inlineSize, 1))
+ : SubRunAllocator{this->data(), SkTo<int>(this->size()), firstHeapAllocation} {}
};
-DEF_TEST(GrSubRunAllocator, r) {
+DEF_TEST(SubRunAllocator, r) {
static int created = 0;
static int destroyed = 0;
struct Foo {
@@ -228,7 +231,7 @@
char buf[10];
};
- auto exercise = [&](GrSubRunAllocator* alloc) {
+ auto exercise = [&](SubRunAllocator* alloc) {
created = 0;
destroyed = 0;
{
@@ -260,7 +263,7 @@
// Exercise default arena
{
- GrSubRunAllocator arena{0};
+ SubRunAllocator arena{0};
exercise(&arena);
}
@@ -273,7 +276,7 @@
// Exercise arena with a heap allocated starting block
{
std::unique_ptr<char[]> block{new char[1024]};
- GrSubRunAllocator arena{block.get(), 1024, 0};
+ SubRunAllocator arena{block.get(), 1024, 0};
exercise(&arena);
}
@@ -281,16 +284,16 @@
{
created = 0;
destroyed = 0;
- GrSubRunAllocator arena;
+ SubRunAllocator arena;
struct Node {
- Node(std::unique_ptr<Node, GrSubRunAllocator::Destroyer> next)
+ Node(std::unique_ptr<Node, SubRunAllocator::Destroyer> next)
: fNext{std::move(next)} { created++; }
~Node() { destroyed++; }
- std::unique_ptr<Node, GrSubRunAllocator::Destroyer> fNext;
+ std::unique_ptr<Node, SubRunAllocator::Destroyer> fNext;
};
- std::unique_ptr<Node, GrSubRunAllocator::Destroyer> current = nullptr;
+ std::unique_ptr<Node, SubRunAllocator::Destroyer> current = nullptr;
for (int i = 0; i < 128; i++) {
current = arena.makeUnique<Node>(std::move(current));
}
@@ -315,7 +318,7 @@
}
{
- GrSubRunAllocator arena(4096);
+ SubRunAllocator arena(4096);
void* ptr = arena.alignedBytes(4081, 8);
REPORTER_ASSERT(r, ((intptr_t)ptr & 7) == 0);
}
diff --git a/tools/gpu/BUILD.bazel b/tools/gpu/BUILD.bazel
index ed0646e..a289b9b 100644
--- a/tools/gpu/BUILD.bazel
+++ b/tools/gpu/BUILD.bazel
@@ -185,10 +185,10 @@
"//src/gpu/ganesh:GrSemaphore_hdr",
"//src/gpu/ganesh:GrTexture_hdr",
"//src/gpu/ganesh:SkGr_hdr",
- "//src/gpu/ganesh/text:GrStrikeCache_hdr",
"//src/gpu/ganesh/text:GrTextBlobRedrawCoordinator_hdr",
"//src/gpu/ganesh/v1:SurfaceDrawContext_v1_hdr",
"//src/image:SkImage_Gpu_hdr",
+ "//src/text/gpu:StrikeCache_hdr",
],
)
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index ea8aeac..e5ba993 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -24,10 +24,10 @@
#include "src/gpu/ganesh/GrSemaphore.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/SkGr.h"
-#include "src/gpu/ganesh/text/GrStrikeCache.h"
#include "src/gpu/ganesh/text/GrTextBlobRedrawCoordinator.h"
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
#include "src/image/SkImage_Gpu.h"
+#include "src/text/gpu/StrikeCache.h"
#include <algorithm>