| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright 2011 Google Inc. |    2  * Copyright 2011 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 "SkBitmapProcState.h" |    9 #include "SkBitmapProcState.h" | 
|   10 #include "SkBitmapProvider.h" |   10 #include "SkBitmapProvider.h" | 
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  405 /////////////////////////////////////////////////////////////////////////////// |  405 /////////////////////////////////////////////////////////////////////////////// | 
|  406  |  406  | 
|  407 #if SK_SUPPORT_GPU |  407 #if SK_SUPPORT_GPU | 
|  408  |  408  | 
|  409 #include "GrTextureAccess.h" |  409 #include "GrTextureAccess.h" | 
|  410 #include "SkGr.h" |  410 #include "SkGr.h" | 
|  411 #include "effects/GrSimpleTextureEffect.h" |  411 #include "effects/GrSimpleTextureEffect.h" | 
|  412  |  412  | 
|  413 const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co
     ntext, |  413 const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co
     ntext, | 
|  414                                              const SkMatrix& viewM, const SkMatr
     ix* localMatrix, |  414                                              const SkMatrix& viewM, const SkMatr
     ix* localMatrix, | 
|  415                                              SkFilterQuality filterQuality) cons
     t { |  415                                              SkFilterQuality filterQuality, | 
 |  416                                              SkSourceGammaTreatment gammaTreatme
     nt) const { | 
|  416     SkMatrix matrix; |  417     SkMatrix matrix; | 
|  417     matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); |  418     matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); | 
|  418  |  419  | 
|  419     SkMatrix lmInverse; |  420     SkMatrix lmInverse; | 
|  420     if (!this->getLocalMatrix().invert(&lmInverse)) { |  421     if (!this->getLocalMatrix().invert(&lmInverse)) { | 
|  421         return nullptr; |  422         return nullptr; | 
|  422     } |  423     } | 
|  423     if (localMatrix) { |  424     if (localMatrix) { | 
|  424         SkMatrix inv; |  425         SkMatrix inv; | 
|  425         if (!localMatrix->invert(&inv)) { |  426         if (!localMatrix->invert(&inv)) { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  436  |  437  | 
|  437     // Must set wrap and filter on the sampler before requesting a texture. In t
     wo places below |  438     // Must set wrap and filter on the sampler before requesting a texture. In t
     wo places below | 
|  438     // we check the matrix scale factors to determine how to interpret the filte
     r quality setting. |  439     // we check the matrix scale factors to determine how to interpret the filte
     r quality setting. | 
|  439     // This completely ignores the complexity of the drawVertices case where exp
     licit local coords |  440     // This completely ignores the complexity of the drawVertices case where exp
     licit local coords | 
|  440     // are provided by the caller. |  441     // are provided by the caller. | 
|  441     bool doBicubic; |  442     bool doBicubic; | 
|  442     GrTextureParams::FilterMode textureFilterMode = |  443     GrTextureParams::FilterMode textureFilterMode = | 
|  443             GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocal
     Matrix(), |  444             GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocal
     Matrix(), | 
|  444                                             &doBicubic); |  445                                             &doBicubic); | 
|  445     GrTextureParams params(tm, textureFilterMode); |  446     GrTextureParams params(tm, textureFilterMode); | 
|  446     SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap
     , params)); |  447     SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap
     , params, | 
 |  448                                                              gammaTreatment)); | 
|  447  |  449  | 
|  448     if (!texture) { |  450     if (!texture) { | 
|  449         SkErrorInternals::SetError( kInternalError_SkError, |  451         SkErrorInternals::SetError( kInternalError_SkError, | 
|  450                                     "Couldn't convert bitmap to texture."); |  452                                     "Couldn't convert bitmap to texture."); | 
|  451         return nullptr; |  453         return nullptr; | 
|  452     } |  454     } | 
|  453  |  455  | 
|  454     SkAutoTUnref<const GrFragmentProcessor> inner; |  456     SkAutoTUnref<const GrFragmentProcessor> inner; | 
|  455     if (doBicubic) { |  457     if (doBicubic) { | 
|  456         inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); |  458         inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); | 
|  457     } else { |  459     } else { | 
|  458         inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |  460         inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 
|  459     } |  461     } | 
|  460  |  462  | 
|  461     if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { |  463     if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { | 
|  462         return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); |  464         return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); | 
|  463     } |  465     } | 
|  464     return GrFragmentProcessor::MulOutputByInputAlpha(inner); |  466     return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 
|  465 } |  467 } | 
|  466  |  468  | 
|  467 #endif |  469 #endif | 
| OLD | NEW |