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

Unified Diff: src/core/SkSpecialImage.cpp

Issue 1813813002: Add SkSpecialImage::makeTextureImage entry point & update filterInput (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix possible nullptr dereference Created 4 years, 9 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/core/SkSpecialImage.h ('k') | tests/SpecialImageTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSpecialImage.cpp
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index e90c655a5824567bb64035da8643567ea77f73e1..991e16351586674ad01272215071f043c72d8408 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"
+#include "SkGr.h"
+#endif
#include "SkCanvas.h"
#include "SkImage_Base.h"
-#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
///////////////////////////////////////////////////////////////////////////////
@@ -42,6 +48,38 @@ static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) {
return static_cast<const SkSpecialImage_Base*>(image);
}
+sk_sp<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 ? sk_sp<SkSpecialImage>(SkRef(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::MakeFromGpu(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);
}
« no previous file with comments | « src/core/SkSpecialImage.h ('k') | tests/SpecialImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698