Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SubRunData.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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
8#ifndef skgpu_graphite_geom_SubRunData_DEFINED
9#define skgpu_graphite_geom_SubRunData_DEFINED
10
11#include "include/core/SkM44.h"
14
15namespace sktext::gpu { class AtlasSubRun; }
16
17namespace skgpu::graphite {
18
19class Recorder;
20
21/**
22 * SubRunData represents an AtlasSubRun subspan for which per-pixel coverage data comes from a
23 * persistent glyph atlas texture.
24 *
25 * The bounds() represent the bounds of the entire AtlasSubRun and does not directly map to the
26 * local coordinates of this particular subspan. Rather, the dimensions and offset coordinates of a
27 * subspan are defined in a coordinate space that is partially transformed by a decomposition of
28 * the local-to-device matrix computed by the AtlasSubRun per instance. The transform of the draw is
29 * the rest of the decomposed transform (often only a translation) that maps this intermediate space
30 * to the device-space coordinates of the draw.
31 *
32 * The local coordinates used in shading are derived by transforming the final device coordinates
33 * using the inverse of the local-to-device matrix.
34 */
36public:
37 SubRunData() = delete;
38 SubRunData(const SubRunData& subRun) = default;
40
42 sk_sp<SkRefCnt> supportDataKeepAlive,
43 Rect deviceBounds,
44 const SkM44& deviceToLocal,
46 int glyphCount,
49 : fSubRun(subRun)
50 , fSupportDataKeepAlive(std::move(supportDataKeepAlive))
51 , fBounds(deviceBounds)
52 , fDeviceToLocal(deviceToLocal)
53 , fStartGlyphIndex(startGlyphIndex)
54 , fGlyphCount(glyphCount)
55 , fRecorder(recorder)
56 , fRendererData(rendererData) {}
57
58 ~SubRunData() = default;
59
60 // NOTE: None of the geometry types benefit from move semantics, so we don't bother
61 // defining a move assignment operator for SubRunData.
63 SubRunData& operator=(const SubRunData& that) = default;
64
65 // The bounding box of the originating AtlasSubRun.
66 Rect bounds() const { return fBounds; }
67
68 // The inverse local-to-device matrix.
69 const SkM44& deviceToLocal() const { return fDeviceToLocal; }
70
71 // Access the individual elements of the subrun data.
72 const sktext::gpu::AtlasSubRun* subRun() const { return fSubRun; }
73 int startGlyphIndex() const { return fStartGlyphIndex; }
74 int glyphCount() const { return fGlyphCount; }
75 Recorder* recorder() const { return fRecorder; }
76 const sktext::gpu::RendererData& rendererData() const { return fRendererData; }
77
78private:
79 const sktext::gpu::AtlasSubRun* fSubRun;
80 // Keep the TextBlob or Slug alive until we're done with the Geometry.
81 sk_sp<SkRefCnt> fSupportDataKeepAlive;
82
83 Rect fBounds; // bounds of the data stored in the SubRun
84 SkM44 fDeviceToLocal;
85 int fStartGlyphIndex;
86 int fGlyphCount;
87 Recorder* fRecorder; // this SubRun can only be associated with this Recorder's atlas
88 sktext::gpu::RendererData fRendererData;
89};
90
91} // namespace skgpu::graphite
92
93#endif // skgpu_graphite_geom_SubRunData_DEFINED
Definition SkM44.h:150
SubRunData(const sktext::gpu::AtlasSubRun *subRun, sk_sp< SkRefCnt > supportDataKeepAlive, Rect deviceBounds, const SkM44 &deviceToLocal, int startGlyphIndex, int glyphCount, Recorder *recorder, sktext::gpu::RendererData rendererData)
Definition SubRunData.h:41
const sktext::gpu::AtlasSubRun * subRun() const
Definition SubRunData.h:72
SubRunData & operator=(SubRunData &&)=delete
const SkM44 & deviceToLocal() const
Definition SubRunData.h:69
SubRunData & operator=(const SubRunData &that)=default
SubRunData(const SubRunData &subRun)=default
Recorder * recorder() const
Definition SubRunData.h:75
SubRunData(SubRunData &&)=delete
const sktext::gpu::RendererData & rendererData() const
Definition SubRunData.h:76
Definition ref_ptr.h:256