aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-19 18:51:02 +0000
committerGravatar jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-19 18:51:02 +0000
commit65eb4d5a210884cc92c43a8582cbd1ccbddcab57 (patch)
tree4051b149f07e8560ec3605fbcdb68ee902b18336 /include
parent0b735631b7d22316693629a4110c7e95b2a7633e (diff)
Add stroked ovals and CircleEdgeEffect.
Adds some optimizations to the circle and ellipse shaders, static effect instances for their GrEffects, and some minor changes to GrDrawState::setEffect to make GrEffect setup faster. git-svn-id: http://skia.googlecode.com/svn/trunk@8238 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrContext.h3
-rw-r--r--include/gpu/GrEffectStage.h39
2 files changed, 28 insertions, 14 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index c5572ac3a7..79edd0b11b 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -894,7 +894,8 @@ private:
void internalDrawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke);
void internalDrawOval(const GrPaint& paint, const GrRect& oval, const SkStrokeRec& stroke);
- bool canDrawOval(const GrPaint& paint, const GrRect& oval, const SkStrokeRec& stroke) const;
+ void internalDrawCircle(const GrPaint& paint, const GrRect& circle, const SkStrokeRec& stroke);
+ bool canDrawOval(const GrPaint& paint, const GrRect& oval, bool* isCircle) const;
GrTexture* createResizedTexture(const GrTextureDesc& desc,
const GrCacheID& cacheID,
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
index ff118c384c..cd9a0910fc 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrEffectStage.h
@@ -116,7 +116,8 @@ public:
stage.fEffectRef->get()->incDeferredRefCounts();
fEffect = stage.fEffectRef->get();
fCoordChangeMatrix = stage.fCoordChangeMatrix;
- fVertexAttribIndices = stage.fVertexAttribIndices;
+ fVertexAttribIndices[0] = stage.fVertexAttribIndices[0];
+ fVertexAttribIndices[1] = stage.fVertexAttribIndices[1];
}
SkDEBUGCODE(fInitialized = true;)
}
@@ -127,7 +128,8 @@ public:
if (NULL != fEffect) {
stage->fEffectRef = GrEffect::CreateEffectRef(fEffect);
stage->fCoordChangeMatrix = fCoordChangeMatrix;
- stage->fVertexAttribIndices = fVertexAttribIndices;
+ stage->fVertexAttribIndices[0] = fVertexAttribIndices[0];
+ stage->fVertexAttribIndices[1] = fVertexAttribIndices[1];
} else {
stage->fEffectRef = NULL;
}
@@ -141,7 +143,8 @@ public:
return false;
}
- if (fVertexAttribIndices != stage.fVertexAttribIndices) {
+ if (fVertexAttribIndices[0] != stage.fVertexAttribIndices[0]
+ || fVertexAttribIndices[1] != stage.fVertexAttribIndices[1]) {
return false;
}
@@ -155,7 +158,8 @@ public:
private:
const GrEffect* fEffect;
SkMatrix fCoordChangeMatrix;
- SkSTArray<GrEffect::kMaxVertexAttribs, int, true> fVertexAttribIndices;
+ int fVertexAttribIndices[2];
+ int fVertexAttribCount;
SkDEBUGCODE(bool fInitialized;)
};
@@ -169,28 +173,37 @@ public:
GrSafeSetNull(fEffectRef);
}
- const GrEffectRef* setEffect(const GrEffectRef* EffectRef, const int* attribIndices = NULL) {
+ const GrEffectRef* setEffect(const GrEffectRef* EffectRef) {
GrAssert(0 == fSavedCoordChangeCnt);
GrSafeAssign(fEffectRef, EffectRef);
fCoordChangeMatrix.reset();
- fVertexAttribIndices.reset();
- int numVertexAttribs = (EffectRef == NULL) ? 0 : EffectRef->get()->numVertexAttribs();
- GrAssert(numVertexAttribs == 0 || attribIndices != NULL);
- fVertexAttribIndices.push_back_n(numVertexAttribs, attribIndices);
-
+ fVertexAttribIndices[0] = -1;
+ fVertexAttribIndices[1] = -1;
+
return EffectRef;
}
+ const GrEffectRef* setEffect(const GrEffectRef* EffectRef, int attr0, int attr1 = -1) {
+ GrAssert(0 == fSavedCoordChangeCnt);
+ GrSafeAssign(fEffectRef, EffectRef);
+ fCoordChangeMatrix.reset();
+
+ fVertexAttribIndices[0] = attr0;
+ fVertexAttribIndices[1] = attr1;
+
+ return EffectRef;
+ }
+
const GrEffectRef* getEffect() const { return fEffectRef; }
- const int* getVertexAttribIndices() const { return fVertexAttribIndices.begin(); }
- int getVertexAttribIndexCount() const { return fVertexAttribIndices.count(); }
+ const int* getVertexAttribIndices() const { return fVertexAttribIndices; }
+ int getVertexAttribIndexCount() const { return fEffectRef->get()->numVertexAttribs(); }
private:
SkMatrix fCoordChangeMatrix;
const GrEffectRef* fEffectRef;
- SkSTArray<2, int, true> fVertexAttribIndices;
+ int fVertexAttribIndices[2];
GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
};