diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index e6c8343943..3a0d6f4e3a 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1063,7 +1063,40 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, } } - if (paint.getMaskFilter()){ + // If the render target is not msaa and draw is antialiased, we call + // drawRect instead of drawing on the render target directly. + // FIXME: the tiled bitmap code path doesn't currently support + // anti-aliased edges, we work around that for now by drawing directly + // if the image size exceeds maximum texture size. + int maxTextureSize = fContext->getMaxTextureSize(); + bool directDraw = fRenderTarget->isMultisampled() || + !paint.isAntiAlias() || + bitmap.width() > maxTextureSize || + bitmap.height() > maxTextureSize; + + // we check whether dst rect are pixel aligned + if (!directDraw) { + bool staysRect = fContext->getMatrix().rectStaysRect(); + + if (staysRect) { + SkRect rect; + SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHeight); + fContext->getMatrix().mapRect(&rect, dstRect); + const SkScalar *scalars = rect.asScalars(); + bool isDstPixelAligned = true; + for (int i = 0; i < 4; i++) { + if (!SkScalarIsInt(scalars[i])) { + isDstPixelAligned = false; + break; + } + } + + if (isDstPixelAligned) + directDraw = true; + } + } + + if (paint.getMaskFilter() || !directDraw) { // Convert the bitmap to a shader so that the rect can be drawn // through drawRect, which supports mask filters. SkBitmap tmp; // subset of bitmap, if necessary |