Flutter Engine
The Flutter Engine
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
SlugImpl(SubRunAllocator &&alloc, gpu::SubRunContainerOwner subRuns, SkRect sourceBounds, SkPoint origin)
Definition: SlugImpl.cpp:30
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
Definition: color_source.cc:38
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
std::unique_ptr< SubRunContainer, SubRunAllocator::Destroyer > SubRunContainerOwner
constexpr SkRect makeOffset(float dx, float dy) const
Definition: SkRect.h:965