Put clear and discard into GrBatch.

Review URL: https://codereview.chromium.org/1293563003
This commit is contained in:
bsalomon 2015-08-18 09:20:09 -07:00 committed by Commit bot
parent d55d13af4f
commit 5346983b2e
23 changed files with 221 additions and 161 deletions

View File

@ -227,6 +227,8 @@
'<(skia_src_path)/gpu/batches/GrBWFillRectBatch.cpp',
'<(skia_src_path)/gpu/batches/GrBatch.cpp',
'<(skia_src_path)/gpu/batches/GrBatch.h',
'<(skia_src_path)/gpu/batches/GrClearBatch.h',
'<(skia_src_path)/gpu/batches/GrDiscardBatch.h',
'<(skia_src_path)/gpu/batches/GrDrawBatch.cpp',
'<(skia_src_path)/gpu/batches/GrDrawBatch.h',
'<(skia_src_path)/gpu/batches/GrDrawAtlasBatch.cpp',

View File

@ -35,3 +35,29 @@ void SkAppendScalar(SkString* str, SkScalar value, SkScalarAsStringType asType)
}
}
SkString SkTabString(const SkString& string, int tabCnt) {
if (tabCnt <= 0) {
return string;
}
SkString tabs;
for (int i = 0; i < tabCnt; ++i) {
tabs.append("\t");
}
SkString result;
static const char newline[] = "\n";
const char* input = string.c_str();
int nextNL = SkStrFind(input, newline);
while (nextNL >= 0) {
if (nextNL > 0) {
result.append(tabs);
}
result.append(input, nextNL + 1);
input += nextNL + 1;
nextNL = SkStrFind(input, newline);
}
if (*input != '\0') {
result.append(tabs);
}
result.append(input);
return result;
}

View File

@ -35,4 +35,7 @@ static inline void SkAppendScalarHex(SkString* str, SkScalar value) {
SkAppendScalar(str, value, kHex_SkScalarAsStringType);
}
/** Indents every non-empty line of the string by tabCnt tabs */
SkString SkTabString(const SkString& string, int tabCnt);
#endif

View File

@ -26,7 +26,7 @@ GrBufferedDrawTarget::~GrBufferedDrawTarget() {
this->reset();
}
void GrBufferedDrawTarget::onDrawBatch(GrDrawBatch* batch) {
void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) {
fCommands->recordDrawBatch(batch, *this->caps());
}
@ -69,24 +69,12 @@ void GrBufferedDrawTarget::onDrawPaths(const GrPathProcessor* pathProc,
opts);
}
void GrBufferedDrawTarget::onClear(const SkIRect& rect, GrColor color,
GrRenderTarget* renderTarget) {
fCommands->recordClear(rect, color, renderTarget);
}
void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget) {
fCommands->recordClearStencilClip(rect, insideClip, renderTarget);
}
void GrBufferedDrawTarget::discard(GrRenderTarget* renderTarget) {
if (!this->caps()->discardRenderTargetSupport()) {
return;
}
fCommands->recordDiscard(renderTarget);
}
void GrBufferedDrawTarget::onReset() {
fCommands->reset();
fPathIndexBuffer.rewind();

View File

@ -34,8 +34,6 @@ public:
bool insideClip,
GrRenderTarget* renderTarget) override;
void discard(GrRenderTarget*) override;
protected:
void appendIndicesAndTransforms(const void* indexValues, PathIndexType indexType,
const float* transformValues, PathTransformType transformType,
@ -78,7 +76,7 @@ private:
void onFlush() override;
// overrides from GrDrawTarget
void onDrawBatch(GrDrawBatch*) override;
void onDrawBatch(GrBatch*) override;
void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
@ -97,9 +95,6 @@ private:
int count,
const GrStencilSettings&,
const PipelineInfo&) override;
void onClear(const SkIRect& rect,
GrColor color,
GrRenderTarget* renderTarget) override;
void onCopySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,

View File

@ -18,20 +18,6 @@ GrCommandBuilder* GrCommandBuilder::Create(GrGpu* gpu, bool reorder) {
}
}
GrTargetCommands::Cmd* GrCommandBuilder::recordClear(const SkIRect& rect,
GrColor color,
GrRenderTarget* renderTarget) {
SkASSERT(renderTarget);
SkASSERT(rect.fLeft <= rect.fRight && rect.fTop <= rect.fBottom);
Clear* clr = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), Clear, (renderTarget));
GrColorIsPMAssert(color);
clr->fColor = color;
clr->fRect = rect;
GrBATCH_INFO("Recording clear %d\n", clr->uniqueID());
return clr;
}
GrTargetCommands::Cmd* GrCommandBuilder::recordClearStencilClip(const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget) {
@ -46,15 +32,6 @@ GrTargetCommands::Cmd* GrCommandBuilder::recordClearStencilClip(const SkIRect& r
return clr;
}
GrTargetCommands::Cmd* GrCommandBuilder::recordDiscard(GrRenderTarget* renderTarget) {
SkASSERT(renderTarget);
Clear* clr = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), Clear, (renderTarget));
clr->fColor = GrColor_ILLEGAL;
GrBATCH_INFO("Recording discard %d\n", clr->uniqueID());
return clr;
}
GrTargetCommands::Cmd* GrCommandBuilder::recordCopySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,

View File

@ -29,8 +29,7 @@ public:
virtual Cmd* recordClearStencilClip(const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget);
virtual Cmd* recordDiscard(GrRenderTarget*);
virtual Cmd* recordDrawBatch(GrDrawBatch*, const GrCaps&) = 0;
virtual Cmd* recordDrawBatch(GrBatch*, const GrCaps&) = 0;
virtual Cmd* recordStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
@ -51,9 +50,6 @@ public:
int,
const GrStencilSettings&,
const GrPipelineOptimizations&) = 0;
virtual Cmd* recordClear(const SkIRect& rect,
GrColor,
GrRenderTarget*);
virtual Cmd* recordCopySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,
@ -64,7 +60,6 @@ protected:
typedef GrTargetCommands::StencilPath StencilPath;
typedef GrTargetCommands::DrawPath DrawPath;
typedef GrTargetCommands::DrawPaths DrawPaths;
typedef GrTargetCommands::Clear Clear;
typedef GrTargetCommands::ClearStencilClip ClearStencilClip;
typedef GrTargetCommands::CopySurface CopySurface;

View File

@ -20,6 +20,8 @@
#include "GrTexture.h"
#include "GrVertexBuffer.h"
#include "batches/GrClearBatch.h"
#include "batches/GrDiscardBatch.h"
#include "batches/GrDrawBatch.h"
#include "batches/GrRectBatchFactory.h"
@ -341,7 +343,17 @@ void GrDrawTarget::clear(const SkIRect* rect,
this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect);
} else {
this->onClear(*rect, color, renderTarget);
GrBatch* batch = SkNEW_ARGS(GrClearBatch, (*rect, color, renderTarget));
this->onDrawBatch(batch);
batch->unref();
}
}
void GrDrawTarget::discard(GrRenderTarget* renderTarget) {
if (this->caps()->discardRenderTargetSupport()) {
GrBatch* batch = SkNEW_ARGS(GrDiscardBatch, (renderTarget));
this->onDrawBatch(batch);
batch->unref();
}
}

View File

@ -30,6 +30,7 @@
#include "SkTypes.h"
#include "SkXfermode.h"
class GrBatch;
class GrClip;
class GrCaps;
class GrPath;
@ -155,10 +156,8 @@ public:
bool canIgnoreRect,
GrRenderTarget* renderTarget);
/**
* Discards the contents render target.
**/
virtual void discard(GrRenderTarget*) = 0;
/** Discards the contents render target. */
void discard(GrRenderTarget*);
/**
* Called at start and end of gpu trace marking
@ -242,7 +241,7 @@ private:
virtual void onFlush() = 0;
virtual void onDrawBatch(GrDrawBatch*) = 0;
virtual void onDrawBatch(GrBatch*) = 0;
virtual void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
@ -262,8 +261,6 @@ private:
const GrStencilSettings&,
const PipelineInfo&) = 0;
virtual void onClear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) = 0;
/** The subclass's copy surface implementation. It should assume that any clipping has already
been performed on the rect and point and that the GrGpu supports the copy. */
virtual void onCopySurface(GrSurface* dst,

View File

@ -25,7 +25,7 @@ GrImmediateDrawTarget::~GrImmediateDrawTarget() {
this->reset();
}
void GrImmediateDrawTarget::onDrawBatch(GrDrawBatch* batch) {
void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch) {
#if 0
// TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so that we can
@ -40,11 +40,6 @@ void GrImmediateDrawTarget::onDrawBatch(GrDrawBatch* batch) {
#endif
}
void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color,
GrRenderTarget* renderTarget) {
this->getGpu()->clear(rect, color, renderTarget);
}
void GrImmediateDrawTarget::onCopySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,
@ -58,14 +53,6 @@ void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect,
this->getGpu()->clearStencilClip(rect, insideClip, renderTarget);
}
void GrImmediateDrawTarget::discard(GrRenderTarget* renderTarget) {
if (!this->caps()->discardRenderTargetSupport()) {
return;
}
this->getGpu()->discard(renderTarget);
}
void GrImmediateDrawTarget::onReset() {}
void GrImmediateDrawTarget::onFlush() {

View File

@ -30,14 +30,12 @@ public:
bool insideClip,
GrRenderTarget* renderTarget) override;
void discard(GrRenderTarget*) override;
private:
void onReset() override;
void onFlush() override;
// overrides from GrDrawTarget
void onDrawBatch(GrDrawBatch*) override;
void onDrawBatch(GrBatch*) override;
void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
@ -62,9 +60,6 @@ private:
const PipelineInfo&) override {
SkFAIL("Only batch implemented\n");
}
void onClear(const SkIRect& rect,
GrColor color,
GrRenderTarget* renderTarget) override;
void onCopySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,

View File

@ -25,7 +25,7 @@ static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin
return isWinding;
}
GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(GrDrawBatch* batch,
GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(GrBatch* batch,
const GrCaps& caps) {
GrBATCH_INFO("In-Recording (%s, %u)\n", batch->name(), batch->uniqueID());
if (!this->cmdBuffer()->empty() &&

View File

@ -17,7 +17,7 @@ public:
GrInOrderCommandBuilder() : INHERITED() { }
Cmd* recordDrawBatch(GrDrawBatch*, const GrCaps&) override;
Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override;
Cmd* recordStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,

View File

@ -6,6 +6,7 @@
*/
#include "GrReorderCommandBuilder.h"
#include "SkStringUtils.h"
template <class Left, class Right>
static bool intersect(const Left& a, const Right& b) {
@ -15,7 +16,7 @@ static bool intersect(const Left& a, const Right& b) {
a.fTop < b.fBottom && b.fTop < a.fBottom;
}
GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrDrawBatch* batch,
GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrBatch* batch,
const GrCaps& caps) {
// Check if there is a Batch Draw we can batch with by linearly searching back until we either
// 1) check every draw
@ -25,26 +26,13 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrDrawBatch* bat
static const int kMaxLookback = 10;
int i = 0;
GrRenderTarget* rt = batch->pipeline()->getRenderTarget();
GrBATCH_INFO("Re-Recording (%s, B%u)\n"
"\tRenderTarget %p\n"
"\tBounds (%f, %f, %f, %f)\n",
batch->name(),
batch->uniqueID(), rt,
batch->uniqueID(),
batch->bounds().fLeft, batch->bounds().fRight,
batch->bounds().fTop, batch->bounds().fBottom);
if (GR_BATCH_SPEW) {
SkDebugf("\tColorStages:\n");
for (int i = 0; i < batch->pipeline()->numColorFragmentStages(); i++) {
SkDebugf("\t\t%s\n", batch->pipeline()->getColorStage(i).processor()->name());
}
SkDebugf("\tCoverageStages:\n");
for (int i = 0; i < batch->pipeline()->numCoverageFragmentStages(); i++) {
SkDebugf("\t\t%s\n", batch->pipeline()->getCoverageStage(i).processor()->name());
}
SkDebugf("\tXP: %s\n", batch->pipeline()->getXferProcessor()->name());
}
GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str());
GrBATCH_INFO("\tOutcome:\n");
if (!this->cmdBuffer()->empty()) {
GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
@ -53,7 +41,7 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrDrawBatch* bat
if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get());
if (previous->batch()->pipeline()->getRenderTarget() != rt) {
if (previous->batch()->renderTargetUniqueID() != batch->renderTargetUniqueID()) {
GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n",
previous->batch()->name(), previous->batch()->uniqueID());
break;
@ -70,24 +58,9 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrDrawBatch* bat
previous->batch()->name(), previous->batch()->uniqueID());
break;
}
} else if (Cmd::kClear_CmdType == reverseIter->type()) {
Clear* previous = static_cast<Clear*>(reverseIter.get());
// We cannot continue to search backwards if the render target changes
if (previous->renderTarget() != rt) {
GrBATCH_INFO("\t\tBreaking because of Clear's Rendertarget change\n");
break;
}
// We set the color to illegal if we are doing a discard.
if (previous->fColor == GrColor_ILLEGAL ||
intersect(batch->bounds(), previous->fRect)) {
GrBATCH_INFO("\t\tBreaking because of Clear intersection\n");
break;
}
} else {
GrBATCH_INFO("\t\tBreaking because of other %08x\n", reverseIter->type());
// TODO temporary until we can navigate the other types of commands
// TODO temporary until we only have batches.
break;
}
} while (reverseIter.previous() && ++i < kMaxLookback);

View File

@ -17,7 +17,7 @@ public:
GrReorderCommandBuilder() : INHERITED() {}
Cmd* recordDrawBatch(GrDrawBatch*, const GrCaps&) override;
Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override;
Cmd* recordStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,

View File

@ -30,11 +30,7 @@ void GrTargetCommands::flush(GrGpu* gpu, GrResourceProvider* resourceProvider) {
while (genIter.next()) {
if (Cmd::kDrawBatch_CmdType == genIter->type()) {
DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get());
// TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so that we can
// remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch.
GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(db->batch());
vertexBatch->prepareDraws(&flushState);
db->batch()->prepare(&flushState);
}
}
@ -77,19 +73,7 @@ void GrTargetCommands::DrawPaths::execute(GrBatchFlushState* state) {
}
void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) {
// TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so that we can
// remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch.
GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(fBatch.get());
vertexBatch->issueDraws(state);
}
void GrTargetCommands::Clear::execute(GrBatchFlushState* state) {
if (GrColor_ILLEGAL == fColor) {
state->gpu()->discard(this->renderTarget());
} else {
state->gpu()->clear(fRect, fColor, this->renderTarget());
}
fBatch->draw(state);
}
void GrTargetCommands::ClearStencilClip::execute(GrBatchFlushState* state) {

View File

@ -15,7 +15,8 @@
#include "GrRenderTarget.h"
#include "GrTRecorder.h"
#include "batches/GrDrawBatch.h"
#include "batches/GrBatch.h"
#include "SkRect.h"
class GrResourceProvider;
@ -30,12 +31,11 @@ public:
public:
enum CmdType {
kStencilPath_CmdType = 1,
kClear_CmdType = 2,
kClearStencil_CmdType = 3,
kCopySurface_CmdType = 4,
kDrawPath_CmdType = 5,
kDrawPaths_CmdType = 6,
kDrawBatch_CmdType = 7,
kClearStencil_CmdType = 2,
kCopySurface_CmdType = 3,
kDrawPath_CmdType = 4,
kDrawPaths_CmdType = 5,
kDrawBatch_CmdType = 6,
};
Cmd(CmdType type)
@ -177,21 +177,6 @@ private:
GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange;
};
// This is also used to record a discard by setting the color to GrColor_ILLEGAL
struct Clear : public Cmd {
Clear(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarget(rt) {}
GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
void execute(GrBatchFlushState*) override;
SkIRect fRect;
GrColor fColor;
private:
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
};
// This command is ONLY used by the clip mask manager to clear the stencil clip bits
struct ClearStencilClip : public Cmd {
ClearStencilClip(GrRenderTarget* rt) : Cmd(kClearStencil_CmdType), fRenderTarget(rt) {}
@ -228,17 +213,17 @@ private:
};
struct DrawBatch : public Cmd {
DrawBatch(GrDrawBatch* batch)
DrawBatch(GrBatch* batch)
: Cmd(kDrawBatch_CmdType)
, fBatch(SkRef(batch)){
SkASSERT(!batch->isUsed());
}
GrDrawBatch* batch() { return fBatch; }
GrBatch* batch() { return fBatch; }
void execute(GrBatchFlushState*) override;
private:
SkAutoTUnref<GrDrawBatch> fBatch;
SkAutoTUnref<GrBatch> fBatch;
};
static const int kCmdBufferInitialSizeInBytes = 8 * 1024;

View File

@ -12,8 +12,10 @@
#include "GrNonAtomicRef.h"
#include "SkRect.h"
#include "SkString.h"
class GrCaps;
class GrBatchFlushState;
/**
* GrBatch is the base class for all Ganesh deferred geometry generators. To facilitate
@ -79,6 +81,20 @@ public:
#endif
SkDEBUGCODE(bool isUsed() const { return fUsed; })
/** Called prior to drawing. The batch should perform any resource creation necessary to
to quickly issue its draw when draw is called. */
void prepare(GrBatchFlushState* state) { this->onPrepare(state); }
/** Issues the batches commands to GrGpu. */
void draw(GrBatchFlushState* state) { this->onDraw(state); }
/** Used to block batching across render target changes. Remove this once we store
GrBatches for different RTs in different targets. */
virtual uint32_t renderTargetUniqueID() const = 0;
/** Used for spewing information about batches when debugging. */
virtual SkString dumpInfo() const = 0;
protected:
template <typename PROC_SUBCLASS> void initClassID() {
static uint32_t kClassID = GenID(&gCurrBatchClassID);
@ -98,6 +114,9 @@ protected:
private:
virtual bool onCombineIfPossible(GrBatch*, const GrCaps& caps) = 0;
virtual void onPrepare(GrBatchFlushState*) = 0;
virtual void onDraw(GrBatchFlushState*) = 0;
static uint32_t GenID(int32_t* idCounter) {
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
// atomic inc returns the old value not the incremented value. So we add

View File

@ -0,0 +1,55 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrClearBatch_DEFINED
#define GrClearBatch_DEFINED
#include "GrBatch.h"
#include "GrBatchFlushState.h"
#include "GrGpu.h"
#include "GrRenderTarget.h"
class GrClearBatch final : public GrBatch {
public:
GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt)
: fRect(rect)
, fColor(color)
, fRenderTarget(rt) {
this->initClassID<GrClearBatch>();
fBounds = SkRect::Make(rect);
}
const char* name() const override { return "Clear"; }
uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
SkString dumpInfo() const {
SkString string;
string.printf("Color: 0x%08x, Rect [L: %d, T: %d, R: %d, B: %d], RT: 0x%p",
fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
fRenderTarget.get());
return string;
}
private:
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
// We could combine clears. TBD how much complexity to put here.
return false;
}
void onPrepare(GrBatchFlushState*) override {}
void onDraw(GrBatchFlushState* state) override {
state->gpu()->clear(fRect, fColor, fRenderTarget.get());
}
SkIRect fRect;
GrColor fColor;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
};
#endif

View File

@ -0,0 +1,48 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrDiscardBatch_DEFINED
#define GrDiscardBatch_DEFINED
#include "GrBatch.h"
#include "GrBatchFlushState.h"
#include "GrGpu.h"
#include "GrRenderTarget.h"
class GrDiscardBatch final : public GrBatch {
public:
GrDiscardBatch(GrRenderTarget* rt)
: fRenderTarget(rt) {
this->initClassID<GrDiscardBatch>();
fBounds = SkRect::MakeWH(SkIntToScalar(rt->width()), SkIntToScalar(rt->height()));
}
const char* name() const override { return "Discard"; }
uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
SkString dumpInfo() const {
SkString string;
string.printf("RT: 0x%p", fRenderTarget.get());
return string;
}
private:
bool onCombineIfPossible(GrBatch* that, const GrCaps& caps) override {
return fRenderTarget == that->cast<GrDiscardBatch>()->fRenderTarget;
}
void onPrepare(GrBatchFlushState*) override {}
void onDraw(GrBatchFlushState* state) override {
state->gpu()->discard(fRenderTarget.get());
}
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
};
#endif

View File

@ -56,6 +56,25 @@ public:
// TODO no GrPrimitiveProcessors yet read fragment position
bool willReadFragmentPosition() const { return false; }
uint32_t renderTargetUniqueID() const final {
SkASSERT(fPipelineInstalled);
return this->pipeline()->getRenderTarget()->getUniqueID();
}
SkString dumpInfo() const override {
SkString string;
string.append("ColorStages:\n");
for (int i = 0; i < this->pipeline()->numColorFragmentStages(); i++) {
string.appendf("\t\t%s\n", this->pipeline()->getColorStage(i).processor()->name());
}
string.append("CoverageStages:\n");
for (int i = 0; i < this->pipeline()->numCoverageFragmentStages(); i++) {
string.appendf("\t%s\n", this->pipeline()->getCoverageStage(i).processor()->name());
}
string.appendf("XP: %s\n", this->pipeline()->getXferProcessor()->name());
return string;
}
private:
/**
* initBatchTracker is a hook for the some additional overrides / optimization possibilities

View File

@ -11,7 +11,7 @@
GrVertexBatch::GrVertexBatch() : fDrawArrays(1) {}
void GrVertexBatch::prepareDraws(GrBatchFlushState* state) {
void GrVertexBatch::onPrepare(GrBatchFlushState* state) {
Target target(state, this);
this->onPrepareDraws(&target);
}
@ -59,7 +59,7 @@ void* GrVertexBatch::QuadHelper::init(Target* target, size_t vertexStride,
quadIndexBuffer, kVerticesPerQuad, kIndicesPerQuad, quadsToDraw);
}
void GrVertexBatch::issueDraws(GrBatchFlushState* state) {
void GrVertexBatch::onDraw(GrBatchFlushState* state) {
int uploadCnt = fInlineUploads.count();
int currUpload = 0;

View File

@ -26,9 +26,6 @@ public:
GrVertexBatch();
void prepareDraws(GrBatchFlushState* state);
void issueDraws(GrBatchFlushState* state);
protected:
/** Helper for rendering instances using an instanced index index buffer. This class creates the
space for the vertices and flushes the draws to the batch target. */
@ -65,6 +62,9 @@ protected:
};
private:
void onPrepare(GrBatchFlushState* state) final;
void onDraw(GrBatchFlushState* state) final;
virtual void onPrepareDraws(Target*) = 0;
// A set of contiguous draws with no inline uploads between them that all use the same