serialization framework down to the Slug level, but not runs
Change-Id: I687ba55a61dd5d0509190804f19255851c328a31 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/509502 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
7b5b00aaf1
commit
2865ea30ff
@ -1208,5 +1208,9 @@ bool SkStrikeClient::translateTypefaceID(SkAutoDescriptor* descriptor) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
sk_sp<GrSlug> SkStrikeClient::makeSlugFromBuffer(SkReadBuffer& buffer) const { return nullptr; }
|
// Entry point for making slugs from the Slug class in GrTextBlob.cpp
|
||||||
|
sk_sp<GrSlug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client);
|
||||||
|
sk_sp<GrSlug> SkStrikeClient::makeSlugFromBuffer(SkReadBuffer& buffer) const {
|
||||||
|
return SkMakeSlugFromBuffer(buffer, this);
|
||||||
|
}
|
||||||
#endif // SK_SUPPORT_GPU
|
#endif // SK_SUPPORT_GPU
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
#include "include/gpu/GrRecordingContext.h"
|
#include "include/gpu/GrRecordingContext.h"
|
||||||
#include "include/private/SkTemplates.h"
|
#include "include/private/SkTemplates.h"
|
||||||
#include "include/private/chromium/GrSlug.h"
|
#include "include/private/chromium/GrSlug.h"
|
||||||
|
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
|
||||||
#include "src/core/SkFontPriv.h"
|
#include "src/core/SkFontPriv.h"
|
||||||
#include "src/core/SkMaskFilterBase.h"
|
#include "src/core/SkMaskFilterBase.h"
|
||||||
#include "src/core/SkMatrixProvider.h"
|
#include "src/core/SkMatrixProvider.h"
|
||||||
#include "src/core/SkPaintPriv.h"
|
#include "src/core/SkPaintPriv.h"
|
||||||
|
#include "src/core/SkReadBuffer.h"
|
||||||
#include "src/core/SkStrikeCache.h"
|
#include "src/core/SkStrikeCache.h"
|
||||||
#include "src/core/SkStrikeSpec.h"
|
#include "src/core/SkStrikeSpec.h"
|
||||||
#include "src/gpu/GrClip.h"
|
#include "src/gpu/GrClip.h"
|
||||||
@ -2611,11 +2613,6 @@ namespace {
|
|||||||
// -- Slug -----------------------------------------------------------------------------------------
|
// -- Slug -----------------------------------------------------------------------------------------
|
||||||
class Slug final : public GrSlug, public SkGlyphRunPainterInterface {
|
class Slug final : public GrSlug, public SkGlyphRunPainterInterface {
|
||||||
public:
|
public:
|
||||||
static sk_sp<Slug> Make(const SkMatrixProvider& viewMatrix,
|
|
||||||
const SkGlyphRunList& glyphRunList,
|
|
||||||
const SkPaint& paint,
|
|
||||||
const GrSDFTControl& control,
|
|
||||||
SkGlyphRunListPainter* painter);
|
|
||||||
Slug(SkRect sourceBounds,
|
Slug(SkRect sourceBounds,
|
||||||
const SkPaint& paint,
|
const SkPaint& paint,
|
||||||
const SkMatrix& positionMatrix,
|
const SkMatrix& positionMatrix,
|
||||||
@ -2623,6 +2620,14 @@ public:
|
|||||||
int allocSize);
|
int allocSize);
|
||||||
~Slug() override = default;
|
~Slug() override = default;
|
||||||
|
|
||||||
|
static sk_sp<Slug> Make(const SkMatrixProvider& viewMatrix,
|
||||||
|
const SkGlyphRunList& glyphRunList,
|
||||||
|
const SkPaint& paint,
|
||||||
|
const GrSDFTControl& control,
|
||||||
|
SkGlyphRunListPainter* painter);
|
||||||
|
static sk_sp<GrSlug> MakeFromBuffer(SkReadBuffer& buffer,
|
||||||
|
const SkStrikeClient* client);
|
||||||
|
|
||||||
void surfaceDraw(SkCanvas*,
|
void surfaceDraw(SkCanvas*,
|
||||||
const GrClip* clip,
|
const GrClip* clip,
|
||||||
const SkMatrixProvider& viewMatrix,
|
const SkMatrixProvider& viewMatrix,
|
||||||
@ -2665,7 +2670,7 @@ public:
|
|||||||
subRunCount += 1;
|
subRunCount += 1;
|
||||||
unflattenSizeHint += subrun.unflattenSize();
|
unflattenSizeHint += subrun.unflattenSize();
|
||||||
}
|
}
|
||||||
return {subRunCount, unflattenSizeHint + sizeof(Slug)};
|
return {subRunCount, unflattenSizeHint};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -2697,6 +2702,51 @@ void Slug::surfaceDraw(SkCanvas* canvas, const GrClip* clip, const SkMatrixProvi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Slug::flatten(SkWriteBuffer& buffer) const {
|
||||||
|
buffer.writeRect(fSourceBounds);
|
||||||
|
SkPaintPriv::Flatten(fPaint, buffer);
|
||||||
|
buffer.writeMatrix(fInitialPositionMatrix);
|
||||||
|
buffer.writePoint(fOrigin);
|
||||||
|
auto [subRunCount, subRunsUnflattenSizeHint] = this->subRunCountAndUnflattenSizeHint();
|
||||||
|
buffer.writeInt(subRunCount);
|
||||||
|
buffer.writeInt(subRunsUnflattenSizeHint);
|
||||||
|
/* This will be uncommented when the serialize-runs CL goes in.
|
||||||
|
for (auto& subRun : fSubRuns) {
|
||||||
|
subRun.flatten(buffer);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
sk_sp<GrSlug> Slug::MakeFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client) {
|
||||||
|
SkRect sourceBounds = buffer.readRect();
|
||||||
|
if (!buffer.validate(!sourceBounds.isEmpty())) { return nullptr; }
|
||||||
|
|
||||||
|
SkPaint paint = buffer.readPaint();
|
||||||
|
SkMatrix positionMatrix;
|
||||||
|
buffer.readMatrix(&positionMatrix);
|
||||||
|
SkPoint origin = buffer.readPoint();
|
||||||
|
int subRunCount = buffer.readInt();
|
||||||
|
if (!buffer.validate(subRunCount != 0)) { return nullptr; }
|
||||||
|
int subRunsUnflattenSizeHint = buffer.readInt();
|
||||||
|
|
||||||
|
sk_sp<Slug> slug{new (::operator new (sizeof(Slug) + subRunsUnflattenSizeHint))
|
||||||
|
Slug(sourceBounds,
|
||||||
|
paint,
|
||||||
|
positionMatrix,
|
||||||
|
origin,
|
||||||
|
subRunsUnflattenSizeHint)};
|
||||||
|
/* This will be uncommented when the serialize-runs CL goes in.
|
||||||
|
for (int i = 0; i < subRunCount; ++i) {
|
||||||
|
slug->fSubRuns.append(GrSubRun::MakeFromBuffer(slug.get(), buffer, &slug->fAlloc, client));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Something went wrong while reading.
|
||||||
|
if (!buffer.isValid()) { return nullptr;}
|
||||||
|
|
||||||
|
return std::move(slug);
|
||||||
|
}
|
||||||
|
|
||||||
// -- DirectMaskSubRunSlug -------------------------------------------------------------------------
|
// -- DirectMaskSubRunSlug -------------------------------------------------------------------------
|
||||||
class DirectMaskSubRunSlug final : public GrSubRun, public GrAtlasSubRun {
|
class DirectMaskSubRunSlug final : public GrSubRun, public GrAtlasSubRun {
|
||||||
public:
|
public:
|
||||||
@ -3177,8 +3227,6 @@ void Slug::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
|
|||||||
|
|
||||||
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
|
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slug::flatten(SkWriteBuffer& buffer) const { SK_ABORT("Not implemented."); }
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace skgpu::v1 {
|
namespace skgpu::v1 {
|
||||||
@ -3222,3 +3270,7 @@ sk_sp<GrSlug> MakeSlug(const SkMatrixProvider& drawMatrix,
|
|||||||
return Slug::Make(drawMatrix, glyphRunList, paint, control, painter);
|
return Slug::Make(drawMatrix, glyphRunList, paint, control, painter);
|
||||||
}
|
}
|
||||||
} // namespace skgpu::v1
|
} // namespace skgpu::v1
|
||||||
|
|
||||||
|
sk_sp<GrSlug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client) {
|
||||||
|
return Slug::MakeFromBuffer(buffer, client);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user