#include "SkPaint.h"
class GrClip;
-class GrContext;
+class GrDrawContext;
class GrPaint;
class GrRenderTarget;
+class GrTextureProvider;
class SkBitmap;
class SkBlitter;
class SkCachedData;
* Try to directly render the mask filter into the target. Returns
* true if drawing was successful.
*/
- virtual bool directFilterMaskGPU(GrContext* context,
+ virtual bool directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
* Try to directly render a rounded rect mask filter into the target. Returns
* true if drawing was successful.
*/
- virtual bool directFilterRRectMaskGPU(GrContext* context,
+ virtual bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
return false;
}
- bool SkMaskFilter::directFilterMaskGPU(GrContext* context,
+ bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
}
-bool SkMaskFilter::directFilterRRectMaskGPU(GrContext* context,
+bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
SkBitmap* dst, SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
return false;
}
void SkBlurImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, dst);
+ if (this->getInput(0)) {
+ this->getInput(0)->computeFastBounds(src, dst);
} else {
*dst = src;
}
SkVector sigma = mapSigma(fSigma, ctm);
bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
- if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
+ if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &bounds)) {
return false;
}
*dst = bounds;
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect rect;
// overrides from SkMaskFilter
SkMask::Format getFormat() const override;
- virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
- SkIPoint* margin) const override;
+ bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
+ SkIPoint* margin) const override;
#if SK_SUPPORT_GPU
- virtual bool canFilterMaskGPU(const SkRect& devBounds,
- const SkIRect& clipBounds,
- const SkMatrix& ctm,
- SkRect* maskRect) const override;
- virtual bool directFilterMaskGPU(GrContext* context,
- GrRenderTarget* rt,
- GrPaint* grp,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec& strokeRec,
- const SkPath& path) const override;
- virtual bool directFilterRRectMaskGPU(GrContext* context,
- GrRenderTarget* rt,
- GrPaint* grp,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec& strokeRec,
- const SkRRect& rrect) const override;
-
- virtual bool filterMaskGPU(GrTexture* src,
- const SkMatrix& ctm,
- const SkRect& maskRect,
- GrTexture** result,
- bool canOverwriteSrc) const override;
+ bool canFilterMaskGPU(const SkRect& devBounds,
+ const SkIRect& clipBounds,
+ const SkMatrix& ctm,
+ SkRect* maskRect) const override;
+ bool directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
+ GrRenderTarget* rt,
+ GrPaint* grp,
+ const GrClip&,
+ const SkMatrix& viewMatrix,
+ const SkStrokeRec& strokeRec,
+ const SkPath& path) const override;
+ bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
+ GrRenderTarget* rt,
+ GrPaint* grp,
+ const GrClip&,
+ const SkMatrix& viewMatrix,
+ const SkStrokeRec& strokeRec,
+ const SkRRect& rrect) const override;
+ bool filterMaskGPU(GrTexture* src,
+ const SkMatrix& ctm,
+ const SkRect& maskRect,
+ GrTexture** result,
+ bool canOverwriteSrc) const override;
#endif
void computeFastBounds(const SkRect&, SkRect*) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl)
protected:
- virtual FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&,
- const SkIRect& clipBounds,
- NinePatch*) const override;
+ FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&,
+ const SkIRect& clipBounds,
+ NinePatch*) const override;
- virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&,
- const SkIRect& clipBounds,
- NinePatch*) const override;
+ FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&,
+ const SkIRect& clipBounds,
+ NinePatch*) const override;
bool filterRectMask(SkMask* dstM, const SkRect& r, const SkMatrix& matrix,
SkIPoint* margin, SkMask::CreateMode createMode) const;
}
-bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
+bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const {
+ SkASSERT(drawContext);
+
if (fBlurStyle != kNormal_SkBlurStyle) {
return false;
}
return false;
}
- SkMatrix ctm = viewMatrix;
- SkScalar xformedSigma = this->computeXformedSigma(ctm);
+ SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- int pad=SkScalarCeilToInt(6*xformedSigma)/2;
+ int pad = SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
SkAutoTUnref<GrFragmentProcessor> fp(GrRectBlurEffect::Create(
- context->textureProvider(), rect, xformedSigma));
+ texProvider, rect, xformedSigma));
if (!fp) {
return false;
}
return false;
}
- GrDrawContext* drawContext = context->drawContext();
- if (drawContext) {
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
- return true;
- }
-
- return false;
+ drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
+ return true;
}
class GrRRectBlurEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrContext* context, float sigma, const SkRRect&);
+ static GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
const char* name() const override { return "GrRRectBlur"; }
};
-GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
+GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvider, float sigma,
const SkRRect& rrect) {
if (!rrect.isSimpleCircular()) {
return NULL;
builder[1] = cornerRadius;
builder.finish();
- SkAutoTUnref<GrTexture> blurNinePatchTexture(
- context->textureProvider()->findAndRefTextureByUniqueKey(key));
+ SkAutoTUnref<GrTexture> blurNinePatchTexture(texProvider->findAndRefTextureByUniqueKey(key));
if (!blurNinePatchTexture) {
SkMask mask;
texDesc.fConfig = kAlpha_8_GrPixelConfig;
blurNinePatchTexture.reset(
- context->textureProvider()->createTexture(texDesc, true, blurredMask.fImage, 0));
+ texProvider->createTexture(texDesc, true, blurredMask.fImage, 0));
SkMask::FreeImage(blurredMask.fImage);
if (!blurNinePatchTexture) {
return NULL;
}
- context->textureProvider()->assignUniqueKeyToTexture(key, blurNinePatchTexture);
+ texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture);
}
return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
}
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- return GrRRectBlurEffect::Create(d->fContext, sigma, rrect);
+ return GrRRectBlurEffect::Create(d->fContext->textureProvider(), sigma, rrect);
}
//////////////////////////////////////////////////////////////////////////////
return SkNEW_ARGS(GrGLRRectBlurEffect, (*this));
}
-bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
+bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
+ GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const {
+ SkASSERT(drawContext);
+
if (fBlurStyle != kNormal_SkBlurStyle) {
return false;
}
return false;
}
- SkRect proxy_rect = rrect.rect();
- SkMatrix ctm = viewMatrix;
- SkScalar xformedSigma = this->computeXformedSigma(ctm);
+ SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
- proxy_rect.outset(extra, extra);
- SkAutoTUnref<GrFragmentProcessor> fp(GrRRectBlurEffect::Create(context, xformedSigma, rrect));
+ SkRect proxyRect = rrect.rect();
+ proxyRect.outset(extra, extra);
+
+ SkAutoTUnref<GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
+ xformedSigma, rrect));
if (!fp) {
return false;
}
return false;
}
- GrDrawContext* drawContext = context->drawContext();
- if (drawContext) {
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(),
- proxy_rect, inverse);
- return true;
- }
-
- return false;
+ drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxyRect, inverse);
+ return true;
}
bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds,
SkBitmap* dst,
SkIPoint* offset) const {
SkBitmap displ = src, color = src;
- const SkImageFilter* colorInput = getColorInput();
- const SkImageFilter* displInput = getDisplacementInput();
+ const SkImageFilter* colorInput = this->getColorInput();
+ const SkImageFilter* displInput = this->getDisplacementInput();
SkIPoint colorOffset = SkIPoint::Make(0, 0), displOffset = SkIPoint::Make(0, 0);
if ((colorInput && !colorInput->filterImage(proxy, src, ctx, &color, &colorOffset)) ||
(displInput && !displInput->filterImage(proxy, src, ctx, &displ, &displOffset))) {
}
void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getColorInput()) {
- getColorInput()->computeFastBounds(src, dst);
+ if (this->getColorInput()) {
+ this->getColorInput()->computeFastBounds(src, dst);
} else {
*dst = src;
}
ctm.mapVectors(&scale, 1);
bounds.outset(SkScalarCeilToInt(scale.fX * SK_ScalarHalf),
SkScalarCeilToInt(scale.fY * SK_ScalarHalf));
- if (getColorInput()) {
- return getColorInput()->filterBounds(bounds, ctm, dst);
+ if (this->getColorInput()) {
+ return this->getColorInput()->filterBounds(bounds, ctm, dst);
}
*dst = bounds;
return true;
SkBitmap* result, SkIPoint* offset) const {
SkBitmap colorBM = src;
SkIPoint colorOffset = SkIPoint::Make(0, 0);
- if (getColorInput() && !getColorInput()->getInputResultGPU(proxy, src, ctx, &colorBM,
- &colorOffset)) {
+ if (this->getColorInput() &&
+ !this->getColorInput()->getInputResultGPU(proxy, src, ctx, &colorBM, &colorOffset)) {
return false;
}
SkBitmap displacementBM = src;
SkIPoint displacementOffset = SkIPoint::Make(0, 0);
- if (getDisplacementInput() &&
- !getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacementBM,
- &displacementOffset)) {
+ if (this->getDisplacementInput() &&
+ !this->getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacementBM,
+ &displacementOffset)) {
return false;
}
SkIRect bounds;
return NULL;
}
- GrDrawContext* drawContext = context->drawContext();
- if (!drawContext) {
- return NULL;
- }
+ GrDrawContext* srcDrawContext = NULL;
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
}
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
- drawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, SkMatrix::I(),
- dstRect, srcRect);
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
+ SkMatrix::I(), dstRect, srcRect);
+
+ srcDrawContext = dstDrawContext;
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
const SkIRect srcIRect = srcRect.roundOut();
- // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is faster to just
+ // For really small blurs (certainly no wider than 5x5 on desktop gpus) it is faster to just
// launch a single non separable kernel vs two launches
- if (sigmaX > 0.0f && sigmaY > 0 &&
+ if (sigmaX > 0.0f && sigmaY > 0.0f &&
(2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) {
// We shouldn't be scaling because this is a small size blur
- SkASSERT((scaleFactorX == scaleFactorY) == 1);
+ SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian_2d(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ convolve_gaussian_2d(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
- srcTexture = dstTexture;
+
+ srcDrawContext = dstDrawContext;
srcRect = dstRect;
+ srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
} else {
if (sigmaX > 0.0f) {
if (scaleFactorX > 1) {
+ // TODO: if we pass in the source draw context we don't need this here
+ if (!srcDrawContext) {
+ srcDrawContext = context->drawContext();
+ if (!srcDrawContext) {
+ return NULL;
+ }
+ }
+
// Clear out a radius to the right of the srcRect to prevent the
// X convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
radiusX, srcIRect.height());
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(drawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
cropToRect);
+
+ srcDrawContext = dstDrawContext;
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
if (sigmaY > 0.0f) {
if (scaleFactorY > 1 || sigmaX > 0.0f) {
+ // TODO: if we pass in the source draw context we don't need this here
+ if (!srcDrawContext) {
+ srcDrawContext = context->drawContext();
+ if (!srcDrawContext) {
+ return NULL;
+ }
+ }
+
// Clear out a radius below the srcRect to prevent the Y
// convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width(), radiusY);
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(drawContext, dstTexture->asRenderTarget(), clip, srcRect,
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect,
dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
cropToRect);
+
+ srcDrawContext = dstDrawContext;
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
}
if (scaleFactorX > 1 || scaleFactorY > 1) {
+ SkASSERT(srcDrawContext);
+
// Clear one pixel to the right and below, to accommodate bilinear
// upsampling.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width() + 1, 1);
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height());
- drawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
- drawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
- SkMatrix::I(), dstRect, srcRect);
+
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return NULL;
+ }
+ dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
+ SkMatrix::I(), dstRect, srcRect);
+
+ srcDrawContext = dstDrawContext;
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
}
+
return SkRef(srcTexture);
}
#endif
SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
return false;
}
}
void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, dst);
+ if (this->getInput(0)) {
+ this->getInput(0)->computeFastBounds(src, dst);
} else {
*dst = src;
}
SkIntToScalar(this->radius().height()));
ctm.mapVectors(&radius, 1);
bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
- if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
+ if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &bounds)) {
return false;
}
*dst = bounds;
desc.fConfig = kSkia8888_GrPixelConfig;
SkIRect srcRect = rect;
- GrDrawContext* drawContext = context->drawContext();
- if (!drawContext) {
- return false;
- }
-
if (radius.fWidth > 0) {
- GrTexture* texture = context->textureProvider()->refScratchTexture(
+ GrTexture* dst = context->textureProvider()->refScratchTexture(
desc, GrTextureProvider::kApprox_ScratchTexMatch);
- if (NULL == texture) {
+ if (NULL == dst) {
return false;
}
- apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture,
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
+ return false;
+ }
+
+ apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
SK_ColorWHITE :
SK_ColorTRANSPARENT;
- drawContext->clear(texture->asRenderTarget(), &clearRect, clearColor, false);
- srcTexture.reset(texture);
+ dstDrawContext->clear(dst->asRenderTarget(), &clearRect, clearColor, false);
+
+ srcTexture.reset(dst);
srcRect = dstRect;
}
if (radius.fHeight > 0) {
- GrTexture* texture = context->textureProvider()->refScratchTexture(desc,
+ GrTexture* dst = context->textureProvider()->refScratchTexture(desc,
GrTextureProvider::kApprox_ScratchTexMatch);
- if (NULL == texture) {
+ if (NULL == dst) {
+ return false;
+ }
+ GrDrawContext* dstDrawContext = context->drawContext();
+ if (!dstDrawContext) {
return false;
}
- apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture,
+
+ apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
- srcTexture.reset(texture);
+
+ srcTexture.reset(dst);
}
SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst);
return true;
SkIPoint* offset) const {
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
return true;
}
- GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType : GrMorphologyEffect::kErode_MorphologyType;
- if (!apply_morphology(input, srcBounds, type,
- SkISize::Make(width, height), result)) {
+ GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType
+ : GrMorphologyEffect::kErode_MorphologyType;
+ if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height), result)) {
return false;
}
offset->fX = bounds.left();
SkBitmap* dst,
SkIPoint* offset) const {
SkBitmap background = src, foreground = src;
- SkImageFilter* backgroundInput = getInput(0);
- SkImageFilter* foregroundInput = getInput(1);
+ SkImageFilter* backgroundInput = this->getInput(0);
+ SkImageFilter* foregroundInput = this->getInput(1);
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
if (backgroundInput &&
!backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundOffset)) {
SkIPoint* offset) const {
SkBitmap background = src;
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &background,
- &backgroundOffset)) {
- return onFilterImage(proxy, src, ctx, result, offset);
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &background, &backgroundOffset)) {
+ return this->onFilterImage(proxy, src, ctx, result, offset);
}
- GrTexture* backgroundTex = background.getTexture();
+ GrTexture* backgroundTex = background.getTexture();
if (NULL == backgroundTex) {
SkASSERT(false);
return false;
SkBitmap foreground = src;
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
- if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground,
- &foregroundOffset)) {
- return onFilterImage(proxy, src, ctx, result, offset);
+ if (this->getInput(1) &&
+ !this->getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground, &foregroundOffset)) {
+ return this->onFilterImage(proxy, src, ctx, result, offset);
}
GrTexture* foregroundTex = foreground.getTexture();
GrContext* context = foregroundTex->getContext();
return;
}
- if (paint.getMaskFilter()->directFilterMaskGPU(context,
+ if (paint.getMaskFilter()->directFilterMaskGPU(context->textureProvider(),
+ drawContext,
renderTarget,
&grPaint,
clip,
return;
}
-
SkAutoTUnref<GrTexture> mask(create_mask_GPU(context,
maskRect,
*devPathPtr,
// clipped out
return;
}
- if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext,
+ if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext->textureProvider(),
+ fDrawContext,
fRenderTarget,
&grPaint,
fClip,
bool failed = true;
- GrDrawContext* drawContext = context->drawContext();
- if (!drawContext) {
- return;
- }
-
for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
*pmToUPMRule = kConversionRules[i][0];
*upmToPMRule = kConversionRules[i][1];
SkMatrix::I())));
paint1.addColorProcessor(pmToUPM1);
- drawContext->drawNonAARectToRect(readTex->asRenderTarget(),
- GrClip::WideOpen(),
- paint1,
- SkMatrix::I(),
- kDstRect,
- kSrcRect);
+
+
+ GrDrawContext* readDrawContext = context->drawContext();
+ if (!readDrawContext) {
+ failed = true;
+ break;
+ }
+
+ readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
+ GrClip::WideOpen(),
+ paint1,
+ SkMatrix::I(),
+ kDstRect,
+ kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
paint2.addColorProcessor(upmToPM);
- drawContext->drawNonAARectToRect(tempTex->asRenderTarget(),
- GrClip::WideOpen(),
- paint2,
- SkMatrix::I(),
- kDstRect,
- kSrcRect);
+
+ GrDrawContext* tempDrawContext = context->drawContext();
+ if (!tempDrawContext) {
+ failed = true;
+ break;
+ }
+ tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(),
+ GrClip::WideOpen(),
+ paint2,
+ SkMatrix::I(),
+ kDstRect,
+ kSrcRect);
paint3.addColorProcessor(pmToUPM2);
- drawContext->drawNonAARectToRect(readTex->asRenderTarget(),
- GrClip::WideOpen(),
- paint3,
- SkMatrix::I(),
- kDstRect,
- kSrcRect);
+
+ readDrawContext = context->drawContext();
+ if (!readDrawContext) {
+ failed = true;
+ break;
+ }
+
+ readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
+ GrClip::WideOpen(),
+ paint3,
+ SkMatrix::I(),
+ kDstRect,
+ kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);