Last round of effect->processor (for now)
R=joshualitt@google.com Review URL: https://codereview.chromium.org/659803005
This commit is contained in:
parent
498bc5f036
commit
f2765410ba
@ -111,22 +111,22 @@ public:
|
||||
* processor's key. This allows keys generated by getGLProcessorKey() to only be unique within a
|
||||
* GrProcessor subclass and not necessarily across subclasses.
|
||||
*/
|
||||
uint32_t effectClassID() const { return fEffectClassID; }
|
||||
uint32_t classID() const { return fProcessorClassID; }
|
||||
|
||||
protected:
|
||||
GrBackendProcessorFactory() : fEffectClassID(GenID()) {}
|
||||
GrBackendProcessorFactory() : fProcessorClassID(GenClassID()) {}
|
||||
virtual ~GrBackendProcessorFactory() {}
|
||||
|
||||
private:
|
||||
enum {
|
||||
kIllegalEffectClassID = 0,
|
||||
kIllegalProcessorClassID = 0,
|
||||
};
|
||||
|
||||
static uint32_t GenID() {
|
||||
// fCurrEffectClassID has been initialized to kIllegalEffectClassID. The
|
||||
static uint32_t GenClassID() {
|
||||
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
|
||||
// atomic inc returns the old value not the incremented value. So we add
|
||||
// 1 to the returned value.
|
||||
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&fCurrEffectClassID)) + 1;
|
||||
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&fCurrProcessorClassID)) + 1;
|
||||
if (!id) {
|
||||
SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
|
||||
"subclass.");
|
||||
@ -134,8 +134,8 @@ private:
|
||||
return id;
|
||||
}
|
||||
|
||||
const uint32_t fEffectClassID;
|
||||
static int32_t fCurrEffectClassID;
|
||||
const uint32_t fProcessorClassID;
|
||||
static int32_t fCurrProcessorClassID;
|
||||
};
|
||||
|
||||
class GrFragmentProcessor;
|
||||
|
@ -41,13 +41,13 @@ enum GrCoordSet {
|
||||
*/
|
||||
class GrCoordTransform : SkNoncopyable {
|
||||
public:
|
||||
GrCoordTransform() { SkDEBUGCODE(fInEffect = false); }
|
||||
GrCoordTransform() { SkDEBUGCODE(fInProcessor = false); }
|
||||
|
||||
/**
|
||||
* Create a transformation that maps [0, 1] to a texture's boundaries.
|
||||
*/
|
||||
GrCoordTransform(GrCoordSet sourceCoords, const GrTexture* texture) {
|
||||
SkDEBUGCODE(fInEffect = false);
|
||||
SkDEBUGCODE(fInProcessor = false);
|
||||
this->reset(sourceCoords, texture);
|
||||
}
|
||||
|
||||
@ -57,25 +57,25 @@ public:
|
||||
* coord convention.
|
||||
*/
|
||||
GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture = NULL) {
|
||||
SkDEBUGCODE(fInEffect = false);
|
||||
SkDEBUGCODE(fInProcessor = false);
|
||||
this->reset(sourceCoords, m, texture);
|
||||
}
|
||||
|
||||
void reset(GrCoordSet sourceCoords, const GrTexture* texture) {
|
||||
SkASSERT(!fInEffect);
|
||||
SkASSERT(!fInProcessor);
|
||||
SkASSERT(texture);
|
||||
this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture);
|
||||
}
|
||||
|
||||
void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture = NULL) {
|
||||
SkASSERT(!fInEffect);
|
||||
SkASSERT(!fInProcessor);
|
||||
fSourceCoords = sourceCoords;
|
||||
fMatrix = m;
|
||||
fReverseY = texture && kBottomLeft_GrSurfaceOrigin == texture->origin();
|
||||
}
|
||||
|
||||
GrCoordTransform& operator= (const GrCoordTransform& other) {
|
||||
SkASSERT(!fInEffect);
|
||||
SkASSERT(!fInProcessor);
|
||||
fSourceCoords = other.fSourceCoords;
|
||||
fMatrix = other.fMatrix;
|
||||
fReverseY = other.fReverseY;
|
||||
@ -87,7 +87,7 @@ public:
|
||||
* effect, since effects are immutable.
|
||||
*/
|
||||
SkMatrix* accessMatrix() {
|
||||
SkASSERT(!fInEffect);
|
||||
SkASSERT(!fInProcessor);
|
||||
return &fMatrix;
|
||||
}
|
||||
|
||||
@ -119,9 +119,9 @@ private:
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
public:
|
||||
void setInEffect() const { fInEffect = true; }
|
||||
void setInProcessor() const { fInProcessor = true; }
|
||||
private:
|
||||
mutable bool fInEffect;
|
||||
mutable bool fInProcessor;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -92,8 +92,8 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
int32_t GrBackendProcessorFactory::fCurrEffectClassID =
|
||||
GrBackendProcessorFactory::kIllegalEffectClassID;
|
||||
int32_t GrBackendProcessorFactory::fCurrProcessorClassID =
|
||||
GrBackendProcessorFactory::kIllegalProcessorClassID;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -173,5 +173,5 @@ bool GrProcessor::InvariantOutput::validPreMulColor() const {
|
||||
|
||||
void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
|
||||
fCoordTransforms.push_back(transform);
|
||||
SkDEBUGCODE(transform->setInEffect();)
|
||||
SkDEBUGCODE(transform->setInProcessor();)
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ static bool get_meta_key(const GrProcessor& proc,
|
||||
}
|
||||
*processorKeySize = SkToU16(size);
|
||||
uint32_t textureKey = gen_texture_key(proc, caps);
|
||||
uint32_t classID = proc.getFactory().effectClassID();
|
||||
uint32_t classID = proc.getFactory().classID();
|
||||
|
||||
// Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
|
||||
// don't fit.
|
||||
|
Loading…
Reference in New Issue
Block a user