Disable AA for ovals and roundrects if MSAA is enabled.
Also remove GrPaint from a number of methods -- we only use it to get the AA state. R=bsalomon@google.com Author: jvanverth@google.com Review URL: https://chromiumcodereview.appspot.com/14109033 git-svn-id: http://skia.googlecode.com/svn/trunk@8954 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
f6a90332ae
commit
37d883d9d3
@ -902,7 +902,7 @@ private:
|
||||
/// draw state is left unmodified.
|
||||
GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw);
|
||||
|
||||
void internalDrawPath(GrDrawTarget* target, const GrPaint& paint, const SkPath& path,
|
||||
void internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path,
|
||||
const SkStrokeRec& stroke);
|
||||
|
||||
GrTexture* createResizedTexture(const GrTextureDesc& desc,
|
||||
|
@ -29,16 +29,16 @@ public:
|
||||
GrOvalRenderer() : fRRectIndexBuffer(NULL) {}
|
||||
~GrOvalRenderer() {}
|
||||
|
||||
bool drawOval(GrDrawTarget* target, const GrContext* context, const GrPaint& paint,
|
||||
bool drawOval(GrDrawTarget* target, const GrContext* context, bool useAA,
|
||||
const GrRect& oval, const SkStrokeRec& stroke);
|
||||
bool drawSimpleRRect(GrDrawTarget* target, GrContext* context, const GrPaint& paint,
|
||||
bool drawSimpleRRect(GrDrawTarget* target, GrContext* context, bool useAA,
|
||||
const SkRRect& rrect, const SkStrokeRec& stroke);
|
||||
|
||||
private:
|
||||
bool drawEllipse(GrDrawTarget* target, const GrPaint& paint,
|
||||
bool drawEllipse(GrDrawTarget* target, bool useAA,
|
||||
const GrRect& ellipse,
|
||||
const SkStrokeRec& stroke);
|
||||
void drawCircle(GrDrawTarget* target, const GrPaint& paint,
|
||||
void drawCircle(GrDrawTarget* target, bool useAA,
|
||||
const GrRect& circle,
|
||||
const SkStrokeRec& stroke);
|
||||
|
||||
|
@ -980,10 +980,12 @@ void GrContext::drawRRect(const GrPaint& paint,
|
||||
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
|
||||
GrDrawState::AutoStageDisable atr(fDrawState);
|
||||
|
||||
if (!fOvalRenderer->drawSimpleRRect(target, this, paint, rect, stroke)) {
|
||||
bool prAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled();
|
||||
|
||||
if (!fOvalRenderer->drawSimpleRRect(target, this, prAA, rect, stroke)) {
|
||||
SkPath path;
|
||||
path.addRRect(rect);
|
||||
this->internalDrawPath(target, paint, path, stroke);
|
||||
this->internalDrawPath(target, prAA, path, stroke);
|
||||
}
|
||||
}
|
||||
|
||||
@ -996,10 +998,12 @@ void GrContext::drawOval(const GrPaint& paint,
|
||||
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
|
||||
GrDrawState::AutoStageDisable atr(fDrawState);
|
||||
|
||||
if (!fOvalRenderer->drawOval(target, this, paint, oval, stroke)) {
|
||||
bool useAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled();
|
||||
|
||||
if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) {
|
||||
SkPath path;
|
||||
path.addOval(oval);
|
||||
this->internalDrawPath(target, paint, path, stroke);
|
||||
this->internalDrawPath(target, useAA, path, stroke);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1022,18 +1026,17 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok
|
||||
|
||||
SkRect ovalRect;
|
||||
bool isOval = path.isOval(&ovalRect);
|
||||
bool useAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled();
|
||||
|
||||
if (!isOval || path.isInverseFillType()
|
||||
|| !fOvalRenderer->drawOval(target, this, paint, ovalRect, stroke)) {
|
||||
this->internalDrawPath(target, paint, path, stroke);
|
||||
|| !fOvalRenderer->drawOval(target, this, useAA, ovalRect, stroke)) {
|
||||
this->internalDrawPath(target, useAA, path, stroke);
|
||||
}
|
||||
}
|
||||
|
||||
void GrContext::internalDrawPath(GrDrawTarget* target, const GrPaint& paint, const SkPath& path,
|
||||
void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path,
|
||||
const SkStrokeRec& stroke) {
|
||||
|
||||
bool prAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled();
|
||||
|
||||
// An Assumption here is that path renderer would use some form of tweaking
|
||||
// the src color (either the input alpha or in the frag shader) to implement
|
||||
// aa. If we have some future driver-mojo path AA that can do the right
|
||||
@ -1042,11 +1045,11 @@ void GrContext::internalDrawPath(GrDrawTarget* target, const GrPaint& paint, con
|
||||
#if GR_DEBUG
|
||||
//GrPrintf("Turning off AA to correctly apply blend.\n");
|
||||
#endif
|
||||
prAA = false;
|
||||
useAA = false;
|
||||
}
|
||||
|
||||
GrPathRendererChain::DrawType type = prAA ? GrPathRendererChain::kColorAntiAlias_DrawType :
|
||||
GrPathRendererChain::kColor_DrawType;
|
||||
GrPathRendererChain::DrawType type = useAA ? GrPathRendererChain::kColorAntiAlias_DrawType :
|
||||
GrPathRendererChain::kColor_DrawType;
|
||||
|
||||
const SkPath* pathPtr = &path;
|
||||
SkPath tmpPath;
|
||||
@ -1074,7 +1077,7 @@ void GrContext::internalDrawPath(GrDrawTarget* target, const GrPaint& paint, con
|
||||
return;
|
||||
}
|
||||
|
||||
pr->drawPath(*pathPtr, strokeRec, target, prAA);
|
||||
pr->drawPath(*pathPtr, strokeRec, target, useAA);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -425,10 +425,10 @@ GrEffectRef* AltEllipseEdgeEffect::TestCreate(SkMWCRandom* random,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, const GrPaint& paint,
|
||||
const GrRect& oval, const SkStrokeRec& stroke)
|
||||
bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, bool useAA,
|
||||
const GrRect& oval, const SkStrokeRec& stroke)
|
||||
{
|
||||
if (!paint.isAntiAlias()) {
|
||||
if (!useAA) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -437,11 +437,11 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, co
|
||||
// we can draw circles
|
||||
if (SkScalarNearlyEqual(oval.width(), oval.height())
|
||||
&& circle_stays_circle(vm)) {
|
||||
drawCircle(target, paint, oval, stroke);
|
||||
this->drawCircle(target, useAA, oval, stroke);
|
||||
|
||||
// and axis-aligned ellipses only
|
||||
} else if (vm.rectStaysRect()) {
|
||||
return drawEllipse(target, paint, oval, stroke);
|
||||
return this->drawEllipse(target, useAA, oval, stroke);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
@ -463,7 +463,7 @@ extern const GrVertexAttrib gCircleVertexAttribs[] = {
|
||||
};
|
||||
|
||||
void GrOvalRenderer::drawCircle(GrDrawTarget* target,
|
||||
const GrPaint& paint,
|
||||
bool useAA,
|
||||
const GrRect& circle,
|
||||
const SkStrokeRec& stroke)
|
||||
{
|
||||
@ -571,7 +571,7 @@ extern const GrVertexAttrib gEllipseVertexAttribs[] = {
|
||||
};
|
||||
|
||||
bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
|
||||
const GrPaint& paint,
|
||||
bool useAA,
|
||||
const GrRect& ellipse,
|
||||
const SkStrokeRec& stroke)
|
||||
{
|
||||
@ -580,7 +580,7 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
|
||||
{
|
||||
// we should have checked for this previously
|
||||
bool isAxisAlignedEllipse = drawState->getViewMatrix().rectStaysRect();
|
||||
SkASSERT(paint.isAntiAlias() && isAxisAlignedEllipse);
|
||||
SkASSERT(useAA && isAxisAlignedEllipse);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -742,15 +742,19 @@ GrIndexBuffer* GrOvalRenderer::rRectIndexBuffer(GrGpu* gpu) {
|
||||
return fRRectIndexBuffer;
|
||||
}
|
||||
|
||||
bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context,
|
||||
const GrPaint& paint, const SkRRect& rrect,
|
||||
const SkStrokeRec& stroke)
|
||||
bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, bool useAA,
|
||||
const SkRRect& rrect, const SkStrokeRec& stroke)
|
||||
{
|
||||
// only anti-aliased rrects for now
|
||||
if (!useAA) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const SkMatrix& vm = context->getMatrix();
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
// we should have checked for this previously
|
||||
SkASSERT(paint.isAntiAlias() && vm.rectStaysRect() && rrect.isSimple());
|
||||
SkASSERT(useAA && vm.rectStaysRect() && rrect.isSimple());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -713,7 +713,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
|
||||
CHECK_FOR_NODRAW_ANNOTATION(paint);
|
||||
CHECK_SHOULD_DRAW(draw, false);
|
||||
|
||||
bool usePath = !rect.isSimple() || !paint.isAntiAlias();
|
||||
bool usePath = !rect.isSimple();
|
||||
// another two reasons we might need to call drawPath...
|
||||
if (paint.getMaskFilter() || paint.getPathEffect()) {
|
||||
usePath = true;
|
||||
|
Loading…
Reference in New Issue
Block a user