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

Unified Diff: src/core/SkPictureImageGenerator.cpp

Issue 1301633002: Add subsets to SkImageGenerator and SkImageCacherator . (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix release-build warning Created 5 years, 4 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
« src/core/SkImageCacherator.cpp ('K') | « src/core/SkImageGenerator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureImageGenerator.cpp
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index f92de3b98660c04054797a39deb6f3f49c4d19e9..acff84c1b4e3e1422edae471e62ef99d0fac27ba 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -22,7 +22,7 @@ protected:
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
int* ctableCount) override;
#if SK_SUPPORT_GPU
- GrTexture* onGenerateTexture(GrContext*, SkImageUsageType) override;
+ GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkIRect*) override;
#endif
private:
@@ -88,18 +88,27 @@ SkImageGenerator* SkImageGenerator::NewFromPicture(const SkISize& size, const Sk
#if SK_SUPPORT_GPU
#include "GrTexture.h"
-GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, SkImageUsageType usage) {
+GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, SkImageUsageType usage,
+ const SkIRect* subset) {
+ const SkImageInfo& info = this->getInfo();
+ SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->height()) : info;
+
//
// TODO: respect the usage, by possibly creating a different (pow2) surface
//
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx,
SkSurface::kYes_Budgeted,
- this->getInfo()));
+ surfaceInfo));
if (!surface.get()) {
return nullptr;
}
+
+ SkMatrix matrix = fMatrix;
+ if (subset) {
+ matrix.postTranslate(-subset->x(), -subset->y());
+ }
surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this for us?
- surface->getCanvas()->drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
+ surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
if (!image.get()) {
return nullptr;
« src/core/SkImageCacherator.cpp ('K') | « src/core/SkImageGenerator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698