GrContext::AutoClip acs(ctx, SkRect::MakeWH(2*S, 2*S));
- ctx->setRenderTarget(target);
-
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrcOver_Mode);
tm.postIDiv(2*S, 2*S);
paint.addColorTextureProcessor(texture, tm);
- ctx->drawRect(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
texture->writePixels(S, (i ? 0 : S), S, S,
texture->config(), gTextureData.get(),
4 * stride);
- ctx->drawRect(paint, vm, SkRect::MakeWH(2*S, 2*S));
+ ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S));
}
} else {
this->drawGpuOnlyMessage(canvas);
class GrContext;
class GrPaint;
+class GrRenderTarget;
class SkBitmap;
class SkBlitter;
class SkCachedData;
* true if drawing was successful.
*/
virtual bool directFilterMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
* true if drawing was successful.
*/
virtual bool directFilterRRectMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
*/
void setMaxTextureSizeOverride(int maxTextureSizeOverride);
- ///////////////////////////////////////////////////////////////////////////
- // Render targets
-
- /**
- * Sets the render target.
- * @param target the render target to set.
- */
- void setRenderTarget(GrRenderTarget* target) {
- fRenderTarget.reset(SkSafeRef(target));
- }
-
- /**
- * Gets the current render target.
- * @return the currently bound render target.
- */
- const GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
- GrRenderTarget* getRenderTarget() { return fRenderTarget.get(); }
-
/**
* Can the provided configuration act as a color render target?
*/
/**
* Draw everywhere (respecting the clip) with the paint.
*/
- void drawPaint(const GrPaint&, const SkMatrix& viewMatrix);
+ void drawPaint(GrRenderTarget*, const GrPaint&, const SkMatrix& viewMatrix);
/**
* Draw the rect using a paint.
* mitered/beveled stroked based on stroke width.
* The rects coords are used to access the paint (through texture matrix)
*/
- void drawRect(const GrPaint& paint,
+ void drawRect(GrRenderTarget*,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect&,
const GrStrokeInfo* strokeInfo = NULL);
* @param localMatrix an optional matrix to transform the shader coordinates before applying
* to rectToDraw
*/
- void drawNonAARectToRect(const GrPaint& paint,
+ void drawNonAARectToRect(GrRenderTarget*,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkRect& localRect,
/**
* Draws a non-AA rect with paint and a localMatrix
*/
- void drawNonAARectWithLocalMatrix(const GrPaint& paint,
+ void drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix) {
- this->drawNonAARectToRect(paint, viewMatrix, rect, rect, &localMatrix);
+ this->drawNonAARectToRect(rt, paint, viewMatrix, rect, rect, &localMatrix);
}
/**
* @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase).
*/
- void drawRRect(const GrPaint&, const SkMatrix& viewMatrix, const SkRRect& rrect,
+ void drawRRect(GrRenderTarget*,
+ const GrPaint&,
+ const SkMatrix& viewMatrix,
+ const SkRRect& rrect,
const GrStrokeInfo&);
/**
* @param outer the outer roundrect
* @param inner the inner roundrect
*/
- void drawDRRect(const GrPaint&, const SkMatrix& viewMatrix, const SkRRect& outer,
+ void drawDRRect(GrRenderTarget*,
+ const GrPaint&,
+ const SkMatrix& viewMatrix,
+ const SkRRect& outer,
const SkRRect& inner);
* @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase).
*/
- void drawPath(const GrPaint&, const SkMatrix& viewMatrix, const SkPath&, const GrStrokeInfo&);
+ void drawPath(GrRenderTarget*,
+ const GrPaint&,
+ const SkMatrix& viewMatrix,
+ const SkPath&,
+ const GrStrokeInfo&);
/**
* Draws vertices with a paint.
* @param indexCount if indices is non-null then this is the
* number of indices.
*/
- void drawVertices(const GrPaint& paint,
+ void drawVertices(GrRenderTarget*,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
int vertexCount,
* @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase).
*/
- void drawOval(const GrPaint& paint,
+ void drawOval(GrRenderTarget*,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
const GrStrokeInfo& strokeInfo);
///////////////////////////////////////////////////////////////////////////
// Helpers
- class AutoRenderTarget : public ::SkNoncopyable {
- public:
- AutoRenderTarget(GrContext* context, GrRenderTarget* target) {
- fPrevTarget = context->getRenderTarget();
- SkSafeRef(fPrevTarget);
- context->setRenderTarget(target);
- fContext = context;
- }
- AutoRenderTarget(GrContext* context) {
- fPrevTarget = context->getRenderTarget();
- SkSafeRef(fPrevTarget);
- fContext = context;
- }
- ~AutoRenderTarget() {
- if (fContext) {
- fContext->setRenderTarget(fPrevTarget);
- }
- SkSafeUnref(fPrevTarget);
- }
- private:
- GrContext* fContext;
- GrRenderTarget* fPrevTarget;
- };
-
class AutoClip : public ::SkNoncopyable {
public:
// This enum exists to require a caller of the constructor to acknowledge that the clip will
class AutoWideOpenIdentityDraw {
public:
- AutoWideOpenIdentityDraw(GrContext* ctx, GrRenderTarget* rt)
- : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip)
- , fAutoRT(ctx, rt) {
+ AutoWideOpenIdentityDraw(GrContext* ctx)
+ : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) {
}
private:
AutoClip fAutoClip;
- AutoRenderTarget fAutoRT;
};
///////////////////////////////////////////////////////////////////////////
private:
GrGpu* fGpu;
- SkAutoTUnref<GrRenderTarget> fRenderTarget;
const GrClipData* fClip; // TODO: make this ref counted
GrResourceCache* fResourceCache;
class AutoCheckFlush;
// 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*, const GrPaint* paint, const AutoCheckFlush*);
+ GrDrawTarget* prepareToDraw(GrPipelineBuilder*, GrRenderTarget* rt, const GrPaint* paint,
+ const AutoCheckFlush*);
void internalDrawPath(GrDrawTarget*,
GrPipelineBuilder*,
// that the final paint will draw the same color at every pixel. This allows
// an optimization where the the color filter can be applied to the SkPaint's
// color once while converting to GrPaint and then ignored.
-void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
- bool constantColor, GrPaint* grPaint);
+void SkPaint2GrPaintNoShader(GrContext* context, GrRenderTarget*, const SkPaint& skPaint,
+ GrColor paintColor, bool constantColor, GrPaint* grPaint);
// This function is similar to skPaint2GrPaintNoShader but also converts
// skPaint's shader to a GrFragmentProcessor if possible.
// constantColor has the same meaning as in skPaint2GrPaintNoShader.
-void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint,
+void SkPaint2GrPaintShader(GrContext* context, GrRenderTarget*, const SkPaint& skPaint,
const SkMatrix& viewM, bool constantColor, GrPaint* grPaint);
////////////////////////////////////////////////////////////////////////////////
if (!IsGpuDeviceType(dType)) {
// need to send the raster bits to the (gpu) window
- fCurContext->setRenderTarget(fCurRenderTarget);
const SkBitmap& bm = win->getBitmap();
fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(),
SkImageInfo2GrPixelConfig(bm.colorType(),
if (!dst) {
return false;
}
- GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
+
GrContext::AutoClip acs(context, dstRect);
GrFragmentProcessor* fp;
offset->fX = bounds.left();
SkASSERT(fp);
GrPaint paint;
paint.addColorProcessor(fp)->unref();
- context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(dst->asRenderTarget(), paint, SkMatrix::I(), dstRect, srcRect);
WrapTexture(dst, bounds.width(), bounds.height(), result);
return true;
// 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, NULL);
+ GrContext::AutoWideOpenIdentityDraw awoid(context);
if (this->canFilterImageGPU()) {
return this->filterImageGPU(proxy, src, ctx, result, offset);
} else {
}
bool SkMaskFilter::directFilterMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
bool SkMaskFilter::directFilterRRectMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
}
{
- GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget());
GrPaint grPaint;
grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkRegion::Iterator iter(fRegion);
while (!iter.done()) {
SkRect rect = SkRect::Make(iter.rect());
- context->drawRect(grPaint, in_matrix, rect);
+ context->drawRect(maskTexture->asRenderTarget(), grPaint, in_matrix, rect);
iter.next();
}
}
const SkMatrix& ctm,
SkRect* maskRect) const SK_OVERRIDE;
virtual bool directFilterMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
const SkPath& path) const SK_OVERRIDE;
virtual bool directFilterRRectMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
if (!viewMatrix.invert(&inverse)) {
return false;
}
- context->drawNonAARectWithLocalMatrix(*grp, SkMatrix::I(), rect, inverse);
+ context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), rect, inverse);
return true;
}
}
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
+ GrRenderTarget* rt,
GrPaint* grp,
const SkMatrix& viewMatrix,
const SkStrokeRec& strokeRec,
if (!viewMatrix.invert(&inverse)) {
return false;
}
- context->drawNonAARectWithLocalMatrix(*grp, SkMatrix::I(), proxy_rect, inverse);
+ context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), proxy_rect, inverse);
return true;
}
GrContext* context = src->getContext();
- GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
+ GrContext::AutoWideOpenIdentityDraw awo(context);
SkScalar xformedSigma = this->computeXformedSigma(ctm);
SkASSERT(xformedSigma > 0);
SkMatrix matrix;
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
paint.addCoverageProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref();
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
// = 0 * src + (1 - src) * dst
paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
}
- context->drawRect(paint, SkMatrix::I(), clipRect);
+ context->drawRect((*result)->asRenderTarget(), paint, SkMatrix::I(), clipRect);
}
return true;
return false;
}
- GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
-
SkVector scale = SkVector::Make(fScale, fScale);
ctx.ctm().mapVectors(&scale, 1);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
-SkIntToScalar(colorBounds.y()));
- context->drawRect(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);
}
static void convolve_gaussian_1d(GrContext* context,
+ GrRenderTarget* rt,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.addColorProcessor(conv);
- context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(rt, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian_2d(GrContext* context,
+ GrRenderTarget* rt,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.addColorProcessor(conv);
- context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(rt, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian(GrContext* context,
+ GrRenderTarget* rt,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
bool cropToSrcRect) {
float bounds[2] = { 0.0f, 1.0f };
if (!cropToSrcRect) {
- convolve_gaussian_1d(context, srcRect, dstRect, texture,
+ convolve_gaussian_1d(context, rt, srcRect, dstRect, texture,
direction, radius, sigma, false, bounds);
return;
}
}
if (radius >= size * SK_ScalarHalf) {
// Blur radius covers srcRect; use bounds over entire draw
- convolve_gaussian_1d(context, 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, lowerSrcRect, lowerDstRect, texture,
+ convolve_gaussian_1d(context, rt, lowerSrcRect, lowerDstRect, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(context, upperSrcRect, upperDstRect, texture,
+ convolve_gaussian_1d(context, rt, upperSrcRect, upperDstRect, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(context, middleSrcRect, middleDstRect, texture,
+ convolve_gaussian_1d(context, rt, middleSrcRect, middleDstRect, texture,
direction, radius, sigma, false, bounds);
}
}
float sigmaY) {
SkASSERT(context);
- GrContext::AutoRenderTarget art(context);
-
SkIRect clearRect;
int scaleFactorX, radiusX;
int scaleFactorY, radiusY;
GrPaint paint;
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
- context->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect(srcRect);
if (cropToRect && i == 1) {
dstRect.offset(-dstRect.fLeft, -dstRect.fTop);
}
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
- context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(dstTexture->asRenderTarget(), paint, SkMatrix::I(), dstRect,
+ srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
(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);
- context->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian_2d(context, 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);
// X convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
radiusX, srcIRect.height());
- context->clear(&clearRect, 0x0, false, context->getRenderTarget());
+ context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget());
}
- context->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(context, srcRect, dstRect, srcTexture,
+ convolve_gaussian(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
Gr1DKernelEffect::kX_Direction, radiusX, sigmaX, cropToRect);
srcTexture = dstTexture;
srcRect = dstRect;
// convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width(), radiusY);
- context->clear(&clearRect, 0x0, false, context->getRenderTarget());
+ context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget());
}
- context->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- convolve_gaussian(context, srcRect, dstRect, srcTexture,
+ convolve_gaussian(context, dstTexture->asRenderTarget(), srcRect, dstRect, srcTexture,
Gr1DKernelEffect::kY_Direction, radiusY, sigmaY, cropToRect);
srcTexture = dstTexture;
srcRect = dstRect;
// upsampling.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width() + 1, 1);
- context->clear(&clearRect, 0x0, false, context->getRenderTarget());
+ context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget());
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height());
- context->clear(&clearRect, 0x0, false, context->getRenderTarget());
+ context->clear(&clearRect, 0x0, false, srcTexture->asRenderTarget());
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
- context->setRenderTarget(dstTexture->asRenderTarget());
GrPaint paint;
// FIXME: this should be mitchell, not bilinear.
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
- context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
+ context->drawNonAARectToRect(dstTexture->asRenderTarget(), paint, SkMatrix::I(), dstRect,
+ srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
void apply_morphology_rect(GrContext* context,
+ GrRenderTarget* rt,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
radius,
morphType,
bounds))->unref();
- context->drawNonAARectToRect(paint, SkMatrix::I(), SkRect::Make(dstRect),
- SkRect::Make(srcRect));
+ context->drawNonAARectToRect(rt, paint, SkMatrix::I(), SkRect::Make(dstRect),
+ SkRect::Make(srcRect));
}
void apply_morphology_rect_no_bounds(GrContext* context,
- GrTexture* texture,
- const SkIRect& srcRect,
- const SkIRect& dstRect,
- int radius,
- GrMorphologyEffect::MorphologyType morphType,
- Gr1DKernelEffect::Direction direction) {
+ GrRenderTarget* rt,
+ GrTexture* texture,
+ const SkIRect& srcRect,
+ const SkIRect& dstRect,
+ int radius,
+ GrMorphologyEffect::MorphologyType morphType,
+ Gr1DKernelEffect::Direction direction) {
GrPaint paint;
paint.addColorProcessor(GrMorphologyEffect::Create(texture,
direction,
radius,
morphType))->unref();
- context->drawNonAARectToRect(paint, SkMatrix::I(), SkRect::Make(dstRect),
- SkRect::Make(srcRect));
+ context->drawNonAARectToRect(rt, paint, SkMatrix::I(), SkRect::Make(dstRect),
+ SkRect::Make(srcRect));
}
void apply_morphology_pass(GrContext* context,
+ GrRenderTarget* rt,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
}
if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) {
// radius covers srcRect; use bounds over entire draw
- apply_morphology_rect(context, 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, texture, lowerSrcRect, lowerDstRect, radius,
+ apply_morphology_rect(context, rt,texture, lowerSrcRect, lowerDstRect, radius,
morphType, bounds, direction);
- apply_morphology_rect(context, texture, upperSrcRect, upperDstRect, radius,
+ apply_morphology_rect(context, rt, texture, upperSrcRect, upperDstRect, radius,
morphType, bounds, direction);
- apply_morphology_rect_no_bounds(context, texture, middleSrcRect, middleDstRect, radius,
+ apply_morphology_rect_no_bounds(context, rt, texture, middleSrcRect, middleDstRect, radius,
morphType, direction);
}
}
if (NULL == texture) {
return false;
}
- GrContext::AutoRenderTarget art(context, texture->asRenderTarget());
- apply_morphology_pass(context, 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 ?
if (NULL == texture) {
return false;
}
- GrContext::AutoRenderTarget art(context, texture->asRenderTarget());
- apply_morphology_pass(context, 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);
if (!dst) {
return false;
}
- GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) {
// canFilterImageGPU() should've taken care of this
GrPaint paint;
paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
paint.addColorProcessor(xferProcessor)->unref();
- context->drawRect(paint, SkMatrix::I(), srcRect);
+ context->drawRect(dst->asRenderTarget(), paint, SkMatrix::I(), srcRect);
offset->fX = backgroundOffset.fX;
offset->fY = backgroundOffset.fY;
return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix);
}
-inline void GrBitmapTextContext::init(const GrPaint& paint, const SkPaint& skPaint) {
- GrTextContext::init(paint, skPaint);
+inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrPaint& paint,
+ const SkPaint& skPaint) {
+ GrTextContext::init(rt, paint, skPaint);
fStrike = NULL;
fTotalVertexCount = 0;
}
-void GrBitmapTextContext::onDrawText(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) {
return;
}
- this->init(paint, skPaint);
+ this->init(rt, paint, skPaint);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
this->finish();
}
-void GrBitmapTextContext::onDrawPosText(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,
return;
}
- this->init(paint, skPaint);
+ this->init(rt, paint, skPaint);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
SkPath tmpPath(*glyph->fPath);
tmpPath.transform(translate);
GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
- fContext->drawPath(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;
if (fCurrVertex > 0) {
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setFromPaint(fPaint, fContext->getRenderTarget());
+ pipelineBuilder.setFromPaint(fPaint, fRenderTarget);
// setup our sampler state for our text texture/atlas
SkASSERT(SkIsAlign4(fCurrVertex));
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
- virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
- const char text[], size_t byteLength,
+ 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(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
+ 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(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
AutoCheckFlush acf(this);
GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
- GrDrawTarget* target = this->prepareToDraw(NULL, NULL, &acf);
+ GrDrawTarget* target = this->prepareToDraw(NULL, renderTarget, NULL, &acf);
if (NULL == target) {
return;
}
target->clear(rect, color, canIgnoreRect, renderTarget);
}
-void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix) {
+void GrContext::drawPaint(GrRenderTarget* rt,
+ const GrPaint& origPaint,
+ const SkMatrix& viewMatrix) {
// set rect to be big enough to fill the space, but not super-huge, so we
// don't overflow fixed-point implementations
SkRect r;
r.setLTRB(0, 0,
- SkIntToScalar(getRenderTarget()->width()),
- SkIntToScalar(getRenderTarget()->height()));
+ SkIntToScalar(rt->width()),
+ SkIntToScalar(rt->height()));
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
// by definition this fills the entire clip, no need for AA
return;
}
inverse.mapRect(&r);
- this->drawRect(*paint, viewMatrix, r);
+ this->drawRect(rt, *paint, viewMatrix, r);
} else {
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, paint, &acf);
if (NULL == target) {
return;
}
point.fY >= rect.fTop && point.fY <= rect.fBottom;
}
-void GrContext::drawRect(const GrPaint& paint,
+void GrContext::drawRect(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrStrokeInfo* strokeInfo) {
if (strokeInfo && strokeInfo->isDashed()) {
SkPath path;
path.addRect(rect);
- this->drawPath(paint, viewMatrix, path, *strokeInfo);
+ this->drawPath(rt, paint, viewMatrix, path, *strokeInfo);
return;
}
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
// Will it blend?
GrColor clearColor;
if (paint.isOpaqueAndConstantColor(&clearColor)) {
- target->clear(NULL, clearColor, true, fRenderTarget);
+ target->clear(NULL, clearColor, true, rt);
return;
}
}
}
}
-void GrContext::drawNonAARectToRect(const GrPaint& paint,
+void GrContext::drawNonAARectToRect(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkRect& localRect,
const SkMatrix* localMatrix) {
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
return GrDefaultGeoProcFactory::Create(flags, color, viewMatrix, SkMatrix::I());
}
-void GrContext::drawVertices(const GrPaint& paint,
+void GrContext::drawVertices(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
int vertexCount,
GrPipelineBuilder pipelineBuilder;
GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scope
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
///////////////////////////////////////////////////////////////////////////////
-void GrContext::drawRRect(const GrPaint& paint,
+void GrContext::drawRRect(GrRenderTarget*rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const GrStrokeInfo& strokeInfo) {
if (strokeInfo.isDashed()) {
SkPath path;
path.addRRect(rrect);
- this->drawPath(paint, viewMatrix, path, strokeInfo);
+ this->drawPath(rt, paint, viewMatrix, path, strokeInfo);
return;
}
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
///////////////////////////////////////////////////////////////////////////////
-void GrContext::drawDRRect(const GrPaint& paint,
+void GrContext::drawDRRect(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& outer,
const SkRRect& inner) {
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target);
///////////////////////////////////////////////////////////////////////////////
-void GrContext::drawOval(const GrPaint& paint,
+void GrContext::drawOval(GrRenderTarget*rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
const GrStrokeInfo& strokeInfo) {
if (strokeInfo.isDashed()) {
SkPath path;
path.addOval(oval);
- this->drawPath(paint, viewMatrix, path, strokeInfo);
+ this->drawPath(rt, paint, viewMatrix, path, strokeInfo);
return;
}
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
return allEq || allGoE1;
}
-void GrContext::drawPath(const GrPaint& paint,
+void GrContext::drawPath(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkPath& path,
const GrStrokeInfo& strokeInfo) {
if (path.isEmpty()) {
if (path.isInverseFillType()) {
- this->drawPaint(paint, viewMatrix);
+ this->drawPaint(rt, paint, viewMatrix);
}
return;
}
if (path.isLine(pts)) {
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
GrStrokeInfo newStrokeInfo(strokeInfo, false);
SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr();
if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, info)) {
- this->drawPath(paint, viewMatrix, *effectPath.get(), newStrokeInfo);
+ this->drawPath(rt, paint, viewMatrix, *effectPath.get(), newStrokeInfo);
return;
}
- this->drawPath(paint, viewMatrix, path, newStrokeInfo);
+ this->drawPath(rt, paint, viewMatrix, path, newStrokeInfo);
return;
}
// OK.
AutoCheckFlush acf(this);
GrPipelineBuilder pipelineBuilder;
- GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, rt, &paint, &acf);
if (NULL == target) {
return;
}
// drawing a rect to the render target.
// The bracket ensures we pop the stack if we wind up flushing below.
{
- GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL);
+ GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL, NULL);
GrDrawTarget::AutoGeometryPush agp(drawTarget);
GrPipelineBuilder pipelineBuilder;
SkASSERT(renderTarget);
ASSERT_OWNED_RESOURCE(renderTarget);
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(NULL, NULL, &acf);
+ GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, NULL);
if (NULL == target) {
return;
}
// Since we're going to the draw target and not GPU, no need to check kNoFlush
// here.
- GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL);
+ GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, NULL);
if (NULL == target) {
return;
}
}
GrDrawTarget* GrContext::prepareToDraw(GrPipelineBuilder* pipelineBuilder,
+ GrRenderTarget* rt,
const GrPaint* paint,
const AutoCheckFlush* acf) {
if (NULL == fGpu) {
return NULL;
}
- ASSERT_OWNED_RESOURCE(fRenderTarget.get());
if (pipelineBuilder) {
- SkASSERT(paint && acf);
- pipelineBuilder->setFromPaint(*paint, fRenderTarget.get());
+ ASSERT_OWNED_RESOURCE(rt);
+ SkASSERT(rt && paint && acf);
+ pipelineBuilder->setFromPaint(*paint, rt);
pipelineBuilder->setState(GrPipelineBuilder::kClip_StateBit,
fClip && !fClip->fClipStack->isWideOpen());
}
}
GrDrawTarget* GrContext::getTextTarget() {
- return this->prepareToDraw(NULL, NULL, NULL);
+ return this->prepareToDraw(NULL, NULL, NULL, NULL);
}
const GrIndexBuffer* GrContext::getQuadIndexBuffer() const {
return true;
}
-inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint& skPaint) {
- GrTextContext::init(paint, skPaint);
+inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrPaint& paint,
+ const SkPaint& skPaint) {
+ GrTextContext::init(rt, paint, skPaint);
fStrike = NULL;
}
}
-void GrDistanceFieldTextContext::onDrawText(const GrPaint& paint, const SkPaint& skPaint,
- const SkMatrix& viewMatrix,
+void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrPaint& paint,
+ const SkPaint& skPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
SkASSERT(byteLength == 0 || text != NULL);
y -= alignY;
SkPoint offset = SkPoint::Make(x, y);
- this->drawPosText(paint, skPaint, viewMatrix, text, byteLength, positions.begin(), 2, offset);
+ this->drawPosText(rt, paint, skPaint, viewMatrix, text, byteLength, positions.begin(), 2,
+ offset);
}
-void GrDistanceFieldTextContext::onDrawPosText(const GrPaint& paint, const SkPaint& skPaint,
- const SkMatrix& viewMatrix,
+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,
const SkPoint& offset) {
}
fViewMatrix = viewMatrix;
- this->init(paint, skPaint);
+ this->init(rt, paint, skPaint);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
this->finish();
if (fallbackTxt.count() > 0) {
- fFallbackTextContext->drawPosText(paint, skPaint, viewMatrix, fallbackTxt.begin(),
+ fFallbackTextContext->drawPosText(rt, paint, skPaint, viewMatrix, fallbackTxt.begin(),
fallbackTxt.count(), fallbackPos.begin(),
scalarsPerPosition, offset);
}
tmpPath.transform(ctm);
GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
- fContext->drawPath(fPaint, fViewMatrix, tmpPath, strokeInfo);
+ fContext->drawPath(fRenderTarget, fPaint, fViewMatrix, tmpPath, strokeInfo);
// remove this glyph from the vertices we need to allocate
fTotalVertexCount -= kVerticesPerGlyph;
if (fCurrVertex > 0) {
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setFromPaint(fPaint, fContext->getRenderTarget());
+ pipelineBuilder.setFromPaint(fPaint, fRenderTarget);
// setup our sampler state for our text texture/atlas
SkASSERT(SkIsAlign4(fCurrVertex));
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
- virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
+ 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(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
+ 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(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);
return rec.getFormat() != SkMask::kARGB32_Format;
}
-void GrStencilAndCoverTextContext::onDrawText(const GrPaint& paint,
+void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[],
// will turn off the use of device-space glyphs when perspective transforms
// are in use.
- this->init(paint, skPaint, byteLength, kMaxAccuracy_RenderMode, viewMatrix);
+ this->init(rt, paint, skPaint, byteLength, kMaxAccuracy_RenderMode, viewMatrix);
// Transform our starting point.
if (fUsingDeviceSpaceGlyphs) {
this->finish();
}
-void GrStencilAndCoverTextContext::onDrawPosText(const GrPaint& paint,
+void GrStencilAndCoverTextContext::onDrawPosText(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[],
// transform is not part of SkPaint::measureText API, and thus we use the
// same glyphs as what were measured.
- this->init(paint, skPaint, byteLength, kMaxPerformance_RenderMode, viewMatrix);
+ this->init(rt, paint, skPaint, byteLength, kMaxPerformance_RenderMode, viewMatrix);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
return glyphs.detach();
}
-void GrStencilAndCoverTextContext::init(const GrPaint& paint,
+void GrStencilAndCoverTextContext::init(GrRenderTarget* rt,
+ const GrPaint& paint,
const SkPaint& skPaint,
size_t textByteLength,
RenderMode renderMode,
const SkMatrix& viewMatrix) {
- GrTextContext::init(paint, skPaint);
+ GrTextContext::init(rt, paint, skPaint);
fContextInitialMatrix = viewMatrix;
fViewMatrix = viewMatrix;
fStateRestore.set(&fPipelineBuilder);
- fPipelineBuilder.setFromPaint(fPaint, fContext->getRenderTarget());
+ fPipelineBuilder.setFromPaint(fPaint, fRenderTarget);
GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
kZero_StencilOp,
inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyphCount);
}
- fFallbackTextContext->drawPosText(paintFallback, skPaintFallback, fViewMatrix,
- (char*)&fGlyphIndices[fFallbackGlyphsIdx],
+ fFallbackTextContext->drawPosText(fRenderTarget, paintFallback, skPaintFallback,
+ fViewMatrix, (char*)&fGlyphIndices[fFallbackGlyphsIdx],
2 * fallbackGlyphCount,
get_xy_scalar_array(&fGlyphPositions[fFallbackGlyphsIdx]),
2, SkPoint::Make(0, 0));
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
- virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
+ 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(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
+ 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(const GrPaint&, const SkPaint&, size_t textByteLength, RenderMode,
+ void init(GrRenderTarget*, const GrPaint&, const SkPaint&, size_t textByteLength, RenderMode,
const SkMatrix& viewMatrix);
bool mapToFallbackContext(SkMatrix* inverse);
void appendGlyph(const SkGlyph&, const SkPoint&);
SkDELETE(fFallbackTextContext);
}
-void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) {
+void GrTextContext::init(GrRenderTarget* rt, const GrPaint& grPaint, const SkPaint& skPaint) {
const GrClipData* clipData = fContext->getClip();
- clipData->getConservativeBounds(fContext->getRenderTarget()->width(),
- fContext->getRenderTarget()->height(),
- &fClipRect);
+ fRenderTarget.reset(SkRef(rt));
+
+ clipData->getConservativeBounds(fRenderTarget->width(), fRenderTarget->height(), &fClipRect);
fDrawTarget = fContext->getTextTarget();
fSkPaint = skPaint;
}
-bool GrTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
+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(paint, skPaint, viewMatrix, text, byteLength, x, y);
+ textContext->onDrawText(rt, paint, skPaint, viewMatrix, text, byteLength, x, y);
return true;
}
textContext = textContext->fFallbackTextContext;
return false;
}
-bool GrTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
+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,
GrTextContext* textContext = this;
do {
if (textContext->canDraw(skPaint, viewMatrix)) {
- textContext->onDrawPosText(paint, skPaint, viewMatrix, text, byteLength, pos,
+ textContext->onDrawPosText(rt, paint, skPaint, viewMatrix, text, byteLength, pos,
scalarsPerPosition, offset);
return true;
}
public:
virtual ~GrTextContext();
- bool drawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix, const char text[],
- size_t byteLength, SkScalar x, SkScalar y);
- bool drawPosText(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);
protected:
- GrTextContext* fFallbackTextContext;
- GrContext* fContext;
- SkDeviceProperties fDeviceProperties;
+ GrTextContext* fFallbackTextContext;
+ GrContext* fContext;
+ SkDeviceProperties fDeviceProperties;
- GrDrawTarget* fDrawTarget;
- SkIRect fClipRect;
- GrPaint fPaint;
- SkPaint fSkPaint;
+ SkAutoTUnref<GrRenderTarget> fRenderTarget;
+ GrDrawTarget* fDrawTarget;
+ SkIRect fClipRect;
+ GrPaint fPaint;
+ SkPaint fSkPaint;
GrTextContext(GrContext*, const SkDeviceProperties&);
virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0;
- virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
- const char text[], size_t byteLength, SkScalar x, SkScalar y) = 0;
- virtual void onDrawPosText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
+ 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 GrPaint&, const SkPaint&,
+ const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) = 0;
- void init(const GrPaint&, const SkPaint&);
+ void init(GrRenderTarget*, const GrPaint&, const SkPaint&);
void finish() { fDrawTarget = NULL; }
static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
delete fTextContext;
- // The GrContext takes a ref on the target. We don't want to cause the render
- // target to be unnecessarily kept alive.
- if (fContext->getRenderTarget() == fRenderTarget) {
- fContext->setRenderTarget(NULL);
- }
-
if (fContext->getClip() == &fClipData) {
fContext->setClip(NULL);
}
void SkGpuDevice::prepareDraw(const SkDraw& draw) {
SkASSERT(fClipData.fClipStack);
- fContext->setRenderTarget(fRenderTarget);
-
SkASSERT(draw.fClipStack && draw.fClipStack == fClipData.fClipStack);
fClipData.fOrigin = this->getOrigin();
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
- fContext->drawPaint(grPaint, *draw.fMatrix);
+ fContext->drawPaint(fRenderTarget, grPaint, *draw.fMatrix);
}
// must be in SkCanvas::PointMode order
if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) {
GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
SkPath path;
path.setIsVolatile(true);
path.moveTo(pts[0]);
path.lineTo(pts[1]);
- fContext->drawPath(grPaint, *draw.fMatrix, path, strokeInfo);
+ fContext->drawPath(fRenderTarget, grPaint, *draw.fMatrix, path, strokeInfo);
return;
}
}
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
- fContext->drawVertices(grPaint,
+ fContext->drawVertices(fRenderTarget,
+ grPaint,
*draw.fMatrix,
gPointMode2PrimtiveType[mode],
SkToS32(count),
}
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
- fContext->drawRect(grPaint, *draw.fMatrix, rect, &strokeInfo);
+ fContext->drawRect(fRenderTarget, grPaint, *draw.fMatrix, rect, &strokeInfo);
}
///////////////////////////////////////////////////////////////////////////////
CHECK_SHOULD_DRAW(draw);
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
GrStrokeInfo strokeInfo(paint);
if (paint.getMaskFilter()) {
// clipped out
return;
}
- if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint,
+ if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext,
+ fRenderTarget,
+ &grPaint,
*draw.fMatrix,
strokeInfo.getStrokeRec(),
devRRect)) {
return;
}
- fContext->drawRRect(grPaint, *draw.fMatrix, rect, strokeInfo);
+ fContext->drawRRect(fRenderTarget, grPaint, *draw.fMatrix, rect, strokeInfo);
}
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
CHECK_SHOULD_DRAW(draw);
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) {
- fContext->drawDRRect(grPaint, *draw.fMatrix, outer, inner);
+ fContext->drawDRRect(fRenderTarget, grPaint, *draw.fMatrix, outer, inner);
return;
}
}
}
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
- fContext->drawOval(grPaint, *draw.fMatrix, oval, strokeInfo);
+ fContext->drawOval(fRenderTarget, grPaint, *draw.fMatrix, oval, strokeInfo);
}
#include "SkMaskFilter.h"
// Draw a mask using the supplied paint. Since the coverage/geometry
// is already burnt into the mask this boils down to a rect draw.
// Return true if the mask was successfully drawn.
-bool draw_mask(GrContext* context, const SkMatrix& viewMatrix, const SkRect& maskRect,
- GrPaint* grp, GrTexture* mask) {
+bool draw_mask(GrContext* context,
+ GrRenderTarget* rt,
+ const SkMatrix& viewMatrix,
+ const SkRect& maskRect,
+ GrPaint* grp,
+ GrTexture* mask) {
SkMatrix matrix;
matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
matrix.postIDiv(mask->width(), mask->height());
if (!viewMatrix.invert(&inverse)) {
return false;
}
- context->drawNonAARectWithLocalMatrix(*grp, SkMatrix::I(), maskRect, inverse);
+ context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), maskRect, inverse);
return true;
}
-bool draw_with_mask_filter(GrContext* context, const SkMatrix& viewMatrix, const SkPath& devPath,
- SkMaskFilter* filter, const SkRegion& clip,
- GrPaint* grp, SkPaint::Style style) {
+bool draw_with_mask_filter(GrContext* context,
+ GrRenderTarget* rt,
+ const SkMatrix& viewMatrix,
+ const SkPath& devPath,
+ SkMaskFilter* filter,
+ const SkRegion& clip,
+ GrPaint* grp,
+ SkPaint::Style style) {
SkMask srcM, dstM;
if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &viewMatrix, &srcM,
SkRect maskRect = SkRect::Make(dstM.fBounds);
- return draw_mask(context, viewMatrix, maskRect, grp, texture);
+ return draw_mask(context, rt, viewMatrix, maskRect, grp, texture);
}
// Create a mask of 'devPath' and place the result in 'mask'.
GrTexture* create_mask_GPU(GrContext* context,
+ GrRenderTarget* rt,
const SkRect& maskRect,
const SkPath& devPath,
const GrStrokeInfo& strokeInfo,
SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height());
- GrContext::AutoRenderTarget art(context, mask->asRenderTarget());
GrContext::AutoClip ac(context, clipRect);
context->clear(NULL, 0x0, true, mask->asRenderTarget());
// 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(tempPaint, translate, devPath, strokeInfo);
+ context->drawPath(mask->asRenderTarget(), tempPaint, translate, devPath, strokeInfo);
return mask;
}
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, viewMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, viewMatrix, true, &grPaint);
const SkRect* cullRect = NULL; // TODO: what is our bounds?
SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr();
return;
}
- if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, viewMatrix,
- stroke, *devPathPtr)) {
+ if (paint.getMaskFilter()->directFilterMaskGPU(fContext,
+ fRenderTarget,
+ &grPaint,
+ viewMatrix,
+ stroke,
+ *devPathPtr)) {
// the mask filter was able to draw itself directly, so there's nothing
// left to do.
return;
}
- SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext, maskRect, *devPathPtr,
- strokeInfo, grPaint.isAntiAlias(),
+ SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext,
+ fRenderTarget,
+ maskRect,
+ *devPathPtr,
+ strokeInfo,
+ grPaint.isAntiAlias(),
fRenderTarget->numSamples()));
if (mask) {
GrTexture* filtered;
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, viewMatrix, maskRect, &grPaint, filtered)) {
+ if (draw_mask(fContext, fRenderTarget, viewMatrix, maskRect, &grPaint,
+ filtered)) {
// This path is completely drawn
return;
}
// GPU path fails
SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style;
- draw_with_mask_filter(fContext, viewMatrix, *devPathPtr, paint.getMaskFilter(),
- *draw.fClip, &grPaint, style);
+ draw_with_mask_filter(fContext, fRenderTarget, viewMatrix, *devPathPtr,
+ paint.getMaskFilter(), *draw.fClip, &grPaint, style);
return;
}
- fContext->drawPath(grPaint, viewMatrix, *pathPtr, strokeInfo);
+ fContext->drawPath(fRenderTarget, grPaint, viewMatrix, *pathPtr, strokeInfo);
}
static const int kBmpSmallTileSize = 1 << 10;
// Given a bitmap, an optional src rect, and a context with a clip and matrix determine what
// pixels from the bitmap are necessary.
static void determine_clipped_src_rect(const GrContext* context,
+ const GrRenderTarget* rt,
const SkMatrix& viewMatrix,
const SkBitmap& bitmap,
const SkRect* srcRectPtr,
SkIRect* clippedSrcIRect) {
const GrClipData* clip = context->getClip();
- clip->getConservativeBounds(context->getRenderTarget(), clippedSrcIRect, NULL);
+ clip->getConservativeBounds(rt, clippedSrcIRect, NULL);
SkMatrix inv;
if (!viewMatrix.invert(&inv)) {
clippedSrcIRect->setEmpty();
// 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, viewMatrix, bitmap, srcRectPtr, clippedSrcRect);
+ determine_clipped_src_rect(fContext, fRenderTarget, viewMatrix, bitmap, srcRectPtr,
+ clippedSrcRect);
*tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize);
return true;
}
}
// Figure out how much of the src we will need based on the src rect and clipping.
- determine_clipped_src_rect(fContext, viewMatrix, bitmap, srcRectPtr, clippedSrcRect);
+ 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) *
kBmpSmallTileSize * kBmpSmallTileSize;
bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
SkColor2GrColor(paint.getColor());
- SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint);
+ SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, false, &grPaint);
- fContext->drawNonAARectToRect(grPaint, viewMatrix, dstRect, paintRect);
+ fContext->drawNonAARectToRect(fRenderTarget, grPaint, viewMatrix, dstRect, paintRect);
}
bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().pixelGeometry()));
if (filter->canFilterImageGPU()) {
- // Save the render target and set it to NULL, so we don't accidentally draw to it in the
- // filter. Also set the clip wide open and the matrix to identity.
- GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
+ // 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;
GrPaint grPaint;
grPaint.addColorTextureProcessor(texture, SkMatrix::I());
- SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()),
- false, &grPaint);
+ SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint,
+ SkColor2GrColorJustAlpha(paint.getColor()), false, &grPaint);
- fContext->drawNonAARectToRect(grPaint,
+ fContext->drawNonAARectToRect(fRenderTarget,
+ grPaint,
SkMatrix::I(),
SkRect::MakeXYWH(SkIntToScalar(left),
SkIntToScalar(top),
GrPaint grPaint;
grPaint.addColorTextureProcessor(devTex, SkMatrix::I());
- SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()),
- false, &grPaint);
+ SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint,
+ SkColor2GrColorJustAlpha(paint.getColor()), false, &grPaint);
SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x),
SkIntToScalar(y),
SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
SK_Scalar1 * h / devTex->height());
- fContext->drawNonAARectToRect(grPaint, SkMatrix::I(), dstRect, srcRect);
+ fContext->drawNonAARectToRect(fRenderTarget, grPaint, SkMatrix::I(), dstRect, srcRect);
}
bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
copy.setStrokeWidth(0);
// we ignore the shader if texs is null.
- SkPaint2GrPaintNoShader(this->context(), copy, SkColor2GrColor(copy.getColor()),
- NULL == colors, &grPaint);
+ SkPaint2GrPaintNoShader(this->context(), fRenderTarget, copy,
+ SkColor2GrColor(copy.getColor()), NULL == colors, &grPaint);
primType = kLines_GrPrimitiveType;
int triangleCount = 0;
primType = gVertexMode2PrimitiveType[vmode];
if (NULL == texs || NULL == paint.getShader()) {
- SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColor(paint.getColor()),
+ SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint,
+ SkColor2GrColor(paint.getColor()),
NULL == colors, &grPaint);
} else {
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, NULL == colors, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
+ NULL == colors, &grPaint);
}
}
}
colors = convertedColors.get();
}
- fContext->drawVertices(grPaint,
+ fContext->drawVertices(fRenderTarget,
+ grPaint,
*draw.fMatrix,
primType,
vertexCount,
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
SkDEBUGCODE(this->validate();)
- if (!fTextContext->drawText(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);
}
CHECK_SHOULD_DRAW(draw);
GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, *draw.fMatrix, true, &grPaint);
+ SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix, true, &grPaint);
SkDEBUGCODE(this->validate();)
- if (!fTextContext->drawPosText(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);
}
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
SkRect localRect = SkRect::MakeWH(1.f, 1.f);
- GrContext::AutoRenderTarget autoRT(context, stretched->asRenderTarget());
GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip);
- context->drawNonAARectToRect(paint, SkMatrix::I(), rect, localRect);
+ context->drawNonAARectToRect(stretched->asRenderTarget(), paint, SkMatrix::I(), rect,
+ localRect);
return stretched;
}
paint.addColorProcessor(yuvToRgbProcessor);
SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
SkIntToScalar(yuvInfo.fSize[0].fHeight));
- GrContext::AutoRenderTarget autoRT(ctx, renderTarget);
GrContext::AutoClip ac(ctx, GrContext::AutoClip::kWideOpen_InitialClip);
- ctx->drawRect(paint, SkMatrix::I(), r);
+ ctx->drawRect(renderTarget, paint, SkMatrix::I(), r);
return result;
}
///////////////////////////////////////////////////////////////////////////////
-void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
- bool constantColor, GrPaint* grPaint) {
+void SkPaint2GrPaintNoShader(GrContext* context, GrRenderTarget* rt, const SkPaint& skPaint,
+ GrColor paintColor, bool constantColor, GrPaint* grPaint) {
grPaint->setDither(skPaint.isDither());
grPaint->setAntiAlias(skPaint.isAntiAlias());
// supports it. If not, then install a dither effect.
if (skPaint.isDither() && grPaint->numColorStages() > 0) {
// What are we rendering into?
- const GrRenderTarget *target = context->getRenderTarget();
- SkASSERT(target);
+ SkASSERT(rt);
// Suspect the dithering flag has no effect on these configs, otherwise
// fall back on setting the appropriate state.
- if (target->config() == kRGBA_8888_GrPixelConfig ||
- target->config() == kBGRA_8888_GrPixelConfig) {
+ if (GrPixelConfigIs8888(rt->config()) ||
+ GrPixelConfigIs8888(rt->config())) {
// The dither flag is set and the target is likely
// not going to be dithered by the GPU.
SkAutoTUnref<GrFragmentProcessor> fp(GrDitherEffect::Create());
#endif
}
-void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint, const SkMatrix& viewM,
- bool constantColor, GrPaint* grPaint) {
+void SkPaint2GrPaintShader(GrContext* context, GrRenderTarget* rt, const SkPaint& skPaint,
+ const SkMatrix& viewM, bool constantColor, GrPaint* grPaint) {
SkShader* shader = skPaint.getShader();
if (NULL == shader) {
- SkPaint2GrPaintNoShader(context, skPaint, SkColor2GrColor(skPaint.getColor()),
+ SkPaint2GrPaintNoShader(context, rt, skPaint, SkColor2GrColor(skPaint.getColor()),
constantColor, grPaint);
return;
}
// asFragmentProcessor(). Since these calls get passed back to the client, we don't really
// want them messing around with the context.
{
- // SkShader::asFragmentProcessor() may do offscreen rendering. Save off the current RT,
- // and clip
- GrContext::AutoRenderTarget art(context, NULL);
GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip);
// Allow the shader to modify paintColor and also create an effect to be installed as
// The grcolor is automatically set when calling asFragmentProcessor.
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
- SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint);
+ SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grPaint);
}
{kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
};
- GrContext::AutoWideOpenIdentityDraw awoid(context, NULL);
+ GrContext::AutoWideOpenIdentityDraw awoid(context);
bool failed = true;
SkNEW_ARGS(GrConfigConversionEffect,
(tempTex, false, *pmToUPMRule, SkMatrix::I())));
- context->setRenderTarget(readTex->asRenderTarget());
GrPaint paint1;
paint1.addColorProcessor(pmToUPM1);
- context->drawNonAARectToRect(paint1, SkMatrix::I(), kDstRect, kSrcRect);
+ context->drawNonAARectToRect(readTex->asRenderTarget(), paint1, SkMatrix::I(), kDstRect,
+ kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
- context->setRenderTarget(tempTex->asRenderTarget());
GrPaint paint2;
paint2.addColorProcessor(upmToPM);
- context->drawNonAARectToRect(paint2, SkMatrix::I(), kDstRect, kSrcRect);
- context->setRenderTarget(readTex->asRenderTarget());
+ context->drawNonAARectToRect(tempTex->asRenderTarget(), paint2, SkMatrix::I(), kDstRect,
+ kSrcRect);
GrPaint paint3;
paint3.addColorProcessor(pmToUPM2);
- context->drawNonAARectToRect(paint3, SkMatrix::I(), kDstRect, kSrcRect);
+ context->drawNonAARectToRect(readTex->asRenderTarget(), paint3, SkMatrix::I(), kDstRect,
+ kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);