Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkShader.cpp
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 */
8
15
16#include <utility>
17
18class SkColorFilter;
19class SkImage;
20enum class SkTileMode;
21
22SkImage* SkShader::isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const {
23 return as_SB(this)->onIsAImage(localMatrix, xy);
24}
25
27 const SkMatrix* lm = &localMatrix;
28
29 sk_sp<SkShader> baseShader;
30 SkMatrix otherLocalMatrix;
31 sk_sp<SkShader> proxy = as_SB(this)->makeAsALocalMatrixShader(&otherLocalMatrix);
32 if (proxy) {
33 otherLocalMatrix = SkShaderBase::ConcatLocalMatrices(localMatrix, otherLocalMatrix);
34 lm = &otherLocalMatrix;
35 baseShader = proxy;
36 } else {
37 baseShader = sk_ref_sp(const_cast<SkShader*>(this));
38 }
39
40 return sk_make_sp<SkLocalMatrixShader>(std::move(baseShader), *lm);
41}
42
44 SkShader* base = const_cast<SkShader*>(this);
45 if (!filter) {
46 return sk_ref_sp(base);
47 }
48 return sk_make_sp<SkColorFilterShader>(sk_ref_sp(base), 1.0f, std::move(filter));
49}
50
52 SkShader* base = const_cast<SkShader*>(this);
53 if (!workingSpace) {
54 return sk_ref_sp(base);
55 }
56 return sk_make_sp<SkWorkingColorSpaceShader>(sk_ref_sp(base), std::move(workingSpace));
57}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
SkShaderBase * as_SB(SkShader *shader)
SkTileMode
Definition SkTileMode.h:13
static SkMatrix ConcatLocalMatrices(const SkMatrix &parentLM, const SkMatrix &childLM)
virtual SkImage * onIsAImage(SkMatrix *, SkTileMode[2]) const
virtual sk_sp< SkShader > makeAsALocalMatrixShader(SkMatrix *localMatrix) const
bool isAImage() const
Definition SkShader.h:52
sk_sp< SkShader > makeWithWorkingColorSpace(sk_sp< SkColorSpace >) const
Definition SkShader.cpp:51
sk_sp< SkShader > makeWithColorFilter(sk_sp< SkColorFilter >) const
Definition SkShader.cpp:43
sk_sp< SkShader > makeWithLocalMatrix(const SkMatrix &) const
Definition SkShader.cpp:26