Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 649313003: use drawRect when drawing a bitmap with anti-aliasing on a non-msaa target (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9a78048aa7f139195a01c0bc0d97756319353da4..3f08aa4def073d422e2afc1ab1e9e5c3a8a02857 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1062,7 +1062,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
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698