* @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
- * @param target if non-NULL, the render target to clear otherwise clear
- * the current render target
+ * @param target The render target to clear.
*/
- void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect,
- GrRenderTarget* target = NULL);
+ void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect, GrRenderTarget* target);
/**
* Draw everywhere (respecting the clip) with the paint.
/**
* Reads a rectangle of pixels from a render target.
- * @param target the render target to read from. NULL means the current render target.
+ * @param target the render target to read from.
* @param left left edge of the rectangle to read (inclusive)
* @param top top edge of the rectangle to read (inclusive)
* @param width width of rectangle to read in pixels.
GrPaint grPaint;
grPaint.setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff);
SkRegion::Iterator iter(fRegion);
- context->clear(NULL, 0x0, true);
+ context->clear(NULL, 0x0, true, maskTexture->asRenderTarget());
SkMatrix old_matrix = context->getMatrix();
context->setMatrix(in_matrix);
// X convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
radiusX, srcIRect.height());
- context->clear(&clearRect, 0x0, false);
+ context->clear(&clearRect, 0x0, false, context->getRenderTarget());
}
context->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
// convolution from reading garbage.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width(), radiusY);
- context->clear(&clearRect, 0x0, false);
+ context->clear(&clearRect, 0x0, false, context->getRenderTarget());
}
context->setRenderTarget(dstTexture->asRenderTarget());
// upsampling.
clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
srcIRect.width() + 1, 1);
- context->clear(&clearRect, 0x0, false);
+ context->clear(&clearRect, 0x0, false, context->getRenderTarget());
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height());
- context->clear(&clearRect, 0x0, false);
+ context->clear(&clearRect, 0x0, false, context->getRenderTarget());
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
context->setRenderTarget(dstTexture->asRenderTarget());
morphType, Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
dstRect.width(), radius.fHeight);
- context->clear(&clearRect, GrMorphologyEffect::kErode_MorphologyType == morphType ?
- SK_ColorWHITE :
- SK_ColorTRANSPARENT, false);
+ GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
+ SK_ColorWHITE :
+ SK_ColorTRANSPARENT;
+ context->clear(&clearRect, clearColor, false, texture->asRenderTarget());
srcTexture.reset(texture);
srcRect = dstRect;
}
bool canIgnoreRect,
GrRenderTarget* renderTarget) {
ASSERT_OWNED_RESOURCE(renderTarget);
+ SkASSERT(renderTarget);
+
AutoRestoreEffects are;
AutoCheckFlush acf(this);
GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
// Will it blend?
GrColor clearColor;
if (paint.isOpaqueAndConstantColor(&clearColor)) {
- target->clear(NULL, clearColor, true);
+ target->clear(NULL, clearColor, true, fRenderTarget);
return;
}
}
GrPixelConfig dstConfig, void* buffer, size_t rowBytes,
uint32_t flags) {
ASSERT_OWNED_RESOURCE(target);
-
- if (NULL == target) {
- target = fRenderTarget.get();
- if (NULL == target) {
- return false;
- }
- }
+ SkASSERT(target);
if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWrite()) {
this->flush();
void GrContext::resolveRenderTarget(GrRenderTarget* target) {
SkASSERT(target);
ASSERT_OWNED_RESOURCE(target);
- // In the future we may track whether there are any pending draws to this
- // target. We don't today so we always perform a flush. We don't promise
- // this to our clients, though.
- this->flush();
+ if (!target->needsResolve()) {
+ return;
+ }
+ if (target->surfacePriv().hasPendingIO()) {
+ this->flush();
+ }
if (fGpu) {
fGpu->resolveRenderTarget(target);
}
const SkRect* devBounds = NULL);
/**
- * Clear the current render target if one isn't passed in. Ignores the
- * clip and all other draw state (blend mode, stages, etc). Clears the
- * whole thing if rect is NULL, otherwise just the rect. If canIgnoreRect
- * is set then the entire render target can be optionally cleared.
+ * Clear the passed in render target. Ignores the draw state and clip. Clears the whole thing if
+ * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the entire render target
+ * can be optionally cleared.
*/
- virtual void clear(const SkIRect* rect,
- GrColor color,
- bool canIgnoreRect,
- GrRenderTarget* renderTarget = NULL) = 0;
+ virtual void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect,
+ GrRenderTarget* renderTarget) = 0;
/**
- * Discards the contents render target. NULL indicates that the current render target should
- * be discarded.
+ * Discards the contents render target.
**/
- virtual void discard(GrRenderTarget* = NULL) = 0;
+ virtual void discard(GrRenderTarget*) = 0;
/**
* Called at start and end of gpu trace marking
GrColor color,
bool canIgnoreRect,
GrRenderTarget* renderTarget) {
- if (NULL == renderTarget) {
- renderTarget = this->getDrawState().getRenderTarget();
- }
- if (NULL == renderTarget) {
- SkASSERT(0);
- return;
- }
+ SkASSERT(renderTarget);
this->handleDirtyContext();
this->onClear(renderTarget, rect, color, canIgnoreRect);
}
size_t rowBytes);
// GrDrawTarget overrides
- virtual void clear(const SkIRect* rect,
- GrColor color,
- bool canIgnoreRect,
- GrRenderTarget* renderTarget = NULL) SK_OVERRIDE;
+ virtual void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect,
+ GrRenderTarget* renderTarget) SK_OVERRIDE;
virtual void clearStencilClip(const SkIRect& rect,
bool insideClip,
}
void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
+ SkASSERT(renderTarget);
if (!this->caps()->discardRenderTargetSupport()) {
return;
}
- if (NULL == renderTarget) {
- renderTarget = this->drawState()->getRenderTarget();
- SkASSERT(renderTarget);
- }
Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
clr->fColor = GrColor_ILLEGAL;
this->recordTraceMarkersIfNecessary();
GrContext::AutoRenderTarget art(context, mask->asRenderTarget());
GrContext::AutoClip ac(context, clipRect);
- context->clear(NULL, 0x0, true);
+ context->clear(NULL, 0x0, true, mask->asRenderTarget());
GrPaint tempPaint;
if (doAA) {
}
void GrGpuGL::discard(GrRenderTarget* renderTarget) {
+ SkASSERT(renderTarget);
if (!this->caps()->discardRenderTargetSupport()) {
return;
}
- if (NULL == renderTarget) {
- renderTarget = this->drawState()->getRenderTarget();
- if (NULL == renderTarget) {
- return;
- }
- }
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) {