Revert of Give GrBatch a pointer to GrPipeline (patchset #1 id:1 of https://codereview.chromium.org/1237283007/)

Reason for revert:
breaking nanobench

Original issue's description:
> Give GrBatch a pointer to GrPipeline
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/1170a12839218f7a23c93487bf95fd83aae0201f

TBR=bsalomon@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1239073002
This commit is contained in:
joshualitt 2015-07-16 07:16:53 -07:00 committed by Commit bot
parent 1170a12839
commit 0df62e3d68
5 changed files with 13 additions and 20 deletions

View File

@ -46,7 +46,6 @@ private:
BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& geo,
const SkScalar klmEqs[9], SkScalar sign)
: INHERITED(gp, geo.fBounds) {
this->initClassID<BezierCubicOrConicTestBatch>();
for (int i = 0; i < 9; i++) {
fKlmEqs[i] = klmEqs[i];
}
@ -448,7 +447,6 @@ private:
: INHERITED(gp, geo.fBounds)
, fGeometry(geo)
, fDevToUV(devToUV) {
this->initClassID<BezierQuadTestBatch>();
}
struct Vertex {

View File

@ -43,7 +43,6 @@ private:
ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo)
: INHERITED(gp, geo.fBounds)
, fGeometry(geo) {
this->initClassID<ConvexPolyTestBatch>();
}
Geometry* geoData(int index) override {

View File

@ -11,9 +11,9 @@
#include <new>
#include "GrBatchTarget.h"
#include "GrGeometryProcessor.h"
#include "GrNonAtomicRef.h"
#include "GrVertices.h"
#include "SkAtomics.h"
#include "SkRefCnt.h"
#include "SkTypes.h"
class GrGpu;
@ -37,8 +37,9 @@ struct GrInitInvariantOutput;
* information will be communicated to the GrBatch prior to geometry generation.
*/
class GrBatch : public GrNonAtomicRef {
class GrBatch : public SkRefCnt {
public:
GrBatch() : fClassID(kIllegalBatchClassID), fNumberOfDraws(0) { SkDEBUGCODE(fUsed = false;) }
virtual ~GrBatch() {}
@ -57,10 +58,6 @@ public:
return false;
}
if (!this->pipeline()->isEqual(*that->pipeline())) {
return false;
}
return this->onCombineIfPossible(that);
}
@ -97,14 +94,14 @@ public:
SkDEBUGCODE(bool isUsed() const { return fUsed; })
void setPipeline(const GrPipeline* pipeline) { fPipeline.reset(SkRef(pipeline)); }
protected:
template <typename PROC_SUBCLASS> void initClassID() {
static uint32_t kClassID = GenClassID();
fClassID = kClassID;
}
uint32_t fClassID;
// NOTE, compute some bounds, even if extremely conservative. Do *NOT* setLargest on the bounds
// rect because we outset it for dst copy textures
void setBounds(const SkRect& newBounds) { fBounds = newBounds; }
@ -113,8 +110,6 @@ protected:
return fBounds.joinPossiblyEmptyRect(otherBounds);
}
const GrPipeline* pipeline() const { return fPipeline; }
/** 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.*/
class InstancedHelper {
@ -153,7 +148,6 @@ protected:
typedef InstancedHelper INHERITED;
};
uint32_t fClassID;
SkRect fBounds;
private:
@ -172,11 +166,12 @@ private:
enum {
kIllegalBatchClassID = 0,
};
SkAutoTUnref<const GrPipeline> fPipeline;
static int32_t gCurrBatchClassID;
int fNumberOfDraws;
SkDEBUGCODE(bool fUsed;)
int fNumberOfDraws;
typedef SkRefCnt INHERITED;
};

View File

@ -10,7 +10,6 @@
#include "GrColor.h"
#include "GrGpu.h"
#include "GrNonAtomicRef.h"
#include "GrPendingFragmentStage.h"
#include "GrPrimitiveProcessor.h"
#include "GrProgramDesc.h"
@ -27,8 +26,10 @@ class GrPipelineBuilder;
* Class that holds an optimized version of a GrPipelineBuilder. It is meant to be an immutable
* class, and contains all data needed to set the state for a gpu draw.
*/
class GrPipeline : public GrNonAtomicRef {
class GrPipeline {
public:
GrPipeline(const GrPipelineBuilder&,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,

View File

@ -23,7 +23,6 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr
// Experimentally we have found that most batching occurs within the first 10 comparisons.
static const int kMaxLookback = 10;
int i = 0;
batch->setPipeline(state->getPipeline());
if (!this->cmdBuffer()->empty()) {
GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
@ -31,7 +30,8 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr
if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get());
if (previous->fBatch->combineIfPossible(batch)) {
if (previous->fState->getPipeline()->isEqual(*state->getPipeline()) &&
previous->fBatch->combineIfPossible(batch)) {
return NULL;
}