| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; | 106 SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; |
| 107 | 107 |
| 108 // Must set wrap and filter on the sampler before requesting a texture. In t
wo places below | 108 // 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. | 109 // 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 | 110 // This completely ignores the complexity of the drawVertices case where exp
licit local coords |
| 111 // are provided by the caller. | 111 // are provided by the caller. |
| 112 bool doBicubic; | 112 bool doBicubic; |
| 113 GrTextureParams::FilterMode textureFilterMode = | 113 GrTextureParams::FilterMode textureFilterMode = |
| 114 GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix()
, &doBicubic); | 114 GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix()
, &doBicubic); |
| 115 GrTextureParams params(tm, textureFilterMode); | 115 GrTextureParams params(tm, textureFilterMode); |
| 116 | 116 SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params)
); |
| 117 SkImageUsageType usageType; | |
| 118 if (kClamp_TileMode == fTileModeX && kClamp_TileMode == fTileModeY) { | |
| 119 usageType = kUntiled_SkImageUsageType; | |
| 120 } else if (GrTextureParams::kNone_FilterMode == textureFilterMode) { | |
| 121 usageType = kTiled_Unfiltered_SkImageUsageType; | |
| 122 } else { | |
| 123 usageType = kTiled_Filtered_SkImageUsageType; | |
| 124 } | |
| 125 | |
| 126 SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, usageTy
pe)); | |
| 127 if (!texture) { | 117 if (!texture) { |
| 128 return nullptr; | 118 return nullptr; |
| 129 } | 119 } |
| 130 | 120 |
| 131 SkAutoTUnref<GrFragmentProcessor> inner; | 121 SkAutoTUnref<GrFragmentProcessor> inner; |
| 132 if (doBicubic) { | 122 if (doBicubic) { |
| 133 inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); | 123 inner.reset(GrBicubicEffect::Create(texture, matrix, tm)); |
| 134 } else { | 124 } else { |
| 135 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 125 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |
| 136 } | 126 } |
| 137 | 127 |
| 138 if (GrPixelConfigIsAlphaOnly(texture->config())) { | 128 if (GrPixelConfigIsAlphaOnly(texture->config())) { |
| 139 return SkRef(inner.get()); | 129 return SkRef(inner.get()); |
| 140 } | 130 } |
| 141 return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 131 return GrFragmentProcessor::MulOutputByInputAlpha(inner); |
| 142 } | 132 } |
| 143 | 133 |
| 144 #endif | 134 #endif |
| OLD | NEW |