Debian Codegraph @

src/shaders/SkShader.cpp

raw
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 */
7 #include "include/core/SkShader.h"
8
9 #include "include/core/SkColorFilter.h"
10 #include "include/core/SkMatrix.h"
11 #include "include/core/SkRefCnt.h"
12 #include "src/shaders/SkColorFilterShader.h"
13 #include "src/shaders/SkLocalMatrixShader.h"
14 #include "src/shaders/SkShaderBase.h"
15 #include "src/shaders/SkWorkingColorSpaceShader.h"
16
17 #include <utility>
18
19 class SkImage;
20 enum class SkTileMode;
21
22 SkImage* SkShader::isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const {
23 return as_SB(this)->onIsAImage(localMatrix, xy);
24 }
25
26 sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const {
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
43 sk_sp<SkShader> SkShader::makeWithColorFilter(sk_sp<SkColorFilter> filter) const {
44 return SkColorFilterShader::Make(sk_ref_sp(this), 1.0f, std::move(filter));
45 }
46
47 sk_sp<SkShader> SkShader::makeWithWorkingColorSpace(sk_sp<SkColorSpace> inputCS,
48 sk_sp<SkColorSpace> outputCS) const {
49 return SkWorkingColorSpaceShader::Make(
50 sk_ref_sp(this), std::move(inputCS), std::move(outputCS), /*workInUnpremul=*/false);
51 }