Index: src/core/SkSpecialImage.cpp |
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp |
index b17d5d4147d998d85016a1f2d50c6bbb63ac91e7..8f6d906db79ae02b89219477797b06577cf89210 100644 |
--- a/src/core/SkSpecialImage.cpp |
+++ b/src/core/SkSpecialImage.cpp |
@@ -4,10 +4,16 @@ |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file |
*/ |
+#include "SkSpecialImage.h" |
+ |
+#if SK_SUPPORT_GPU |
+#include "GrTexture.h" |
+#include "GrTextureParams.h" |
+#endif |
#include "SkCanvas.h" |
+#include "SkGr.h" |
#include "SkImage_Base.h" |
-#include "SkSpecialImage.h" |
#include "SkSpecialSurface.h" |
/////////////////////////////////////////////////////////////////////////////// |
@@ -42,6 +48,37 @@ static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { |
return static_cast<const SkSpecialImage_Base*>(image); |
} |
+SkSpecialImage* SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* proxy, GrContext* context) { |
+#if SK_SUPPORT_GPU |
+ if (!context) { |
+ return nullptr; |
+ } |
+ if (GrTexture* peek = as_SIB(this)->peekTexture()) { |
+ return peek->getContext() == context ? this : nullptr; |
+ } |
+ |
+ SkBitmap bmp; |
+ if (!this->internal_getBM(&bmp)) { |
+ return nullptr; |
+ } |
+ |
+ SkAutoTUnref<GrTexture> resultTex( |
+ GrRefCachedBitmapTexture(context, bmp, GrTextureParams::ClampNoFilter())); |
+ if (!resultTex) { |
+ return nullptr; |
+ } |
+ |
+ SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
+ |
+ return SkSpecialImage::NewFromGpu(proxy, |
+ SkIRect::MakeWH(resultTex->width(), resultTex->height()), |
+ this->uniqueID(), |
+ resultTex, at); |
+#else |
+ return nullptr; |
+#endif |
+} |
+ |
void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const { |
return as_SIB(this)->onDraw(canvas, x, y, paint); |
} |