Remove GrClipMaskManager's path renderer chain (in favor of GrContext's)

http://codereview.appspot.com/6211078/



git-svn-id: http://skia.googlecode.com/svn/trunk@4032 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2012-05-22 20:28:23 +00:00
parent 0f645b68a3
commit 2c75681e36
3 changed files with 28 additions and 53 deletions

View File

@ -680,6 +680,11 @@ public:
void unlockStencilBuffer(GrResourceEntry* sbEntry);
GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt);
GrPathRenderer* getPathRenderer(const SkPath& path,
GrPathFill fill,
const GrDrawTarget* target,
bool antiAlias);
private:
// used to keep track of when we need to flush the draw buffer
enum DrawCategory {
@ -728,11 +733,6 @@ private:
GrDrawTarget* prepareToDraw(const GrPaint& paint, DrawCategory drawType);
GrPathRenderer* getPathRenderer(const SkPath& path,
GrPathFill fill,
const GrDrawTarget* target,
bool antiAlias);
void internalDrawPath(const GrPaint& paint, const SkPath& path,
GrPathFill fill, const GrPoint* translate);

View File

@ -136,7 +136,6 @@ bool GrClipMaskManager::useSWOnlyPath(GrGpu* gpu, const GrClip& clipIn) {
return useSW;
}
////////////////////////////////////////////////////////////////////////////////
// sort out what kind of clip mask needs to be created: alpha, stencil,
// scissor, or entirely software
@ -396,13 +395,15 @@ void setup_boolean_blendcoeffs(GrDrawState* drawState, SkRegion::Op op) {
}
namespace {
////////////////////////////////////////////////////////////////////////////////
bool GrClipMaskManager::drawPath(GrGpu* gpu,
const SkPath& path,
GrPathFill fill,
bool doAA) {
bool draw_path(GrContext* context,
GrGpu* gpu,
const SkPath& path,
GrPathFill fill,
bool doAA) {
GrPathRenderer* pr = this->getClipPathRenderer(gpu, path, fill, doAA);
GrPathRenderer* pr = context->getPathRenderer(path, fill, gpu, doAA);
if (NULL == pr) {
return false;
}
@ -410,6 +411,7 @@ bool GrClipMaskManager::drawPath(GrGpu* gpu,
pr->drawPath(path, fill, NULL, gpu, 0, doAA);
return true;
}
};
////////////////////////////////////////////////////////////////////////////////
bool GrClipMaskManager::drawClipShape(GrGpu* gpu,
@ -427,16 +429,16 @@ bool GrClipMaskManager::drawClipShape(GrGpu* gpu,
SkPath temp;
temp.addRect(clipIn.getRect(index));
return this->drawPath(gpu, temp,
kEvenOdd_PathFill, clipIn.getDoAA(index));
return draw_path(this->getContext(), gpu, temp,
kEvenOdd_PathFill, clipIn.getDoAA(index));
} else {
gpu->drawSimpleRect(clipIn.getRect(index), NULL, 0);
}
} else {
return this->drawPath(gpu,
clipIn.getPath(index),
clipIn.getPathFill(index),
clipIn.getDoAA(index));
return draw_path(this->getContext(), gpu,
clipIn.getPath(index),
clipIn.getPathFill(index),
clipIn.getDoAA(index));
}
return true;
}
@ -498,7 +500,7 @@ void GrClipMaskManager::getTemp(const GrIRect& bounds,
0 // samples
};
temp->set(fAACache.getContext(), desc);
temp->set(this->getContext(), desc);
}
@ -793,7 +795,8 @@ bool GrClipMaskManager::createStencilClipMask(GrGpu* gpu,
fillInverted = GrIsFillInverted(fill);
fill = GrNonInvertedFill(fill);
clipPath = &clipCopy.getPath(c);
pr = this->getClipPathRenderer(gpu, *clipPath, fill, false);
pr = this->getContext()->getPathRenderer(*clipPath,
fill, gpu, false);
if (NULL == pr) {
fClipMaskInStencil = false;
gpu->setClip(clipCopy); // restore to the original
@ -907,7 +910,7 @@ bool GrClipMaskManager::createSoftwareClipMask(GrGpu* gpu,
return false;
}
GrSWMaskHelper helper(fAACache.getContext());
GrSWMaskHelper helper(this->getContext());
helper.init(*resultBounds, NULL, false);
@ -1005,23 +1008,7 @@ bool GrClipMaskManager::createSoftwareClipMask(GrGpu* gpu,
return true;
}
////////////////////////////////////////////////////////////////////////////////
GrPathRenderer* GrClipMaskManager::getClipPathRenderer(GrGpu* gpu,
const SkPath& path,
GrPathFill fill,
bool antiAlias) {
if (NULL == fPathRendererChain) {
fPathRendererChain =
new GrPathRendererChain(gpu->getContext(),
GrPathRendererChain::kNone_UsageFlag);
}
return fPathRendererChain->getPathRenderer(path, fill, gpu, antiAlias);
}
////////////////////////////////////////////////////////////////////////////////
void GrClipMaskManager::releaseResources() {
// in case path renderer has any GrResources, start from scratch
GrSafeSetNull(fPathRendererChain);
fAACache.releaseResources();
}

View File

@ -284,8 +284,7 @@ class GrClipMaskManager : public GrNoncopyable {
public:
GrClipMaskManager()
: fClipMaskInStencil(false)
, fClipMaskInAlpha(false)
, fPathRendererChain(NULL) {
, fClipMaskInAlpha(false) {
}
bool createClipMask(GrGpu* gpu,
@ -305,16 +304,16 @@ public:
fAACache.setContext(context);
}
GrContext* getContext() {
return fAACache.getContext();
}
protected:
private:
bool fClipMaskInStencil; // is the clip mask in the stencil buffer?
bool fClipMaskInAlpha; // is the clip mask in an alpha texture?
GrClipMaskCache fAACache; // cache for the AA path
// must be instantiated after GrGpu object has been given its owning
// GrContext ptr. (GrGpu is constructed first then handed off to GrContext).
GrPathRendererChain* fPathRendererChain;
bool createStencilClipMask(GrGpu* gpu,
const GrClip& clip,
const GrRect& bounds,
@ -334,11 +333,6 @@ private:
bool useSWOnlyPath(GrGpu* gpu, const GrClip& clipIn);
bool drawPath(GrGpu* gpu,
const SkPath& path,
GrPathFill fill,
bool doAA);
bool drawClipShape(GrGpu* gpu,
GrTexture* target,
const GrClip& clipIn,
@ -353,12 +347,6 @@ private:
void setupCache(const GrClip& clip,
const GrIRect& bounds);
// determines the path renderer used to draw a clip path element.
GrPathRenderer* getClipPathRenderer(GrGpu* gpu,
const SkPath& path,
GrPathFill fill,
bool antiAlias);
typedef GrNoncopyable INHERITED;
};