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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); | 1157 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); |
1158 params.setTileModeX(tileMode); | 1158 params.setTileModeX(tileMode); |
1159 | 1159 |
1160 fRow = fAtlas->lockRow(bitmap); | 1160 fRow = fAtlas->lockRow(bitmap); |
1161 if (-1 != fRow) { | 1161 if (-1 != fRow) { |
1162 fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * | 1162 fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * |
1163 fAtlas->getVerticalScaleFactor(); | 1163 fAtlas->getVerticalScaleFactor(); |
1164 fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture()); | 1164 fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture()); |
1165 fTextureAccess.reset(fAtlas->getTexture(), params); | 1165 fTextureAccess.reset(fAtlas->getTexture(), params); |
1166 } else { | 1166 } else { |
1167 GrTexture* texture = GrLockAndRefCachedBitmapTexture(ctx, bitmap, &p
arams); | 1167 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap
, ¶ms)); |
1168 fCoordTransform.reset(kCoordSet, matrix, texture); | 1168 fCoordTransform.reset(kCoordSet, matrix, texture); |
1169 fTextureAccess.reset(texture, params); | 1169 fTextureAccess.reset(texture, params); |
1170 fYCoord = SK_ScalarHalf; | 1170 fYCoord = SK_ScalarHalf; |
1171 | |
1172 // Unlock immediately, this is not great, but we don't have a way of | |
1173 // knowing when else to unlock it currently, so it may get purged fr
om | |
1174 // the cache, but it'll still be ref'd until it's no longer being us
ed. | |
1175 GrUnlockAndUnrefCachedBitmapTexture(texture); | |
1176 } | 1171 } |
1177 this->addTextureAccess(&fTextureAccess); | 1172 this->addTextureAccess(&fTextureAccess); |
1178 } | 1173 } |
1179 this->addCoordTransform(&fCoordTransform); | 1174 this->addCoordTransform(&fCoordTransform); |
1180 } | 1175 } |
1181 | 1176 |
1182 GrGradientEffect::~GrGradientEffect() { | 1177 GrGradientEffect::~GrGradientEffect() { |
1183 if (this->useAtlas()) { | 1178 if (this->useAtlas()) { |
1184 fAtlas->unlockRow(fRow); | 1179 fAtlas->unlockRow(fRow); |
1185 } | 1180 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 (*stops)[i] = stop; | 1239 (*stops)[i] = stop; |
1245 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1240 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1246 } | 1241 } |
1247 } | 1242 } |
1248 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1243 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1249 | 1244 |
1250 return outColors; | 1245 return outColors; |
1251 } | 1246 } |
1252 | 1247 |
1253 #endif | 1248 #endif |
OLD | NEW |