aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureShader.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-09-28 09:32:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-28 09:32:50 -0700
commit25a5b0dd0c9e94d508b8a9f4de1f977e63775bd1 (patch)
tree756f3c1f2aa91e9f2b0281f73adbde7cf1feb1ac /src/core/SkPictureShader.cpp
parent0869267a7c6c58fb68a49b3c2e6d4f231d6645dc (diff)
Revert of SkImage-backed SkPictureShader (patchset #4 id:60001 of https://codereview.chromium.org/1343153003/ )
Reason for revert: This CL appears to be breaking the pictureshader, pictureshadertile and tiled_picture_shader GMs on the iPad4 and the N7. The artifact is black rectangles. Original issue's description: > SkImage-backed SkPictureShader > > Instead of using an explicit image generator + SkBitmap + bitmap shader, > switch to the shiny new SkImage/image generator/image shader. > > R=reed@google.com > > Committed: https://skia.googlesource.com/skia/+/97be9a0c86eedd8ab85ae7d9aaccb0b0a8e4577d TBR=reed@google.com,fmalita@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1374763003
Diffstat (limited to 'src/core/SkPictureShader.cpp')
-rw-r--r--src/core/SkPictureShader.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 6685211df7..906313d819 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,26 +215,20 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM
this->getLocalMatrix());
if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
- 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) {
+ 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)) {
return nullptr;
}
SkMatrix shaderMatrix = this->getLocalMatrix();
shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
- 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));
+ tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix));
+
+ SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSize()));
}
return tileShader.detach();