Remove SkDEPRECATED_InstallDiscardablePixelRef from SkPictureShader
Use an SkImage generator/shader instead. R=reed@google.com Review URL: https://codereview.chromium.org/1405103003
This commit is contained in:
parent
338047e21f
commit
fa694ad067
@ -10,6 +10,7 @@
|
|||||||
#include "SkBitmap.h"
|
#include "SkBitmap.h"
|
||||||
#include "SkBitmapProcShader.h"
|
#include "SkBitmapProcShader.h"
|
||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
|
#include "SkImage.h"
|
||||||
#include "SkImageGenerator.h"
|
#include "SkImageGenerator.h"
|
||||||
#include "SkMatrixUtils.h"
|
#include "SkMatrixUtils.h"
|
||||||
#include "SkPicture.h"
|
#include "SkPicture.h"
|
||||||
@ -217,18 +218,28 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM
|
|||||||
if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
|
if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
|
||||||
SkMatrix tileMatrix;
|
SkMatrix tileMatrix;
|
||||||
tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()),
|
tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()),
|
||||||
SkMatrix::kFill_ScaleToFit);
|
SkMatrix::kFill_ScaleToFit);
|
||||||
SkBitmap bm;
|
|
||||||
if (!SkDEPRECATED_InstallDiscardablePixelRef(
|
SkAutoTDelete<SkImageGenerator> tileGenerator(
|
||||||
SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nullptr), &bm)) {
|
SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nullptr));
|
||||||
|
if (!tileGenerator) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab this before the generator goes poof!
|
||||||
|
const SkImageInfo tileInfo = tileGenerator->getInfo();
|
||||||
|
|
||||||
|
SkAutoTUnref<SkImage> tileImage(SkImage::NewFromGenerator(tileGenerator.detach()));
|
||||||
|
if (!tileImage) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkMatrix shaderMatrix = this->getLocalMatrix();
|
SkMatrix shaderMatrix = this->getLocalMatrix();
|
||||||
shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
|
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();
|
return tileShader.detach();
|
||||||
|
Loading…
Reference in New Issue
Block a user