#include "SkDashPathPriv.h"
#include "SkConfig8888.h"
#include "SkGr.h"
-#include "SkRTConf.h"
#include "SkRRect.h"
#include "SkStrokeRec.h"
#include "SkTLazy.h"
#include "SkTLS.h"
#include "SkTraceEvent.h"
-// It can be useful to set this to false to test whether a bug is caused by using the
-// InOrderDrawBuffer, to compare performance of using/not using InOrderDrawBuffer, or to make
-// debugging simpler.
-SK_CONF_DECLARE(bool, c_Defer, "gpu.deferContext", true,
- "Defers rendering in GrContext via GrInOrderDrawBuffer.");
-
-#define BUFFERED_DRAW (c_Defer ? kYes_BufferedDraw : kNo_BufferedDraw)
-
#ifdef SK_DEBUG
// change this to a 1 to see notifications when partial coverage fails
#define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0
fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this)));
- fLastDrawWasBuffered = kNo_BufferedDraw;
-
fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu));
fOvalRenderer = SkNEW(GrOvalRenderer);
GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0);
if (texture) {
- GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
- GrDrawState* drawState = fGpu->drawState();
+ GrDrawTarget::AutoStateRestore asr(fDrawBuffer, GrDrawTarget::kReset_ASRInit);
+ GrDrawState* drawState = fDrawBuffer->drawState();
drawState->setRenderTarget(texture->asRenderTarget());
// if filtering is not desired then we want to ensure all
// texels in the resampled image are copies of texels from
// the original.
- GrTextureParams params(SkShader::kClamp_TileMode, filter ? GrTextureParams::kBilerp_FilterMode :
- GrTextureParams::kNone_FilterMode);
+ GrTextureParams params(SkShader::kClamp_TileMode,
+ filter ? GrTextureParams::kBilerp_FilterMode :
+ GrTextureParams::kNone_FilterMode);
drawState->addColorTextureProcessor(clampedTexture, SkMatrix::I(), params);
drawState->setVertexAttribs<gVertexAttribs>(SK_ARRAY_COUNT(gVertexAttribs),
2 * sizeof(SkPoint));
- GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0);
+ GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, 0);
if (arg.succeeded()) {
SkPoint* verts = (SkPoint*) arg.vertices();
verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint));
verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint));
- fGpu->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
+ fDrawBuffer->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
}
} else {
// TODO: Our CPU stretch doesn't filter. But we create separate
AutoRestoreEffects are;
AutoCheckFlush acf(this);
GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
- GrDrawTarget* target = this->prepareToDraw(NULL, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(NULL, &are, &acf);
if (NULL == target) {
return;
}
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
const SkMatrix* localMatrix) {
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
AutoCheckFlush acf(this);
GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scope
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target);
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
if (path.isLine(pts)) {
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
// OK.
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&paint, &are, &acf);
if (NULL == target) {
return;
}
// drawing a rect to the render target.
// The bracket ensures we pop the stack if we wind up flushing below.
{
- GrDrawTarget* drawTarget = this->prepareToDraw(NULL, kYes_BufferedDraw, NULL, NULL);
+ GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL);
GrDrawTarget::AutoGeometryAndStatePush agasp(drawTarget, GrDrawTarget::kReset_ASRInit,
&matrix);
GrDrawState* drawState = drawTarget->drawState();
// We protect the existing geometry here since it may not be
// clear to the caller that a draw operation (i.e., drawSimpleRect)
// can be invoked in this method
- GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit);
- GrDrawState* drawState = fGpu->drawState();
- SkASSERT(fp);
- drawState->addColorProcessor(fp);
-
- drawState->setRenderTarget(texture->asRenderTarget());
- SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- fGpu->drawSimpleRect(rect);
- // we want to read back from the scratch's origin
- left = 0;
- top = 0;
- target = texture->asRenderTarget();
+ {
+ GrDrawTarget::AutoGeometryAndStatePush agasp(fDrawBuffer,
+ GrDrawTarget::kReset_ASRInit);
+ GrDrawState* drawState = fDrawBuffer->drawState();
+ SkASSERT(fp);
+ drawState->addColorProcessor(fp);
+
+ drawState->setRenderTarget(texture->asRenderTarget());
+ SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+ fDrawBuffer->drawSimpleRect(rect);
+ // we want to read back from the scratch's origin
+ left = 0;
+ top = 0;
+ target = texture->asRenderTarget();
+ }
+ this->flushSurfaceWrites(target);
}
}
}
+
if (!fGpu->readPixels(target,
left, top, width, height,
readConfig, buffer, rowBytes)) {
ASSERT_OWNED_RESOURCE(renderTarget);
AutoRestoreEffects are;
AutoCheckFlush acf(this);
- GrDrawTarget* target = this->prepareToDraw(NULL, BUFFERED_DRAW, &are, &acf);
+ GrDrawTarget* target = this->prepareToDraw(NULL, &are, &acf);
if (NULL == target) {
return;
}
// Since we're going to the draw target and not GPU, no need to check kNoFlush
// here.
- GrDrawTarget* target = this->prepareToDraw(NULL, BUFFERED_DRAW, NULL, NULL);
+ GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL);
if (NULL == target) {
return;
}
////////////////////////////////////////////////////////////////////////////////
GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint,
- BufferedDraw buffered,
AutoRestoreEffects* are,
AutoCheckFlush* acf) {
// All users of this draw state should be freeing up all effects when they're done.
return NULL;
}
- if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffered) {
- fDrawBuffer->flush();
- fLastDrawWasBuffered = kNo_BufferedDraw;
- }
ASSERT_OWNED_RESOURCE(fRenderTarget.get());
if (paint) {
SkASSERT(are);
fDrawState->reset(fViewMatrix);
fDrawState->setRenderTarget(fRenderTarget.get());
}
- GrDrawTarget* target;
- if (kYes_BufferedDraw == buffered) {
- fLastDrawWasBuffered = kYes_BufferedDraw;
- target = fDrawBuffer;
- } else {
- SkASSERT(kNo_BufferedDraw == buffered);
- fLastDrawWasBuffered = kNo_BufferedDraw;
- target = fGpu;
- }
fDrawState->setState(GrDrawState::kClip_StateBit, fClip &&
!fClip->fClipStack->isWideOpen());
- target->setClip(fClip);
- SkASSERT(fDrawState == target->drawState());
- return target;
+ fDrawBuffer->setClip(fClip);
+ SkASSERT(fDrawState == fDrawBuffer->drawState());
+ return fDrawBuffer;
}
/*
}
GrDrawTarget* GrContext::getTextTarget() {
- return this->prepareToDraw(NULL, BUFFERED_DRAW, NULL, NULL);
+ return this->prepareToDraw(NULL, NULL, NULL);
}
const GrIndexBuffer* GrContext::getQuadIndexBuffer() const {