}
}
-SkShader* SkPictureShader::buildBitmapShader(const SkMatrix& matrix) const {
+SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix) const {
if (!fPicture || (0 == fPicture->width() && 0 == fPicture->height())) {
return NULL;
}
return NULL;
}
- SkShader* bitmapShader = this->buildBitmapShader(matrix);
- if (!bitmapShader) {
- return NULL;
- }
-
- if (!bitmapShader->validContext(device, paint, matrix)) {
- bitmapShader->unref();
+ SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(matrix));
+ if (!bitmapShader || !bitmapShader->validContext(device, paint, matrix)) {
return NULL;
}
- return bitmapShader;
+ return bitmapShader.detach();
}
bool SkPictureShader::validContext(const SkBitmap& device, const SkPaint& paint,
SkShader::Context* SkPictureShader::createContext(const SkBitmap& device, const SkPaint& paint,
const SkMatrix& matrix, void* storage) const {
- SkShader* bitmapShader = this->validInternal(device, paint, matrix, NULL);
+ SkAutoTUnref<SkShader> bitmapShader(this->validInternal(device, paint, matrix, NULL));
if (!bitmapShader) {
return NULL;
}
return SkNEW_PLACEMENT_ARGS(storage, PictureShaderContext,
- (*this, device, paint, matrix, bitmapShader));
+ (*this, device, paint, matrix, bitmapShader.detach()));
}
size_t SkPictureShader::contextSize() const {
#if SK_SUPPORT_GPU
GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint) const {
- SkAutoTUnref<SkShader> bitmapShader(this->buildBitmapShader(context->getMatrix()));
+ SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix()));
if (!bitmapShader) {
return NULL;
}
const SkGradientShaderBase& shader, const SkBitmap& device,
const SkPaint& paint, const SkMatrix& matrix)
: INHERITED(shader, device, paint, matrix)
- , fCache(shader.getCache(getPaintAlpha()))
+ , fCache(shader.refCache(getPaintAlpha()))
{
const SkMatrix& inverse = this->getTotalInverse();
* The gradient holds a cache for the most recent value of alpha. Successive
* callers with the same alpha value will share the same cache.
*/
-SkGradientShaderBase::GradientShaderCache* SkGradientShaderBase::getCache(U8CPU alpha) const {
+SkGradientShaderBase::GradientShaderCache* SkGradientShaderBase::refCache(U8CPU alpha) const {
SkAutoMutexAcquire ama(fCacheMutex);
if (!fCache || fCache->getAlpha() != alpha) {
fCache.reset(SkNEW_ARGS(GradientShaderCache, (alpha, *this)));
void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
// our caller assumes no external alpha, so we ensure that our cache is
// built with 0xFF
- GradientShaderCache* cache = this->getCache(0xFF);
+ SkAutoTUnref<GradientShaderCache> cache(this->refCache(0xFF));
// don't have a way to put the mapper into our cache-key yet
if (fMapper) {