Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
AnalyticBlurMask.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_geom_AnalyticBlurMask_DEFINED
9#define skgpu_graphite_geom_AnalyticBlurMask_DEFINED
10
11#include "include/core/SkM44.h"
14
15#include <optional>
16
17class SkMatrix;
18class SkRRect;
19
20namespace skgpu::graphite {
21
22class Recorder;
23class Transform;
24
25/**
26 * AnalyticBlurMask holds the shader inputs used to do an analytic blur over rects, rrects, or
27 * circles.
28 */
30public:
31 enum class ShapeType {
32 kRect,
33 kRRect,
34 kCircle,
35 };
36
37 static_assert(0 == static_cast<int>(ShapeType::kRect),
38 "Blur shader code depends on AnalyticBlurMask::ShapeType");
39 static_assert(1 == static_cast<int>(ShapeType::kRRect),
40 "Blur shader code depends on AnalyticBlurMask::ShapeType");
41 static_assert(2 == static_cast<int>(ShapeType::kCircle),
42 "Blur shader code depends on AnalyticBlurMask::ShapeType");
43
44 AnalyticBlurMask() = delete;
45
46 static std::optional<AnalyticBlurMask> Make(Recorder*,
47 const Transform& localToDevice,
48 float deviceSigma,
49 const SkRRect& srcRRect);
50
51 const Rect& drawBounds() const { return fDrawBounds; }
52 const SkM44& deviceToScaledShape() const { return fDevToScaledShape; }
53 const Rect& shapeData() const { return fShapeData; }
54 ShapeType shapeType() const { return fShapeType; }
55 bool isFast() const { return fIsFast; }
56 float invSixSigma() const { return fInvSixSigma; }
57 sk_sp<TextureProxy> refProxy() const { return fProxy; }
58
59private:
61 const SkM44& devToScaledShape,
62 const Rect& shapeData,
64 bool isFast,
65 float invSixSigma,
67 : fDrawBounds(drawBounds)
68 , fDevToScaledShape(devToScaledShape)
69 , fShapeData(shapeData)
70 , fShapeType(shapeType)
71 , fIsFast(isFast)
72 , fInvSixSigma(invSixSigma)
73 , fProxy(std::move(proxy)) {}
74
75 static std::optional<AnalyticBlurMask> MakeRect(Recorder*,
76 const SkMatrix& localToDevice,
77 float devSigma,
78 const SkRect& srcRect);
79
80 static std::optional<AnalyticBlurMask> MakeCircle(Recorder*,
81 const SkMatrix& localToDevice,
82 float devSigma,
83 const SkRect& srcRect,
84 const SkRect& devRect);
85
86 // Draw bounds in local space.
87 Rect fDrawBounds;
88
89 // Transforms device-space coordinates to the shape data's space.
90 SkM44 fDevToScaledShape;
91
92 // Shape data, which can define a rectangle, circle, or rounded rectangle.
93 // This data is in a local space defined by the concatenation of the local-to-device matrix and
94 // fDevToScaledShape.
95 Rect fShapeData;
96
97 ShapeType fShapeType;
98 bool fIsFast;
99 float fInvSixSigma;
100 sk_sp<TextureProxy> fProxy;
101};
102
103} // namespace skgpu::graphite
104
105#endif // skgpu_graphite_geom_AnalyticBlurMask_DEFINED
Definition SkM44.h:150
const SkM44 & deviceToScaledShape() const
sk_sp< TextureProxy > refProxy() const
static std::optional< AnalyticBlurMask > Make(Recorder *, const Transform &localToDevice, float deviceSigma, const SkRRect &srcRRect)
skgpu::graphite::Transform Transform
Definition ref_ptr.h:256