Revert of Pass clip to context (patchset #8 id:180001 of https://codereview.chromium.org/936943002/)

Reason for revert:
Strange blur problems on nexus 5

Original issue's description:
> I'd really like to land this before the branch so speedy reviews are appreciated.
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/586d5d640b19860dfbbd903a5188da1bbbe87336

TBR=jvanverth@google.com,senorblanco@google.com,bsalomon@google.com,senorblanco@chromium.org,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/956083002
This commit is contained in:
joshualitt 2015-02-25 13:04:43 -08:00 committed by Commit bot
parent edeccc5860
commit 2907059d0e
32 changed files with 290 additions and 359 deletions

View File

@ -91,8 +91,7 @@ protected:
}
SkAutoTUnref<GrTexture> au(texture);
// setup new clip
GrClip clip(SkRect::MakeWH(2*S, 2*S));
GrContext::AutoClip acs(ctx, SkRect::MakeWH(2*S, 2*S));
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrcOver_Mode);
@ -110,7 +109,7 @@ protected:
tm.postIDiv(2*S, 2*S);
paint.addColorTextureProcessor(texture, tm);
ctx->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S));
// now update the lower right of the texture in first pass
// or upper right in second pass
@ -124,7 +123,7 @@ protected:
texture->writePixels(S, (i ? 0 : S), S, S,
texture->config(), gTextureData.get(),
4 * stride);
ctx->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S));
}
} else {
this->drawGpuOnlyMessage(canvas);

View File

@ -15,7 +15,6 @@
#include "SkMask.h"
#include "SkPaint.h"
class GrClip;
class GrContext;
class GrPaint;
class GrRenderTarget;
@ -101,7 +100,6 @@ public:
virtual bool directFilterMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const;
@ -112,7 +110,6 @@ public:
virtual bool directFilterRRectMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const;

View File

@ -783,16 +783,6 @@ public:
fRight >= r.fRight && fBottom >= r.fBottom;
}
/**
* Returns true if the specified rectangle r is inside or equal to this rectangle.
*/
bool contains(const SkIRect& r) const {
// todo: can we eliminate the this->isEmpty check?
return !r.isEmpty() && !this->isEmpty() &&
fLeft <= SkIntToScalar(r.fLeft) && fTop <= SkIntToScalar(r.fTop) &&
fRight >= SkIntToScalar(r.fRight) && fBottom >= SkIntToScalar(r.fBottom);
}
/**
* Set the dst rectangle by rounding this rectangle's coordinates to their
* nearest integer values using SkScalarRoundToInt.

View File

@ -15,7 +15,7 @@ struct SkIRect;
/**
* GrClip encapsulates the information required to construct the clip
* masks. 'A GrClip is either wide open, just an IRect, just a Rect, or a full clipstack.
* masks. 'A GrClip is either wide open, just an IRect, just a Rect(TODO), or a full clipstack.
* If the clip is a clipstack than the origin is used to translate the stack with
* respect to device coordinates. This allows us to use a clip stack that is
* specified for a root device with a layer device that is restricted to a subset
@ -28,23 +28,18 @@ public:
GrClip() : fClipType(kWideOpen_ClipType) {
fOrigin.setZero();
}
GrClip(const SkIRect& rect) : fClipType(kIRect_ClipType) {
fOrigin.setZero();
fClip.fIRect = rect;
}
GrClip(const SkRect& rect) : fClipType(kRect_ClipType) {
fOrigin.setZero();
fClip.fRect = rect;
}
~GrClip() { this->reset(); }
const GrClip& operator=(const GrClip& other) {
this->reset();
fClipType = other.fClipType;
switch (other.fClipType) {
default:
SkFAIL("Incomplete Switch\n");
case kWideOpen_ClipType:
fOrigin.setZero();
break;
@ -56,10 +51,6 @@ public:
fClip.fIRect = other.irect();
fOrigin.setZero();
break;
case kRect_ClipType:
fClip.fRect = other.rect();
fOrigin.setZero();
break;
}
return *this;
}
@ -70,6 +61,9 @@ public:
}
switch (fClipType) {
default:
SkFAIL("Incomplete Switch\n");
return false;
case kWideOpen_ClipType:
return true;
case kClipStack_ClipType:
@ -86,9 +80,6 @@ public:
case kIRect_ClipType:
return this->irect() == other.irect();
break;
case kRect_ClipType:
return this->rect() == other.rect();
break;
}
}
@ -122,11 +113,6 @@ public:
return fClip.fIRect;
}
const SkRect& rect() const {
SkASSERT(kRect_ClipType == fClipType);
return fClip.fRect;
}
void reset() {
if (kClipStack_ClipType == fClipType) {
fClip.fStack->unref();
@ -146,15 +132,13 @@ public:
bool isWideOpen(const SkRect& rect) const {
return (kWideOpen_ClipType == fClipType) ||
(kClipStack_ClipType == fClipType && this->clipStack()->isWideOpen()) ||
(kIRect_ClipType == fClipType && this->irect().contains(rect)) ||
(kRect_ClipType == fClipType && this->rect().contains(rect));
(kIRect_ClipType == fClipType && this->irect().contains(rect));
}
bool isWideOpen(const SkIRect& rect) const {
return (kWideOpen_ClipType == fClipType) ||
(kClipStack_ClipType == fClipType && this->clipStack()->isWideOpen()) ||
(kIRect_ClipType == fClipType && this->irect().contains(rect)) ||
(kRect_ClipType == fClipType && this->rect().contains(rect));
(kIRect_ClipType == fClipType && this->irect().contains(rect));
}
bool isWideOpen() const {
@ -162,13 +146,6 @@ public:
(kClipStack_ClipType == fClipType && this->clipStack()->isWideOpen());
}
bool quickContains(const SkRect& rect) const {
return (kWideOpen_ClipType == fClipType) ||
(kClipStack_ClipType == fClipType && this->clipStack()->quickContains(rect)) ||
(kIRect_ClipType == fClipType && this->irect().contains(rect)) ||
(kRect_ClipType == fClipType && this->rect().contains(rect));
}
void getConservativeBounds(const GrSurface* surface,
SkIRect* devResult,
bool* isIntersectionOfRects = NULL) const {
@ -186,7 +163,6 @@ public:
kClipStack_ClipType,
kWideOpen_ClipType,
kIRect_ClipType,
kRect_ClipType,
};
ClipType clipType() const { return fClipType; }
@ -194,7 +170,6 @@ public:
private:
union Clip {
const SkClipStack* fStack;
SkRect fRect;
SkIRect fIRect;
} fClip;

View File

@ -361,6 +361,20 @@ public:
*/
GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
///////////////////////////////////////////////////////////////////////////
// Clip state
/**
* Gets the current clip.
* @return the current clip.
*/
const GrClip* getClip() const { return fClip; }
/**
* Sets the clip.
* @param clipData the clip to set.
*/
void setClip(const GrClip* clipData) { fClip = clipData; }
///////////////////////////////////////////////////////////////////////////
// Draws
@ -377,7 +391,7 @@ public:
/**
* Draw everywhere (respecting the clip) with the paint.
*/
void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
void drawPaint(GrRenderTarget*, const GrPaint&, const SkMatrix& viewMatrix);
/**
* Draw the rect using a paint.
@ -392,7 +406,6 @@ public:
* The rects coords are used to access the paint (through texture matrix)
*/
void drawRect(GrRenderTarget*,
const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect&,
@ -409,7 +422,6 @@ public:
* to rectToDraw
*/
void drawNonAARectToRect(GrRenderTarget*,
const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
@ -420,12 +432,11 @@ public:
* Draws a non-AA rect with paint and a localMatrix
*/
void drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix) {
this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &localMatrix);
this->drawNonAARectToRect(rt, paint, viewMatrix, rect, rect, &localMatrix);
}
/**
@ -438,7 +449,6 @@ public:
* the dash information (intervals, count, phase).
*/
void drawRRect(GrRenderTarget*,
const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
@ -455,7 +465,6 @@ public:
* @param inner the inner roundrect
*/
void drawDRRect(GrRenderTarget*,
const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkRRect& outer,
@ -472,7 +481,6 @@ public:
* the dash information (intervals, count, phase).
*/
void drawPath(GrRenderTarget*,
const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkPath&,
@ -496,7 +504,6 @@ public:
* number of indices.
*/
void drawVertices(GrRenderTarget*,
const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
@ -517,7 +524,6 @@ public:
* the dash information (intervals, count, phase).
*/
void drawOval(GrRenderTarget*,
const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
@ -659,6 +665,59 @@ public:
void dumpFontCache() const;
#endif
///////////////////////////////////////////////////////////////////////////
// Helpers
class AutoClip : public ::SkNoncopyable {
public:
// This enum exists to require a caller of the constructor to acknowledge that the clip will
// initially be wide open. It also could be extended if there are other desirable initial
// clip states.
enum InitialClip {
kWideOpen_InitialClip,
};
AutoClip(GrContext* context, InitialClip SkDEBUGCODE(initialState))
: fContext(context) {
SkASSERT(kWideOpen_InitialClip == initialState);
fNewClipData.setClipStack(&fNewClipStack);
fOldClip = context->getClip();
context->setClip(&fNewClipData);
}
AutoClip(GrContext* context, const SkRect& newClipRect)
: fContext(context)
, fNewClipStack(newClipRect) {
fNewClipData.setClipStack(&fNewClipStack);
fOldClip = fContext->getClip();
fContext->setClip(&fNewClipData);
}
~AutoClip() {
if (fContext) {
fContext->setClip(fOldClip);
}
}
private:
GrContext* fContext;
const GrClip* fOldClip;
SkClipStack fNewClipStack;
GrClip fNewClipData;
};
class AutoWideOpenIdentityDraw {
public:
AutoWideOpenIdentityDraw(GrContext* ctx)
: fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) {
}
private:
AutoClip fAutoClip;
};
///////////////////////////////////////////////////////////////////////////
// Functions intended for internal use only.
GrGpu* getGpu() { return fGpu; }
@ -702,6 +761,7 @@ public:
private:
GrGpu* fGpu;
const GrClip* fClip;
GrResourceCache* fResourceCache;
GrFontCache* fFontCache;
@ -742,16 +802,11 @@ private:
void setupDrawBuffer();
class AutoCheckFlush;
// Sets the paint and returns the target to draw into.
GrDrawTarget* prepareToDraw(GrPipelineBuilder*,
GrRenderTarget* rt,
const GrClip&,
const GrPaint* paint,
// Sets the paint and returns the target to draw into. This function is overloaded to either
// take a GrDrawState, GrPaint, and AutoCheckFlush, or JUST an AutoCheckFlush
GrDrawTarget* prepareToDraw(GrPipelineBuilder*, GrRenderTarget* rt, const GrPaint* paint,
const AutoCheckFlush*);
// A simpler version of the above which just returns the draw target. Clip is *NOT* set
GrDrawTarget* prepareToDraw();
void internalDrawPath(GrDrawTarget*,
GrPipelineBuilder*,
const SkMatrix& viewMatrix,

View File

@ -257,9 +257,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
return false;
}
// setup new clip
GrClip clip(dstRect);
GrContext::AutoClip acs(context, dstRect);
GrFragmentProcessor* fp;
offset->fX = bounds.left();
offset->fY = bounds.top();
@ -270,8 +268,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
SkASSERT(fp);
GrPaint paint;
paint.addColorProcessor(fp)->unref();
context->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(), dstRect,
srcRect);
context->drawNonAARectToRect(dst->asRenderTarget(), paint, SkMatrix::I(), dstRect, srcRect);
WrapTexture(dst, bounds.width(), bounds.height(), result);
return true;
@ -385,7 +382,7 @@ bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy,
// matrix with no clip and that the matrix, clip, and render target set before this function was
// called are restored before we return to the caller.
GrContext* context = src.getTexture()->getContext();
GrContext::AutoWideOpenIdentityDraw awoid(context);
if (this->canFilterImageGPU()) {
return this->filterImageGPU(proxy, src, ctx, result, offset);
} else {

View File

@ -318,7 +318,6 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRect& devBounds,
bool SkMaskFilter::directFilterMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const {
@ -329,7 +328,6 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRect& devBounds,
bool SkMaskFilter::directFilterRRectMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const {

View File

@ -292,8 +292,7 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
while (!iter.done()) {
SkRect rect = SkRect::Make(iter.rect());
context->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint,
in_matrix, rect);
context->drawRect(maskTexture->asRenderTarget(), grPaint, in_matrix, rect);
iter.next();
}
}

View File

@ -50,14 +50,12 @@ public:
virtual bool directFilterMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const SK_OVERRIDE;
virtual bool directFilterRRectMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const SK_OVERRIDE;
@ -832,7 +830,6 @@ GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random,
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const {
@ -866,7 +863,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
if (!viewMatrix.invert(&inverse)) {
return false;
}
context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), rect, inverse);
return true;
}
@ -1123,7 +1120,6 @@ GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const {
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkRRect& rrect) const {
@ -1152,7 +1148,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
if (!viewMatrix.invert(&inverse)) {
return false;
}
context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxy_rect, inverse);
context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), proxy_rect, inverse);
return true;
}
@ -1204,6 +1200,8 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
GrContext* context = src->getContext();
GrContext::AutoWideOpenIdentityDraw awo(context);
SkScalar xformedSigma = this->computeXformedSigma(ctm);
SkASSERT(xformedSigma > 0);
@ -1234,8 +1232,7 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
// = 0 * src + (1 - src) * dst
paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
}
context->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(),
clipRect);
context->drawRect((*result)->asRenderTarget(), paint, SkMatrix::I(), clipRect);
}
return true;

View File

@ -449,8 +449,7 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
-SkIntToScalar(colorBounds.y()));
context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matrix,
SkRect::Make(colorBounds));
context->drawRect(dst->asRenderTarget(), paint, matrix, SkRect::Make(colorBounds));
offset->fX = bounds.left();
offset->fY = bounds.top();
WrapTexture(dst, bounds.width(), bounds.height(), result);

View File

@ -45,7 +45,6 @@ static float adjust_sigma(float sigma, int maxTextureSize, int *scaleFactor, int
static void convolve_gaussian_1d(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
@ -58,12 +57,11 @@ static void convolve_gaussian_1d(GrContext* context,
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.addColorProcessor(conv);
context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
context->drawNonAARectToRect(rt, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian_2d(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
@ -81,12 +79,11 @@ static void convolve_gaussian_2d(GrContext* context,
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.addColorProcessor(conv);
context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
context->drawNonAARectToRect(rt, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
@ -96,7 +93,7 @@ static void convolve_gaussian(GrContext* context,
bool cropToSrcRect) {
float bounds[2] = { 0.0f, 1.0f };
if (!cropToSrcRect) {
convolve_gaussian_1d(context, rt, clip, srcRect, dstRect, texture,
convolve_gaussian_1d(context, rt, srcRect, dstRect, texture,
direction, radius, sigma, false, bounds);
return;
}
@ -128,15 +125,15 @@ static void convolve_gaussian(GrContext* context,
}
if (radius >= size * SK_ScalarHalf) {
// Blur radius covers srcRect; use bounds over entire draw
convolve_gaussian_1d(context, rt, clip, srcRect, dstRect, texture,
convolve_gaussian_1d(context, rt, srcRect, dstRect, texture,
direction, radius, sigma, true, bounds);
} else {
// Draw upper and lower margins with bounds; middle without.
convolve_gaussian_1d(context, rt, clip, lowerSrcRect, lowerDstRect, texture,
convolve_gaussian_1d(context, rt, lowerSrcRect, lowerDstRect, texture,
direction, radius, sigma, true, bounds);
convolve_gaussian_1d(context, rt, clip, upperSrcRect, upperDstRect, texture,
convolve_gaussian_1d(context, rt, upperSrcRect, upperDstRect, texture,
direction, radius, sigma, true, bounds);
convolve_gaussian_1d(context, rt, clip, middleSrcRect, middleDstRect, texture,
convolve_gaussian_1d(context, rt, middleSrcRect, middleDstRect, texture,
direction, radius, sigma, false, bounds);
}
}
@ -163,8 +160,7 @@ GrTexture* GaussianBlur(GrContext* context,
scale_rect(&srcRect, static_cast<float>(scaleFactorX),
static_cast<float>(scaleFactorY));
// setup new clip
GrClip clip(SkRect::MakeWH(srcRect.width(), srcRect.height()));
GrContext::AutoClip acs(context, SkRect::MakeWH(srcRect.width(), srcRect.height()));
SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() ||
kRGBA_8888_GrPixelConfig == srcTexture->config() ||
@ -217,8 +213,8 @@ GrTexture* GaussianBlur(GrContext* context,
}
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
context->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, SkMatrix::I(),
dstRect, srcRect);
context->drawNonAARectToRect(dstTexture->asRenderTarget(), paint, SkMatrix::I(), dstRect,
srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
@ -233,8 +229,8 @@ GrTexture* GaussianBlur(GrContext* context,
// We shouldn't be scaling because this is a small size blur
SkASSERT((scaleFactorX == scaleFactorY) == 1);
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
convolve_gaussian_2d(context, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
convolve_gaussian_2d(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@ -249,9 +245,8 @@ GrTexture* GaussianBlur(GrContext* context,
context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget());
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
convolve_gaussian(context, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
cropToRect);
convolve_gaussian(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
Gr1DKernelEffect::kX_Direction, radiusX, sigmaX, cropToRect);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@ -267,9 +262,8 @@ GrTexture* GaussianBlur(GrContext* context,
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
convolve_gaussian(context, dstTexture->asRenderTarget(), clip, srcRect,
dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
cropToRect);
convolve_gaussian(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
Gr1DKernelEffect::kY_Direction, radiusY, sigmaY, cropToRect);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@ -295,8 +289,8 @@ GrTexture* GaussianBlur(GrContext* context,
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
context->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
SkMatrix::I(), dstRect, srcRect);
context->drawNonAARectToRect(dstTexture->asRenderTarget(), paint, SkMatrix::I(), dstRect,
srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);

View File

@ -563,7 +563,6 @@ namespace {
void apply_morphology_rect(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
@ -577,13 +576,12 @@ void apply_morphology_rect(GrContext* context,
radius,
morphType,
bounds))->unref();
context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
context->drawNonAARectToRect(rt, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
void apply_morphology_rect_no_bounds(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
@ -595,13 +593,12 @@ void apply_morphology_rect_no_bounds(GrContext* context,
direction,
radius,
morphType))->unref();
context->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
context->drawNonAARectToRect(rt, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
void apply_morphology_pass(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
@ -633,16 +630,16 @@ void apply_morphology_pass(GrContext* context,
}
if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) {
// radius covers srcRect; use bounds over entire draw
apply_morphology_rect(context, rt, clip, texture, srcRect, dstRect, radius,
apply_morphology_rect(context, rt, texture, srcRect, dstRect, radius,
morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
apply_morphology_rect(context, rt, clip, texture, lowerSrcRect, lowerDstRect, radius,
apply_morphology_rect(context, rt,texture, lowerSrcRect, lowerDstRect, radius,
morphType, bounds, direction);
apply_morphology_rect(context, rt, clip, texture, upperSrcRect, upperDstRect, radius,
apply_morphology_rect(context, rt, texture, upperSrcRect, upperDstRect, radius,
morphType, bounds, direction);
apply_morphology_rect_no_bounds(context, rt, clip, texture, middleSrcRect, middleDstRect,
radius, morphType, direction);
apply_morphology_rect_no_bounds(context, rt, texture, middleSrcRect, middleDstRect, radius,
morphType, direction);
}
}
@ -655,8 +652,7 @@ bool apply_morphology(const SkBitmap& input,
SkASSERT(srcTexture);
GrContext* context = srcTexture->getContext();
// setup new clip
GrClip clip(SkRect::MakeWH(SkIntToScalar(srcTexture->width()),
GrContext::AutoClip acs(context, SkRect::MakeWH(SkIntToScalar(srcTexture->width()),
SkIntToScalar(srcTexture->height())));
SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height());
@ -672,9 +668,8 @@ bool apply_morphology(const SkBitmap& input,
if (NULL == texture) {
return false;
}
apply_morphology_pass(context, texture->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction);
apply_morphology_pass(context, texture->asRenderTarget(), srcTexture, srcRect, dstRect,
radius.fWidth, morphType, Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
dstRect.width(), radius.fHeight);
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
@ -689,9 +684,8 @@ bool apply_morphology(const SkBitmap& input,
if (NULL == texture) {
return false;
}
apply_morphology_pass(context, texture->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
apply_morphology_pass(context, texture->asRenderTarget(), srcTexture, srcRect, dstRect,
radius.fHeight, morphType, Gr1DKernelEffect::kY_Direction);
srcTexture.reset(texture);
}
SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst);

View File

@ -172,7 +172,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
GrPaint paint;
paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
paint.addColorProcessor(xferProcessor)->unref();
context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), srcRect);
context->drawRect(dst->asRenderTarget(), paint, SkMatrix::I(), srcRect);
offset->fX = backgroundOffset.fX;
offset->fY = backgroundOffset.fY;

View File

@ -70,9 +70,9 @@ bool GrBitmapTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatr
return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix);
}
inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint) {
GrTextContext::init(rt, clip, paint, skPaint);
inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrPaint& paint,
const SkPaint& skPaint) {
GrTextContext::init(rt, paint, skPaint);
fStrike = NULL;
@ -84,8 +84,8 @@ inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrClip& clip,
fTotalVertexCount = 0;
}
void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
@ -96,7 +96,7 @@ void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
return;
}
this->init(rt, clip, paint, skPaint);
this->init(rt, paint, skPaint);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
@ -184,8 +184,8 @@ void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
this->finish();
}
void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
@ -198,7 +198,7 @@ void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
return;
}
this->init(rt, clip, paint, skPaint);
this->init(rt, paint, skPaint);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
@ -455,7 +455,7 @@ void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed,
SkPath tmpPath(*glyph->fPath);
tmpPath.transform(translate);
GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
fContext->drawPath(fRenderTarget, fClip, fPaint, SkMatrix::I(), tmpPath, strokeInfo);
fContext->drawPath(fRenderTarget, fPaint, SkMatrix::I(), tmpPath, strokeInfo);
// remove this glyph from the vertices we need to allocate
fTotalVertexCount -= kVerticesPerGlyph;

View File

@ -40,16 +40,16 @@ private:
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawPosText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&);
void init(GrRenderTarget*, const GrPaint&, const SkPaint&);
void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
bool uploadGlyph(GrGlyph*, GrFontScaler*);
void flush(); // automatically called by destructor

View File

@ -21,6 +21,8 @@
void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const {
switch (fClipType) {
default:
SkFAIL("incomplete switch\n");
case kWideOpen_ClipType: {
devResult->setLTRB(0, 0, width, height);
if (isIntersectionOfRects) {
@ -33,15 +35,6 @@ void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult,
*isIntersectionOfRects = true;
}
} break;
case kRect_ClipType: {
devResult->setLTRB(SkScalarCeilToInt(this->rect().fLeft),
SkScalarCeilToInt(this->rect().fTop),
SkScalarCeilToInt(this->rect().fRight),
SkScalarCeilToInt(this->rect().fBottom));
if (isIntersectionOfRects) {
*isIntersectionOfRects = true;
}
} break;
case kClipStack_ClipType: {
SkRect devBounds;
this->clipStack()->getConservativeBounds(-this->origin().fX,

View File

@ -231,31 +231,14 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder,
bool ignoreClip = clip.isWideOpen(clipSpaceRTIBounds);
if (!ignoreClip) {
// The clip mask manager always draws with a single IRect so we special case that logic here
// Image filters just use a rect, so we also special case that logic
switch (clip.clipType()) {
case GrClip::kWideOpen_ClipType:
// we should have handled this case above
SkASSERT(false);
case GrClip::kIRect_ClipType: {
if (GrClip::kIRect_ClipType == clip.clipType()) {
initialState = GrReducedClip::kAllIn_InitialState;
clipSpaceIBounds = clip.irect();
SkNEW_INSERT_AT_LLIST_HEAD(&elements,
Element,
(SkRect::Make(clipSpaceIBounds),
SkRegion::kIntersect_Op, false));
} break;
case GrClip::kRect_ClipType: {
initialState = GrReducedClip::kAllIn_InitialState;
clipSpaceIBounds.setLTRB(SkScalarCeilToInt(clip.rect().fLeft),
SkScalarCeilToInt(clip.rect().fTop),
SkScalarCeilToInt(clip.rect().fRight),
SkScalarCeilToInt(clip.rect().fBottom));
SkNEW_INSERT_AT_LLIST_HEAD(&elements,
Element,
(SkRect::Make(clipSpaceIBounds),
SkRegion::kIntersect_Op, false));
} break;
case GrClip::kClipStack_ClipType: {
} else {
clipSpaceRTIBounds.offset(clip.origin());
GrReducedClip::ReduceClipStack(*clip.clipStack(),
clipSpaceRTIBounds,
@ -271,7 +254,6 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder,
return false;
}
}
} break;
}
}

View File

@ -86,6 +86,7 @@ GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
GrContext::GrContext(const Options& opts) : fOptions(opts) {
fGpu = NULL;
fClip = NULL;
fPathRendererChain = NULL;
fSoftwarePathRenderer = NULL;
fResourceCache = NULL;
@ -362,7 +363,7 @@ void GrContext::clear(const SkIRect* rect,
AutoCheckFlush acf(this);
GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
GrDrawTarget* target = this->prepareToDraw();
GrDrawTarget* target = this->prepareToDraw(NULL, renderTarget, NULL, &acf);
if (NULL == target) {
return;
}
@ -370,7 +371,6 @@ void GrContext::clear(const SkIRect* rect,
}
void GrContext::drawPaint(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& origPaint,
const SkMatrix& viewMatrix) {
// set rect to be big enough to fill the space, but not super-huge, so we
@ -398,7 +398,7 @@ void GrContext::drawPaint(GrRenderTarget* rt,
return;
}
inverse.mapRect(&r);
this->drawRect(rt, clip, *paint, viewMatrix, r);
this->drawRect(rt, *paint, viewMatrix, r);
} else {
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
@ -408,7 +408,7 @@ void GrContext::drawPaint(GrRenderTarget* rt,
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, paint, &acf);
if (NULL == target) {
return;
}
@ -502,7 +502,6 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
}
void GrContext::drawRect(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
@ -510,13 +509,13 @@ void GrContext::drawRect(GrRenderTarget* rt,
if (strokeInfo && strokeInfo->isDashed()) {
SkPath path;
path.addRect(rect);
this->drawPath(rt, clip, paint, viewMatrix, path, *strokeInfo);
this->drawPath(rt, paint, viewMatrix, path, *strokeInfo);
return;
}
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -530,13 +529,13 @@ void GrContext::drawRect(GrRenderTarget* rt,
SkRect rtRect;
pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect);
SkRect clipSpaceRTRect = rtRect;
bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType();
bool checkClip = fClip && GrClip::kWideOpen_ClipType != fClip->clipType();
if (checkClip) {
clipSpaceRTRect.offset(SkIntToScalar(clip.origin().fX),
SkIntToScalar(clip.origin().fY));
clipSpaceRTRect.offset(SkIntToScalar(this->getClip()->origin().fX),
SkIntToScalar(this->getClip()->origin().fY));
}
// Does the clip contain the entire RT?
if (!checkClip || clip.quickContains(clipSpaceRTRect)) {
if (!checkClip || fClip->clipStack()->quickContains(clipSpaceRTRect)) {
SkMatrix invM;
if (!viewMatrix.invert(&invM)) {
return;
@ -635,7 +634,6 @@ void GrContext::drawRect(GrRenderTarget* rt,
}
void GrContext::drawNonAARectToRect(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
@ -643,7 +641,7 @@ void GrContext::drawNonAARectToRect(GrRenderTarget* rt,
const SkMatrix* localMatrix) {
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -683,7 +681,6 @@ static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords
}
void GrContext::drawVertices(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
@ -697,7 +694,7 @@ void GrContext::drawVertices(GrRenderTarget* rt,
GrPipelineBuilder pipelineBuilder;
GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scope
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -746,7 +743,6 @@ void GrContext::drawVertices(GrRenderTarget* rt,
///////////////////////////////////////////////////////////////////////////////
void GrContext::drawRRect(GrRenderTarget*rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
@ -758,13 +754,13 @@ void GrContext::drawRRect(GrRenderTarget*rt,
if (strokeInfo.isDashed()) {
SkPath path;
path.addRRect(rrect);
this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo);
this->drawPath(rt, paint, viewMatrix, path, strokeInfo);
return;
}
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -791,7 +787,6 @@ void GrContext::drawRRect(GrRenderTarget*rt,
///////////////////////////////////////////////////////////////////////////////
void GrContext::drawDRRect(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& outer,
@ -802,7 +797,7 @@ void GrContext::drawDRRect(GrRenderTarget* rt,
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target);
@ -827,8 +822,7 @@ void GrContext::drawDRRect(GrRenderTarget* rt,
///////////////////////////////////////////////////////////////////////////////
void GrContext::drawOval(GrRenderTarget* rt,
const GrClip& clip,
void GrContext::drawOval(GrRenderTarget*rt,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
@ -840,13 +834,13 @@ void GrContext::drawOval(GrRenderTarget* rt,
if (strokeInfo.isDashed()) {
SkPath path;
path.addOval(oval);
this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo);
this->drawPath(rt, paint, viewMatrix, path, strokeInfo);
return;
}
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -924,7 +918,6 @@ static bool is_nested_rects(GrDrawTarget* target,
}
void GrContext::drawPath(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkPath& path,
@ -932,7 +925,7 @@ void GrContext::drawPath(GrRenderTarget* rt,
if (path.isEmpty()) {
if (path.isInverseFillType()) {
this->drawPaint(rt, clip, paint, viewMatrix);
this->drawPaint(rt, paint, viewMatrix);
}
return;
}
@ -943,7 +936,7 @@ void GrContext::drawPath(GrRenderTarget* rt,
if (path.isLine(pts)) {
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -960,11 +953,11 @@ void GrContext::drawPath(GrRenderTarget* rt,
GrStrokeInfo newStrokeInfo(strokeInfo, false);
SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr();
if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, info)) {
this->drawPath(rt, clip, paint, viewMatrix, *effectPath.get(), newStrokeInfo);
this->drawPath(rt, paint, viewMatrix, *effectPath.get(), newStrokeInfo);
return;
}
this->drawPath(rt, clip, paint, viewMatrix, path, newStrokeInfo);
this->drawPath(rt, paint, viewMatrix, path, newStrokeInfo);
return;
}
@ -975,7 +968,7 @@ void GrContext::drawPath(GrRenderTarget* rt,
// OK.
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, clip, &paint, &acf);
GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
@ -1204,10 +1197,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
// drawing a rect to the render target.
// The bracket ensures we pop the stack if we wind up flushing below.
{
GrDrawTarget* drawTarget = this->prepareToDraw();
if (!drawTarget) {
return false;
}
GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL, NULL);
GrDrawTarget::AutoGeometryPush agp(drawTarget);
GrPipelineBuilder pipelineBuilder;
@ -1393,7 +1383,7 @@ void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) {
SkASSERT(renderTarget);
ASSERT_OWNED_RESOURCE(renderTarget);
AutoCheckFlush acf(this);
GrDrawTarget* target = this->prepareToDraw();
GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, NULL);
if (NULL == target) {
return;
}
@ -1411,7 +1401,7 @@ void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe
// Since we're going to the draw target and not GPU, no need to check kNoFlush
// here.
GrDrawTarget* target = this->prepareToDraw();
GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, NULL);
if (NULL == target) {
return;
}
@ -1430,22 +1420,16 @@ void GrContext::flushSurfaceWrites(GrSurface* surface) {
GrDrawTarget* GrContext::prepareToDraw(GrPipelineBuilder* pipelineBuilder,
GrRenderTarget* rt,
const GrClip& clip,
const GrPaint* paint,
const AutoCheckFlush* acf) {
if (NULL == fGpu) {
return NULL;
}
if (pipelineBuilder) {
ASSERT_OWNED_RESOURCE(rt);
SkASSERT(rt && paint && acf);
pipelineBuilder->setFromPaint(*paint, rt, clip);
return fDrawBuffer;
}
GrDrawTarget* GrContext::prepareToDraw() {
if (NULL == fGpu) {
return NULL;
pipelineBuilder->setFromPaint(*paint, rt, fClip);
}
return fDrawBuffer;
}
@ -1529,7 +1513,7 @@ void GrContext::setupDrawBuffer() {
}
GrDrawTarget* GrContext::getTextTarget() {
return this->prepareToDraw();
return this->prepareToDraw(NULL, NULL, NULL, NULL);
}
const GrIndexBuffer* GrContext::getQuadIndexBuffer() const {

View File

@ -112,9 +112,9 @@ bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& v
return true;
}
inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint) {
GrTextContext::init(rt, clip, paint, skPaint);
inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrPaint& paint,
const SkPaint& skPaint) {
GrTextContext::init(rt, paint, skPaint);
fStrike = NULL;
@ -207,8 +207,7 @@ static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache,
}
}
void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint,
void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrPaint& paint,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
@ -269,12 +268,11 @@ void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrClip& cl
y -= alignY;
SkPoint offset = SkPoint::Make(x, y);
this->drawPosText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, positions.begin(), 2,
this->drawPosText(rt, paint, skPaint, viewMatrix, text, byteLength, positions.begin(), 2,
offset);
}
void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint,
void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrPaint& paint,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
@ -289,7 +287,7 @@ void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip&
}
fViewMatrix = viewMatrix;
this->init(rt, clip, paint, skPaint);
this->init(rt, paint, skPaint);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
@ -364,7 +362,7 @@ void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip&
this->finish();
if (fallbackTxt.count() > 0) {
fFallbackTextContext->drawPosText(rt, clip, paint, skPaint, viewMatrix, fallbackTxt.begin(),
fFallbackTextContext->drawPosText(rt, paint, skPaint, viewMatrix, fallbackTxt.begin(),
fallbackTxt.count(), fallbackPos.begin(),
scalarsPerPosition, offset);
}
@ -573,7 +571,7 @@ bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed,
tmpPath.transform(ctm);
GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
fContext->drawPath(fRenderTarget, fClip, fPaint, fViewMatrix, tmpPath, strokeInfo);
fContext->drawPath(fRenderTarget, fPaint, fViewMatrix, tmpPath, strokeInfo);
// remove this glyph from the vertices we need to allocate
fTotalVertexCount -= kVerticesPerGlyph;

View File

@ -52,17 +52,17 @@ private:
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawPosText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&);
void init(GrRenderTarget*, const GrPaint&, const SkPaint&);
bool appendGlyph(GrGlyph::PackedID, SkScalar left, SkScalar top, GrFontScaler*);
bool uploadGlyph(GrGlyph*, GrFontScaler*);
void setupCoverageEffect(const SkColor& filteredColor);

View File

@ -47,7 +47,7 @@ GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) {
return *this;
}
void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt, const GrClip& clip) {
void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt, const GrClip* clip) {
SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
fColorStages.reset();
@ -70,7 +70,9 @@ void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt, c
fStencilSettings.setDisabled();
fFlagBits = 0;
fClip = clip;
if (clip) {
fClip = *clip;
}
this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither());
this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias());

View File

@ -45,7 +45,7 @@ public:
* no GrPaint equivalents are set to default values with the exception of vertex attribute state
* which is unmodified by this function and clipping which will be enabled.
*/
void setFromPaint(const GrPaint&, GrRenderTarget*, const GrClip&);
void setFromPaint(const GrPaint&, GrRenderTarget*, const GrClip*);
/// @}

View File

@ -65,7 +65,6 @@ bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint, const SkMatrix&
}
void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
@ -93,7 +92,7 @@ void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt,
// will turn off the use of device-space glyphs when perspective transforms
// are in use.
this->init(rt, clip, paint, skPaint, byteLength, kMaxAccuracy_RenderMode, viewMatrix);
this->init(rt, paint, skPaint, byteLength, kMaxAccuracy_RenderMode, viewMatrix);
// Transform our starting point.
if (fUsingDeviceSpaceGlyphs) {
@ -156,7 +155,6 @@ void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt,
}
void GrStencilAndCoverTextContext::onDrawPosText(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
@ -181,7 +179,7 @@ void GrStencilAndCoverTextContext::onDrawPosText(GrRenderTarget* rt,
// transform is not part of SkPaint::measureText API, and thus we use the
// same glyphs as what were measured.
this->init(rt, clip, paint, skPaint, byteLength, kMaxPerformance_RenderMode, viewMatrix);
this->init(rt, paint, skPaint, byteLength, kMaxPerformance_RenderMode, viewMatrix);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
@ -234,13 +232,12 @@ static GrPathRange* get_gr_glyphs(GrContext* ctx,
}
void GrStencilAndCoverTextContext::init(GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
size_t textByteLength,
RenderMode renderMode,
const SkMatrix& viewMatrix) {
GrTextContext::init(rt, clip, paint, skPaint);
GrTextContext::init(rt, paint, skPaint);
fContextInitialMatrix = viewMatrix;
fViewMatrix = viewMatrix;
@ -445,7 +442,7 @@ void GrStencilAndCoverTextContext::flush() {
inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyphCount);
}
fFallbackTextContext->drawPosText(fRenderTarget, fClip, paintFallback, skPaintFallback,
fFallbackTextContext->drawPosText(fRenderTarget, paintFallback, skPaintFallback,
fViewMatrix, (char*)&fGlyphIndices[fFallbackGlyphsIdx],
2 * fallbackGlyphCount,
get_xy_scalar_array(&fGlyphPositions[fFallbackGlyphsIdx]),

View File

@ -71,18 +71,18 @@ private:
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawPosText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
size_t textByteLength, RenderMode, const SkMatrix& viewMatrix);
void init(GrRenderTarget*, const GrPaint&, const SkPaint&, size_t textByteLength, RenderMode,
const SkMatrix& viewMatrix);
bool mapToFallbackContext(SkMatrix* inverse);
void appendGlyph(const SkGlyph&, const SkPoint&);
void flush();

View File

@ -7,11 +7,10 @@
#include "GrTextContext.h"
#include "GrContext.h"
#include "GrDrawTarget.h"
#include "GrFontScaler.h"
#include "SkAutoKern.h"
#include "SkGlyphCache.h"
#include "GrFontScaler.h"
GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& properties) :
fFallbackTextContext(NULL),
@ -22,13 +21,12 @@ GrTextContext::~GrTextContext() {
SkDELETE(fFallbackTextContext);
}
void GrTextContext::init(GrRenderTarget* rt, const GrClip& clip, const GrPaint& grPaint,
const SkPaint& skPaint) {
fClip = clip;
void GrTextContext::init(GrRenderTarget* rt, const GrPaint& grPaint, const SkPaint& skPaint) {
fClip = fContext->getClip();
fRenderTarget.reset(SkRef(rt));
fClip.getConservativeBounds(fRenderTarget->width(), fRenderTarget->height(), &fClipRect);
fClip->getConservativeBounds(fRenderTarget->width(), fRenderTarget->height(), &fClipRect);
fDrawTarget = fContext->getTextTarget();
@ -36,15 +34,15 @@ void GrTextContext::init(GrRenderTarget* rt, const GrClip& clip, const GrPaint&
fSkPaint = skPaint;
}
bool GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPaint& paint,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
bool GrTextContext::drawText(GrRenderTarget* rt, const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
GrTextContext* textContext = this;
do {
if (textContext->canDraw(skPaint, viewMatrix)) {
textContext->onDrawText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, x, y);
textContext->onDrawText(rt, paint, skPaint, viewMatrix, text, byteLength, x, y);
return true;
}
textContext = textContext->fFallbackTextContext;
@ -53,8 +51,8 @@ bool GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
return false;
}
bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const GrPaint& paint,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) {
@ -62,7 +60,7 @@ bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr
GrTextContext* textContext = this;
do {
if (textContext->canDraw(skPaint, viewMatrix)) {
textContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, pos,
textContext->onDrawPosText(rt, paint, skPaint, viewMatrix, text, byteLength, pos,
scalarsPerPosition, offset);
return true;
}

View File

@ -15,7 +15,6 @@
#include "SkPostConfig.h"
class GrClip;
class GrContext;
class GrDrawTarget;
class GrFontScaler;
@ -27,11 +26,9 @@ class GrTextContext {
public:
virtual ~GrTextContext();
bool drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x,
SkScalar y);
bool drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
bool drawText(GrRenderTarget* rt, const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, SkScalar x, SkScalar y);
bool drawPosText(GrRenderTarget* rt, const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset);
@ -42,7 +39,7 @@ protected:
SkDeviceProperties fDeviceProperties;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
GrClip fClip;
const GrClip* fClip;
GrDrawTarget* fDrawTarget;
SkIRect fClipRect;
GrPaint fPaint;
@ -52,16 +49,16 @@ protected:
virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0;
virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
SkScalar x, SkScalar y) = 0;
virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
virtual void onDrawPosText(GrRenderTarget*, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) = 0;
void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&);
void init(GrRenderTarget*, const GrPaint&, const SkPaint&);
void finish() { fDrawTarget = NULL; }
static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);

View File

@ -220,6 +220,10 @@ SkGpuDevice::~SkGpuDevice() {
delete fTextContext;
if (fContext->getClip() == &fClipData) {
fContext->setClip(NULL);
}
fRenderTarget->unref();
fContext->unref();
}
@ -277,7 +281,7 @@ void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
void SkGpuDevice::onDetachFromCanvas() {
INHERITED::onDetachFromCanvas();
fClip.reset();
fClipData.reset();
fClipStack.reset(NULL);
}
@ -288,7 +292,9 @@ void SkGpuDevice::prepareDraw(const SkDraw& draw) {
SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack);
fClip.setClipStack(fClipStack, &this->getOrigin());
fClipData.setClipStack(fClipStack, &this->getOrigin());
fContext->setClip(&fClipData);
DO_DEFERRED_CLEAR();
}
@ -360,7 +366,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
fContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix);
fContext->drawPaint(fRenderTarget, grPaint, *draw.fMatrix);
}
// must be in SkCanvas::PointMode order
@ -388,7 +394,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
path.setIsVolatile(true);
path.moveTo(pts[0]);
path.lineTo(pts[1]);
fContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, path, strokeInfo);
fContext->drawPath(fRenderTarget, grPaint, *draw.fMatrix, path, strokeInfo);
return;
}
@ -403,7 +409,6 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
fContext->drawVertices(fRenderTarget,
fClip,
grPaint,
*draw.fMatrix,
gPointMode2PrimtiveType[mode],
@ -474,7 +479,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
fContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
fContext->drawRect(fRenderTarget, grPaint, *draw.fMatrix, rect, &strokeInfo);
}
///////////////////////////////////////////////////////////////////////////////
@ -509,7 +514,6 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext,
fRenderTarget,
&grPaint,
fClip,
*draw.fMatrix,
strokeInfo.getStrokeRec(),
devRRect)) {
@ -542,7 +546,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
return;
}
fContext->drawRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, strokeInfo);
fContext->drawRRect(fRenderTarget, grPaint, *draw.fMatrix, rect, strokeInfo);
}
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
@ -557,7 +561,7 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) {
fContext->drawDRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, outer, inner);
fContext->drawDRRect(fRenderTarget, grPaint, *draw.fMatrix, outer, inner);
return;
}
}
@ -604,7 +608,7 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
fContext->drawOval(fRenderTarget, fClip, grPaint, *draw.fMatrix, oval, strokeInfo);
fContext->drawOval(fRenderTarget, grPaint, *draw.fMatrix, oval, strokeInfo);
}
#include "SkMaskFilter.h"
@ -619,7 +623,6 @@ namespace {
// Return true if the mask was successfully drawn.
bool draw_mask(GrContext* context,
GrRenderTarget* rt,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkRect& maskRect,
GrPaint* grp,
@ -635,13 +638,12 @@ bool draw_mask(GrContext* context,
if (!viewMatrix.invert(&inverse)) {
return false;
}
context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), maskRect, inverse);
context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), maskRect, inverse);
return true;
}
bool draw_with_mask_filter(GrContext* context,
GrRenderTarget* rt,
const GrClip& clipData,
const SkMatrix& viewMatrix,
const SkPath& devPath,
SkMaskFilter* filter,
@ -683,7 +685,7 @@ bool draw_with_mask_filter(GrContext* context,
SkRect maskRect = SkRect::Make(dstM.fBounds);
return draw_mask(context, rt, clipData, viewMatrix, maskRect, grp, texture);
return draw_mask(context, rt, viewMatrix, maskRect, grp, texture);
}
// Create a mask of 'devPath' and place the result in 'mask'.
@ -715,19 +717,18 @@ GrTexture* create_mask_GPU(GrContext* context,
SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height());
GrContext::AutoClip ac(context, clipRect);
context->clear(NULL, 0x0, true, mask->asRenderTarget());
GrPaint tempPaint;
tempPaint.setAntiAlias(doAA);
tempPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
// setup new clip
GrClip clip(clipRect);
// Draw the mask into maskTexture with the path's top-left at the origin using tempPaint.
SkMatrix translate;
translate.setTranslate(-maskRect.fLeft, -maskRect.fTop);
context->drawPath(mask->asRenderTarget(), clip, tempPaint, translate, devPath, strokeInfo);
context->drawPath(mask->asRenderTarget(), tempPaint, translate, devPath, strokeInfo);
return mask;
}
@ -832,7 +833,6 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
if (paint.getMaskFilter()->directFilterMaskGPU(fContext,
fRenderTarget,
&grPaint,
fClip,
viewMatrix,
stroke,
*devPathPtr)) {
@ -855,12 +855,7 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
if (paint.getMaskFilter()->filterMaskGPU(mask, viewMatrix, maskRect, &filtered, true)) {
// filterMaskGPU gives us ownership of a ref to the result
SkAutoTUnref<GrTexture> atu(filtered);
if (draw_mask(fContext,
fRenderTarget,
fClip,
viewMatrix,
maskRect,
&grPaint,
if (draw_mask(fContext, fRenderTarget, viewMatrix, maskRect, &grPaint,
filtered)) {
// This path is completely drawn
return;
@ -873,12 +868,12 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
// GPU path fails
SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style;
draw_with_mask_filter(fContext, fRenderTarget, fClip, viewMatrix, *devPathPtr,
draw_with_mask_filter(fContext, fRenderTarget, viewMatrix, *devPathPtr,
paint.getMaskFilter(), *draw.fClip, &grPaint, style);
return;
}
fContext->drawPath(fRenderTarget, fClip, grPaint, viewMatrix, *pathPtr, strokeInfo);
fContext->drawPath(fRenderTarget, grPaint, viewMatrix, *pathPtr, strokeInfo);
}
static const int kBmpSmallTileSize = 1 << 10;
@ -911,12 +906,12 @@ static int determine_tile_size(const SkBitmap& bitmap, const SkIRect& src, int m
// pixels from the bitmap are necessary.
static void determine_clipped_src_rect(const GrContext* context,
const GrRenderTarget* rt,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkBitmap& bitmap,
const SkRect* srcRectPtr,
SkIRect* clippedSrcIRect) {
clip.getConservativeBounds(rt, clippedSrcIRect, NULL);
const GrClip* clip = context->getClip();
clip->getConservativeBounds(rt, clippedSrcIRect, NULL);
SkMatrix inv;
if (!viewMatrix.invert(&inv)) {
clippedSrcIRect->setEmpty();
@ -953,8 +948,8 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
// if it's larger than the max tile size, then we have no choice but tiling.
if (bitmap.width() > maxTileSize || bitmap.height() > maxTileSize) {
determine_clipped_src_rect(fContext, fRenderTarget, fClip, viewMatrix, bitmap,
srcRectPtr, clippedSrcRect);
determine_clipped_src_rect(fContext, fRenderTarget, viewMatrix, bitmap, srcRectPtr,
clippedSrcRect);
*tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize);
return true;
}
@ -983,7 +978,7 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
}
// Figure out how much of the src we will need based on the src rect and clipping.
determine_clipped_src_rect(fContext, fRenderTarget, fClip, viewMatrix, bitmap, srcRectPtr,
determine_clipped_src_rect(fContext, fRenderTarget, viewMatrix, bitmap, srcRectPtr,
clippedSrcRect);
*tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max sized tile.
size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) *
@ -1457,8 +1452,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
SkColor2GrColor(paint.getColor());
SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, false, &grPaint);
fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect,
paintRect);
fContext->drawNonAARectToRect(fRenderTarget, grPaint, viewMatrix, dstRect, paintRect);
}
bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
@ -1472,6 +1466,8 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().pixelGeometry()));
if (filter->canFilterImageGPU()) {
// Set the clip wide open and the matrix to identity.
GrContext::AutoWideOpenIdentityDraw awo(context);
return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result, offset);
} else {
return false;
@ -1527,7 +1523,6 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
SkColor2GrColorJustAlpha(paint.getColor()), false, &grPaint);
fContext->drawNonAARectToRect(fRenderTarget,
fClip,
grPaint,
SkMatrix::I(),
SkRect::MakeXYWH(SkIntToScalar(left),
@ -1650,8 +1645,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
SK_Scalar1 * h / devTex->height());
fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, SkMatrix::I(), dstRect,
srcRect);
fContext->drawNonAARectToRect(fRenderTarget, grPaint, SkMatrix::I(), dstRect, srcRect);
}
bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
@ -1785,7 +1779,6 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
colors = convertedColors.get();
}
fContext->drawVertices(fRenderTarget,
fClip,
grPaint,
*draw.fMatrix,
primType,
@ -1810,8 +1803,8 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
SkDEBUGCODE(this->validate();)
if (!fTextContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix,
(const char *)text, byteLength, x, y)) {
if (!fTextContext->drawText(fRenderTarget, grPaint, paint, *draw.fMatrix, (const char *)text,
byteLength, x, y)) {
// this will just call our drawPath()
draw.drawText_asPaths((const char*)text, byteLength, x, y, paint);
}
@ -1828,8 +1821,8 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
SkDEBUGCODE(this->validate();)
if (!fTextContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix,
(const char *)text, byteLength, pos, scalarsPerPos, offset)) {
if (!fTextContext->drawPosText(fRenderTarget, grPaint, paint, *draw.fMatrix, (const char *)text,
byteLength, pos, scalarsPerPos, offset)) {
// this will just call our drawPath()
draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
}

View File

@ -137,7 +137,7 @@ private:
GrSkDrawProcs* fDrawProcs;
SkAutoTUnref<const SkClipStack> fClipStack;
SkIPoint fClipOrigin;
GrClip fClip;
GrClip fClipData;
GrTextContext* fTextContext;
SkSurfaceProps fSurfaceProps;
GrRenderTarget* fRenderTarget;

View File

@ -243,8 +243,9 @@ GrTexture* stretch_texture_to_next_pot(GrTexture* inputTexture, Stretch stretch,
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
SkRect localRect = SkRect::MakeWH(1.f, 1.f);
context->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOpen(), paint,
SkMatrix::I(), rect, localRect);
GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip);
context->drawNonAARectToRect(stretched->asRenderTarget(), paint, SkMatrix::I(), rect,
localRect);
return stretched;
}
@ -391,8 +392,8 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrUniqueKey& optionalKe
paint.addColorProcessor(yuvToRgbProcessor);
SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
SkIntToScalar(yuvInfo.fSize[0].fHeight));
ctx->drawRect(renderTarget, GrClip::WideOpen(), paint, SkMatrix::I(), r);
GrContext::AutoClip ac(ctx, GrContext::AutoClip::kWideOpen_InitialClip);
ctx->drawRect(renderTarget, paint, SkMatrix::I(), r);
return result;
}
@ -705,6 +706,8 @@ void SkPaint2GrPaintShader(GrContext* context, GrRenderTarget* rt, const SkPaint
// asFragmentProcessor(). Since these calls get passed back to the client, we don't really
// want them messing around with the context.
{
GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip);
// Allow the shader to modify paintColor and also create an effect to be installed as
// the first color effect on the GrPaint.
GrFragmentProcessor* fp = NULL;

View File

@ -205,6 +205,8 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
{kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
};
GrContext::AutoWideOpenIdentityDraw awoid(context);
bool failed = true;
for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
@ -229,31 +231,19 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
GrPaint paint1;
paint1.addColorProcessor(pmToUPM1);
context->drawNonAARectToRect(readTex->asRenderTarget(),
GrClip::WideOpen(),
paint1,
SkMatrix::I(),
kDstRect,
context->drawNonAARectToRect(readTex->asRenderTarget(), paint1, SkMatrix::I(), kDstRect,
kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
GrPaint paint2;
paint2.addColorProcessor(upmToPM);
context->drawNonAARectToRect(tempTex->asRenderTarget(),
GrClip::WideOpen(),
paint2,
SkMatrix::I(),
kDstRect,
context->drawNonAARectToRect(tempTex->asRenderTarget(), paint2, SkMatrix::I(), kDstRect,
kSrcRect);
GrPaint paint3;
paint3.addColorProcessor(pmToUPM2);
context->drawNonAARectToRect(readTex->asRenderTarget(),
GrClip::WideOpen(),
paint3,
SkMatrix::I(),
kDstRect,
context->drawNonAARectToRect(readTex->asRenderTarget(), paint3, SkMatrix::I(), kDstRect,
kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);

View File

@ -84,17 +84,17 @@ static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* context) {
REPORTER_ASSERT(reporter, screen == devStackBounds);
REPORTER_ASSERT(reporter, isIntersectionOfRects);
// wrap the SkClipStack in a GrClip
// wrap the SkClipStack in a GrClipData
GrClip clipData;
clipData.setClipStack(&stack);
SkIRect devGrClipBound;
SkIRect devGrClipDataBound;
clipData.getConservativeBounds(texture,
&devGrClipBound,
&devGrClipDataBound,
&isIntersectionOfRects);
// make sure that GrClip is behaving itself
REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
// make sure that GrClipData is behaving itself
REPORTER_ASSERT(reporter, intScreen == devGrClipDataBound);
REPORTER_ASSERT(reporter, isIntersectionOfRects);
}

View File

@ -247,7 +247,7 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
SkClipStack stack;
stack.clipDevRect(screen, SkRegion::kReplace_Op, false);
// wrap the SkClipStack in a GrClip
// wrap the SkClipStack in a GrClipData
GrClip clip;
clip.setClipStack(&stack);