Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
include
core
SkShader.h
Go to the documentation of this file.
1
/*
2
* Copyright 2006 The Android Open Source Project
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 SkShader_DEFINED
9
#define SkShader_DEFINED
10
11
#include "
include/core/SkColor.h
"
12
#include "
include/core/SkFlattenable.h
"
13
#include "
include/core/SkRefCnt.h
"
14
#include "
include/private/base/SkAPI.h
"
15
16
class
SkBlender
;
17
class
SkColorFilter
;
18
class
SkColorSpace
;
19
class
SkImage
;
20
class
SkMatrix
;
21
enum class
SkBlendMode
;
22
enum class
SkTileMode
;
23
struct
SkRect
;
24
struct
SkSamplingOptions
;
25
26
/** \class SkShader
27
*
28
* Shaders specify the source color(s) for what is being drawn. If a paint
29
* has no shader, then the paint's color is used. If the paint has a
30
* shader, then the shader's color(s) are use instead, but they are
31
* modulated by the paint's alpha. This makes it easy to create a shader
32
* once (e.g. bitmap tiling or gradient) and then change its transparency
33
* w/o having to modify the original shader... only the paint's alpha needs
34
* to be modified.
35
*/
36
class
SK_API
SkShader
:
public
SkFlattenable
{
37
public
:
38
/**
39
* Returns true if the shader is guaranteed to produce only opaque
40
* colors, subject to the SkPaint using the shader to apply an opaque
41
* alpha value. Subclasses should override this to allow some
42
* optimizations.
43
*/
44
virtual
bool
isOpaque
()
const
{
return
false
; }
45
46
/**
47
* Iff this shader is backed by a single SkImage, return its ptr (the caller must ref this
48
* if they want to keep it longer than the lifetime of the shader). If not, return nullptr.
49
*/
50
SkImage
* isAImage(
SkMatrix
* localMatrix,
SkTileMode
xy[2])
const
;
51
52
bool
isAImage
()
const
{
53
return
this->isAImage(
nullptr
, (
SkTileMode
*)
nullptr
) !=
nullptr
;
54
}
55
56
//////////////////////////////////////////////////////////////////////////
57
// Methods to create combinations or variants of shaders
58
59
/**
60
* Return a shader that will apply the specified localMatrix to this shader.
61
* The specified matrix will be applied before any matrix associated with this shader.
62
*/
63
sk_sp<SkShader>
makeWithLocalMatrix(
const
SkMatrix
&)
const
;
64
65
/**
66
* Create a new shader that produces the same colors as invoking this shader and then applying
67
* the colorfilter.
68
*/
69
sk_sp<SkShader>
makeWithColorFilter(
sk_sp<SkColorFilter>
)
const
;
70
71
/**
72
* Return a shader that will compute this shader in a specific color space.
73
* By default, all shaders operate in the destination (surface) color space.
74
* The results of a shader are still always converted to the destination - this
75
* API has no impact on simple shaders or images. Primarily, it impacts shaders
76
* that perform mathematical operations, like Blend shaders, or runtime shaders.
77
*/
78
sk_sp<SkShader>
makeWithWorkingColorSpace(
sk_sp<SkColorSpace>
)
const
;
79
80
private
:
81
SkShader
() =
default
;
82
friend
class
SkShaderBase
;
83
84
using
INHERITED
=
SkFlattenable
;
85
};
86
87
namespace
SkShaders
{
88
SK_API
sk_sp<SkShader>
Empty();
89
SK_API
sk_sp<SkShader>
Color(
SkColor
);
90
SK_API
sk_sp<SkShader>
Color(
const
SkColor4f
&,
sk_sp<SkColorSpace>
);
91
SK_API
sk_sp<SkShader>
Blend(
SkBlendMode
mode,
sk_sp<SkShader>
dst,
sk_sp<SkShader>
src);
92
SK_API
sk_sp<SkShader>
Blend(
sk_sp<SkBlender>
,
sk_sp<SkShader>
dst,
sk_sp<SkShader>
src);
93
SK_API
sk_sp<SkShader>
CoordClamp(
sk_sp<SkShader>
,
const
SkRect
& subset);
94
95
/*
96
* Create an SkShader that will sample the 'image'. This is equivalent to SkImage::makeShader.
97
*/
98
SK_API
sk_sp<SkShader>
Image(
sk_sp<SkImage>
image
,
99
SkTileMode
tmx
,
SkTileMode
tmy
,
100
const
SkSamplingOptions
&
options
,
101
const
SkMatrix
* localMatrix =
nullptr
);
102
/*
103
* Create an SkShader that will sample 'image' with minimal processing. This is equivalent to
104
* SkImage::makeRawShader.
105
*/
106
SK_API
sk_sp<SkShader>
RawImage(
sk_sp<SkImage>
image
,
107
SkTileMode
tmx
,
SkTileMode
tmy
,
108
const
SkSamplingOptions
&
options
,
109
const
SkMatrix
* localMatrix =
nullptr
);
110
}
111
112
#endif
options
const char * options
Definition
CommonFlagsConfig.cpp:43
SkAPI.h
SK_API
#define SK_API
Definition
SkAPI.h:35
SkBlendMode
SkBlendMode
Definition
SkBlendMode.h:38
SkColor.h
SkColor
uint32_t SkColor
Definition
SkColor.h:37
SkFlattenable.h
SkRefCnt.h
SkTileMode
SkTileMode
Definition
SkTileMode.h:13
SkBlender
Definition
SkBlender.h:19
SkColorFilter
Definition
SkColorFilter.h:35
SkColorSpace
Definition
SkColorSpace.h:107
SkFlattenable
Definition
SkFlattenable.h:28
SkFlattenable::SkFlattenable
SkFlattenable()
Definition
SkFlattenable.h:43
SkImage
Definition
SkImage.h:272
SkMatrix
Definition
SkMatrix.h:54
SkShaderBase
Definition
SkShaderBase.h:186
SkShader
Definition
SkShader.h:36
SkShader::isAImage
bool isAImage() const
Definition
SkShader.h:52
SkShader::isOpaque
virtual bool isOpaque() const
Definition
SkShader.h:44
sk_sp
Definition
SkRefCnt.h:220
image
sk_sp< SkImage > image
Definition
examples.cpp:29
SkShaders
Definition
SkShader.h:87
tmy
SkTileMode tmy
Definition
pictureshader.cpp:31
tmx
SkTileMode tmx
Definition
pictureshader.cpp:30
SkColor4f
SkRect
Definition
extension.cpp:13
SkSamplingOptions
Definition
SkSamplingOptions.h:58
Generated on Fri Apr 26 2024 06:16:11 for Flutter Engine by
1.9.8