aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkDevice.h5
-rw-r--r--include/core/SkImageGenerator.h40
2 files changed, 44 insertions, 1 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index d521fec5ca..b0aac41d0b 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -255,7 +255,6 @@ protected:
virtual GrContext* context() const { return nullptr; }
-protected:
virtual sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&);
virtual bool onPeekPixels(SkPixmap*) { return false; }
@@ -359,6 +358,10 @@ private:
*const_cast<SkImageInfo*>(&fInfo) = fInfo.makeWH(w, h);
}
+ bool drawExternallyScaledImage(const SkDraw& draw, const SkImage* image, const SkRect* src,
+ const SkRect& dst, const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint);
+
SkIPoint fOrigin;
SkMetaData* fMetaData;
const SkImageInfo fInfo;
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 5e7214c7d1..2e34bfe2ce 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -19,6 +19,7 @@ class GrTexture;
class GrTextureParams;
class SkBitmap;
class SkData;
+class SkImage;
class SkImageGenerator;
class SkMatrix;
class SkPaint;
@@ -199,6 +200,40 @@ public:
}
/**
+ * External generator API: provides efficient access to externally-managed image data.
+ *
+ * Skia calls accessScaledPixels() during rasterization, to gain temporary access to
+ * the external pixel data, packaged as a raster SkImage.
+ *
+ * @param srcRect the source rect in use for the current draw
+ * @param totalMatrix full matrix in effect (mapping srcRect -> device space)
+ * @param quality the SkFilterQuality requested for rasterization.
+ * @param rec out param, expected to be set when the call succeeds:
+ *
+ * - fImage wraps the external pixel data
+ * - fSrcRect is an adjusted srcRect
+ * - fQuality is the adjusted filter quality
+ *
+ * @return true on success, false otherwise (error or if this API is not supported;
+ * in this case Skia will fall back to its internal scaling and caching
+ * heuristics)
+ *
+ * Implementors can return pixmaps with a different size than requested, by adjusting the
+ * src rect. The contract is that Skia will observe the adjusted src rect, and will map it
+ * to the same dest as the original draw (the impl doesn't get to control the destination).
+ *
+ */
+
+ struct ScaledImageRec {
+ sk_sp<SkImage> fImage;
+ SkRect fSrcRect;
+ SkFilterQuality fQuality;
+ };
+
+ bool accessScaledImage(const SkRect& srcRect, const SkMatrix& totalMatrix,
+ SkFilterQuality quality, ScaledImageRec* rec);
+
+ /**
* If the default image decoder system can interpret the specified (encoded) data, then
* this returns a new ImageGenerator for it. Otherwise this returns NULL. Either way
* the caller is still responsible for managing their ownership of the data.
@@ -263,6 +298,11 @@ protected:
return false;
}
+ virtual bool onAccessScaledImage(const SkRect&, const SkMatrix&, SkFilterQuality,
+ ScaledImageRec*) {
+ return false;
+ }
+
bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitmap::Allocator*);
private: