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

Unified Diff: src/core/SkMaskFilter.cpp

Issue 18110012: Add canFilterMaskGPU & filterMaskGPU to SkMaskFilter (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: added comments & fixed nits Created 7 years, 6 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 | « include/core/SkMaskFilter.h ('k') | src/device/xps/SkXPSDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMaskFilter.cpp
===================================================================
--- src/core/SkMaskFilter.cpp (revision 9883)
+++ src/core/SkMaskFilter.cpp (working copy)
@@ -11,7 +11,11 @@
#include "SkBlitter.h"
#include "SkBounder.h"
#include "SkDraw.h"
+#include "SkGr.h"
+#include "SkGrPixelRef.h"
#include "SkRasterClip.h"
+#include "SkTypes.h"
+#include "GrTexture.h"
SK_DEFINE_INST_COUNT(SkMaskFilter)
@@ -266,10 +270,71 @@
return kUnimplemented_FilterReturn;
}
-SkMaskFilter::BlurType SkMaskFilter::asABlur(BlurInfo*) const {
- return kNone_BlurType;
+bool SkMaskFilter::asNewEffect(GrEffectRef** effect, GrTexture*) const {
+ return false;
}
+bool SkMaskFilter::canFilterMaskGPU(const SkRect& devBounds,
+ const SkIRect& clipBounds,
+ const SkMatrix& ctm,
+ SkRect* maskRect) const {
+ return false;
+}
+
+bool SkMaskFilter::filterMaskGPU(GrContext* context,
+ const SkBitmap& srcBM,
+ const SkRect& maskRect,
+ SkBitmap* resultBM) const {
+ SkAutoTUnref<GrTexture> src;
+ bool canOverwriteSrc = false;
+ if (NULL == srcBM.getTexture()) {
+ GrTextureDesc desc;
+ // Needs to be a render target to be overwritten in filterMaskGPU
+ desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
+ desc.fConfig = SkBitmapConfig2GrPixelConfig(srcBM.config());
+ desc.fWidth = srcBM.width();
+ desc.fHeight = srcBM.height();
+
+ // TODO: right now this is exact to guard against out of bounds reads
+ // by the filter code. More thought needs to be devoted to the
+ // "filterMaskGPU" contract and then enforced (i.e., clamp the code
+ // in "filterMaskGPU" so it never samples beyond maskRect)
+ GrAutoScratchTexture ast(context, desc, GrContext::kExact_ScratchTexMatch);
+ if (NULL == ast.texture()) {
+ return false;
+ }
+
+ SkAutoLockPixels alp(srcBM);
+ ast.texture()->writePixels(0, 0, srcBM.width(), srcBM.height(),
+ desc.fConfig,
+ srcBM.getPixels(), srcBM.rowBytes());
+
+ src.reset(ast.detach());
+ canOverwriteSrc = true;
+ } else {
+ src.reset((GrTexture*) srcBM.getTexture());
+ src.get()->ref();
+ }
+ GrTexture* dst;
+
+ bool result = this->filterMaskGPU(src, maskRect, &dst, canOverwriteSrc);
+ if (!result) {
+ return false;
+ }
+
+ resultBM->setConfig(srcBM.config(), dst->width(), dst->height());
+ resultBM->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (dst)))->unref();
+ dst->unref();
Stephen White 2013/07/03 14:32:56 FYI, one of the reasons I changed the SkImageFilte
+ return true;
+}
+
+bool SkMaskFilter::filterMaskGPU(GrTexture* src,
+ const SkRect& maskRect,
+ GrTexture** result,
+ bool canOverwriteSrc) const {
+ return false;
+}
+
void SkMaskFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
SkMask srcM, dstM;
« no previous file with comments | « include/core/SkMaskFilter.h ('k') | src/device/xps/SkXPSDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698