Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkImageShader.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 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 SkImageShader_DEFINED
9#define SkImageShader_DEFINED
10
13#include "include/core/SkM44.h"
14#include "include/core/SkRect.h"
19
20class SkArenaAlloc;
21class SkMatrix;
22class SkReadBuffer;
23class SkShader;
24class SkWriteBuffer;
25enum class SkTileMode;
26struct SkStageRec;
27
29public:
33 const SkSamplingOptions&,
34 const SkMatrix* localMatrix,
35 bool clampAsIfUnpremul = false);
36
40 const SkSamplingOptions&,
41 const SkMatrix* localMatrix);
42
43 // TODO(skbug.com/12784): Requires SkImage to be texture backed, and created SkShader can only
44 // be used on GPU-backed surfaces.
46 const SkRect& subset,
49 const SkSamplingOptions&,
50 const SkMatrix* localMatrix,
51 bool clampAsIfUnpremul = false);
52
54 const SkRect& subset,
56 const SkSamplingOptions&,
57 bool raw,
58 bool clampAsIfUnpremul);
59
60 bool isOpaque() const override;
61
62 ShaderType type() const override { return ShaderType::kImage; }
63
64 static SkM44 CubicResamplerMatrix(float B, float C);
65
66 SkTileMode tileModeX() const { return fTileModeX; }
67 SkTileMode tileModeY() const { return fTileModeY; }
68 sk_sp<SkImage> image() const { return fImage; }
69 SkSamplingOptions sampling() const { return fSampling; }
70 SkRect subset() const { return fSubset; }
71 bool isRaw() const { return fRaw; }
72
73private:
75
76 void flatten(SkWriteBuffer&) const override;
77#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
78 Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override;
79#endif
80 SkImage* onIsAImage(SkMatrix*, SkTileMode*) const override;
81
82 bool appendStages(const SkStageRec&, const SkShaders::MatrixRec&) const override;
83
84 sk_sp<SkImage> fImage;
85 const SkSamplingOptions fSampling;
86 const SkTileMode fTileModeX;
87 const SkTileMode fTileModeY;
88
89 // TODO(skbug.com/12784): This is only supported for GPU images currently.
90 // If subset == (0,0,w,h) of the image, then no subset is applied. Subset will not be empty.
91 const SkRect fSubset;
92
93 const bool fRaw;
94 const bool fClampAsIfUnpremul;
95
96 friend class SkShaderBase;
97 using INHERITED = SkShaderBase;
98};
99
100#endif
#define SK_FLATTENABLE_HOOKS(type)
SkTileMode
Definition SkTileMode.h:13
SkSamplingOptions sampling() const
bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const override
static sk_sp< SkShader > Make(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
static SkM44 CubicResamplerMatrix(float B, float C)
ShaderType type() const override
bool isOpaque() const override
static sk_sp< SkShader > MakeSubset(sk_sp< SkImage >, const SkRect &subset, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
SkTileMode tileModeX() const
sk_sp< SkImage > image() const
static sk_sp< SkShader > MakeRaw(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix)
SkImage * onIsAImage(SkMatrix *, SkTileMode *) const override
bool isRaw() const
SkTileMode tileModeY() const
void flatten(SkWriteBuffer &) const override
SkRect subset() const
friend class SkShaderBase
Definition SkM44.h:150
SkTileMode tmy
SkTileMode tmx