diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-06 14:28:02 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-06 14:28:02 +0000 |
commit | 7de5fc22e69ffc64ae73c3a1605c45823f77fec3 (patch) | |
tree | 105a42e4fbd5314feeff340df5e4cddaaba6db31 | |
parent | f1f4a67e0d98a3385c21b50a8641a98fa5184948 (diff) |
re-re-enable antialiased rects for gpu
git-svn-id: http://skia.googlecode.com/svn/trunk@1065 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0c9b6ed016..90728b1dda 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -729,7 +729,7 @@ static void strokeDevAARect(GrContext* ctx, const GrPaint& paint, fillDevAARect(ctx, paint, r); return; } - + GrAutoMatrix avm(ctx, GrMatrix::I()); GrPoint verts[16]; @@ -750,6 +750,20 @@ static void strokeDevAARect(GrContext* ctx, const GrPaint& paint, gStrokeAARectIdx, SK_ARRAY_COUNT(gStrokeAARectIdx)); } +/* + * If the paint has a texture, preconcat the ctx's inverse, since when we + * draw verts which are already in device coordinates, we need to "undo" that + * before we run our vertex shaders, which expect the coordinates to be local. + */ +static void preConcatInverseToTextureMatrix(GrContext* ctx, GrPaint* paint) { + if (paint->getTexture()) { + GrMatrix inverse; + if (ctx->getMatrix().invert(&inverse)) { + paint->fSampler.preConcatMatrix(inverse); + } + } +} + void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint& paint) { CHECK_SHOULD_DRAW(draw); @@ -770,7 +784,6 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, } bool doAA = paint.isAntiAlias(); - doAA = false; if (SkDraw::kHair_RectType == type && doAA) { strokeSize.set(SK_Scalar1, SK_Scalar1); @@ -786,6 +799,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, if (doAA) { SkRect devRect; matrix.mapRect(&devRect, rect); + preConcatInverseToTextureMatrix(fContext, &grPaint); fillDevAARect(fContext, grPaint, Sk2Gr(devRect)); } else { fContext->drawRect(grPaint, Sk2Gr(rect), -1); @@ -795,6 +809,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, if (doAA) { SkRect devRect; matrix.mapRect(&devRect, rect); + preConcatInverseToTextureMatrix(fContext, &grPaint); strokeDevAARect(fContext, grPaint, Sk2Gr(devRect), strokeSize); } else { fContext->drawRect(grPaint, Sk2Gr(rect), paint.getStrokeWidth()); |