Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPictureShader.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 Google Inc.
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 SkPictureShader_DEFINED
9#define SkPictureShader_DEFINED
10
15#include "include/core/SkRect.h"
17#include "include/core/SkSize.h"
21
22class SkArenaAlloc;
23class SkColorSpace;
24class SkImage;
25class SkReadBuffer;
26class SkShader;
27class SkSurface;
28class SkWriteBuffer;
29enum SkColorType : int;
30enum class SkFilterMode;
31enum class SkTileMode;
32struct SkStageRec;
33
34/*
35 * An SkPictureShader can be used to draw SkPicture-based patterns.
36 *
37 * The SkPicture is first rendered into a tile, which is then used to shade the area according
38 * to specified tiling rules.
39 */
41public:
43 const SkMatrix*, const SkRect*);
44
46
47 ShaderType type() const override { return ShaderType::kPicture; }
48
49 sk_sp<SkPicture> picture() const { return fPicture; }
50 SkRect tile() const { return fTile; }
51 SkTileMode tileModeX() const { return fTmx; }
52 SkTileMode tileModeY() const { return fTmy; }
53 SkFilterMode filter() const { return fFilter; }
54
56 bool success;
57 SkSize tileScale; // Additional scale factors to apply when sampling image.
58 SkMatrix matrixForDraw; // Matrix used to produce an image from the picture
61
62 static CachedImageInfo Make(const SkRect& bounds,
63 const SkMatrix& totalM,
64 SkColorType dstColorType,
65 SkColorSpace* dstColorSpace,
66 const int maxTextureSize,
67 const SkSurfaceProps& propsIn);
68
69 sk_sp<SkImage> makeImage(sk_sp<SkSurface> surf, const SkPicture* pict) const;
70 };
71
72protected:
74 void flatten(SkWriteBuffer&) const override;
75 bool appendStages(const SkStageRec&, const SkShaders::MatrixRec&) const override;
76#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
77 Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
78#endif
79
80private:
82
83 sk_sp<SkShader> rasterShader(const SkMatrix&,
84 SkColorType dstColorType,
85 SkColorSpace* dstColorSpace,
86 const SkSurfaceProps& props) const;
87
88 sk_sp<SkPicture> fPicture;
89 SkRect fTile;
90 SkTileMode fTmx, fTmy;
91 SkFilterMode fFilter;
92};
93
94#endif // SkPictureShader_DEFINED
SkColorType
Definition SkColorType.h:19
#define SK_FLATTENABLE_HOOKS(type)
SkFilterMode
SkTileMode
Definition SkTileMode.h:13
Type::kYUV Type::kRGBA() int(0.7 *637)
SkRect tile() const
SkTileMode tileModeY() const
SkTileMode tileModeX() const
bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const override
static sk_sp< SkShader > Make(sk_sp< SkPicture >, SkTileMode, SkTileMode, SkFilterMode, const SkMatrix *, const SkRect *)
SkFilterMode filter() const
SkPictureShader(SkReadBuffer &)
sk_sp< SkPicture > picture() const
ShaderType type() const override
void flatten(SkWriteBuffer &) const override
static CachedImageInfo Make(const SkRect &bounds, const SkMatrix &totalM, SkColorType dstColorType, SkColorSpace *dstColorSpace, const int maxTextureSize, const SkSurfaceProps &propsIn)
sk_sp< SkImage > makeImage(sk_sp< SkSurface > surf, const SkPicture *pict) const