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

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, 1 month 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 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
« 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