| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   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(GrContext* context
     , | 
|   87                                                               const SkMatrix& vi
     ewM, |   87                                                               const SkMatrix& vi
     ewM, | 
|   88                                                               const SkMatrix* lo
     calMatrix, |   88                                                               const SkMatrix* lo
     calMatrix, | 
|   89                                                               SkFilterQuality fi
     lterQuality) const { |   89                                                               SkFilterQuality fi
     lterQuality, | 
 |   90                                                               bool gammaCorrect)
      const { | 
|   90     SkMatrix matrix; |   91     SkMatrix matrix; | 
|   91     matrix.setIDiv(fImage->width(), fImage->height()); |   92     matrix.setIDiv(fImage->width(), fImage->height()); | 
|   92  |   93  | 
|   93     SkMatrix lmInverse; |   94     SkMatrix lmInverse; | 
|   94     if (!this->getLocalMatrix().invert(&lmInverse)) { |   95     if (!this->getLocalMatrix().invert(&lmInverse)) { | 
|   95         return nullptr; |   96         return nullptr; | 
|   96     } |   97     } | 
|   97     if (localMatrix) { |   98     if (localMatrix) { | 
|   98         SkMatrix inv; |   99         SkMatrix inv; | 
|   99         if (!localMatrix->invert(&inv)) { |  100         if (!localMatrix->invert(&inv)) { | 
|  100             return nullptr; |  101             return nullptr; | 
|  101         } |  102         } | 
|  102         lmInverse.postConcat(inv); |  103         lmInverse.postConcat(inv); | 
|  103     } |  104     } | 
|  104     matrix.preConcat(lmInverse); |  105     matrix.preConcat(lmInverse); | 
|  105  |  106  | 
|  106     SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; |  107     SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; | 
|  107  |  108  | 
|  108     // Must set wrap and filter on the sampler before requesting a texture. In t
     wo places below |  109     // 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. |  110     // 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 |  111     // This completely ignores the complexity of the drawVertices case where exp
     licit local coords | 
|  111     // are provided by the caller. |  112     // are provided by the caller. | 
|  112     bool doBicubic; |  113     bool doBicubic; | 
|  113     GrTextureParams::FilterMode textureFilterMode = |  114     GrTextureParams::FilterMode textureFilterMode = | 
|  114     GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix()
     , &doBicubic); |  115     GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix()
     , &doBicubic); | 
|  115     GrTextureParams params(tm, textureFilterMode); |  116     GrTextureParams params(tm, textureFilterMode); | 
|  116     SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params)
     ); |  117     SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params,
      gammaCorrect)); | 
|  117     if (!texture) { |  118     if (!texture) { | 
|  118         return nullptr; |  119         return nullptr; | 
|  119     } |  120     } | 
|  120  |  121  | 
|  121     SkAutoTUnref<const GrFragmentProcessor> inner; |  122     SkAutoTUnref<const GrFragmentProcessor> inner; | 
|  122     if (doBicubic) { |  123     if (doBicubic) { | 
|  123         inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); |  124         inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); | 
|  124     } else { |  125     } else { | 
|  125         inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |  126         inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 
|  126     } |  127     } | 
|  127  |  128  | 
|  128     if (GrPixelConfigIsAlphaOnly(texture->config())) { |  129     if (GrPixelConfigIsAlphaOnly(texture->config())) { | 
|  129         return SkRef(inner.get()); |  130         return SkRef(inner.get()); | 
|  130     } |  131     } | 
|  131     return GrFragmentProcessor::MulOutputByInputAlpha(inner); |  132     return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 
|  132 } |  133 } | 
|  133  |  134  | 
|  134 #endif |  135 #endif | 
| OLD | NEW |