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