Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
gpu
graphite
ComputePathAtlas.h
Go to the documentation of this file.
1
/*
2
* Copyright 2024 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_ComputePathAtlas_DEFINED
9
#define skgpu_graphite_ComputePathAtlas_DEFINED
10
11
#include "
src/gpu/graphite/PathAtlas.h
"
12
13
#include "
src/gpu/RectanizerSkyline.h
"
14
15
#ifdef SK_ENABLE_VELLO_SHADERS
16
#include "
src/gpu/graphite/compute/VelloRenderer.h
"
17
#endif
18
19
#include <memory>
20
21
namespace
skgpu::graphite
{
22
23
class
DispatchGroup;
24
25
/**
26
* Base class for PathAtlas implementations that rasterize coverage masks on the GPU using compute
27
* shaders.
28
*
29
* When a new shape gets added, it gets tracked as input to a series of GPU compute passes. This
30
* data is recorded by `recordDispatches()` into a DispatchGroup which can be added to a
31
* ComputeTask.
32
*
33
* After a successful call to `recordDispatches()`, the client is free to call `reset()` and start
34
* adding new shapes for a future atlas render.
35
*/
36
class
ComputePathAtlas
:
public
PathAtlas
{
37
public
:
38
// Returns the currently preferred ComputePathAtlas implementation.
39
static
std::unique_ptr<ComputePathAtlas>
CreateDefault
(
Recorder
*);
40
41
virtual
std::unique_ptr<DispatchGroup>
recordDispatches
(
Recorder
*)
const
= 0;
42
43
// Clear all scheduled atlas draws and free up atlas allocations, if necessary. After this call
44
// the atlas can be considered cleared and available for new shape insertions. However this
45
// method does not have any bearing on the contents of any atlas textures themselves, which may
46
// be in use by GPU commands that are in-flight or yet to be submitted.
47
void
reset
();
48
49
protected
:
50
explicit
ComputePathAtlas
(
Recorder
*);
51
52
const
TextureProxy
*
texture
()
const
{
return
fTexture.get(); }
53
const
TextureProxy
*
addRect
(
skvx::half2
maskSize,
54
SkIPoint16
* outPos);
55
bool
isSuitableForAtlasing
(
const
Rect
& transformedShapeBounds)
const override
;
56
57
virtual
void
onReset
() = 0;
58
59
private
:
60
bool
initializeTextureIfNeeded();
61
62
skgpu::RectanizerSkyline
fRectanizer;
63
64
// ComputePathAtlas lazily requests a texture from the AtlasProvider when the first shape gets
65
// added to it and references the same texture for the duration of its lifetime. A reference to
66
// this texture is stored here, which is used by AtlasShapeRenderStep when encoding the render
67
// pass.
68
sk_sp<TextureProxy>
fTexture;
69
};
70
71
}
// namespace skgpu::graphite
72
73
#endif
// skgpu_graphite_ComputePathAtlas_DEFINED
PathAtlas.h
RectanizerSkyline.h
VelloRenderer.h
sk_sp
Definition
SkRefCnt.h:220
skgpu::RectanizerSkyline
Definition
RectanizerSkyline.h:24
skgpu::graphite::ComputePathAtlas
Definition
ComputePathAtlas.h:36
skgpu::graphite::ComputePathAtlas::isSuitableForAtlasing
bool isSuitableForAtlasing(const Rect &transformedShapeBounds) const override
Definition
ComputePathAtlas.cpp:49
skgpu::graphite::ComputePathAtlas::onReset
virtual void onReset()=0
skgpu::graphite::ComputePathAtlas::texture
const TextureProxy * texture() const
Definition
ComputePathAtlas.h:52
skgpu::graphite::ComputePathAtlas::CreateDefault
static std::unique_ptr< ComputePathAtlas > CreateDefault(Recorder *)
Definition
ComputePathAtlas.cpp:243
skgpu::graphite::ComputePathAtlas::reset
void reset()
Definition
ComputePathAtlas.cpp:95
skgpu::graphite::ComputePathAtlas::addRect
const TextureProxy * addRect(skvx::half2 maskSize, SkIPoint16 *outPos)
Definition
ComputePathAtlas.cpp:73
skgpu::graphite::ComputePathAtlas::recordDispatches
virtual std::unique_ptr< DispatchGroup > recordDispatches(Recorder *) const =0
skgpu::graphite::PathAtlas
Definition
PathAtlas.h:41
skgpu::graphite::Recorder
Definition
Recorder.h:74
skgpu::graphite::Rect
Definition
Rect.h:27
skgpu::graphite::TextureProxy
Definition
TextureProxy.h:27
skgpu::graphite
Definition
BoundsManagerBench.cpp:27
SkIPoint16
Definition
SkIPoint16.h:17
skvx::Vec
Definition
SkVx.h:83
Generated on Fri Apr 26 2024 06:17:16 for Flutter Engine by
1.9.8