GrDrawContext now holds GrRenderTarget pointer

Review URL: https://codereview.chromium.org/1404823005
This commit is contained in:
robertphillips 2015-10-15 08:01:48 -07:00 committed by Commit bot
parent 860e8a6719
commit 2e1e51f049
23 changed files with 238 additions and 305 deletions

View File

@ -22,7 +22,7 @@ static const int S = 200;
DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) { DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
GrRenderTarget* target = canvas->internal_private_accessTopLayerRenderTarget(); GrRenderTarget* target = canvas->internal_private_accessTopLayerRenderTarget();
GrContext* ctx = canvas->getGrContext(); GrContext* ctx = canvas->getGrContext();
SkAutoTUnref<GrDrawContext> drawContext(ctx ? ctx->drawContext() : nullptr); SkAutoTUnref<GrDrawContext> drawContext(ctx ? ctx->drawContext(target) : nullptr);
if (drawContext && target) { if (drawContext && target) {
SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S)); SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
static const int stride = 2 * S; static const int stride = 2 * S;
@ -96,7 +96,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
tm.postIDiv(2*S, 2*S); tm.postIDiv(2*S, 2*S);
paint.addColorTextureProcessor(texture, tm); 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 // now update the lower right of the texture in first pass
// or upper right in second pass // or upper right in second pass
@ -110,7 +110,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
texture->writePixels(S, (i ? 0 : S), S, S, texture->writePixels(S, (i ? 0 : S), S, S,
texture->config(), gTextureData.get(), texture->config(), gTextureData.get(),
4 * stride); 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 { } else {
skiagm::GM::DrawGpuOnlyMessage(canvas); skiagm::GM::DrawGpuOnlyMessage(canvas);

View File

@ -113,7 +113,6 @@ public:
*/ */
virtual bool directFilterMaskGPU(GrTextureProvider* texProvider, virtual bool directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip&, const GrClip&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
@ -125,7 +124,6 @@ public:
*/ */
virtual bool directFilterRRectMaskGPU(GrTextureProvider* texProvider, virtual bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip&, const GrClip&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,

View File

@ -175,12 +175,13 @@ public:
* Callers should take a ref if they rely on the GrDrawContext sticking around. * Callers should take a ref if they rely on the GrDrawContext sticking around.
* NULL will be returned if the context has been abandoned. * 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) * @param surfaceProps the surface properties (mainly defines text drawing)
* *
* @return a draw context * @return a draw context
*/ */
GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) { GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps = NULL) {
return fDrawingMgr.drawContext(surfaceProps); return fDrawingMgr.drawContext(rt, surfaceProps);
} }
GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarget* rt) { GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarget* rt) {
@ -441,7 +442,7 @@ private:
// Callers assume the creation ref of the drawContext! // Callers assume the creation ref of the drawContext!
// NULL will be returned if the context has been abandoned. // 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); GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt);

View File

@ -44,20 +44,19 @@ class SK_API GrDrawContext : public SkRefCnt {
public: public:
~GrDrawContext() override; ~GrDrawContext() override;
void copySurface(GrRenderTarget* dst, GrSurface* src, void copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
const SkIRect& srcRect, const SkIPoint& dstPoint);
// TODO: it is odd that we need both the SkPaint in the following 3 methods. // 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 // We should extract the text parameters from SkPaint and pass them separately
// akin to GrStrokeInfo (GrTextInfo?) // 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, const SkMatrix& viewMatrix, const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds); 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 SkMatrix& viewMatrix, const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition, const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds); const SkPoint& offset, const SkIRect& clipBounds);
void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, void drawTextBlob(const GrClip&, const SkPaint&,
const SkMatrix& viewMatrix, const SkTextBlob*, const SkMatrix& viewMatrix, const SkTextBlob*,
SkScalar x, SkScalar y, SkScalar x, SkScalar y,
SkDrawFilter*, const SkIRect& clipBounds); SkDrawFilter*, const SkIRect& clipBounds);
@ -76,22 +75,21 @@ public:
* Provides a perfomance hint that the render target's contents are allowed * Provides a perfomance hint that the render target's contents are allowed
* to become undefined. * to become undefined.
*/ */
void discard(GrRenderTarget*); void discard();
/** /**
* Clear the entire or rect of the render target, ignoring any clips. * 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 rect the rect to clear or the whole thing if rect is NULL.
* @param color the color to clear to. * @param color the color to clear to.
* @param canIgnoreRect allows partial clears to be converted to whole * @param canIgnoreRect allows partial clears to be converted to whole
* clears on platforms for which that is cheap * 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. * 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. * Draw the rect using a paint.
@ -105,8 +103,7 @@ public:
* mitered/beveled stroked based on stroke width. * mitered/beveled stroked based on stroke width.
* The rects coords are used to access the paint (through texture matrix) * The rects coords are used to access the paint (through texture matrix)
*/ */
void drawRect(GrRenderTarget*, void drawRect(const GrClip&,
const GrClip&,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect&, const SkRect&,
@ -120,8 +117,7 @@ public:
* @param rectToDraw the rectangle to draw * @param rectToDraw the rectangle to draw
* @param localRect the rectangle of shader coordinates applied to rectToDraw * @param localRect the rectangle of shader coordinates applied to rectToDraw
*/ */
void drawNonAARectToRect(GrRenderTarget*, void drawNonAARectToRect(const GrClip&,
const GrClip&,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& rectToDraw, const SkRect& rectToDraw,
@ -130,8 +126,7 @@ public:
/** /**
* Draws a non-AA rect with paint and a localMatrix * Draws a non-AA rect with paint and a localMatrix
*/ */
void drawNonAARectWithLocalMatrix(GrRenderTarget* rt, void drawNonAARectWithLocalMatrix(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& rect, const SkRect& rect,
@ -146,8 +141,7 @@ public:
* @param strokeInfo the stroke information (width, join, cap) and * @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase). * the dash information (intervals, count, phase).
*/ */
void drawRRect(GrRenderTarget*, void drawRRect(const GrClip&,
const GrClip&,
const GrPaint&, const GrPaint&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRRect& rrect, const SkRRect& rrect,
@ -163,8 +157,7 @@ public:
* @param outer the outer roundrect * @param outer the outer roundrect
* @param inner the inner roundrect * @param inner the inner roundrect
*/ */
void drawDRRect(GrRenderTarget*, void drawDRRect(const GrClip&,
const GrClip&,
const GrPaint&, const GrPaint&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRRect& outer, const SkRRect& outer,
@ -180,8 +173,7 @@ public:
* @param strokeInfo the stroke information (width, join, cap) and * @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase). * the dash information (intervals, count, phase).
*/ */
void drawPath(GrRenderTarget*, void drawPath(const GrClip&,
const GrClip&,
const GrPaint&, const GrPaint&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkPath&, const SkPath&,
@ -204,8 +196,7 @@ public:
* @param indexCount if indices is non-null then this is the * @param indexCount if indices is non-null then this is the
* number of indices. * number of indices.
*/ */
void drawVertices(GrRenderTarget*, void drawVertices(const GrClip&,
const GrClip&,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType, GrPrimitiveType primitiveType,
@ -227,8 +218,7 @@ public:
* @param colors optional array of per-sprite colors, supercedes * @param colors optional array of per-sprite colors, supercedes
* the paint's color field. * the paint's color field.
*/ */
void drawAtlas(GrRenderTarget*, void drawAtlas(const GrClip&,
const GrClip&,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
int spriteCount, int spriteCount,
@ -245,8 +235,7 @@ public:
* @param strokeInfo the stroke information (width, join, cap) and * @param strokeInfo the stroke information (width, join, cap) and
* the dash information (intervals, count, phase). * the dash information (intervals, count, phase).
*/ */
void drawOval(GrRenderTarget*, void drawOval(const GrClip&,
const GrClip&,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& oval, const SkRect& oval,
@ -259,16 +248,15 @@ public:
* @param paint describes how to color pixels. * @param paint describes how to color pixels.
* @param batch the batch to draw * @param batch the batch to draw
*/ */
void drawBatch(GrRenderTarget*, const GrClip&, const GrPaint&, GrDrawBatch*); void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*);
private: private:
friend class GrAtlasTextContext; // for access to drawBatch friend class GrAtlasTextContext; // for access to drawBatch
friend class GrContext; // for ctor 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 GrDrawContext(GrContext*, GrRenderTarget*, GrDrawTarget*, const SkSurfaceProps* surfaceProps);
bool prepareToDraw(GrRenderTarget* rt);
void internalDrawPath(GrDrawTarget*, void internalDrawPath(GrDrawTarget*,
GrPipelineBuilder*, GrPipelineBuilder*,
@ -283,6 +271,7 @@ private:
void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch); void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch);
GrContext* fContext; // owning context -> no ref GrContext* fContext; // owning context -> no ref
GrRenderTarget* fRenderTarget;
GrDrawTarget* fDrawTarget; GrDrawTarget* fDrawTarget;
GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMgr GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMgr

View File

@ -360,10 +360,9 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
SkASSERT(fp); SkASSERT(fp);
paint.addColorFragmentProcessor(fp)->unref(); paint.addColorFragmentProcessor(fp)->unref();
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (drawContext) { if (drawContext) {
drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(), drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
dstRect, srcRect);
WrapTexture(dst, bounds.width(), bounds.height(), result); WrapTexture(dst, bounds.width(), bounds.height(), result);
return true; return true;

View File

@ -318,7 +318,6 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect,
bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider, bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip&, const GrClip&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
@ -330,7 +329,6 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect,
bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider, bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip&, const GrClip&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,

View File

@ -251,7 +251,7 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
GrTexture* texture, GrTexture* texture,
const SkMatrix& in_matrix, const SkMatrix& inMatrix,
const SkIRect&) const { const SkIRect&) const {
if (fp) { if (fp) {
GrContext* context = texture->getContext(); GrContext* context = texture->getContext();
@ -272,17 +272,17 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
return false; return false;
} }
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(
context->drawContext(maskTexture->asRenderTarget()));
if (drawContext) { if (drawContext) {
GrPaint grPaint; GrPaint grPaint;
grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkRegion::Iterator iter(fRegion); SkRegion::Iterator iter(fRegion);
drawContext->clear(maskTexture->asRenderTarget(), nullptr, 0x0, true); drawContext->clear(nullptr, 0x0, true);
while (!iter.done()) { while (!iter.done()) {
SkRect rect = SkRect::Make(iter.rect()); SkRect rect = SkRect::Make(iter.rect());
drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint, drawContext->drawRect(GrClip::WideOpen(), grPaint, inMatrix, rect);
in_matrix, rect);
iter.next(); iter.next();
} }
} }

View File

@ -51,7 +51,6 @@ public:
SkRect* maskRect) const override; SkRect* maskRect) const override;
bool directFilterMaskGPU(GrTextureProvider* texProvider, bool directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip&, const GrClip&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
@ -59,7 +58,6 @@ public:
const SkPath& path) const override; const SkPath& path) const override;
bool directFilterRRectMaskGPU(GrTextureProvider* texProvider, bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip&, const GrClip&,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
@ -806,7 +804,6 @@ const GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d)
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider, bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip& clip, const GrClip& clip,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
@ -854,7 +851,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
return false; return false;
} }
drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse); drawContext->drawNonAARectWithLocalMatrix(clip, *grp, SkMatrix::I(), rect, inverse);
return true; return true;
} }
@ -1101,7 +1098,6 @@ GrGLFragmentProcessor* GrRRectBlurEffect::onCreateGLInstance() const {
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider, bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
GrDrawContext* drawContext, GrDrawContext* drawContext,
GrRenderTarget* rt,
GrPaint* grp, GrPaint* grp,
const GrClip& clip, const GrClip& clip,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
@ -1136,7 +1132,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
return false; return false;
} }
drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxyRect, inverse); drawContext->drawNonAARectWithLocalMatrix(clip, *grp, SkMatrix::I(), proxyRect, inverse);
return true; return true;
} }
@ -1222,13 +1218,12 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
} }
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext((*result)->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return false; return false;
} }
drawContext->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), clipRect);
paint, SkMatrix::I(), clipRect);
} }
return true; return true;

View File

@ -449,13 +449,12 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
-SkIntToScalar(colorBounds.y())); -SkIntToScalar(colorBounds.y()));
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return false; return false;
} }
drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matrix, drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(colorBounds));
SkRect::Make(colorBounds));
offset->fX = bounds.left(); offset->fX = bounds.left();
offset->fY = bounds.top(); offset->fY = bounds.top();
WrapTexture(dst, bounds.width(), bounds.height(), result); WrapTexture(dst, bounds.width(), bounds.height(), result);

View File

@ -46,7 +46,6 @@ static float adjust_sigma(float sigma, int maxTextureSize, int *scaleFactor, int
} }
static void convolve_gaussian_1d(GrDrawContext* drawContext, static void convolve_gaussian_1d(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
const SkRect& srcRect, const SkRect& srcRect,
const SkRect& dstRect, const SkRect& dstRect,
@ -60,11 +59,10 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds)); texture, direction, radius, sigma, useBounds, bounds));
paint.addColorFragmentProcessor(conv); 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, static void convolve_gaussian_2d(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
const SkRect& srcRect, const SkRect& srcRect,
const SkRect& dstRect, const SkRect& dstRect,
@ -83,11 +81,10 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext,
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode, useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY)); true, sigmaX, sigmaY));
paint.addColorFragmentProcessor(conv); 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, static void convolve_gaussian(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
const SkRect& srcRect, const SkRect& srcRect,
const SkRect& dstRect, const SkRect& dstRect,
@ -98,7 +95,7 @@ static void convolve_gaussian(GrDrawContext* drawContext,
bool cropToSrcRect) { bool cropToSrcRect) {
float bounds[2] = { 0.0f, 1.0f }; float bounds[2] = { 0.0f, 1.0f };
if (!cropToSrcRect) { if (!cropToSrcRect) {
convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture, convolve_gaussian_1d(drawContext, clip, srcRect, dstRect, texture,
direction, radius, sigma, false, bounds); direction, radius, sigma, false, bounds);
return; return;
} }
@ -130,15 +127,15 @@ static void convolve_gaussian(GrDrawContext* drawContext,
} }
if (radius >= size * SK_ScalarHalf) { if (radius >= size * SK_ScalarHalf) {
// Blur radius covers srcRect; use bounds over entire draw // 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); direction, radius, sigma, true, bounds);
} else { } else {
// Draw upper and lower margins with bounds; middle without. // 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); 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); 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); direction, radius, sigma, false, bounds);
} }
} }
@ -222,12 +219,12 @@ GrTexture* GaussianBlur(GrContext* context,
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f); i < scaleFactorY ? 0.5f : 1.0f);
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return nullptr; return nullptr;
} }
dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, dstDrawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
SkMatrix::I(), dstRect, srcRect);
srcDrawContext.swap(dstDrawContext); srcDrawContext.swap(dstDrawContext);
srcRect = dstRect; srcRect = dstRect;
@ -245,11 +242,12 @@ GrTexture* GaussianBlur(GrContext* context,
SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY)); SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return nullptr; 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); srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
srcDrawContext.swap(dstDrawContext); srcDrawContext.swap(dstDrawContext);
@ -262,7 +260,7 @@ GrTexture* GaussianBlur(GrContext* context,
if (scaleFactorX > 1) { if (scaleFactorX > 1) {
// TODO: if we pass in the source draw context we don't need this here // TODO: if we pass in the source draw context we don't need this here
if (!srcDrawContext) { if (!srcDrawContext) {
srcDrawContext.reset(context->drawContext()); srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
if (!srcDrawContext) { if (!srcDrawContext) {
return nullptr; return nullptr;
} }
@ -272,15 +270,16 @@ GrTexture* GaussianBlur(GrContext* context,
// X convolution from reading garbage. // X convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
radiusX, srcIRect.height()); radiusX, srcIRect.height());
srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); srcDrawContext->clear(&clearRect, 0x0, false);
} }
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return nullptr; return nullptr;
} }
convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect, convolve_gaussian(dstDrawContext, clip, srcRect, dstRect,
srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX, srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
cropToRect); cropToRect);
@ -294,7 +293,7 @@ GrTexture* GaussianBlur(GrContext* context,
if (scaleFactorY > 1 || sigmaX > 0.0f) { if (scaleFactorY > 1 || sigmaX > 0.0f) {
// TODO: if we pass in the source draw context we don't need this here // TODO: if we pass in the source draw context we don't need this here
if (!srcDrawContext) { if (!srcDrawContext) {
srcDrawContext.reset(context->drawContext()); srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
if (!srcDrawContext) { if (!srcDrawContext) {
return nullptr; return nullptr;
} }
@ -304,16 +303,17 @@ GrTexture* GaussianBlur(GrContext* context,
// convolution from reading garbage. // convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom, clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width(), radiusY); srcIRect.width(), radiusY);
srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); srcDrawContext->clear(&clearRect, 0x0, false);
} }
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return nullptr; return nullptr;
} }
convolve_gaussian(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, convolve_gaussian(dstDrawContext, clip, srcRect,
dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY, dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
cropToRect); cropToRect);
@ -331,10 +331,10 @@ GrTexture* GaussianBlur(GrContext* context,
// upsampling. // upsampling.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom, clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width() + 1, 1); srcIRect.width() + 1, 1);
srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); srcDrawContext->clear(&clearRect, 0x0, false);
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height()); 1, srcIRect.height());
srcDrawContext->clear(srcTexture->asRenderTarget(), &clearRect, 0x0, false); srcDrawContext->clear(&clearRect, 0x0, false);
SkMatrix matrix; SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height()); matrix.setIDiv(srcTexture->width(), srcTexture->height());
@ -346,12 +346,12 @@ GrTexture* GaussianBlur(GrContext* context,
SkRect dstRect(srcRect); SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return nullptr; return nullptr;
} }
dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint, dstDrawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
SkMatrix::I(), dstRect, srcRect);
srcDrawContext.swap(dstDrawContext); srcDrawContext.swap(dstDrawContext);
srcRect = dstRect; srcRect = dstRect;

View File

@ -330,7 +330,6 @@ private:
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
void drawRect(GrDrawContext* drawContext, void drawRect(GrDrawContext* drawContext,
GrTexture* src, GrTexture* src,
GrTexture* dst,
const SkMatrix& matrix, const SkMatrix& matrix,
const GrClip& clip, const GrClip& clip,
const SkRect& dstRect, const SkRect& dstRect,
@ -343,7 +342,6 @@ private:
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext, void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
GrTexture* src, GrTexture* src,
GrTexture* dst,
const SkMatrix& matrix, const SkMatrix& matrix,
const GrClip& clip, const GrClip& clip,
const SkRect& dstRect, const SkRect& dstRect,
@ -353,8 +351,7 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
GrPaint paint; GrPaint paint;
GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, bounds, boundaryMode); GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, bounds, boundaryMode);
paint.addColorFragmentProcessor(fp)->unref(); paint.addColorFragmentProcessor(fp)->unref();
drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(), drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
dstRect, srcRect);
} }
bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy, bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy,
@ -406,24 +403,23 @@ bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy,
SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() - 2, 1); SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() - 2, 1);
SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height() - 1, 1, 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) { if (!drawContext) {
return false; 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); bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, top, kTop_BoundaryMode, bounds); this->drawRect(drawContext, srcTexture, matrix, clip, left, kLeft_BoundaryMode, bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, topRight, kTopRight_BoundaryMode, this->drawRect(drawContext, srcTexture, matrix, clip, interior, kInterior_BoundaryMode,
bounds); bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, left, kLeft_BoundaryMode, bounds); this->drawRect(drawContext, srcTexture, matrix, clip, right, kRight_BoundaryMode, bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, interior, kInterior_BoundaryMode, this->drawRect(drawContext, srcTexture, matrix, clip, bottomLeft, kBottomLeft_BoundaryMode,
bounds); bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, right, kRight_BoundaryMode, bounds); this->drawRect(drawContext, srcTexture, matrix, clip, bottom, kBottom_BoundaryMode, bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottomLeft, kBottomLeft_BoundaryMode, this->drawRect(drawContext, srcTexture, matrix, clip, bottomRight,
bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottom, kBottom_BoundaryMode, bounds);
this->drawRect(drawContext, srcTexture, dst, matrix, clip, bottomRight,
kBottomRight_BoundaryMode, bounds); kBottomRight_BoundaryMode, bounds);
WrapTexture(dst, bounds.width(), bounds.height(), result); WrapTexture(dst, bounds.width(), bounds.height(), result);
return true; return true;

View File

@ -458,7 +458,6 @@ namespace {
void apply_morphology_rect(GrDrawContext* drawContext, void apply_morphology_rect(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
GrTexture* texture, GrTexture* texture,
const SkIRect& srcRect, const SkIRect& srcRect,
@ -473,12 +472,11 @@ void apply_morphology_rect(GrDrawContext* drawContext,
radius, radius,
morphType, morphType,
bounds))->unref(); bounds))->unref();
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect), drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect)); SkRect::Make(srcRect));
} }
void apply_morphology_rect_no_bounds(GrDrawContext* drawContext, void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
GrTexture* texture, GrTexture* texture,
const SkIRect& srcRect, const SkIRect& srcRect,
@ -491,12 +489,11 @@ void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
direction, direction,
radius, radius,
morphType))->unref(); morphType))->unref();
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect), drawContext->drawNonAARectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect)); SkRect::Make(srcRect));
} }
void apply_morphology_pass(GrDrawContext* drawContext, void apply_morphology_pass(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
GrTexture* texture, GrTexture* texture,
const SkIRect& srcRect, const SkIRect& srcRect,
@ -529,15 +526,15 @@ void apply_morphology_pass(GrDrawContext* drawContext,
} }
if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) { if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) {
// radius covers srcRect; use bounds over entire draw // 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); morphType, bounds, direction);
} else { } else {
// Draw upper and lower margins with bounds; middle without. // 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); 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); 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); radius, morphType, direction);
} }
} }
@ -568,12 +565,12 @@ bool apply_morphology(const SkBitmap& input,
if (nullptr == scratch) { if (nullptr == scratch) {
return false; return false;
} }
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext(scratch->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return false; return false;
} }
apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, srcTexture, apply_morphology_pass(dstDrawContext, clip, srcTexture,
srcRect, dstRect, radius.fWidth, morphType, srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction); Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
@ -581,7 +578,7 @@ bool apply_morphology(const SkBitmap& input,
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ? GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
SK_ColorWHITE : SK_ColorWHITE :
SK_ColorTRANSPARENT; SK_ColorTRANSPARENT;
dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor, false); dstDrawContext->clear(&clearRect, clearColor, false);
srcTexture.reset(scratch); srcTexture.reset(scratch);
srcRect = dstRect; srcRect = dstRect;
@ -591,12 +588,12 @@ bool apply_morphology(const SkBitmap& input,
if (nullptr == scratch) { if (nullptr == scratch) {
return false; return false;
} }
SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext(scratch->asRenderTarget()));
if (!dstDrawContext) { if (!dstDrawContext) {
return false; return false;
} }
apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, srcTexture, apply_morphology_pass(dstDrawContext, clip, srcTexture,
srcRect, dstRect, radius.fHeight, morphType, srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction); Gr1DKernelEffect::kY_Direction);

View File

@ -197,13 +197,12 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
paint.addColorFragmentProcessor(xferFP)->unref(); paint.addColorFragmentProcessor(xferFP)->unref();
} }
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return false; return false;
} }
drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), srcRect);
SkMatrix::I(), srcRect);
offset->fX = backgroundOffset.fX; offset->fX = backgroundOffset.fX;
offset->fY = backgroundOffset.fY; offset->fY = backgroundOffset.fY;

View File

@ -26,7 +26,6 @@ static bool clip_bounds_quick_reject(const SkIRect& clipBounds, const SkIRect& r
// is already burnt into the mask this boils down to a rect draw. // is already burnt into the mask this boils down to a rect draw.
// Return true if the mask was successfully drawn. // Return true if the mask was successfully drawn.
static bool draw_mask(GrDrawContext* drawContext, static bool draw_mask(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip, const GrClip& clip,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& maskRect, const SkRect& maskRect,
@ -43,13 +42,12 @@ static bool draw_mask(GrDrawContext* drawContext,
if (!viewMatrix.invert(&inverse)) { if (!viewMatrix.invert(&inverse)) {
return false; return false;
} }
drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), maskRect, inverse); drawContext->drawNonAARectWithLocalMatrix(clip, *grp, SkMatrix::I(), maskRect, inverse);
return true; return true;
} }
static bool draw_with_mask_filter(GrDrawContext* drawContext, static bool draw_with_mask_filter(GrDrawContext* drawContext,
GrTextureProvider* textureProvider, GrTextureProvider* textureProvider,
GrRenderTarget* rt,
const GrClip& clipData, const GrClip& clipData,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkPath& devPath, const SkPath& devPath,
@ -91,7 +89,7 @@ static bool draw_with_mask_filter(GrDrawContext* drawContext,
SkRect maskRect = SkRect::Make(dstM.fBounds); 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'. // Create a mask of 'devPath' and place the result in 'mask'.
@ -126,12 +124,12 @@ static GrTexture* create_mask_GPU(GrContext* context,
SkRect clipRect = SkRect::MakeWH(maskRect->width(), maskRect->height()); SkRect clipRect = SkRect::MakeWH(maskRect->width(), maskRect->height());
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(mask->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return nullptr; return nullptr;
} }
drawContext->clear(mask->asRenderTarget(), nullptr, 0x0, true); drawContext->clear(nullptr, 0x0, true);
GrPaint tempPaint; GrPaint tempPaint;
tempPaint.setAntiAlias(doAA); tempPaint.setAntiAlias(doAA);
@ -144,7 +142,7 @@ static GrTexture* create_mask_GPU(GrContext* context,
// the origin using tempPaint. // the origin using tempPaint.
SkMatrix translate; SkMatrix translate;
translate.setTranslate(-maskRect->fLeft, -maskRect->fTop); translate.setTranslate(-maskRect->fLeft, -maskRect->fTop);
drawContext->drawPath(mask->asRenderTarget(), clip, tempPaint, translate, devPath, strokeInfo); drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo);
return mask; return mask;
} }
@ -247,7 +245,6 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
if (paint.getMaskFilter()->directFilterMaskGPU(context->textureProvider(), if (paint.getMaskFilter()->directFilterMaskGPU(context->textureProvider(),
drawContext, drawContext,
renderTarget,
&grPaint, &grPaint,
clip, clip,
viewMatrix, viewMatrix,
@ -272,7 +269,6 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
// filterMaskGPU gives us ownership of a ref to the result // filterMaskGPU gives us ownership of a ref to the result
SkAutoTUnref<GrTexture> atu(filtered); SkAutoTUnref<GrTexture> atu(filtered);
if (draw_mask(drawContext, if (draw_mask(drawContext,
renderTarget,
clip, clip,
viewMatrix, viewMatrix,
maskRect, maskRect,
@ -289,12 +285,12 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
// GPU path fails // GPU path fails
SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style : SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style; SkPaint::kFill_Style;
draw_with_mask_filter(drawContext, context->textureProvider(), renderTarget, draw_with_mask_filter(drawContext, context->textureProvider(),
clip, viewMatrix, *devPathPtr, clip, viewMatrix, *devPathPtr,
paint.getMaskFilter(), clipBounds, &grPaint, style); paint.getMaskFilter(), clipBounds, &grPaint, style);
return; return;
} }
drawContext->drawPath(renderTarget, clip, grPaint, viewMatrix, *pathPtr, strokeInfo); drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
} }

View File

@ -125,12 +125,13 @@ GrTextContext* GrContext::DrawingMgr::textContext(const SkSurfaceProps& props,
return fTextContexts[props.pixelGeometry()][useDIF]; return fTextContexts[props.pixelGeometry()][useDIF];
} }
GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceProps) { GrDrawContext* GrContext::DrawingMgr::drawContext(GrRenderTarget* rt,
const SkSurfaceProps* surfaceProps) {
if (this->abandoned()) { if (this->abandoned()) {
return nullptr; return nullptr;
} }
return new GrDrawContext(fContext, fDrawTarget, surfaceProps); return new GrDrawContext(fContext, rt, fDrawTarget, surfaceProps);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -429,13 +430,13 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
} }
SkMatrix matrix; SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarget));
if (!drawContext) { if (!drawContext) {
return false; return false;
} }
paint.addColorFragmentProcessor(fp); paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); 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) { if (kFlushWrites_PixelOp & pixelOpsFlags) {
this->flushSurfaceWrites(surface); this->flushSurfaceWrites(surface);
@ -541,9 +542,8 @@ bool GrContext::readSurfacePixels(GrSurface* src,
if (fp) { if (fp) {
paint.addColorFragmentProcessor(fp); paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(temp->asRenderTarget()));
drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint, drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, nullptr);
SkMatrix::I(), rect, nullptr);
surfaceToRead.reset(SkRef(temp.get())); surfaceToRead.reset(SkRef(temp.get()));
left = 0; left = 0;
top = 0; top = 0;
@ -617,12 +617,12 @@ void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe
return; return;
} }
SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return; return;
} }
drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint); drawContext->copySurface(src, srcRect, dstPoint);
if (kFlushWrites_PixelOp & pixelOpsFlags) { if (kFlushWrites_PixelOp & pixelOpsFlags) {
this->flush(); this->flush();

View File

@ -38,72 +38,81 @@ private:
}; };
GrDrawContext::GrDrawContext(GrContext* context, GrDrawContext::GrDrawContext(GrContext* context,
GrRenderTarget* rt,
GrDrawTarget* drawTarget, GrDrawTarget* drawTarget,
const SkSurfaceProps* surfaceProps) const SkSurfaceProps* surfaceProps)
: fContext(context) : fContext(context)
, fRenderTarget(rt)
, fDrawTarget(SkRef(drawTarget)) , fDrawTarget(SkRef(drawTarget))
, fTextContext(nullptr) , fTextContext(nullptr)
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) { , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) {
SkDEBUGCODE(this->validate();)
} }
GrDrawContext::~GrDrawContext() { GrDrawContext::~GrDrawContext() {
SkSafeUnref(fDrawTarget); SkSafeUnref(fDrawTarget);
} }
void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src, #ifdef SK_DEBUG
const SkIRect& srcRect, const SkIPoint& dstPoint) { 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 RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (!this->prepareToDraw(dst)) { fDrawTarget->copySurface(fRenderTarget, src, srcRect, dstPoint);
return;
}
fDrawTarget->copySurface(dst, 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 SkPaint& skPaint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) { SkScalar x, SkScalar y, const SkIRect& clipBounds) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (!fTextContext) { 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); 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 SkPaint& skPaint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition, const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) { const SkPoint& offset, const SkIRect& clipBounds) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (!fTextContext) { 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); 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, const SkMatrix& viewMatrix, const SkTextBlob* blob,
SkScalar x, SkScalar y, SkScalar x, SkScalar y,
SkDrawFilter* filter, const SkIRect& clipBounds) { SkDrawFilter* filter, const SkIRect& clipBounds) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (!fTextContext) { 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); clip, skPaint, viewMatrix, blob, x, y, filter, clipBounds);
} }
@ -115,47 +124,43 @@ void GrDrawContext::drawPathsFromRange(const GrPipelineBuilder* pipelineBuilder,
GrPathRangeDraw* draw, GrPathRangeDraw* draw,
int /*GrPathRendering::FillType*/ fill) { int /*GrPathRendering::FillType*/ fill) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
fDrawTarget->drawPathsFromRange(*pipelineBuilder, viewMatrix, localMatrix, color, range, draw, fDrawTarget->drawPathsFromRange(*pipelineBuilder, viewMatrix, localMatrix, color, range, draw,
(GrPathRendering::FillType) fill); (GrPathRendering::FillType) fill);
} }
void GrDrawContext::discard(GrRenderTarget* renderTarget) { void GrDrawContext::discard() {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkASSERT(renderTarget); SkDEBUGCODE(this->validate();)
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(renderTarget)) { fDrawTarget->discard(fRenderTarget);
return;
}
fDrawTarget->discard(renderTarget);
} }
void GrDrawContext::clear(GrRenderTarget* renderTarget, void GrDrawContext::clear(const SkIRect* rect,
const SkIRect* rect,
const GrColor color, const GrColor color,
bool canIgnoreRect) { bool canIgnoreRect) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkASSERT(renderTarget); SkDEBUGCODE(this->validate();)
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(renderTarget)) { fDrawTarget->clear(rect, color, canIgnoreRect, fRenderTarget);
return;
}
fDrawTarget->clear(rect, color, canIgnoreRect, renderTarget);
} }
void GrDrawContext::drawPaint(GrRenderTarget* rt, void GrDrawContext::drawPaint(const GrClip& clip,
const GrClip& clip,
const GrPaint& origPaint, const GrPaint& origPaint,
const SkMatrix& viewMatrix) { const SkMatrix& viewMatrix) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
// set rect to be big enough to fill the space, but not super-huge, so we // set rect to be big enough to fill the space, but not super-huge, so we
// don't overflow fixed-point implementations // don't overflow fixed-point implementations
SkRect r; SkRect r;
r.setLTRB(0, 0, r.setLTRB(0, 0,
SkIntToScalar(rt->width()), SkIntToScalar(fRenderTarget->width()),
SkIntToScalar(rt->height())); SkIntToScalar(fRenderTarget->height()));
SkTCopyOnFirstWrite<GrPaint> paint(origPaint); SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
// by definition this fills the entire clip, no need for AA // by definition this fills the entire clip, no need for AA
@ -175,7 +180,7 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt,
return; return;
} }
inverse.mapRect(&r); inverse.mapRect(&r);
this->drawRect(rt, clip, *paint, viewMatrix, r); this->drawRect(clip, *paint, viewMatrix, r);
} else { } else {
SkMatrix localMatrix; SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) { if (!viewMatrix.invert(&localMatrix)) {
@ -184,11 +189,8 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt,
} }
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(*paint, rt, clip); GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip);
fDrawTarget->drawNonAARect(pipelineBuilder, fDrawTarget->drawNonAARect(pipelineBuilder,
paint->getColor(), paint->getColor(),
SkMatrix::I(), SkMatrix::I(),
@ -202,27 +204,25 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
point.fY >= rect.fTop && point.fY <= rect.fBottom; point.fY >= rect.fTop && point.fY <= rect.fBottom;
} }
void GrDrawContext::drawRect(GrRenderTarget* rt, void GrDrawContext::drawRect(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& rect, const SkRect& rect,
const GrStrokeInfo* strokeInfo) { const GrStrokeInfo* strokeInfo) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (strokeInfo && strokeInfo->isDashed()) { if (strokeInfo && strokeInfo->isDashed()) {
SkPath path; SkPath path;
path.setIsVolatile(true); path.setIsVolatile(true);
path.addRect(rect); path.addRect(rect);
this->drawPath(rt, clip, paint, viewMatrix, path, *strokeInfo); this->drawPath(clip, paint, viewMatrix, path, *strokeInfo);
return; return;
} }
AutoCheckFlush acf(fContext); 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(); SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth();
@ -253,7 +253,7 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
// Will it blend? // Will it blend?
GrColor clearColor; GrColor clearColor;
if (paint.isConstantBlendedColor(&clearColor)) { if (paint.isConstantBlendedColor(&clearColor)) {
fDrawTarget->clear(nullptr, clearColor, true, rt); fDrawTarget->clear(nullptr, clearColor, true, fRenderTarget);
return; return;
} }
} }
@ -285,7 +285,7 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
if (width >= 0) { if (width >= 0) {
// Non-AA hairlines are snapped to pixel centers to make which pixels are hit deterministic // 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( SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke(
color, viewMatrix, rect, width, snapToPixelCenters)); color, viewMatrix, rect, width, snapToPixelCenters));
@ -301,19 +301,17 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
} }
} }
void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, void GrDrawContext::drawNonAARectToRect(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& rectToDraw, const SkRect& rectToDraw,
const SkRect& localRect) { const SkRect& localRect) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
AutoCheckFlush acf(fContext); SkDEBUGCODE(this->validate();)
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); AutoCheckFlush acf(fContext);
GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
fDrawTarget->drawNonAARect(pipelineBuilder, fDrawTarget->drawNonAARect(pipelineBuilder,
paint.getColor(), paint.getColor(),
viewMatrix, viewMatrix,
@ -321,19 +319,17 @@ void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt,
localRect); localRect);
} }
void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt, void GrDrawContext::drawNonAARectWithLocalMatrix(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& rectToDraw, const SkRect& rectToDraw,
const SkMatrix& localMatrix) { const SkMatrix& localMatrix) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
AutoCheckFlush acf(fContext); SkDEBUGCODE(this->validate();)
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); AutoCheckFlush acf(fContext);
GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
fDrawTarget->drawNonAARect(pipelineBuilder, fDrawTarget->drawNonAARect(pipelineBuilder,
paint.getColor(), paint.getColor(),
viewMatrix, viewMatrix,
@ -341,8 +337,7 @@ void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
localMatrix); localMatrix);
} }
void GrDrawContext::drawVertices(GrRenderTarget* rt, void GrDrawContext::drawVertices(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType, GrPrimitiveType primitiveType,
@ -353,12 +348,11 @@ void GrDrawContext::drawVertices(GrRenderTarget* rt,
const uint16_t indices[], const uint16_t indices[],
int indexCount) { int indexCount) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
AutoCheckFlush acf(fContext); SkDEBUGCODE(this->validate();)
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); AutoCheckFlush acf(fContext);
GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
// TODO clients should give us bounds // TODO clients should give us bounds
SkRect bounds; SkRect bounds;
@ -387,8 +381,7 @@ void GrDrawContext::drawVertices(GrRenderTarget* rt,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawAtlas(GrRenderTarget* rt, void GrDrawContext::drawAtlas(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
int spriteCount, int spriteCount,
@ -396,12 +389,11 @@ void GrDrawContext::drawAtlas(GrRenderTarget* rt,
const SkRect texRect[], const SkRect texRect[],
const SkColor colors[]) { const SkColor colors[]) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
AutoCheckFlush acf(fContext); SkDEBUGCODE(this->validate();)
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); AutoCheckFlush acf(fContext);
GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrDrawAtlasBatch::Geometry geometry; GrDrawAtlasBatch::Geometry geometry;
geometry.fColor = paint.getColor(); geometry.fColor = paint.getColor();
@ -413,13 +405,14 @@ void GrDrawContext::drawAtlas(GrRenderTarget* rt,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawRRect(GrRenderTarget*rt, void GrDrawContext::drawRRect(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRRect& rrect, const SkRRect& rrect,
const GrStrokeInfo& strokeInfo) { const GrStrokeInfo& strokeInfo) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (rrect.isEmpty()) { if (rrect.isEmpty()) {
return; return;
} }
@ -428,17 +421,15 @@ void GrDrawContext::drawRRect(GrRenderTarget*rt,
SkPath path; SkPath path;
path.setIsVolatile(true); path.setIsVolatile(true);
path.addRRect(rrect); path.addRRect(rrect);
this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo); this->drawPath(clip, paint, viewMatrix, path, strokeInfo);
return; return;
} }
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrColor color = paint.getColor(); GrColor color = paint.getColor();
if (!GrOvalRenderer::DrawRRect(fDrawTarget, if (!GrOvalRenderer::DrawRRect(fDrawTarget,
pipelineBuilder, pipelineBuilder,
color, color,
@ -456,23 +447,21 @@ void GrDrawContext::drawRRect(GrRenderTarget*rt,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawDRRect(GrRenderTarget* rt, void GrDrawContext::drawDRRect(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRRect& outer, const SkRRect& outer,
const SkRRect& inner) { const SkRRect& inner) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (outer.isEmpty()) { if (outer.isEmpty()) {
return; return;
} }
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrColor color = paint.getColor(); GrColor color = paint.getColor();
if (!GrOvalRenderer::DrawDRRect(fDrawTarget, if (!GrOvalRenderer::DrawDRRect(fDrawTarget,
pipelineBuilder, pipelineBuilder,
@ -495,13 +484,14 @@ void GrDrawContext::drawDRRect(GrRenderTarget* rt,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawOval(GrRenderTarget* rt, void GrDrawContext::drawOval(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkRect& oval, const SkRect& oval,
const GrStrokeInfo& strokeInfo) { const GrStrokeInfo& strokeInfo) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (oval.isEmpty()) { if (oval.isEmpty()) {
return; return;
} }
@ -510,17 +500,15 @@ void GrDrawContext::drawOval(GrRenderTarget* rt,
SkPath path; SkPath path;
path.setIsVolatile(true); path.setIsVolatile(true);
path.addOval(oval); path.addOval(oval);
this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo); this->drawPath(clip, paint, viewMatrix, path, strokeInfo);
return; return;
} }
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
GrColor color = paint.getColor(); GrColor color = paint.getColor();
if (!GrOvalRenderer::DrawOval(fDrawTarget, if (!GrOvalRenderer::DrawOval(fDrawTarget,
pipelineBuilder, pipelineBuilder,
color, color,
@ -586,29 +574,28 @@ static bool is_nested_rects(const SkMatrix& viewMatrix,
return allEq || allGoE1; return allEq || allGoE1;
} }
void GrDrawContext::drawBatch(GrRenderTarget* rt, const GrClip& clip, void GrDrawContext::drawBatch(const GrClip& clip,
const GrPaint& paint, GrDrawBatch* batch) { const GrPaint& paint, GrDrawBatch* batch) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
fDrawTarget->drawBatch(pipelineBuilder, batch); fDrawTarget->drawBatch(pipelineBuilder, batch);
} }
void GrDrawContext::drawPath(GrRenderTarget* rt, void GrDrawContext::drawPath(const GrClip& clip,
const GrClip& clip,
const GrPaint& paint, const GrPaint& paint,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkPath& path, const SkPath& path,
const GrStrokeInfo& strokeInfo) { const GrStrokeInfo& strokeInfo) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
if (path.isEmpty()) { if (path.isEmpty()) {
if (path.isInverseFillType()) { if (path.isInverseFillType()) {
this->drawPaint(rt, clip, paint, viewMatrix); this->drawPaint(clip, paint, viewMatrix);
} }
return; return;
} }
@ -621,11 +608,8 @@ void GrDrawContext::drawPath(GrRenderTarget* rt,
// the writePixels that uploads to the scratch will perform a flush so we're // the writePixels that uploads to the scratch will perform a flush so we're
// OK. // OK.
AutoCheckFlush acf(fContext); AutoCheckFlush acf(fContext);
if (!this->prepareToDraw(rt)) {
return;
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip); GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
if (!strokeInfo.isDashed()) { if (!strokeInfo.isDashed()) {
bool useCoverageAA = paint.isAntiAlias() && bool useCoverageAA = paint.isAntiAlias() &&
!pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
@ -670,7 +654,6 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkASSERT(!path.isEmpty()); SkASSERT(!path.isEmpty());
// An Assumption here is that path renderer would use some form of tweaking // 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 // 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 // aa. If we have some future driver-mojo path AA that can do the right
@ -749,16 +732,9 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
pr->drawPath(args); 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) { void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch) {
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
fDrawTarget->drawBatch(*pipelineBuilder, batch); fDrawTarget->drawBatch(*pipelineBuilder, batch);
} }

View File

@ -467,10 +467,11 @@ void GrLayerCache::purgeAll() {
SkASSERT(0 == fPictureHash.count()); SkASSERT(0 == fPictureHash.count());
SkAutoTUnref<GrDrawContext> drawContext(fContext->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(
fContext->drawContext(fAtlas->getTexture()->asRenderTarget()));
if (drawContext) { if (drawContext) {
drawContext->discard(fAtlas->getTexture()->asRenderTarget()); drawContext->discard();
} }
} }
#endif #endif

View File

@ -22,12 +22,12 @@ void GrRenderTarget::discard() {
return; return;
} }
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(this));
if (!drawContext) { if (!drawContext) {
return; return;
} }
drawContext->discard(this); drawContext->discard();
} }
void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) {

View File

@ -130,12 +130,12 @@ GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc
paint.addColorFragmentProcessor(yuvToRgbProcessor); paint.addColorFragmentProcessor(yuvToRgbProcessor);
const SkRect r = SkRect::MakeIWH(yuvInfo.fSize[0].fWidth, yuvInfo.fSize[0].fHeight); 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) { if (!drawContext) {
return nullptr; return nullptr;
} }
drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, SkMatrix::I(), r); drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), r);
return result.detach(); return result.detach();
} }

View File

@ -198,7 +198,7 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
fLegacyBitmap.setInfo(info); fLegacyBitmap.setInfo(info);
fLegacyBitmap.setPixelRef(pr)->unref(); 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, GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::Budgeted budgeted,
@ -336,7 +336,7 @@ void SkGpuDevice::clearAll() {
GrColor color = 0; GrColor color = 0;
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clearAll", fContext); GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clearAll", fContext);
SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
fDrawContext->clear(fRenderTarget, &rect, color, true); fDrawContext->clear(&rect, color, true);
fNeedClear = false; fNeedClear = false;
} }
@ -375,7 +375,8 @@ void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget);
fLegacyBitmap.setPixelRef(pr)->unref(); fLegacyBitmap.setPixelRef(pr)->unref();
fDrawContext.reset(fRenderTarget->getContext()->drawContext(&this->surfaceProps())); fDrawContext.reset(fRenderTarget->getContext()->drawContext(fRenderTarget,
&this->surfaceProps()));
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -389,7 +390,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
return; return;
} }
fDrawContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix); fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix);
} }
// must be in SkCanvas::PointMode order // must be in SkCanvas::PointMode order
@ -441,7 +442,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
path.setIsVolatile(true); path.setIsVolatile(true);
path.moveTo(pts[0]); path.moveTo(pts[0]);
path.lineTo(pts[1]); path.lineTo(pts[1]);
fDrawContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, path, strokeInfo); fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, strokeInfo);
return; return;
} }
@ -458,8 +459,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
return; return;
} }
fDrawContext->drawVertices(fRenderTarget, fDrawContext->drawVertices(fClip,
fClip,
grPaint, grPaint,
*draw.fMatrix, *draw.fMatrix,
gPointMode2PrimtiveType[mode], gPointMode2PrimtiveType[mode],
@ -521,7 +521,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
return; return;
} }
fDrawContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -557,7 +557,6 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
} }
if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext->textureProvider(), if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext->textureProvider(),
fDrawContext, fDrawContext,
fRenderTarget,
&grPaint, &grPaint,
fClip, fClip,
*draw.fMatrix, *draw.fMatrix,
@ -592,7 +591,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
return; 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, void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
@ -609,7 +608,7 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
} }
if (nullptr == paint.getMaskFilter() && nullptr == paint.getPathEffect()) { 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; return;
} }
} }
@ -660,7 +659,7 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
return; return;
} }
fDrawContext->drawOval(fRenderTarget, fClip, grPaint, *draw.fMatrix, oval, strokeInfo); fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo);
} }
#include "SkMaskFilter.h" #include "SkMaskFilter.h"
@ -1033,7 +1032,7 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context,
dstRect, dstRect,
devRect)); 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) { static bool can_ignore_strict_subset_constraint(const SkBitmap& bitmap, const SkRect& subset) {
@ -1381,10 +1380,9 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) {
// We don't have local coords in this case and have previously set the transform // We don't have local coords in this case and have previously set the transform
// matrices directly on the texture processor. // matrices directly on the texture processor.
fDrawContext->drawRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect); fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect);
} else { } else {
fDrawContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect, fDrawContext->drawNonAARectToRect(fClip, grPaint, viewMatrix, dstRect, paintRect);
paintRect);
} }
} }
@ -1466,8 +1464,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
return; return;
} }
fDrawContext->drawNonAARectToRect(fRenderTarget, fDrawContext->drawNonAARectToRect(fClip,
fClip,
grPaint, grPaint,
SkMatrix::I(), SkMatrix::I(),
SkRect::MakeXYWH(SkIntToScalar(left), SkRect::MakeXYWH(SkIntToScalar(left),
@ -1597,8 +1594,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
SK_Scalar1 * h / devTex->height()); SK_Scalar1 * h / devTex->height());
fDrawContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, SkMatrix::I(), dstRect, fDrawContext->drawNonAARectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect);
srcRect);
} }
bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
@ -1749,8 +1745,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
lineIndices[i + 5] = state.f0; lineIndices[i + 5] = state.f0;
i += 6; i += 6;
} }
fDrawContext->drawVertices(fRenderTarget, fDrawContext->drawVertices(fClip,
fClip,
grPaint, grPaint,
*draw.fMatrix, *draw.fMatrix,
kLines_GrPrimitiveType, kLines_GrPrimitiveType,
@ -1813,8 +1808,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
} }
} }
fDrawContext->drawVertices(fRenderTarget, fDrawContext->drawVertices(fClip,
fClip,
grPaint, grPaint,
*draw.fMatrix, *draw.fMatrix,
primType, primType,
@ -1855,8 +1849,7 @@ void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
} }
SkDEBUGCODE(this->validate();) SkDEBUGCODE(this->validate();)
fDrawContext->drawAtlas(fRenderTarget, fClip, grPaint, *draw.fMatrix, fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect, colors);
count, xform, texRect, colors);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -1874,7 +1867,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
SkDEBUGCODE(this->validate();) 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()); (const char *)text, byteLength, x, y, draw.fClip->getBounds());
} }
@ -1891,7 +1884,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
SkDEBUGCODE(this->validate();) 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, (const char *)text, byteLength, pos, scalarsPerPos, offset,
draw.fClip->getBounds()); draw.fClip->getBounds());
} }
@ -1903,7 +1896,7 @@ void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
SkDEBUGCODE(this->validate();) SkDEBUGCODE(this->validate();)
fDrawContext->drawTextBlob(fRenderTarget, fClip, paint, *draw.fMatrix, fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix,
blob, x, y, drawFilter, draw.fClip->getBounds()); blob, x, y, drawFilter, draw.fClip->getBounds());
} }

View File

@ -285,13 +285,12 @@ GrTexture* stretch_texture(GrTexture* inputTexture, const SkGrStretch& stretch,
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight)); SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
SkRect localRect = SkRect::MakeWH(1.f, 1.f); SkRect localRect = SkRect::MakeWH(1.f, 1.f);
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(stretched->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return nullptr; return nullptr;
} }
drawContext->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOpen(), paint, drawContext->drawNonAARectToRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, localRect);
SkMatrix::I(), rect, localRect);
return stretched.detach(); return stretched.detach();
} }

View File

@ -224,14 +224,13 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
paint1.addColorFragmentProcessor(pmToUPM1); paint1.addColorFragmentProcessor(pmToUPM1);
SkAutoTUnref<GrDrawContext> readDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> readDrawContext(context->drawContext(readTex->asRenderTarget()));
if (!readDrawContext) { if (!readDrawContext) {
failed = true; failed = true;
break; break;
} }
readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(), readDrawContext->drawNonAARectToRect(GrClip::WideOpen(),
GrClip::WideOpen(),
paint1, paint1,
SkMatrix::I(), SkMatrix::I(),
kDstRect, kDstRect,
@ -241,13 +240,12 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
paint2.addColorFragmentProcessor(upmToPM); paint2.addColorFragmentProcessor(upmToPM);
SkAutoTUnref<GrDrawContext> tempDrawContext(context->drawContext()); SkAutoTUnref<GrDrawContext> tempDrawContext(context->drawContext(tempTex->asRenderTarget()));
if (!tempDrawContext) { if (!tempDrawContext) {
failed = true; failed = true;
break; break;
} }
tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(), tempDrawContext->drawNonAARectToRect(GrClip::WideOpen(),
GrClip::WideOpen(),
paint2, paint2,
SkMatrix::I(), SkMatrix::I(),
kDstRect, kDstRect,
@ -255,14 +253,13 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
paint3.addColorFragmentProcessor(pmToUPM2); paint3.addColorFragmentProcessor(pmToUPM2);
readDrawContext.reset(context->drawContext()); readDrawContext.reset(context->drawContext(readTex->asRenderTarget()));
if (!readDrawContext) { if (!readDrawContext) {
failed = true; failed = true;
break; break;
} }
readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(), readDrawContext->drawNonAARectToRect(GrClip::WideOpen(),
GrClip::WideOpen(),
paint3, paint3,
SkMatrix::I(), SkMatrix::I(),
kDstRect, kDstRect,

View File

@ -364,12 +364,12 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS
const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
SkIntToScalar(dstDesc.fHeight)); SkIntToScalar(dstDesc.fHeight));
SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext()); SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(dst->asRenderTarget()));
if (!drawContext) { if (!drawContext) {
return nullptr; return nullptr;
} }
drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect); drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(dst); ctx->flushSurfaceWrites(dst);
return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID, return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
kOpaque_SkAlphaType, dst, budgeted); kOpaque_SkAlphaType, dst, budgeted);