OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkGradientShaderPriv.h" | 8 #include "SkGradientShaderPriv.h" |
9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
10 #include "SkRadialGradient.h" | 10 #include "SkRadialGradient.h" |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 "coord"); | 1083 "coord"); |
1084 fsBuilder->codeAppend(";\n"); | 1084 fsBuilder->codeAppend(";\n"); |
1085 } | 1085 } |
1086 } | 1086 } |
1087 | 1087 |
1088 ///////////////////////////////////////////////////////////////////// | 1088 ///////////////////////////////////////////////////////////////////// |
1089 | 1089 |
1090 GrGradientEffect::GrGradientEffect(GrContext* ctx, | 1090 GrGradientEffect::GrGradientEffect(GrContext* ctx, |
1091 const SkGradientShaderBase& shader, | 1091 const SkGradientShaderBase& shader, |
1092 const SkMatrix& matrix, | 1092 const SkMatrix& matrix, |
1093 SkShader::TileMode tileMode) { | 1093 SkShader::TileMode tileMode, GrRenderTarget*
dst) { |
1094 | 1094 |
1095 fIsOpaque = shader.isOpaque(); | 1095 fIsOpaque = shader.isOpaque(); |
1096 | 1096 |
1097 fColorType = shader.getGpuColorType(&fColors[0]); | 1097 fColorType = shader.getGpuColorType(&fColors[0]); |
1098 | 1098 |
1099 // The two and three color specializations do not currently support tiling. | 1099 // The two and three color specializations do not currently support tiling. |
1100 if (SkGradientShaderBase::kTwo_GpuColorType == fColorType || | 1100 if (SkGradientShaderBase::kTwo_GpuColorType == fColorType || |
1101 SkGradientShaderBase::kThree_GpuColorType == fColorType) { | 1101 SkGradientShaderBase::kThree_GpuColorType == fColorType) { |
1102 fRow = -1; | 1102 fRow = -1; |
1103 | 1103 |
(...skipping 20 matching lines...) Expand all Loading... |
1124 | 1124 |
1125 // We always filter the gradient table. Each table is one row of a textu
re, always y-clamp. | 1125 // We always filter the gradient table. Each table is one row of a textu
re, always y-clamp. |
1126 GrTextureParams params; | 1126 GrTextureParams params; |
1127 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); | 1127 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); |
1128 params.setTileModeX(tileMode); | 1128 params.setTileModeX(tileMode); |
1129 | 1129 |
1130 fRow = fAtlas->lockRow(bitmap); | 1130 fRow = fAtlas->lockRow(bitmap); |
1131 if (-1 != fRow) { | 1131 if (-1 != fRow) { |
1132 fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * fAtlas->getNorm
alizedTexelHeight(); | 1132 fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * fAtlas->getNorm
alizedTexelHeight(); |
1133 fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture(), param
s.filterMode()); | 1133 fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture(), param
s.filterMode()); |
1134 fTextureAccess.reset(fAtlas->getTexture(), params); | 1134 fTextureAccess.reset(fAtlas->getTexture(), params, dst); |
1135 } else { | 1135 } else { |
1136 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap
, params)); | 1136 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap
, params)); |
1137 if (!texture) { | 1137 if (!texture) { |
1138 return; | 1138 return; |
1139 } | 1139 } |
1140 fCoordTransform.reset(kCoordSet, matrix, texture, params.filterMode(
)); | 1140 fCoordTransform.reset(kCoordSet, matrix, texture, params.filterMode(
)); |
1141 fTextureAccess.reset(texture, params); | 1141 fTextureAccess.reset(texture, params, dst); |
1142 fYCoord = SK_ScalarHalf; | 1142 fYCoord = SK_ScalarHalf; |
1143 } | 1143 } |
1144 this->addTextureAccess(&fTextureAccess); | 1144 this->addTextureAccess(&fTextureAccess); |
1145 } | 1145 } |
1146 this->addCoordTransform(&fCoordTransform); | 1146 this->addCoordTransform(&fCoordTransform); |
1147 } | 1147 } |
1148 | 1148 |
1149 GrGradientEffect::~GrGradientEffect() { | 1149 GrGradientEffect::~GrGradientEffect() { |
1150 if (this->useAtlas()) { | 1150 if (this->useAtlas()) { |
1151 fAtlas->unlockRow(fRow); | 1151 fAtlas->unlockRow(fRow); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 (*stops)[i] = stop; | 1207 (*stops)[i] = stop; |
1208 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1208 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1209 } | 1209 } |
1210 } | 1210 } |
1211 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1211 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1212 | 1212 |
1213 return outColors; | 1213 return outColors; |
1214 } | 1214 } |
1215 | 1215 |
1216 #endif | 1216 #endif |
OLD | NEW |