Flutter Engine
The Flutter Engine
RasterPathAtlas.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
8#ifndef skgpu_graphite_RasterPathAtlas_DEFINED
9#define skgpu_graphite_RasterPathAtlas_DEFINED
10
12
13namespace skgpu::graphite {
14
15/**
16 * PathAtlas class that rasterizes coverage masks on the CPU.
17 *
18 * When a new shape gets added, its path is rasterized in preparation for upload. These
19 * uploads are recorded by `recordUploads()` and subsequently added to an UploadTask.
20 *
21 * Shapes are cached for future frames to avoid the cost of raster pipeline rendering. Multiple
22 * textures (or Pages) are used to cache masks, so if the atlas is full we can reset a Page and
23 * start adding new shapes for a future atlas render.
24 */
25class RasterPathAtlas : public PathAtlas {
26public:
27 explicit RasterPathAtlas(Recorder* recorder);
28 ~RasterPathAtlas() override {}
30
31 void postFlush() {
32 fCachedAtlasMgr.postFlush(fRecorder);
33 fSmallPathAtlasMgr.postFlush(fRecorder);
34 fUncachedAtlasMgr.postFlush(fRecorder);
35 }
36
37protected:
38 const TextureProxy* onAddShape(const Shape&,
39 const Transform& transform,
40 const SkStrokeRec&,
41 skvx::half2 maskSize,
42 skvx::half2* outPos) override;
43private:
44 class RasterAtlasMgr : public PathAtlas::DrawAtlasMgr {
45 public:
46 RasterAtlasMgr(size_t width, size_t height,
47 size_t plotWidth, size_t plotHeight,
48 const Caps* caps)
49 : PathAtlas::DrawAtlasMgr(width, height, plotWidth, plotHeight,
50 DrawAtlas::UseStorageTextures::kNo,
51 /*label=*/"RasterPathAtlas", caps) {}
52
53 protected:
54 bool onAddToAtlas(const Shape&,
55 const Transform& transform,
56 const SkStrokeRec&,
57 SkIRect shapeBounds,
58 const AtlasLocator&) override;
59 };
60
61 RasterAtlasMgr fCachedAtlasMgr;
62 RasterAtlasMgr fSmallPathAtlasMgr;
63 RasterAtlasMgr fUncachedAtlasMgr;
64};
65
66} // namespace skgpu::graphite
67
68#endif // skgpu_graphite_RasterPathAtlas_DEFINED
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
Shape
Definition: aaxfermodes.cpp:43
uint32_t height() const
Definition: PathAtlas.h:109
uint32_t width() const
Definition: PathAtlas.h:108
const TextureProxy * onAddShape(const Shape &, const Transform &transform, const SkStrokeRec &, skvx::half2 maskSize, skvx::half2 *outPos) override
skgpu::graphite::Transform Transform
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
Definition: SkRect.h:32
Definition: SkVx.h:83