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

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, 2 months 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 | « no previous file | 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 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698