GrSlug proposed API for serialization
I don't have serialization working yet, but I have enough of the plumbing to sketch out an API. It seems simplistic, but notice it requires access to the SkStrikeClient. Change-Id: I29f046b62f20c635cee86f0666e8112ac3097f16 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/507837 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
ff616b89e3
commit
0c58105085
@ -15,6 +15,7 @@ class SkCanvas;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
class SkTextBlob;
|
||||
class SkWriteBuffer;
|
||||
|
||||
// You can use GrSlug to simulate drawTextBlob by defining the following at compile time.
|
||||
// SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG
|
||||
@ -43,6 +44,9 @@ public:
|
||||
// Draw the GrSlug obeying the canvas's mapping and clipping.
|
||||
void draw(SkCanvas* canvas);
|
||||
|
||||
// Serialize the slug.
|
||||
virtual void flatten(SkWriteBuffer&) const = 0;
|
||||
|
||||
virtual SkRect sourceBounds() const = 0;
|
||||
virtual const SkPaint& paint() const = 0;
|
||||
};
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/utils/SkNoDrawCanvas.h"
|
||||
|
||||
class GrSlug;
|
||||
struct SkPackedGlyphID;
|
||||
class SkAutoDescriptor;
|
||||
class SkStrikeCache;
|
||||
@ -138,6 +139,10 @@ public:
|
||||
// corresponding typefaceID on the GPU.
|
||||
SK_SPI bool translateTypefaceID(SkAutoDescriptor* descriptor) const;
|
||||
|
||||
// Given a buffer, unflatten into a slug making sure to do the typefaceID translation from
|
||||
// renderer to GPU. Returns nullptr if there was a problem.
|
||||
sk_sp<GrSlug> makeSlugFromBuffer(SkReadBuffer& buffer) const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<SkStrikeClientImpl> fImpl;
|
||||
};
|
||||
|
@ -1185,3 +1185,6 @@ bool SkStrikeClient::translateTypefaceID(SkAutoDescriptor* descriptor) const {
|
||||
return fImpl->translateTypefaceID(descriptor);
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrSlug> SkStrikeClient::makeSlugFromBuffer(SkReadBuffer& buffer) const { return nullptr; }
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
@ -2592,6 +2592,7 @@ public:
|
||||
const SkMatrixProvider& viewMatrix,
|
||||
skgpu::v1::SurfaceDrawContext* sdc);
|
||||
|
||||
void flatten(SkWriteBuffer& buffer) const override;
|
||||
SkRect sourceBounds() const override { return fSourceBounds; }
|
||||
const SkPaint& paint() const override { return fPaint; }
|
||||
|
||||
@ -3121,6 +3122,8 @@ void Slug::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
|
||||
|
||||
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
|
||||
}
|
||||
|
||||
void Slug::flatten(SkWriteBuffer& buffer) const { SK_ABORT("Not implemented."); }
|
||||
} // namespace
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
Loading…
Reference in New Issue
Block a user