Make GrProcessorDataManager a noop

TBR=bsalomon@google.com
BUG=skia:

Review URL: https://codereview.chromium.org/1323963003
This commit is contained in:
joshualitt 2015-09-09 10:00:12 -07:00 committed by Commit bot
parent 1fcc01c415
commit af2533a165
6 changed files with 24 additions and 85 deletions

View File

@ -136,7 +136,6 @@ public:
}
fXPFactory.reset(SkRef(paint.getXPFactory()));
fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataManager()));
return *this;
}
@ -149,9 +148,9 @@ public:
*/
bool isConstantBlendedColor(GrColor* constantColor) const;
GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager.get(); }
GrProcessorDataManager* getProcessorDataManager() { return &fProcDataManager; }
const GrProcessorDataManager* processorDataManager() const { return fProcDataManager.get(); }
const GrProcessorDataManager* processorDataManager() const { return &fProcDataManager; }
private:
void resetFragmentProcessors() {
@ -173,7 +172,7 @@ private:
bool fDither;
GrColor fColor;
SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
GrProcessorDataManager fProcDataManager;
};
#endif

View File

@ -8,48 +8,9 @@
#ifndef GrProcessorDataManager_DEFINED
#define GrProcessorDataManager_DEFINED
#include "SkRefCnt.h"
#include "SkTArray.h"
// TODO this class is just an empty stub for now
class GrProcessorDataManager : public SkRefCnt {
public:
GrProcessorDataManager() {}
GrProcessorDataManager(const GrProcessorDataManager& procDataManager) {
fIndices = procDataManager.fIndices;
fStorage = procDataManager.fStorage;
}
void* operator new(size_t size);
void operator delete(void* target);
void* operator new(size_t size, void* placement) {
return ::operator new(size, placement);
}
void operator delete(void* target, void* placement) {
::operator delete(target, placement);
}
private:
uint32_t currentSaveMarker() const { return 0; }
void restoreToSaveMarker(/*uint32_t marker*/) {}
// For GrPipelineBuilder::AutoRestoreProcessorDataManager
friend class GrPipelineBuilder;
static const uint32_t kNumProcessor = 1;
static const uint32_t kDataIndicesPerProcessor = 1;
static const uint32_t kPreAllocDataPerProcessor = 1;
/*static const size_t kPreAllocStorage = kNumProcessor * kPreAllocDataPerProcessor;
static const uint32_t kNumProcessor = 8;
static const uint32_t kDataIndicesPerProcessor = 4;
static const uint32_t kPreAllocDataPerProcessor = kDataIndicesPerProcessor *
sizeof(GrCoordTransform);*/
static const size_t kPreAllocIndices = kNumProcessor * kDataIndicesPerProcessor;
static const size_t kPreAllocStorage = kNumProcessor * kPreAllocDataPerProcessor;
SkSTArray<kPreAllocIndices, uint32_t, true> fIndices;
SkSTArray<kPreAllocStorage, unsigned char, true> fStorage;
typedef SkRefCnt INHERITED;
class GrProcessorDataManager {
};
#endif

View File

@ -16,35 +16,34 @@
GrPaint::GrPaint()
: fAntiAlias(false)
, fDither(false)
, fColor(GrColor_WHITE)
, fProcDataManager(new GrProcessorDataManager) {}
, fColor(GrColor_WHITE) {}
void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) {
fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage));
}
void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix))->unref();
}
void GrPaint::addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
params))->unref();
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix, params))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
params))->unref();
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix, params))->unref();
}
bool GrPaint::isConstantBlendedColor(GrColor* color) const {

View File

@ -16,17 +16,13 @@
#include "effects/GrPorterDuffXferProcessor.h"
GrPipelineBuilder::GrPipelineBuilder()
: fProcDataManager(new GrProcessorDataManager), fFlags(0x0), fDrawFace(kBoth_DrawFace) {
: fFlags(0x0), fDrawFace(kBoth_DrawFace) {
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
}
GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, const GrClip& clip) {
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
// TODO keep this logically const using an AutoReset
fProcDataManager.reset(
const_cast<GrProcessorDataManager*>(SkRef(paint.processorDataManager())));
for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor(i)));
}
@ -77,14 +73,12 @@ void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
}
fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n);
SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker(/*fSaveMarker*/);
}
fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder);
if (nullptr != pipelineBuilder) {
fColorEffectCnt = pipelineBuilder->numColorFragmentProcessors();
fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentProcessors();
SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;)
fSaveMarker = pipelineBuilder->processorDataManager()->currentSaveMarker();
}
}

View File

@ -80,19 +80,19 @@ public:
* Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
*/
void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix))->unref();
}
void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix))->unref();
}
void addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix,
params))->unref();
}
@ -100,7 +100,7 @@ public:
void addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcDataManager, texture,
matrix, params))->unref();
}
@ -116,14 +116,12 @@ public:
AutoRestoreFragmentProcessorState()
: fPipelineBuilder(nullptr)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0)
, fSaveMarker(0) {}
, fCoverageEffectCnt(0) {}
AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds)
: fPipelineBuilder(nullptr)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0)
, fSaveMarker(0) {
, fCoverageEffectCnt(0) {
this->set(&ds);
}
@ -148,7 +146,6 @@ public:
GrPipelineBuilder* fPipelineBuilder;
int fColorEffectCnt;
int fCoverageEffectCnt;
uint32_t fSaveMarker;
};
/// @}
@ -408,8 +405,8 @@ public:
void setClip(const GrClip& clip) { fClip = clip; }
const GrClip& clip() const { return fClip; }
GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager.get(); }
const GrProcessorDataManager* processorDataManager() const { return fProcDataManager.get(); }
GrProcessorDataManager* getProcessorDataManager() { return &fProcDataManager; }
const GrProcessorDataManager* processorDataManager() const { return &fProcDataManager; }
private:
// Calculating invariant color / coverage information is expensive, so we partially cache the
@ -438,7 +435,7 @@ private:
typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
GrProcessorDataManager fProcDataManager;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
uint32_t fFlags;
GrStencilSettings fStencilSettings;

View File

@ -246,14 +246,3 @@ bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con
// Initial static variable from GrXPFactory
int32_t GrXPFactory::gCurrXPFClassID =
GrXPFactory::kIllegalXPFClassID;
///////////////////////////////////////////////////////////////////////////////////////////////////
// GrProcessorDataManager lives in the same pool
void* GrProcessorDataManager::operator new(size_t size) {
return MemoryPoolAccessor().pool()->allocate(size);
}
void GrProcessorDataManager::operator delete(void* target) {
return MemoryPoolAccessor().pool()->release(target);
}