/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkShaderBase_DEFINED #define SkShaderBase_DEFINED #include "include/core/SkColor.h" #include "include/core/SkFlattenable.h" #include "include/core/SkMatrix.h" #include "include/core/SkPoint.h" #include "include/core/SkRefCnt.h" #include "include/core/SkScalar.h" #include "include/core/SkShader.h" #include "include/core/SkSurfaceProps.h" #include "include/core/SkTypes.h" #include "include/private/base/SkNoncopyable.h" #include <cstddef> #include <cstdint> #include <optional> #include <tuple> class SkArenaAlloc; class SkColorSpace; class SkImage; class SkRuntimeEffect; class SkWriteBuffer; enum SkColorType : int; enum class SkTileMode; struct SkDeserialProcs; struct SkStageRec; namespace SkShaders { /** * This is used to accumulate matrices, starting with the CTM, when building up * SkRasterPipeline or GrFragmentProcessor by walking the SkShader tree. It avoids * adding a matrix multiply for each individual matrix. It also handles the reverse matrix * concatenation order required by Android Framework, see b/256873449. * * This also tracks the dubious concept of a "total matrix", in the legacy Context/shadeSpan system. * That includes all the matrices encountered during traversal to the current shader, including ones * that have already been applied. The total matrix represents the transformation from the current * shader's coordinate space to device space. It is dubious because it doesn't account for SkShaders * that manipulate the coordinates passed to their children, which may not even be representable by * a matrix. * * The total matrix is used for mipmap level selection and a filter downgrade optimizations in * SkImageShader and sizing of the SkImage created by SkPictureShader. If we can remove usages * of the "total matrix" and if Android Framework could be updated to not use backwards local * matrix concatenation this could just be replaced by a simple SkMatrix or SkM44 passed down * during traversal. */ class MatrixRec { … }; } // namespace SkShaders #define SK_ALL_SHADERS(M) … #define SK_ALL_GRADIENTS(M) … class SkShaderBase : public SkShader { … }; inline SkShaderBase* as_SB(SkShader* shader) { … } inline const SkShaderBase* as_SB(const SkShader* shader) { … } inline const SkShaderBase* as_SB(const sk_sp<SkShader>& shader) { … } void SkRegisterBlendShaderFlattenable(); void SkRegisterColor4ShaderFlattenable(); void SkRegisterColorShaderFlattenable(); void SkRegisterCoordClampShaderFlattenable(); void SkRegisterEmptyShaderFlattenable(); void SkRegisterPerlinNoiseShaderFlattenable(); void SkRegisterWorkingColorSpaceShaderFlattenable(); #endif // SkShaderBase_DEFINED