| Index: src/core/SkPictureShader.cpp
|
| diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
|
| index 906313d819f615b14325b6b0c2ad225b2ef5c7d1..6685211df75f8d5861f8a597caece4ff3d6cda99 100644
|
| --- a/src/core/SkPictureShader.cpp
|
| +++ b/src/core/SkPictureShader.cpp
|
| @@ -7,10 +7,10 @@
|
|
|
| #include "SkPictureShader.h"
|
|
|
| -#include "SkBitmap.h"
|
| -#include "SkBitmapProcShader.h"
|
| #include "SkCanvas.h"
|
| +#include "SkImageCacherator.h"
|
| #include "SkImageGenerator.h"
|
| +#include "SkImageShader.h"
|
| #include "SkMatrixUtils.h"
|
| #include "SkPicture.h"
|
| #include "SkReadBuffer.h"
|
| @@ -215,20 +215,26 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM
|
| this->getLocalMatrix());
|
|
|
| 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 tileMatrix =
|
| + SkMatrix::MakeRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()),
|
| + SkMatrix::kFill_ScaleToFit);
|
| + SkAutoTUnref<SkImage> tileImage(
|
| + SkImage::NewFromPicture(fPicture, tileSize, &tileMatrix, nullptr));
|
| + if (!tileImage) {
|
| return nullptr;
|
| }
|
|
|
| SkMatrix shaderMatrix = this->getLocalMatrix();
|
| shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
|
| - tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix));
|
| -
|
| - SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSize()));
|
| + tileShader.reset(tileImage->newShader(fTmx, fTmy, &shaderMatrix));
|
| +
|
| + // The actual pixels are accounted for in the SkImage cacherator budget. Here we
|
| + // use a rough estimate for the related objects.
|
| + const size_t bytesUsed = sizeof(SkImageShader) +
|
| + sizeof(SkImage) +
|
| + sizeof(SkImageCacherator) +
|
| + sizeof(SkImageGenerator);
|
| + SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bytesUsed));
|
| }
|
|
|
| return tileShader.detach();
|
|
|