Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: src/core/SkPictureShader.cpp

Issue 1374763003: Revert of SkImage-backed SkPictureShader (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureShader.cpp
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 6685211df75f8d5861f8a597caece4ff3d6cda99..906313d819f615b14325b6b0c2ad225b2ef5c7d1 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 @@
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698