GrDrawContext now holds GrRenderTarget pointer
Review URL: https://codereview.chromium.org/1404823005
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index e36e94d..c89ce73 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -22,7 +22,7 @@
DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
GrRenderTarget* target = canvas->internal_private_accessTopLayerRenderTarget();
GrContext* ctx = canvas->getGrContext();
- SkAutoTUnref<GrDrawContext> drawContext(ctx ? ctx->drawContext() : nullptr);
+ SkAutoTUnref<GrDrawContext> drawContext(ctx ? ctx->drawContext(target) : nullptr);
if (drawContext && target) {
SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
static const int stride = 2 * S;
@@ -96,7 +96,7 @@
tm.postIDiv(2*S, 2*S);
paint.addColorTextureProcessor(texture, tm);
- drawContext->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
+ drawContext->drawRect(clip, 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
@@ -110,7 +110,7 @@
texture->writePixels(S, (i ? 0 : S), S, S,
texture->config(), gTextureData.get(),
4 * stride);
- drawContext->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
+ drawContext->drawRect(clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
}
} else {
skiagm::GM::DrawGpuOnlyMessage(canvas);
diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h
index 50a1e87..1fe1d9a 100644
--- a/include/core/SkMaskFilter.h
+++ b/include/core/SkMaskFilter.h
@@ -113,7 +113,6 @@
*/
virtual bool directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
@@ -125,7 +124,6 @@
*/
virtual bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index b79ab64..91ae2d1 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -175,12 +175,13 @@
* Callers should take a ref if they rely on the GrDrawContext sticking around.
* NULL will be returned if the context has been abandoned.
*
+ * @param rt the render target receiving the draws
* @param surfaceProps the surface properties (mainly defines text drawing)
*
* @return a draw context
*/
- GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) {
- return fDrawingMgr.drawContext(surfaceProps);
+ GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps = NULL) {
+ return fDrawingMgr.drawContext(rt, surfaceProps);
}
GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarget* rt) {
@@ -441,7 +442,7 @@
// Callers assume the creation ref of the drawContext!
// NULL will be returned if the context has been abandoned.
- GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps);
+ GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps);
GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt);
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index 03dd8c4..5e1dc07 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -44,20 +44,19 @@
public:
~GrDrawContext() override;
- void copySurface(GrRenderTarget* dst, GrSurface* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint);
+ void copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
// TODO: it is odd that we need both the SkPaint in the following 3 methods.
// We should extract the text parameters from SkPaint and pass them separately
// akin to GrStrokeInfo (GrTextInfo?)
- void drawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
+ void drawText(const GrClip&, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds);
- void drawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
+ void drawPosText(const GrClip&, const GrPaint&, const SkPaint&,
const SkMatrix& viewMatrix, const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds);
- void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&,
+ void drawTextBlob(const GrClip&, const SkPaint&,
const SkMatrix& viewMatrix, const SkTextBlob*,
SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds);
@@ -76,22 +75,21 @@
* Provides a perfomance hint that the render target's contents are allowed
* to become undefined.
*/
- void discard(GrRenderTarget*);
+ void discard();
/**
* Clear the entire or rect of the render target, ignoring any clips.
- * @param target The render target to clear.
* @param rect the rect to clear or the whole thing if rect is NULL.
* @param color the color to clear to.
* @param canIgnoreRect allows partial clears to be converted to whole
* clears on platforms for which that is cheap
*/
- void clear(GrRenderTarget*, const SkIRect* rect, GrColor color, bool canIgnoreRect);
+ void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect);
/**
* Draw everywhere (respecting the clip) with the paint.
*/
- void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
+ void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
/**
* Draw the rect using a paint.
@@ -105,8 +103,7 @@
* mitered/beveled stroked based on stroke width.
* The rects coords are used to access the paint (through texture matrix)
*/
- void drawRect(GrRenderTarget*,
- const GrClip&,
+ void drawRect(const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect&,
@@ -120,8 +117,7 @@
* @param rectToDraw the rectangle to draw
* @param localRect the rectangle of shader coordinates applied to rectToDraw
*/
- void drawNonAARectToRect(GrRenderTarget*,
- const GrClip&,
+ void drawNonAARectToRect(const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
@@ -130,8 +126,7 @@
/**
* Draws a non-AA rect with paint and a localMatrix
*/
- void drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
- const GrClip& clip,
+ void drawNonAARectWithLocalMatrix(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
@@ -146,8 +141,7 @@
* @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase).
*/
- void drawRRect(GrRenderTarget*,
- const GrClip&,
+ void drawRRect(const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
@@ -163,8 +157,7 @@
* @param outer the outer roundrect
* @param inner the inner roundrect
*/
- void drawDRRect(GrRenderTarget*,
- const GrClip&,
+ void drawDRRect(const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkRRect& outer,
@@ -180,8 +173,7 @@
* @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase).
*/
- void drawPath(GrRenderTarget*,
- const GrClip&,
+ void drawPath(const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -204,8 +196,7 @@
* @param indexCount if indices is non-null then this is the
* number of indices.
*/
- void drawVertices(GrRenderTarget*,
- const GrClip&,
+ void drawVertices(const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
@@ -227,8 +218,7 @@
* @param colors optional array of per-sprite colors, supercedes
* the paint's color field.
*/
- void drawAtlas(GrRenderTarget*,
- const GrClip&,
+ void drawAtlas(const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
int spriteCount,
@@ -245,8 +235,7 @@
* @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase).
*/
- void drawOval(GrRenderTarget*,
- const GrClip&,
+ void drawOval(const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
@@ -259,16 +248,15 @@
* @param paint describes how to color pixels.
* @param batch the batch to draw
*/
- void drawBatch(GrRenderTarget*, const GrClip&, const GrPaint&, GrDrawBatch*);
+ void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*);
private:
friend class GrAtlasTextContext; // for access to drawBatch
friend class GrContext; // for ctor
- GrDrawContext(GrContext*, GrDrawTarget*, const SkSurfaceProps* surfaceProps);
+ SkDEBUGCODE(void validate() const;)
- // Checks if the context has been abandoned and if the rendertarget is owned by this context
- bool prepareToDraw(GrRenderTarget* rt);
+ GrDrawContext(GrContext*, GrRenderTarget*, GrDrawTarget*, const SkSurfaceProps* surfaceProps);
void internalDrawPath(GrDrawTarget*,
GrPipelineBuilder*,
@@ -283,6 +271,7 @@
void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch);
GrContext* fContext; // owning context -> no ref
+ GrRenderTarget* fRenderTarget;
GrDrawTarget* fDrawTarget;
GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMgr
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index bb79276..2f1cfea 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -360,10 +360,9 @@
SkASSERT(fp);
paint.addColorFragmentProcessor(fp)->unref();
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (drawContext) {
- drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(),
- dstRect, srcRect);
+ drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
WrapTexture(dst, bounds.width(), bounds.height(), result);
return true;
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index 6a9c2df..0753944 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -318,7 +318,6 @@
bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
@@ -330,7 +329,6 @@
bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 95860ac..32de522 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -251,7 +251,7 @@
#if SK_SUPPORT_GPU
bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
GrTexture* texture,
- const SkMatrix& in_matrix,
+ const SkMatrix& inMatrix,
const SkIRect&) const {
if (fp) {
GrContext* context = texture->getContext();
@@ -272,17 +272,17 @@
return false;
}
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(
+ context->drawContext(maskTexture->asRenderTarget()));
if (drawContext) {
GrPaint grPaint;
grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkRegion::Iterator iter(fRegion);
- drawContext->clear(maskTexture->asRenderTarget(), nullptr, 0x0, true);
+ drawContext->clear(nullptr, 0x0, true);
while (!iter.done()) {
SkRect rect = SkRect::Make(iter.rect());
- drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint,
- in_matrix, rect);
+ drawContext->drawRect(GrClip::WideOpen(), grPaint, inMatrix, rect);
iter.next();
}
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 0a95206..ab631c6 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -51,7 +51,6 @@
SkRect* maskRect) const override;
bool directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
@@ -59,7 +58,6 @@
const SkPath& path) const override;
bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip&,
const SkMatrix& viewMatrix,
@@ -806,7 +804,6 @@
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
@@ -854,7 +851,7 @@
return false;
}
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
+ drawContext->drawNonAARectWithLocalMatrix(clip, *grp, SkMatrix::I(), rect, inverse);
return true;
}
@@ -1101,7 +1098,6 @@
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext,
- GrRenderTarget* rt,
GrPaint* grp,
const GrClip& clip,
const SkMatrix& viewMatrix,
@@ -1136,7 +1132,7 @@
return false;
}
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxyRect, inverse);
+ drawContext->drawNonAARectWithLocalMatrix(clip, *grp, SkMatrix::I(), proxyRect, inverse);
return true;
}
@@ -1222,13 +1218,12 @@
paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
}
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext((*result)->asRenderTarget()));
if (!drawContext) {
return false;
}
- drawContext->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(),
- paint, SkMatrix::I(), clipRect);
+ drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), clipRect);
}
return true;
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 17f96df..ca11c38 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -449,13 +449,12 @@
matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
-SkIntToScalar(colorBounds.y()));
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (!drawContext) {
return false;
}
- drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matrix,
- SkRect::Make(colorBounds));
+ drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(colorBounds));
offset->fX = bounds.left();
offset->fY = bounds.top();
WrapTexture(dst, bounds.width(), bounds.height(), result);
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 276fb6c..ec37505 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -46,7 +46,6 @@
}
static void convolve_gaussian_1d(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
@@ -60,11 +59,10 @@
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.addColorFragmentProcessor(conv);
- drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
+ drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian_2d(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
@@ -83,11 +81,10 @@
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.addColorFragmentProcessor(conv);
- drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
+ drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
}
static void convolve_gaussian(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
@@ -98,7 +95,7 @@
bool cropToSrcRect) {
float bounds[2] = { 0.0f, 1.0f };
if (!cropToSrcRect) {
- convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture,
+ convolve_gaussian_1d(drawContext, clip, srcRect, dstRect, texture,
direction, radius, sigma, false, bounds);
return;
}
@@ -130,15 +127,15 @@
}
if (radius >= size * SK_ScalarHalf) {
// Blur radius covers srcRect; use bounds over entire draw
- convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture,
+ convolve_gaussian_1d(drawContext, clip, srcRect, dstRect, texture,
direction, radius, sigma, true, bounds);
} else {
// Draw upper and lower margins with bounds; middle without.
- convolve_gaussian_1d(drawContext, rt, clip, lowerSrcRect, lowerDstRect, texture,
+ convolve_gaussian_1d(drawContext, clip, lowerSrcRect, lowerDstRect, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(drawContext, rt, clip, upperSrcRect, upperDstRect, texture,
+ convolve_gaussian_1d(drawContext, clip, upperSrcRect, upperDstRect, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(drawContext, rt, clip, middleSrcRect, middleDstRect, texture,
+ convolve_gaussian_1d(drawContext, clip, middleSrcRect, middleDstRect, texture,
direction, radius, sigma, false, bounds);
}
}
@@ -222,12 +219,12 @@
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(
+ context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) {
return nullptr;
}
- dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
- SkMatrix::I(), dstRect, srcRect);
+ dstDrawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
srcDrawContext.swap(dstDrawContext);
srcRect = dstRect;
@@ -245,11 +242,12 @@
SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(
+ context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) {
return nullptr;
}
- convolve_gaussian_2d(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+ convolve_gaussian_2d(dstDrawContext, clip, srcRect, dstRect,
srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
srcDrawContext.swap(dstDrawContext);
@@ -262,7 +260,7 @@
if (scaleFactorX > 1) {
// TODO: if we pass in the source draw context we don't need this here
if (!srcDrawContext) {
- srcDrawContext.reset(context->drawContext());
+ srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
if (!srcDrawContext) {
return nullptr;
}
@@ -272,15 +270,16 @@
// X convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
radiusX, srcIRect.height());
- srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(&clearRect, 0x0, false);
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(
+ context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) {
return nullptr;
}
- convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
+ convolve_gaussian(dstDrawContext, clip, srcRect, dstRect,
srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
cropToRect);
@@ -294,7 +293,7 @@
if (scaleFactorY > 1 || sigmaX > 0.0f) {
// TODO: if we pass in the source draw context we don't need this here
if (!srcDrawContext) {
- srcDrawContext.reset(context->drawContext());
+ srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
if (!srcDrawContext) {
return nullptr;
}
@@ -304,16 +303,17 @@
// convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width(), radiusY);
- srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(&clearRect, 0x0, false);
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(
+ context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) {
return nullptr;
}
- convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect,
+ convolve_gaussian(dstDrawContext, clip, srcRect,
dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
cropToRect);
@@ -331,10 +331,10 @@
// upsampling.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width() + 1, 1);
- srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(&clearRect, 0x0, false);
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height());
- srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false);
+ srcDrawContext->clear(&clearRect, 0x0, false);
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
@@ -346,12 +346,12 @@
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(
+ context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) {
return nullptr;
}
- dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
- SkMatrix::I(), dstRect, srcRect);
+ dstDrawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
srcDrawContext.swap(dstDrawContext);
srcRect = dstRect;
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 32589e1..4265f6e 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -330,7 +330,6 @@
#if SK_SUPPORT_GPU
void drawRect(GrDrawContext* drawContext,
GrTexture* src,
- GrTexture* dst,
const SkMatrix& matrix,
const GrClip& clip,
const SkRect& dstRect,
@@ -343,7 +342,6 @@
#if SK_SUPPORT_GPU
void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
GrTexture* src,
- GrTexture* dst,
const SkMatrix& matrix,
const GrClip& clip,
const SkRect& dstRect,
@@ -353,8 +351,7 @@
GrPaint paint;
GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, bounds, boundaryMode);
paint.addColorFragmentProcessor(fp)->unref();
- drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(),
- dstRect, srcRect);
+ drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
}
bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy,
@@ -406,24 +403,23 @@
SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() - 2, 1);
SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height() - 1, 1, 1);
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (!drawContext) {
return false;
}
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, topLeft, kTopLeft_BoundaryMode,
+ this->drawRect(drawContext, srcTexture, matrix, clip, topLeft, kTopLeft_BoundaryMode, bounds);
+ this->drawRect(drawContext, srcTexture, matrix, clip, top, kTop_BoundaryMode, bounds);
+ this->drawRect(drawContext, srcTexture, matrix, clip, topRight, kTopRight_BoundaryMode,
bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, top, kTop_BoundaryMode, bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, topRight, kTopRight_BoundaryMode,
+ this->drawRect(drawContext, srcTexture, matrix, clip, left, kLeft_BoundaryMode, bounds);
+ this->drawRect(drawContext, srcTexture, matrix, clip, interior, kInterior_BoundaryMode,
bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, left, kLeft_BoundaryMode, bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, interior, kInterior_BoundaryMode,
+ this->drawRect(drawContext, srcTexture, matrix, clip, right, kRight_BoundaryMode, bounds);
+ this->drawRect(drawContext, srcTexture, matrix, clip, bottomLeft, kBottomLeft_BoundaryMode,
bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, right, kRight_BoundaryMode, bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottomLeft, kBottomLeft_BoundaryMode,
- bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottom, kBottom_BoundaryMode, bounds);
- this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottomRight,
+ this->drawRect(drawContext, srcTexture, matrix, clip, bottom, kBottom_BoundaryMode, bounds);
+ this->drawRect(drawContext, srcTexture, matrix, clip, bottomRight,
kBottomRight_BoundaryMode, bounds);
WrapTexture(dst, bounds.width(), bounds.height(), result);
return true;
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 584cf1b..4f60666 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -458,7 +458,6 @@
void apply_morphology_rect(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
@@ -473,12 +472,11 @@
radius,
morphType,
bounds))->unref();
- drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
+ drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
@@ -491,12 +489,11 @@
direction,
radius,
morphType))->unref();
- drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
+ drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
void apply_morphology_pass(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
@@ -529,15 +526,15 @@
}
if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) {
// radius covers srcRect; use bounds over entire draw
- apply_morphology_rect(drawContext, rt, clip, texture, srcRect, dstRect, radius,
+ apply_morphology_rect(drawContext, clip, texture, srcRect, dstRect, radius,
morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
- apply_morphology_rect(drawContext, rt, clip, texture, lowerSrcRect, lowerDstRect, radius,
+ apply_morphology_rect(drawContext, clip, texture, lowerSrcRect, lowerDstRect, radius,
morphType, bounds, direction);
- apply_morphology_rect(drawContext, rt, clip, texture, upperSrcRect, upperDstRect, radius,
+ apply_morphology_rect(drawContext, clip, texture, upperSrcRect, upperDstRect, radius,
morphType, bounds, direction);
- apply_morphology_rect_no_bounds(drawContext, rt, clip, texture, middleSrcRect, middleDstRect,
+ apply_morphology_rect_no_bounds(drawContext, clip, texture, middleSrcRect, middleDstRect,
radius, morphType, direction);
}
}
@@ -568,12 +565,12 @@
if (nullptr == scratch) {
return false;
}
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext(scratch->asRenderTarget()));
if (!dstDrawContext) {
return false;
}
- apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, srcTexture,
+ apply_morphology_pass(dstDrawContext, clip, srcTexture,
srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
@@ -581,7 +578,7 @@
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
SK_ColorWHITE :
SK_ColorTRANSPARENT;
- dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor, false);
+ dstDrawContext->clear(&clearRect, clearColor, false);
srcTexture.reset(scratch);
srcRect = dstRect;
@@ -591,12 +588,12 @@
if (nullptr == scratch) {
return false;
}
- SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext(scratch->asRenderTarget()));
if (!dstDrawContext) {
return false;
}
- apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, srcTexture,
+ apply_morphology_pass(dstDrawContext, clip, srcTexture,
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 2311bb7..e443a00 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -197,13 +197,12 @@
paint.addColorFragmentProcessor(xferFP)->unref();
}
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (!drawContext) {
return false;
}
- drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint,
- SkMatrix::I(), srcRect);
+ drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), srcRect);
offset->fX = backgroundOffset.fX;
offset->fY = backgroundOffset.fY;
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index a396c33..5d691fb 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -26,7 +26,6 @@
// is already burnt into the mask this boils down to a rect draw.
// Return true if the mask was successfully drawn.
static bool draw_mask(GrDrawContext* drawContext,
- GrRenderTarget* rt,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkRect& maskRect,
@@ -43,13 +42,12 @@
if (!viewMatrix.invert(&inverse)) {
return false;
}
- drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), maskRect, inverse);
+ drawContext->drawNonAARectWithLocalMatrix(clip, *grp, SkMatrix::I(), maskRect, inverse);
return true;
}
static bool draw_with_mask_filter(GrDrawContext* drawContext,
GrTextureProvider* textureProvider,
- GrRenderTarget* rt,
const GrClip& clipData,
const SkMatrix& viewMatrix,
const SkPath& devPath,
@@ -91,7 +89,7 @@
SkRect maskRect = SkRect::Make(dstM.fBounds);
- return draw_mask(drawContext, rt, clipData, viewMatrix, maskRect, grp, texture);
+ return draw_mask(drawContext, clipData, viewMatrix, maskRect, grp, texture);
}
// Create a mask of 'devPath' and place the result in 'mask'.
@@ -126,12 +124,12 @@
SkRect clipRect = SkRect::MakeWH(maskRect->width(), maskRect->height());
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(mask->asRenderTarget()));
if (!drawContext) {
return nullptr;
}
- drawContext->clear(mask->asRenderTarget(), nullptr, 0x0, true);
+ drawContext->clear(nullptr, 0x0, true);
GrPaint tempPaint;
tempPaint.setAntiAlias(doAA);
@@ -144,7 +142,7 @@
// the origin using tempPaint.
SkMatrix translate;
translate.setTranslate(-maskRect->fLeft, -maskRect->fTop);
- drawContext->drawPath(mask->asRenderTarget(), clip, tempPaint, translate, devPath, strokeInfo);
+ drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo);
return mask;
}
@@ -247,7 +245,6 @@
if (paint.getMaskFilter()->directFilterMaskGPU(context->textureProvider(),
drawContext,
- renderTarget,
&grPaint,
clip,
viewMatrix,
@@ -272,7 +269,6 @@
// filterMaskGPU gives us ownership of a ref to the result
SkAutoTUnref<GrTexture> atu(filtered);
if (draw_mask(drawContext,
- renderTarget,
clip,
viewMatrix,
maskRect,
@@ -289,12 +285,12 @@
// GPU path fails
SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style;
- draw_with_mask_filter(drawContext, context->textureProvider(), renderTarget,
+ draw_with_mask_filter(drawContext, context->textureProvider(),
clip, viewMatrix, *devPathPtr,
paint.getMaskFilter(), clipBounds, &grPaint, style);
return;
}
- drawContext->drawPath(renderTarget, clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
+ drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d402604..82550d0 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -125,12 +125,13 @@
return fTextContexts[props.pixelGeometry()][useDIF];
}
-GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceProps) {
+GrDrawContext* GrContext::DrawingMgr::drawContext(GrRenderTarget* rt,
+ const SkSurfaceProps* surfaceProps) {
if (this->abandoned()) {
return nullptr;
}
- return new GrDrawContext(fContext, fDrawTarget, surfaceProps);
+ return new GrDrawContext(fContext, rt, fDrawTarget, surfaceProps);
}
////////////////////////////////////////////////////////////////////////////////
@@ -429,13 +430,13 @@
}
SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
- SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarget));
if (!drawContext) {
return false;
}
paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matrix, rect, nullptr);
+ drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullptr);
if (kFlushWrites_PixelOp & pixelOpsFlags) {
this->flushSurfaceWrites(surface);
@@ -541,9 +542,8 @@
if (fp) {
paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
- drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint,
- SkMatrix::I(), rect, nullptr);
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(temp->asRenderTarget()));
+ drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, nullptr);
surfaceToRead.reset(SkRef(temp.get()));
left = 0;
top = 0;
@@ -617,12 +617,12 @@
return;
}
- SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarget()));
if (!drawContext) {
return;
}
- drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint);
+ drawContext->copySurface(src, srcRect, dstPoint);
if (kFlushWrites_PixelOp & pixelOpsFlags) {
this->flush();
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 96bc3f3..dcf148f 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -38,72 +38,81 @@
};
GrDrawContext::GrDrawContext(GrContext* context,
+ GrRenderTarget* rt,
GrDrawTarget* drawTarget,
const SkSurfaceProps* surfaceProps)
: fContext(context)
+ , fRenderTarget(rt)
, fDrawTarget(SkRef(drawTarget))
, fTextContext(nullptr)
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) {
+ SkDEBUGCODE(this->validate();)
}
GrDrawContext::~GrDrawContext() {
SkSafeUnref(fDrawTarget);
}
-void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) {
+#ifdef SK_DEBUG
+void GrDrawContext::validate() const {
+ SkASSERT(fRenderTarget);
+ ASSERT_OWNED_RESOURCE(fRenderTarget);
+}
+#endif
+
+void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
- if (!this->prepareToDraw(dst)) {
- return;
- }
-
- fDrawTarget->copySurface(dst, src, srcRect, dstPoint);
+ fDrawTarget->copySurface(fRenderTarget, src, srcRect, dstPoint);
}
-void GrDrawContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPaint& grPaint,
+void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
if (!fTextContext) {
- fTextContext = fContext->textContext(fSurfaceProps, rt);
+ fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawText(this, rt, clip, grPaint, skPaint, viewMatrix,
+ fTextContext->drawText(this, fRenderTarget, clip, grPaint, skPaint, viewMatrix,
text, byteLength, x, y, clipBounds);
}
-void GrDrawContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const GrPaint& grPaint,
+void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
if (!fTextContext) {
- fTextContext = fContext->textContext(fSurfaceProps, rt);
+ fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawPosText(this, rt, clip, grPaint, skPaint, viewMatrix, text, byteLength,
+ fTextContext->drawPosText(this, fRenderTarget, clip, grPaint, skPaint, viewMatrix, text, byteLength,
pos, scalarsPerPosition, offset, clipBounds);
}
-void GrDrawContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip, const SkPaint& skPaint,
+void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix, const SkTextBlob* blob,
SkScalar x, SkScalar y,
SkDrawFilter* filter, const SkIRect& clipBounds) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
if (!fTextContext) {
- fTextContext = fContext->textContext(fSurfaceProps, rt);
+ fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget);
}
- fTextContext->drawTextBlob(this, rt,
+ fTextContext->drawTextBlob(this, fRenderTarget,
clip, skPaint, viewMatrix, blob, x, y, filter, clipBounds);
}
@@ -115,47 +124,43 @@
GrPathRangeDraw* draw,
int /*GrPathRendering::FillType*/ fill) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
fDrawTarget->drawPathsFromRange(*pipelineBuilder, viewMatrix, localMatrix, color, range, draw,
(GrPathRendering::FillType) fill);
}
-void GrDrawContext::discard(GrRenderTarget* renderTarget) {
+void GrDrawContext::discard() {
RETURN_IF_ABANDONED
- SkASSERT(renderTarget);
+ SkDEBUGCODE(this->validate();)
+
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(renderTarget)) {
- return;
- }
- fDrawTarget->discard(renderTarget);
+ fDrawTarget->discard(fRenderTarget);
}
-void GrDrawContext::clear(GrRenderTarget* renderTarget,
- const SkIRect* rect,
+void GrDrawContext::clear(const SkIRect* rect,
const GrColor color,
bool canIgnoreRect) {
RETURN_IF_ABANDONED
- SkASSERT(renderTarget);
+ SkDEBUGCODE(this->validate();)
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(renderTarget)) {
- return;
- }
- fDrawTarget->clear(rect, color, canIgnoreRect, renderTarget);
+ fDrawTarget->clear(rect, color, canIgnoreRect, fRenderTarget);
}
-void GrDrawContext::drawPaint(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawPaint(const GrClip& clip,
const GrPaint& origPaint,
const SkMatrix& viewMatrix) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
// 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(rt->width()),
- SkIntToScalar(rt->height()));
+ SkIntToScalar(fRenderTarget->width()),
+ SkIntToScalar(fRenderTarget->height()));
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
// by definition this fills the entire clip, no need for AA
@@ -175,7 +180,7 @@
return;
}
inverse.mapRect(&r);
- this->drawRect(rt, clip, *paint, viewMatrix, r);
+ this->drawRect(clip, *paint, viewMatrix, r);
} else {
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
@@ -184,11 +189,8 @@
}
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(*paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip);
fDrawTarget->drawNonAARect(pipelineBuilder,
paint->getColor(),
SkMatrix::I(),
@@ -202,27 +204,25 @@
point.fY >= rect.fTop && point.fY <= rect.fBottom;
}
-void GrDrawContext::drawRect(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrStrokeInfo* strokeInfo) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
if (strokeInfo && strokeInfo->isDashed()) {
SkPath path;
path.setIsVolatile(true);
path.addRect(rect);
- this->drawPath(rt, clip, paint, viewMatrix, path, *strokeInfo);
+ this->drawPath(clip, paint, viewMatrix, path, *strokeInfo);
return;
}
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth();
@@ -253,7 +253,7 @@
// Will it blend?
GrColor clearColor;
if (paint.isConstantBlendedColor(&clearColor)) {
- fDrawTarget->clear(nullptr, clearColor, true, rt);
+ fDrawTarget->clear(nullptr, clearColor, true, fRenderTarget);
return;
}
}
@@ -285,7 +285,7 @@
if (width >= 0) {
// Non-AA hairlines are snapped to pixel centers to make which pixels are hit deterministic
- bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled());
+ bool snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisampled());
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke(
color, viewMatrix, rect, width, snapToPixelCenters));
@@ -301,19 +301,17 @@
}
}
-void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawNonAARectToRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkRect& localRect) {
RETURN_IF_ABANDONED
- AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
+ SkDEBUGCODE(this->validate();)
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ AutoCheckFlush acf(fContext);
+
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
fDrawTarget->drawNonAARect(pipelineBuilder,
paint.getColor(),
viewMatrix,
@@ -321,19 +319,17 @@
localRect);
}
-void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawNonAARectWithLocalMatrix(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkMatrix& localMatrix) {
RETURN_IF_ABANDONED
- AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
+ SkDEBUGCODE(this->validate();)
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ AutoCheckFlush acf(fContext);
+
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
fDrawTarget->drawNonAARect(pipelineBuilder,
paint.getColor(),
viewMatrix,
@@ -341,8 +337,7 @@
localMatrix);
}
-void GrDrawContext::drawVertices(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawVertices(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
@@ -353,12 +348,11 @@
const uint16_t indices[],
int indexCount) {
RETURN_IF_ABANDONED
- AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
+ SkDEBUGCODE(this->validate();)
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ AutoCheckFlush acf(fContext);
+
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
// TODO clients should give us bounds
SkRect bounds;
@@ -387,8 +381,7 @@
///////////////////////////////////////////////////////////////////////////////
-void GrDrawContext::drawAtlas(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawAtlas(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
int spriteCount,
@@ -396,12 +389,11 @@
const SkRect texRect[],
const SkColor colors[]) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrDrawAtlasBatch::Geometry geometry;
geometry.fColor = paint.getColor();
@@ -413,13 +405,14 @@
///////////////////////////////////////////////////////////////////////////////
-void GrDrawContext::drawRRect(GrRenderTarget*rt,
- const GrClip& clip,
+void GrDrawContext::drawRRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const GrStrokeInfo& strokeInfo) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
if (rrect.isEmpty()) {
return;
}
@@ -428,17 +421,15 @@
SkPath path;
path.setIsVolatile(true);
path.addRRect(rrect);
- this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo);
+ this->drawPath(clip, paint, viewMatrix, path, strokeInfo);
return;
}
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrColor color = paint.getColor();
+
if (!GrOvalRenderer::DrawRRect(fDrawTarget,
pipelineBuilder,
color,
@@ -456,23 +447,21 @@
///////////////////////////////////////////////////////////////////////////////
-void GrDrawContext::drawDRRect(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawDRRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& outer,
const SkRRect& inner) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
if (outer.isEmpty()) {
return;
}
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrColor color = paint.getColor();
if (!GrOvalRenderer::DrawDRRect(fDrawTarget,
pipelineBuilder,
@@ -495,13 +484,14 @@
///////////////////////////////////////////////////////////////////////////////
-void GrDrawContext::drawOval(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawOval(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
const GrStrokeInfo& strokeInfo) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
if (oval.isEmpty()) {
return;
}
@@ -510,17 +500,15 @@
SkPath path;
path.setIsVolatile(true);
path.addOval(oval);
- this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo);
+ this->drawPath(clip, paint, viewMatrix, path, strokeInfo);
return;
}
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrColor color = paint.getColor();
+
if (!GrOvalRenderer::DrawOval(fDrawTarget,
pipelineBuilder,
color,
@@ -586,29 +574,28 @@
return allEq || allGoE1;
}
-void GrDrawContext::drawBatch(GrRenderTarget* rt, const GrClip& clip,
+void GrDrawContext::drawBatch(const GrClip& clip,
const GrPaint& paint, GrDrawBatch* batch) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
fDrawTarget->drawBatch(pipelineBuilder, batch);
}
-void GrDrawContext::drawPath(GrRenderTarget* rt,
- const GrClip& clip,
+void GrDrawContext::drawPath(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkPath& path,
const GrStrokeInfo& strokeInfo) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+
if (path.isEmpty()) {
if (path.isInverseFillType()) {
- this->drawPaint(rt, clip, paint, viewMatrix);
+ this->drawPaint(clip, paint, viewMatrix);
}
return;
}
@@ -621,11 +608,8 @@
// the writePixels that uploads to the scratch will perform a flush so we're
// OK.
AutoCheckFlush acf(fContext);
- if (!this->prepareToDraw(rt)) {
- return;
- }
- GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
if (!strokeInfo.isDashed()) {
bool useCoverageAA = paint.isAntiAlias() &&
!pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
@@ -670,7 +654,6 @@
RETURN_IF_ABANDONED
SkASSERT(!path.isEmpty());
-
// An Assumption here is that path renderer would use some form of tweaking
// the src color (either the input alpha or in the frag shader) to implement
// aa. If we have some future driver-mojo path AA that can do the right
@@ -749,16 +732,9 @@
pr->drawPath(args);
}
-bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) {
- RETURN_FALSE_IF_ABANDONED
-
- ASSERT_OWNED_RESOURCE(rt);
- SkASSERT(rt);
- return true;
-}
-
void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch) {
RETURN_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
fDrawTarget->drawBatch(*pipelineBuilder, batch);
}
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 27cb55b..b2d4c4e 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -467,10 +467,11 @@
SkASSERT(0 == fPictureHash.count());
- SkAutoTUnref<GrDrawContext> drawContext(fContext->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(
+ fContext->drawContext(fAtlas->getTexture()->asRenderTarget()));
if (drawContext) {
- drawContext->discard(fAtlas->getTexture()->asRenderTarget());
+ drawContext->discard();
}
}
#endif
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 4bb0143..e81a9cf 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -22,12 +22,12 @@
return;
}
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(this));
if (!drawContext) {
return;
}
- drawContext->discard(this);
+ drawContext->discard();
}
void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 071cd4d..9385948 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -130,12 +130,12 @@
paint.addColorFragmentProcessor(yuvToRgbProcessor);
const SkRect r = SkRect::MakeIWH(yuvInfo.fSize[0].fWidth, yuvInfo.fSize[0].fHeight);
- SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(renderTarget));
if (!drawContext) {
return nullptr;
}
- drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, SkMatrix::I(), r);
+ drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), r);
return result.detach();
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index ab91316..cb532fe 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -198,7 +198,7 @@
fLegacyBitmap.setInfo(info);
fLegacyBitmap.setPixelRef(pr)->unref();
- fDrawContext.reset(fContext->drawContext(&this->surfaceProps()));
+ fDrawContext.reset(fContext->drawContext(rt, &this->surfaceProps()));
}
GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::Budgeted budgeted,
@@ -336,7 +336,7 @@
GrColor color = 0;
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clearAll", fContext);
SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
- fDrawContext->clear(fRenderTarget, &rect, color, true);
+ fDrawContext->clear(&rect, color, true);
fNeedClear = false;
}
@@ -375,7 +375,8 @@
SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget);
fLegacyBitmap.setPixelRef(pr)->unref();
- fDrawContext.reset(fRenderTarget->getContext()->drawContext(&this->surfaceProps()));
+ fDrawContext.reset(fRenderTarget->getContext()->drawContext(fRenderTarget,
+ &this->surfaceProps()));
}
///////////////////////////////////////////////////////////////////////////////
@@ -389,7 +390,7 @@
return;
}
- fDrawContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix);
+ fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix);
}
// must be in SkCanvas::PointMode order
@@ -441,7 +442,7 @@
path.setIsVolatile(true);
path.moveTo(pts[0]);
path.lineTo(pts[1]);
- fDrawContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, path, strokeInfo);
+ fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, strokeInfo);
return;
}
@@ -458,8 +459,7 @@
return;
}
- fDrawContext->drawVertices(fRenderTarget,
- fClip,
+ fDrawContext->drawVertices(fClip,
grPaint,
*draw.fMatrix,
gPointMode2PrimtiveType[mode],
@@ -521,7 +521,7 @@
return;
}
- fDrawContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
+ fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
}
///////////////////////////////////////////////////////////////////////////////
@@ -557,7 +557,6 @@
}
if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext->textureProvider(),
fDrawContext,
- fRenderTarget,
&grPaint,
fClip,
*draw.fMatrix,
@@ -592,7 +591,7 @@
return;
}
- fDrawContext->drawRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, strokeInfo);
+ fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo);
}
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
@@ -609,7 +608,7 @@
}
if (nullptr == paint.getMaskFilter() && nullptr == paint.getPathEffect()) {
- fDrawContext->drawDRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, outer, inner);
+ fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
return;
}
}
@@ -660,7 +659,7 @@
return;
}
- fDrawContext->drawOval(fRenderTarget, fClip, grPaint, *draw.fMatrix, oval, strokeInfo);
+ fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo);
}
#include "SkMaskFilter.h"
@@ -1033,7 +1032,7 @@
dstRect,
devRect));
- drawContext->drawBatch(renderTarget, clip, grPaint, batch);
+ drawContext->drawBatch(clip, grPaint, batch);
}
static bool can_ignore_strict_subset_constraint(const SkBitmap& bitmap, const SkRect& subset) {
@@ -1381,10 +1380,9 @@
if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) {
// We don't have local coords in this case and have previously set the transform
// matrices directly on the texture processor.
- fDrawContext->drawRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect);
+ fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect);
} else {
- fDrawContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect,
- paintRect);
+ fDrawContext->drawNonAARectToRect(fClip, grPaint, viewMatrix, dstRect, paintRect);
}
}
@@ -1466,8 +1464,7 @@
return;
}
- fDrawContext->drawNonAARectToRect(fRenderTarget,
- fClip,
+ fDrawContext->drawNonAARectToRect(fClip,
grPaint,
SkMatrix::I(),
SkRect::MakeXYWH(SkIntToScalar(left),
@@ -1597,8 +1594,7 @@
SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
SK_Scalar1 * h / devTex->height());
- fDrawContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, SkMatrix::I(), dstRect,
- srcRect);
+ fDrawContext->drawNonAARectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect);
}
bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
@@ -1749,8 +1745,7 @@
lineIndices[i + 5] = state.f0;
i += 6;
}
- fDrawContext->drawVertices(fRenderTarget,
- fClip,
+ fDrawContext->drawVertices(fClip,
grPaint,
*draw.fMatrix,
kLines_GrPrimitiveType,
@@ -1813,8 +1808,7 @@
}
}
- fDrawContext->drawVertices(fRenderTarget,
- fClip,
+ fDrawContext->drawVertices(fClip,
grPaint,
*draw.fMatrix,
primType,
@@ -1855,8 +1849,7 @@
}
SkDEBUGCODE(this->validate();)
- fDrawContext->drawAtlas(fRenderTarget, fClip, grPaint, *draw.fMatrix,
- count, xform, texRect, colors);
+ fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect, colors);
}
///////////////////////////////////////////////////////////////////////////////
@@ -1874,7 +1867,7 @@
SkDEBUGCODE(this->validate();)
- fDrawContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix,
+ fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix,
(const char *)text, byteLength, x, y, draw.fClip->getBounds());
}
@@ -1891,7 +1884,7 @@
SkDEBUGCODE(this->validate();)
- fDrawContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix,
+ fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix,
(const char *)text, byteLength, pos, scalarsPerPos, offset,
draw.fClip->getBounds());
}
@@ -1903,7 +1896,7 @@
SkDEBUGCODE(this->validate();)
- fDrawContext->drawTextBlob(fRenderTarget, fClip, paint, *draw.fMatrix,
+ fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix,
blob, x, y, drawFilter, draw.fClip->getBounds());
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ce4af0b..50cd5fa 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -285,13 +285,12 @@
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
SkRect localRect = SkRect::MakeWH(1.f, 1.f);
- SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(stretched->asRenderTarget()));
if (!drawContext) {
return nullptr;
}
- drawContext->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOpen(), paint,
- SkMatrix::I(), rect, localRect);
+ drawContext->drawNonAARectToRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, localRect);
return stretched.detach();
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 909e461..8acf727 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -224,14 +224,13 @@
paint1.addColorFragmentProcessor(pmToUPM1);
- SkAutoTUnref<GrDrawContext> readDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> readDrawContext(context->drawContext(readTex->asRenderTarget()));
if (!readDrawContext) {
failed = true;
break;
}
- readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
- GrClip::WideOpen(),
+ readDrawContext->drawNonAARectToRect(GrClip::WideOpen(),
paint1,
SkMatrix::I(),
kDstRect,
@@ -241,13 +240,12 @@
paint2.addColorFragmentProcessor(upmToPM);
- SkAutoTUnref<GrDrawContext> tempDrawContext(context->drawContext());
+ SkAutoTUnref<GrDrawContext> tempDrawContext(context->drawContext(tempTex->asRenderTarget()));
if (!tempDrawContext) {
failed = true;
break;
}
- tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(),
- GrClip::WideOpen(),
+ tempDrawContext->drawNonAARectToRect(GrClip::WideOpen(),
paint2,
SkMatrix::I(),
kDstRect,
@@ -255,14 +253,13 @@
paint3.addColorFragmentProcessor(pmToUPM2);
- readDrawContext.reset(context->drawContext());
+ readDrawContext.reset(context->drawContext(readTex->asRenderTarget()));
if (!readDrawContext) {
failed = true;
break;
}
- readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
- GrClip::WideOpen(),
+ readDrawContext->drawNonAARectToRect(GrClip::WideOpen(),
paint3,
SkMatrix::I(),
kDstRect,
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index f7a73b9..67d1b8c 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -364,12 +364,12 @@
const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
SkIntToScalar(dstDesc.fHeight));
- SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext());
+ SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(dst->asRenderTarget()));
if (!drawContext) {
return nullptr;
}
- drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect);
+ drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(dst);
return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
kOpaque_SkAlphaType, dst, budgeted);