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

Unified Diff: src/image/SkImage.cpp

Issue 1463373002: scaling API on SkPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ready for review Created 5 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
Index: src/image/SkImage.cpp
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index b96f7d16aba6ba8855595c38a217df2eb7556dad..8573bc61f8f101fc59ae6dadcf3bafa7c05a0670 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -48,12 +48,29 @@ const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
}
bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
- int srcX, int srcY) const {
+ int srcX, int srcY, CachingHint chint) const {
SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
if (!rec.trim(this->width(), this->height())) {
return false;
}
- return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY);
+ return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY, chint);
+}
+
+bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingHint chint) const {
+ // Idea: If/when images can natively scale themselves (e.g. backed by picture), then
+ // this code path should take advantage of that.
f(malita) 2015/11/23 18:06:37 Don't we already have this (SkPictureImageGenerato
reed1 2015/11/23 20:07:22 The ImageGenerator API doesn't support scaling yet
+ //
+ SkBitmap bm;
+ if (as_IB(this)->getROPixels(&bm, chint)) {
+ bm.lockPixels();
+ SkPixmap pmap;
+ // Note: By calling the pixmap scaler, we never cache the final result, so the chint
+ // is (currently) only being applied to the getROPixels. If we get a request to
+ // also attempt to cache the final (scaled) result, we would add that logic here.
+ //
+ return bm.peekPixels(&pmap) && pmap.scalePixels(dst, quality);
+ }
+ return false;
}
void SkImage::preroll(GrContext* ctx) const {
@@ -286,7 +303,7 @@ SkImage_Base::~SkImage_Base() {
}
bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
- int srcX, int srcY) const {
+ int srcX, int srcY, CachingHint) const {
if (!raster_canvas_supports(dstInfo)) {
return false;
}
@@ -317,8 +334,8 @@ bool SkImage::peekPixels(SkPixmap* pmap) const {
return false;
}
-bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY) const {
- return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY);
+bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
+ return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
« gm/image.cpp ('K') | « src/core/SkPixmap.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698