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

Unified Diff: src/image/SkImage_Generator.cpp

Issue 2462013003: Deferred image generator subsetting (Closed)
Patch Set: unlocked generator access comments Created 4 years, 1 month 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 | « src/core/SkImageCacherator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Generator.cpp
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index 8fa022de7bdc1a6f11fb21c73cf0504ec0963e0b..483ebdf2b1ff5696cc90a2c44b543acdd375e364 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -7,12 +7,10 @@
#include "SkImage_Base.h"
#include "SkBitmap.h"
-#include "SkCanvas.h"
#include "SkData.h"
#include "SkImageCacherator.h"
#include "SkImagePriv.h"
#include "SkPixelRef.h"
-#include "SkSurface.h"
class SkImage_Generator : public SkImage_Base {
public:
@@ -82,23 +80,17 @@ GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams
}
sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const {
- // TODO: make this lazy, by wrapping the subset inside a new generator or something
- // For now, we do effectively what we did before, make it a raster
-
- const SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(),
- this->alphaType());
- auto surface(SkSurface::MakeRaster(info));
- if (!surface) {
- return nullptr;
- }
- surface->getCanvas()->clear(0);
- surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToScalar(-subset.y()),
- nullptr);
- return surface->makeImageSnapshot();
+ SkASSERT(fCache.info().bounds().contains(subset));
+ SkASSERT(fCache.info().bounds() != subset);
+
+ const SkIRect generatorSubset = subset.makeOffset(fCache.fOrigin.x(), fCache.fOrigin.y());
+ SkImageCacherator::Validator validator(fCache.fSharedGenerator, &generatorSubset);
+ return validator ? sk_sp<SkImage>(new SkImage_Generator(&validator)) : nullptr;
}
sk_sp<SkImage> SkImage::MakeFromGenerator(SkImageGenerator* generator, const SkIRect* subset) {
- SkImageCacherator::Validator validator(generator, subset);
+ SkImageCacherator::Validator validator(SkImageCacherator::SharedGenerator::Make(generator),
+ subset);
return validator ? sk_make_sp<SkImage_Generator>(&validator) : nullptr;
}
« no previous file with comments | « src/core/SkImageCacherator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698