Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index 83cdef701a077f71614feb6f202a327d75fdb810..0a678c69591b2476de1508142f3b1cab51eead77 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -1046,9 +1046,33 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, |
| } |
| } |
| - if (paint.getMaskFilter()){ |
| + // if anti-aliasing without an msaa render target we must call drawRect |
| + // or the result won't be anti-aliased |
| + bool directDraw = fRenderTarget->isMultisampled() || !paint.isAntiAlias(); |
| + if (!directDraw) { |
| + // if src and dst are pixel aligned we can still draw directly |
| + if (fContext->getMatrix().rectStaysRect()) { |
| + SkRect rect; |
| + fContext->getMatrix().mapRect(&rect, srcRect); |
|
bsalomon
2014/10/22 18:47:03
Why does it matter if the src rect is aligned?
Al
|
| + const SkScalar *scalars = rect.asScalars(); |
| + bool isSrcPixelAligned = true; |
| + for (int i = 0; i < 4; i++) { |
| + if (!SkScalarIsInt(scalars[i])) { |
| + isSrcPixelAligned = false; |
| + break; |
| + } |
| + } |
| + |
| + if (isSrcPixelAligned) |
| + directDraw = SkScalarIsInt(dstSize.fWidth) && |
| + SkScalarIsInt(dstSize.fHeight); |
| + } |
| + } |
| + |
| + if (paint.getMaskFilter() || !directDraw) { |
| // Convert the bitmap to a shader so that the rect can be drawn |
| - // through drawRect, which supports mask filters. |
| + // through drawRect, which supports mask filters and anti-aliasing |
| + // without an msaa target. |
| SkBitmap tmp; // subset of bitmap, if necessary |
| const SkBitmap* bitmapPtr = &bitmap; |
| SkMatrix localM; |