aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar derekf <derekf@osg.samsung.com>2014-12-02 11:02:06 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-02 11:02:06 -0800
commit367e1867b2d6901e3327d0707738d2bc7d13826e (patch)
tree9debddf71bd1f6f97cedde4b46a0ea87f5810a93 /src
parent8b896e71f613880a681dd57f5380e3fa4d3e1ae9 (diff)
use drawRect when drawing a bitmap with anti-aliasing on a non-msaa target
If the dest isn't pixel aligned, or if a non 90 degree rotation is present, we need to use drawRect() for drawing anti-aliased bitmaps on non-msaa targets or the edges won't be anti-aliased as intended. Note: If the bitmap size is bigger than max texture size we fall back to drawBitmapCommon. Original-Author: Henry Song <henrysong@samsung.com> Review URL: https://codereview.chromium.org/649313003
Diffstat (limited to 'src')
-rw-r--r--src/gpu/SkGpuDevice.cpp35
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