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

Unified Diff: src/image/SkImage_Generator.cpp

Issue 1375673002: Revert of Revert[2] of add ImageShader, sharing code with its Bitmap cousin (Closed) Base URL: https://skia.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 | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.h » ('j') | 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 1c1b26337178aa1965058a8fb0121ef73fd85c25..765234fa0c0e1757487220b99f1d1b2fdfc39706 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -28,6 +28,11 @@
SkImage* onNewSubset(const SkIRect&) const override;
bool getROPixels(SkBitmap*) const override;
GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
+
+ SkShader* onNewShader(SkShader::TileMode,
+ SkShader::TileMode,
+ const SkMatrix* localMatrix) const override;
+
bool onIsLazyGenerated() const override { return true; }
private:
@@ -37,6 +42,17 @@
};
///////////////////////////////////////////////////////////////////////////////
+
+SkShader* SkImage_Generator::onNewShader(SkShader::TileMode tileX, SkShader::TileMode tileY,
+ const SkMatrix* localMatrix) const {
+ // TODO: need a native Shader that takes Cacherator (or this image) so we can natively return
+ // textures as output from the shader.
+ SkBitmap bm;
+ if (this->getROPixels(&bm)) {
+ return SkShader::CreateBitmapShader(bm, tileX, tileY, localMatrix);
+ }
+ return nullptr;
+}
bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
int srcX, int srcY) const {
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698