GrDrawContext now holds GrRenderTarget pointer
Review URL: https://codereview.chromium.org/1404823005
This commit is contained in:
parent
860e8a6719
commit
2e1e51f049
@ -22,7 +22,7 @@ static const int S = 200;
|
||||
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 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
|
||||
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 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
|
||||
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);
|
||||
|
@ -113,7 +113,6 @@ public:
|
||||
*/
|
||||
virtual bool directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -125,7 +124,6 @@ public:
|
||||
*/
|
||||
virtual bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
|
@ -175,12 +175,13 @@ public:
|
||||
* 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 @@ private:
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -44,20 +44,19 @@ class SK_API GrDrawContext : public SkRefCnt {
|
||||
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 @@ public:
|
||||
* 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 @@ public:
|
||||
* 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 @@ public:
|
||||
* @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 @@ public:
|
||||
/**
|
||||
* 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 @@ public:
|
||||
* @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 @@ public:
|
||||
* @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 @@ public:
|
||||
* @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 @@ public:
|
||||
* @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 @@ public:
|
||||
* @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 @@ public:
|
||||
* @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 @@ public:
|
||||
* @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 @@ private:
|
||||
void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch);
|
||||
|
||||
GrContext* fContext; // owning context -> no ref
|
||||
GrRenderTarget* fRenderTarget;
|
||||
GrDrawTarget* fDrawTarget;
|
||||
GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMgr
|
||||
|
||||
|
@ -360,10 +360,9 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
|
||||
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;
|
||||
|
@ -318,7 +318,6 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect,
|
||||
|
||||
bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -330,7 +329,6 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect,
|
||||
|
||||
bool SkMaskFilter::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
|
@ -251,7 +251,7 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
|
||||
#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 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ public:
|
||||
SkRect* maskRect) const override;
|
||||
bool directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -59,7 +58,6 @@ public:
|
||||
const SkPath& path) const override;
|
||||
bool directFilterRRectMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -806,7 +804,6 @@ const GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d)
|
||||
|
||||
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip& clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -854,7 +851,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
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 @@ GrGLFragmentProcessor* GrRRectBlurEffect::onCreateGLInstance() const {
|
||||
|
||||
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
|
||||
GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
GrPaint* grp,
|
||||
const GrClip& clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -1136,7 +1132,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
|
||||
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 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
|
||||
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;
|
||||
|
@ -449,13 +449,12 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
|
||||
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);
|
||||
|
@ -46,7 +46,6 @@ static float adjust_sigma(float sigma, int maxTextureSize, int *scaleFactor, int
|
||||
}
|
||||
|
||||
static void convolve_gaussian_1d(GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
const GrClip& clip,
|
||||
const SkRect& srcRect,
|
||||
const SkRect& dstRect,
|
||||
@ -60,11 +59,10 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
|
||||
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 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext,
|
||||
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 @@ static void convolve_gaussian(GrDrawContext* drawContext,
|
||||
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 @@ static void convolve_gaussian(GrDrawContext* drawContext,
|
||||
}
|
||||
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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
// 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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
// 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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
// 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 @@ GrTexture* GaussianBlur(GrContext* context,
|
||||
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;
|
||||
|
@ -330,7 +330,6 @@ private:
|
||||
#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 @@ private:
|
||||
#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 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
|
||||
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 @@ bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy,
|
||||
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;
|
||||
|
@ -458,7 +458,6 @@ namespace {
|
||||
|
||||
|
||||
void apply_morphology_rect(GrDrawContext* drawContext,
|
||||
GrRenderTarget* rt,
|
||||
const GrClip& clip,
|
||||
GrTexture* texture,
|
||||
const SkIRect& srcRect,
|
||||
@ -473,12 +472,11 @@ void apply_morphology_rect(GrDrawContext* drawContext,
|
||||
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 @@ void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
|
||||
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 @@ void apply_morphology_pass(GrDrawContext* drawContext,
|
||||
}
|
||||
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 @@ bool apply_morphology(const SkBitmap& input,
|
||||
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 @@ bool apply_morphology(const SkBitmap& input,
|
||||
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 @@ bool apply_morphology(const SkBitmap& input,
|
||||
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);
|
||||
|
||||
|
@ -197,13 +197,12 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
|
||||
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;
|
||||
|
@ -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.
|
||||
// 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 @@ static bool draw_mask(GrDrawContext* drawContext,
|
||||
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 @@ static bool draw_with_mask_filter(GrDrawContext* drawContext,
|
||||
|
||||
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 @@ static GrTexture* create_mask_GPU(GrContext* context,
|
||||
|
||||
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 @@ static GrTexture* create_mask_GPU(GrContext* context,
|
||||
// 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 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
|
||||
if (paint.getMaskFilter()->directFilterMaskGPU(context->textureProvider(),
|
||||
drawContext,
|
||||
renderTarget,
|
||||
&grPaint,
|
||||
clip,
|
||||
viewMatrix,
|
||||
@ -272,7 +269,6 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
// 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 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -125,12 +125,13 @@ GrTextContext* GrContext::DrawingMgr::textContext(const SkSurfaceProps& props,
|
||||
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 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
||||
}
|
||||
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 @@ bool GrContext::readSurfacePixels(GrSurface* src,
|
||||
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 @@ void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe
|
||||
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();
|
||||
|
@ -38,72 +38,81 @@ private:
|
||||
};
|
||||
|
||||
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 @@ void GrDrawContext::drawPathsFromRange(const GrPipelineBuilder* pipelineBuilder,
|
||||
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 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt,
|
||||
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 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt,
|
||||
}
|
||||
|
||||
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 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
|
||||
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 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
|
||||
// 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 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
|
||||
|
||||
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::drawRect(GrRenderTarget* rt,
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt,
|
||||
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 @@ void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
|
||||
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 @@ void GrDrawContext::drawVertices(GrRenderTarget* rt,
|
||||
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::drawVertices(GrRenderTarget* rt,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ void GrDrawContext::drawAtlas(GrRenderTarget* rt,
|
||||
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::drawAtlas(GrRenderTarget* rt,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ void GrDrawContext::drawRRect(GrRenderTarget*rt,
|
||||
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::drawRRect(GrRenderTarget*rt,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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::drawDRRect(GrRenderTarget* rt,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ void GrDrawContext::drawOval(GrRenderTarget* rt,
|
||||
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 @@ static bool is_nested_rects(const SkMatrix& viewMatrix,
|
||||
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 @@ void GrDrawContext::drawPath(GrRenderTarget* rt,
|
||||
// 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 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
|
||||
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 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
|
||||
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);
|
||||
}
|
||||
|
@ -467,10 +467,11 @@ void GrLayerCache::purgeAll() {
|
||||
|
||||
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
|
||||
|
@ -22,12 +22,12 @@ void GrRenderTarget::discard() {
|
||||
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) {
|
||||
|
@ -130,12 +130,12 @@ GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc
|
||||
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();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
|
||||
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 @@ void SkGpuDevice::clearAll() {
|
||||
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 @@ void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
|
||||
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 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
|
||||
return;
|
||||
}
|
||||
|
||||
fDrawContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix);
|
||||
fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix);
|
||||
}
|
||||
|
||||
// must be in SkCanvas::PointMode order
|
||||
@ -441,7 +442,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
||||
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 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
||||
return;
|
||||
}
|
||||
|
||||
fDrawContext->drawVertices(fRenderTarget,
|
||||
fClip,
|
||||
fDrawContext->drawVertices(fClip,
|
||||
grPaint,
|
||||
*draw.fMatrix,
|
||||
gPointMode2PrimtiveType[mode],
|
||||
@ -521,7 +521,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
|
||||
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(),
|
||||
fDrawContext,
|
||||
fRenderTarget,
|
||||
&grPaint,
|
||||
fClip,
|
||||
*draw.fMatrix,
|
||||
@ -592,7 +591,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
|
||||
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 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
|
||||
}
|
||||
|
||||
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 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
|
||||
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 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context,
|
||||
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 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
||||
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 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
return;
|
||||
}
|
||||
|
||||
fDrawContext->drawNonAARectToRect(fRenderTarget,
|
||||
fClip,
|
||||
fDrawContext->drawNonAARectToRect(fClip,
|
||||
grPaint,
|
||||
SkMatrix::I(),
|
||||
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(),
|
||||
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 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
||||
lineIndices[i + 5] = state.f0;
|
||||
i += 6;
|
||||
}
|
||||
fDrawContext->drawVertices(fRenderTarget,
|
||||
fClip,
|
||||
fDrawContext->drawVertices(fClip,
|
||||
grPaint,
|
||||
*draw.fMatrix,
|
||||
kLines_GrPrimitiveType,
|
||||
@ -1813,8 +1808,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
||||
}
|
||||
}
|
||||
|
||||
fDrawContext->drawVertices(fRenderTarget,
|
||||
fClip,
|
||||
fDrawContext->drawVertices(fClip,
|
||||
grPaint,
|
||||
*draw.fMatrix,
|
||||
primType,
|
||||
@ -1855,8 +1849,7 @@ void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
|
||||
}
|
||||
|
||||
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 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
|
||||
|
||||
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 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
|
||||
|
||||
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 @@ void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
|
||||
|
||||
SkDEBUGCODE(this->validate();)
|
||||
|
||||
fDrawContext->drawTextBlob(fRenderTarget, fClip, paint, *draw.fMatrix,
|
||||
fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix,
|
||||
blob, x, y, drawFilter, draw.fClip->getBounds());
|
||||
}
|
||||
|
||||
|
@ -285,13 +285,12 @@ GrTexture* stretch_texture(GrTexture* inputTexture, const SkGrStretch& stretch,
|
||||
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();
|
||||
}
|
||||
|
@ -224,14 +224,13 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
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 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
|
||||
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 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
|
||||
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,
|
||||
|
@ -364,12 +364,12 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user