| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
| 9 #include "SkBitmapProvider.h" | 9 #include "SkBitmapProvider.h" |
| 10 #include "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 #if SK_SUPPORT_GPU | 77 #if SK_SUPPORT_GPU |
| 78 | 78 |
| 79 #include "GrTextureAccess.h" | 79 #include "GrTextureAccess.h" |
| 80 #include "SkGr.h" | 80 #include "SkGr.h" |
| 81 #include "SkGrPriv.h" | 81 #include "SkGrPriv.h" |
| 82 #include "effects/GrSimpleTextureEffect.h" | 82 #include "effects/GrSimpleTextureEffect.h" |
| 83 #include "effects/GrBicubicEffect.h" | 83 #include "effects/GrBicubicEffect.h" |
| 84 #include "effects/GrSimpleTextureEffect.h" | 84 #include "effects/GrSimpleTextureEffect.h" |
| 85 | 85 |
| 86 const GrFragmentProcessor* SkImageShader::asFragmentProcessor(GrContext* context
, | 86 const GrFragmentProcessor* SkImageShader::asFragmentProcessor( |
| 87 const SkMatrix& vi
ewM, | 87 GrContext* context, |
| 88 const SkMatrix* lo
calMatrix, | 88 const SkMatrix& viewM, |
| 89 SkFilterQuality fi
lterQuality) const { | 89 const SkMatrix* localMatrix
, |
| 90 SkFilterQuality filterQuali
ty, |
| 91 SkSourceGammaTreatment gamm
aTreatment) const { |
| 90 SkMatrix matrix; | 92 SkMatrix matrix; |
| 91 matrix.setIDiv(fImage->width(), fImage->height()); | 93 matrix.setIDiv(fImage->width(), fImage->height()); |
| 92 | 94 |
| 93 SkMatrix lmInverse; | 95 SkMatrix lmInverse; |
| 94 if (!this->getLocalMatrix().invert(&lmInverse)) { | 96 if (!this->getLocalMatrix().invert(&lmInverse)) { |
| 95 return nullptr; | 97 return nullptr; |
| 96 } | 98 } |
| 97 if (localMatrix) { | 99 if (localMatrix) { |
| 98 SkMatrix inv; | 100 SkMatrix inv; |
| 99 if (!localMatrix->invert(&inv)) { | 101 if (!localMatrix->invert(&inv)) { |
| 100 return nullptr; | 102 return nullptr; |
| 101 } | 103 } |
| 102 lmInverse.postConcat(inv); | 104 lmInverse.postConcat(inv); |
| 103 } | 105 } |
| 104 matrix.preConcat(lmInverse); | 106 matrix.preConcat(lmInverse); |
| 105 | 107 |
| 106 SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; | 108 SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; |
| 107 | 109 |
| 108 // Must set wrap and filter on the sampler before requesting a texture. In t
wo places below | 110 // Must set wrap and filter on the sampler before requesting a texture. In t
wo places below |
| 109 // we check the matrix scale factors to determine how to interpret the filte
r quality setting. | 111 // we check the matrix scale factors to determine how to interpret the filte
r quality setting. |
| 110 // This completely ignores the complexity of the drawVertices case where exp
licit local coords | 112 // This completely ignores the complexity of the drawVertices case where exp
licit local coords |
| 111 // are provided by the caller. | 113 // are provided by the caller. |
| 112 bool doBicubic; | 114 bool doBicubic; |
| 113 GrTextureParams::FilterMode textureFilterMode = | 115 GrTextureParams::FilterMode textureFilterMode = |
| 114 GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix()
, &doBicubic); | 116 GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix()
, &doBicubic); |
| 115 GrTextureParams params(tm, textureFilterMode); | 117 GrTextureParams params(tm, textureFilterMode); |
| 116 SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params)
); | 118 SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params,
gammaTreatment)); |
| 117 if (!texture) { | 119 if (!texture) { |
| 118 return nullptr; | 120 return nullptr; |
| 119 } | 121 } |
| 120 | 122 |
| 121 SkAutoTUnref<const GrFragmentProcessor> inner; | 123 SkAutoTUnref<const GrFragmentProcessor> inner; |
| 122 if (doBicubic) { | 124 if (doBicubic) { |
| 123 inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); | 125 inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); |
| 124 } else { | 126 } else { |
| 125 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 127 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |
| 126 } | 128 } |
| 127 | 129 |
| 128 if (GrPixelConfigIsAlphaOnly(texture->config())) { | 130 if (GrPixelConfigIsAlphaOnly(texture->config())) { |
| 129 return SkRef(inner.get()); | 131 return SkRef(inner.get()); |
| 130 } | 132 } |
| 131 return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 133 return GrFragmentProcessor::MulOutputByInputAlpha(inner); |
| 132 } | 134 } |
| 133 | 135 |
| 134 #endif | 136 #endif |
| OLD | NEW |