Flutter Engine
The Flutter Engine
SkTransformShader.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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#ifndef SkTextCoordShader_DEFINED
8#define SkTextCoordShader_DEFINED
9
13
14class SkMatrix;
15struct SkStageRec;
16
17// SkTransformShader applies a matrix transform to the shader coordinates, like a local matrix
18// shader. The difference with a typical local matrix shader is that this shader's matrix is
19// not combined with the inverse CTM or other local matrices in order to facilitate modifying the
20// matrix between uses of the SkVM or SkRasterPipeline. This supports drawVertices and drawAtlas, in
21// which the mapping from each triangle (when explicit texture coords are used) or atlas quad to
22// shader space is different.
24public:
25 explicit SkTransformShader(const SkShaderBase& shader, bool allowPerspective);
26
27 // Adds a pipestage to multiply the incoming coords in 'r' and 'g' by the matrix. The child
28 // shader is called with no pending local matrix and the total transform as unknowable.
29 bool appendStages(const SkStageRec& rec, const SkShaders::MatrixRec&) const override;
30
31 // Change the matrix used by the generated SkRasterPipeline.
32 bool update(const SkMatrix& matrix);
33
34 ShaderType type() const override { return ShaderType::kTransform; }
35
36 // These are never serialized/deserialized
37 Factory getFactory() const override {
38 SkDEBUGFAIL("SkTransformShader shouldn't be serialized.");
39 return {};
40 }
41 const char* getTypeName() const override {
42 SkDEBUGFAIL("SkTransformShader shouldn't be serialized.");
43 return nullptr;
44 }
45
46 bool isOpaque() const override { return fShader.isOpaque(); }
47
48private:
49 const SkShaderBase& fShader;
50 SkScalar fMatrixStorage[9]; // actual memory used by generated RP or VM
51 bool fAllowPerspective;
52};
53#endif //SkTextCoordShader_DEFINED
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
sk_sp< SkFlattenable >(* Factory)(SkReadBuffer &)
Definition: SkFlattenable.h:41
virtual bool isOpaque() const
Definition: SkShader.h:44
bool update(const SkMatrix &matrix)
SkTransformShader(const SkShaderBase &shader, bool allowPerspective)
ShaderType type() const override
bool isOpaque() const override
bool appendStages(const SkStageRec &rec, const SkShaders::MatrixRec &) const override
Factory getFactory() const override
const char * getTypeName() const override
float SkScalar
Definition: extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258