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/SkColorSpace.h" 11 #include "include/core/SkMatrix.h" 12 #include "include/core/SkRefCnt.h" 13 #include "src/shaders/SkColorFilterShader.h" 14 #include "src/shaders/SkLocalMatrixShader.h" 15 #include "src/shaders/SkShaderBase.h" 16 #include "src/shaders/SkWorkingColorSpaceShader.h" 17 18 #include <utility> 19 20 class SkImage; 21 enum class SkTileMode; 22 isAImage(SkMatrix * localMatrix,SkTileMode xy[2]) const23SkImage* SkShader::isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const { 24 return as_SB(this)->onIsAImage(localMatrix, xy); 25 } 26 makeWithLocalMatrix(const SkMatrix & localMatrix) const27sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const { 28 const SkMatrix* lm = &localMatrix; 29 30 sk_sp<SkShader> baseShader; 31 SkMatrix otherLocalMatrix; 32 sk_sp<SkShader> proxy = as_SB(this)->makeAsALocalMatrixShader(&otherLocalMatrix); 33 if (proxy) { 34 otherLocalMatrix = SkShaderBase::ConcatLocalMatrices(localMatrix, otherLocalMatrix); 35 lm = &otherLocalMatrix; 36 baseShader = proxy; 37 } else { 38 baseShader = sk_ref_sp(const_cast<SkShader*>(this)); 39 } 40 41 return sk_make_sp<SkLocalMatrixShader>(std::move(baseShader), *lm); 42 } 43 makeWithColorFilter(sk_sp<SkColorFilter> filter) const44sk_sp<SkShader> SkShader::makeWithColorFilter(sk_sp<SkColorFilter> filter) const { 45 return SkColorFilterShader::Make(sk_ref_sp(this), 1.0f, std::move(filter)); 46 } 47 makeWithWorkingColorSpace(sk_sp<SkColorSpace> workingSpace) const48sk_sp<SkShader> SkShader::makeWithWorkingColorSpace(sk_sp<SkColorSpace> workingSpace) const { 49 return SkWorkingColorSpaceShader::Make(sk_ref_sp(this), std::move(workingSpace)); 50 } 51