Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SlugImpl.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef sktext_SlugImpl_DEFINED
8#define sktext_SlugImpl_DEFINED
9
11#include "include/core/SkRect.h"
17
18#include <cstddef>
19
20class SkMatrix;
21class SkPaint;
22class SkReadBuffer;
23class SkStrikeClient;
24class SkWriteBuffer;
26
27namespace sktext {
28class GlyphRunList;
29class StrikeForGPUCacheInterface;
30}
31
32namespace sktext::gpu {
33
34class SlugImpl final : public Slug {
35public:
40 ~SlugImpl() override = default;
41
42 static sk_sp<SlugImpl> Make(const SkMatrix& viewMatrix,
43 const sktext::GlyphRunList& glyphRunList,
44 const SkPaint& paint,
45 SkStrikeDeviceInfo strikeDeviceInfo,
48 const SkStrikeClient* client);
49 void doFlatten(SkWriteBuffer& buffer) const override;
50
51 SkRect sourceBounds() const override { return fSourceBounds; }
52 SkRect sourceBoundsWithOrigin() const override { return fSourceBounds.makeOffset(fOrigin); }
53
54 const SkMatrix& initialPositionMatrix() const { return fSubRuns->initialPosition(); }
55 SkPoint origin() const { return fOrigin; }
56
57 const gpu::SubRunContainerOwner& subRuns() const { return fSubRuns; }
58
59 // Change memory management to handle the data after Slug, but in the same allocation
60 // of memory. Only allow placement new.
61 void operator delete(void* p) { ::operator delete(p); }
62 void* operator new(size_t) { SK_ABORT("All slugs are created by placement new."); }
63 void* operator new(size_t, void* p) { return p; }
64
65private:
66 // The allocator must come first because it needs to be destroyed last. Other fields of this
67 // structure may have pointers into it.
68 SubRunAllocator fAlloc;
70 const SkRect fSourceBounds;
71 const SkPoint fOrigin;
72};
73
74} // namespace sktext::gpu
75
76#endif
#define SK_ABORT(message,...)
Definition SkAssert.h:70
const gpu::SubRunContainerOwner & subRuns() const
Definition SlugImpl.h:57
~SlugImpl() override=default
void doFlatten(SkWriteBuffer &buffer) const override
Definition SlugImpl.cpp:39
SkRect sourceBoundsWithOrigin() const override
Definition SlugImpl.h:52
SkRect sourceBounds() const override
Definition SlugImpl.h:51
const SkMatrix & initialPositionMatrix() const
Definition SlugImpl.h:54
SkPoint origin() const
Definition SlugImpl.h:55
static sk_sp< SlugImpl > Make(const SkMatrix &viewMatrix, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, SkStrikeDeviceInfo strikeDeviceInfo, sktext::StrikeForGPUCacheInterface *strikeCache)
Definition SlugImpl.cpp:74
static sk_sp< Slug > MakeFromBuffer(SkReadBuffer &buffer, const SkStrikeClient *client)
Definition SlugImpl.cpp:46
const Paint & paint
static const uint8_t buffer[]
std::unique_ptr< SubRunContainer, SubRunAllocator::Destroyer > SubRunContainerOwner
constexpr SkRect makeOffset(float dx, float dy) const
Definition SkRect.h:965