Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index 34964d53d69eda1f94ce3f4319dda6e2c3b25a80..3113eb21296baf13752a12d311c779755b231834 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -1061,7 +1061,38 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, |
| } |
| } |
| - if (paint.getMaskFilter()){ |
| + // if the render target is not msaa and draw is antialiased, |
|
bsalomon
2014/11/26 14:22:48
Can we update the comment to say something like "T
|
| + // or the image size exceeds maximum texture size |
| + // we must call drawRect instead draw on render target directly |
| + 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 |