Index: src/core/SkPictureShader.cpp |
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp |
index 92e615734380dd02cc1367bfcc3108e54cef1022..ab599322a57eff618650233aa34da8c8f863760b 100644 |
--- a/src/core/SkPictureShader.cpp |
+++ b/src/core/SkPictureShader.cpp |
@@ -10,6 +10,7 @@ |
#include "SkBitmap.h" |
#include "SkBitmapProcShader.h" |
#include "SkCanvas.h" |
+#include "SkImage.h" |
#include "SkImageGenerator.h" |
#include "SkMatrixUtils.h" |
#include "SkPicture.h" |
@@ -217,18 +218,28 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM |
if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { |
SkMatrix tileMatrix; |
tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()), |
- SkMatrix::kFill_ScaleToFit); |
- SkBitmap bm; |
- if (!SkDEPRECATED_InstallDiscardablePixelRef( |
- SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nullptr), &bm)) { |
+ SkMatrix::kFill_ScaleToFit); |
+ |
+ SkAutoTDelete<SkImageGenerator> tileGenerator( |
+ SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nullptr)); |
+ if (!tileGenerator) { |
+ return nullptr; |
+ } |
+ |
+ // Grab this before the generator goes poof! |
+ const SkImageInfo tileInfo = tileGenerator->getInfo(); |
reed1
2015/10/16 14:12:19
Can we replace these to New calls with just
s
|
+ |
+ SkAutoTUnref<SkImage> tileImage(SkImage::NewFromGenerator(tileGenerator.detach())); |
+ if (!tileImage) { |
return nullptr; |
} |
SkMatrix shaderMatrix = this->getLocalMatrix(); |
shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); |
- tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); |
+ tileShader.reset(tileImage->newShader(fTmx, fTmy, &shaderMatrix)); |
- SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSize())); |
+ SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), |
+ tileInfo.getSafeSize(tileInfo.minRowBytes()))); |
} |
return tileShader.detach(); |