aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrContext.h10
-rw-r--r--src/gpu/GrClipMaskManager.cpp49
-rw-r--r--src/gpu/GrClipMaskManager.h22
3 files changed, 28 insertions, 53 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index bb661c90b7..8a18331d9c 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -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);
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index a2bc2984be..d930c06b37 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -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();
}
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index d5fcc831aa..aa2c0880a5 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -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;
};