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
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index bb661c9..8a18331 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -680,6 +680,11 @@
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 @@
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);
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index a2bc298..d930c06 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -136,7 +136,6 @@
return useSW;
}
-
////////////////////////////////////////////////////////////////////////////////
// sort out what kind of clip mask needs to be created: alpha, stencil,
// scissor, or entirely software
@@ -396,13 +395,15 @@
}
+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 @@
pr->drawPath(path, fill, NULL, gpu, 0, doAA);
return true;
}
+};
////////////////////////////////////////////////////////////////////////////////
bool GrClipMaskManager::drawClipShape(GrGpu* gpu,
@@ -427,16 +429,16 @@
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 @@
0 // samples
};
- temp->set(fAACache.getContext(), desc);
+ temp->set(this->getContext(), desc);
}
@@ -793,7 +795,8 @@
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 @@
return false;
}
- GrSWMaskHelper helper(fAACache.getContext());
+ GrSWMaskHelper helper(this->getContext());
helper.init(*resultBounds, NULL, false);
@@ -1005,23 +1008,7 @@
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();
}
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index d5fcc83..aa2c088 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -284,8 +284,7 @@
public:
GrClipMaskManager()
: fClipMaskInStencil(false)
- , fClipMaskInAlpha(false)
- , fPathRendererChain(NULL) {
+ , fClipMaskInAlpha(false) {
}
bool createClipMask(GrGpu* gpu,
@@ -305,16 +304,16 @@
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 @@
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 @@
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;
};