GrDrawTarget* target,
const GrRect& rect,
const SkMatrix& combinedMatrix,
- const GrRect& devRect,
bool useVertexCoverage) {
#ifdef SHADER_AA_FILL_RECT
if (combinedMatrix.rectStaysRect()) {
#else
this->geometryFillAARect(gpu, target,
rect, combinedMatrix,
- devRect, useVertexCoverage);
+ useVertexCoverage);
#endif
}
void strokeAARect(GrGpu* gpu,
GrDrawTarget* target,
- const GrRect& devRect,
+ const GrRect& rect,
+ const SkMatrix& combinedMatrix,
const GrVec& devStrokeSize,
bool useVertexCoverage);
GrDrawTarget* target,
const GrRect& rect,
const SkMatrix& combinedMatrix,
- const GrRect& devRect,
bool useVertexCoverage);
void shaderFillAARect(GrGpu* gpu,
GrDrawTarget* target,
const GrRect& rect,
const SkMatrix& combinedMatrix,
- const GrRect& devRect,
bool useVertexCoverage) {
GrDrawState* drawState = target->drawState();
GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts);
GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
+ SkRect devRect;
+ combinedMatrix.mapRect(&devRect, rect);
+
if (combinedMatrix.rectStaysRect()) {
set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
set_inset_fan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf);
void GrAARectRenderer::strokeAARect(GrGpu* gpu,
GrDrawTarget* target,
- const GrRect& devRect,
+ const GrRect& rect,
+ const SkMatrix& combinedMatrix,
const GrVec& devStrokeSize,
bool useVertexCoverage) {
GrDrawState* drawState = target->drawState();
- const SkScalar& dx = devStrokeSize.fX;
- const SkScalar& dy = devStrokeSize.fY;
+ const SkScalar dx = devStrokeSize.fX;
+ const SkScalar dy = devStrokeSize.fY;
const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
+ SkRect devRect;
+ combinedMatrix.mapRect(&devRect, rect);
+
SkScalar spare;
{
SkScalar w = devRect.width() - dx;
}
if (spare <= 0) {
- GrRect r(devRect);
- r.inset(-rx, -ry);
- this->fillAARect(gpu, target, r, SkMatrix::I(), r, useVertexCoverage);
+ devRect.inset(-rx, -ry);
+ this->fillAARect(gpu, target, devRect, SkMatrix::I(), useVertexCoverage);
return;
}
fGpu,
element->getRect(),
SkMatrix::I(),
- element->getRect(),
false);
} else {
fGpu->drawSimpleRect(element->getRect(), NULL);
verts[9] = verts[1];
}
-/**
- * Returns true if the rects edges are integer-aligned.
- */
-static bool isIRect(const GrRect& r) {
- return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
- SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
-}
-
static bool apply_aa_to_rect(GrDrawTarget* target,
- const GrRect& rect,
SkScalar strokeWidth,
const SkMatrix* matrix,
SkMatrix* combinedMatrix,
- GrRect* devRect,
bool* useVertexCoverage) {
// we use a simple coverage ramp to do aa on axis-aligned rects
// we check if the rect will be axis-aligned, and the rect won't land on
#endif
}
- combinedMatrix->mapRect(devRect, rect);
-
- if (strokeWidth < 0
-#if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
- && drawState.getViewMatrix().preservesAxisAlignment()
-#endif
- ) {
- return !isIRect(*devRect);
- } else {
- return true;
- }
+ return true;
}
void GrContext::drawRect(const GrPaint& paint,
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
GrDrawState::AutoStageDisable atr(fDrawState);
- GrRect devRect;
SkMatrix combinedMatrix;
bool useVertexCoverage;
bool needAA = paint.isAntiAlias() &&
!this->getRenderTarget()->isMultisampled();
- bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix,
- &combinedMatrix, &devRect,
+ bool doAA = needAA && apply_aa_to_rect(target, width, matrix,
+ &combinedMatrix,
&useVertexCoverage);
if (doAA) {
GrDrawState::AutoDeviceCoordDraw adcd(target->drawState());
} else {
strokeSize.set(SK_Scalar1, SK_Scalar1);
}
- fAARectRenderer->strokeAARect(this->getGpu(), target, devRect,
+ fAARectRenderer->strokeAARect(this->getGpu(), target,
+ rect, combinedMatrix,
strokeSize, useVertexCoverage);
} else {
// filled AA rect
fAARectRenderer->fillAARect(this->getGpu(), target,
- rect, combinedMatrix, devRect,
+ rect, combinedMatrix,
useVertexCoverage);
}
return;