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 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap
, ¶ms)); | 1167 GrTexture* texture = GrLockAndRefCachedBitmapTexture(ctx, bitmap, &p
arams); |
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); |
1171 } | 1176 } |
1172 this->addTextureAccess(&fTextureAccess); | 1177 this->addTextureAccess(&fTextureAccess); |
1173 } | 1178 } |
1174 this->addCoordTransform(&fCoordTransform); | 1179 this->addCoordTransform(&fCoordTransform); |
1175 } | 1180 } |
1176 | 1181 |
1177 GrGradientEffect::~GrGradientEffect() { | 1182 GrGradientEffect::~GrGradientEffect() { |
1178 if (this->useAtlas()) { | 1183 if (this->useAtlas()) { |
1179 fAtlas->unlockRow(fRow); | 1184 fAtlas->unlockRow(fRow); |
1180 } | 1185 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 (*stops)[i] = stop; | 1243 (*stops)[i] = stop; |
1239 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1244 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1240 } | 1245 } |
1241 } | 1246 } |
1242 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1247 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1243 | 1248 |
1244 return outColors; | 1249 return outColors; |
1245 } | 1250 } |
1246 | 1251 |
1247 #endif | 1252 #endif |
OLD | NEW |