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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 } else { 1039 } else {
1040 SkASSERT(dstSizePtr); 1040 SkASSERT(dstSizePtr);
1041 srcRect = *srcRectPtr; 1041 srcRect = *srcRectPtr;
1042 dstSize = *dstSizePtr; 1042 dstSize = *dstSizePtr;
1043 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && 1043 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
1044 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) { 1044 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) {
1045 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag); 1045 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag);
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 if (paint.getMaskFilter()){ 1049 // if anti-aliasing without an msaa render target we must call drawRect
1050 // or the result won't be anti-aliased
1051 bool directDraw = fRenderTarget->isMultisampled() || !paint.isAntiAlias();
1052 if (!directDraw) {
1053 // if src and dst are pixel aligned we can still draw directly
1054 if (fContext->getMatrix().rectStaysRect()) {
1055 SkRect rect;
1056 fContext->getMatrix().mapRect(&rect, srcRect);
bsalomon 2014/10/22 18:47:03 Why does it matter if the src rect is aligned? Al
1057 const SkScalar *scalars = rect.asScalars();
1058 bool isSrcPixelAligned = true;
1059 for (int i = 0; i < 4; i++) {
1060 if (!SkScalarIsInt(scalars[i])) {
1061 isSrcPixelAligned = false;
1062 break;
1063 }
1064 }
1065
1066 if (isSrcPixelAligned)
1067 directDraw = SkScalarIsInt(dstSize.fWidth) &&
1068 SkScalarIsInt(dstSize.fHeight);
1069 }
1070 }
1071
1072 if (paint.getMaskFilter() || !directDraw) {
1050 // Convert the bitmap to a shader so that the rect can be drawn 1073 // Convert the bitmap to a shader so that the rect can be drawn
1051 // through drawRect, which supports mask filters. 1074 // through drawRect, which supports mask filters and anti-aliasing
1075 // without an msaa target.
1052 SkBitmap tmp; // subset of bitmap, if necessary 1076 SkBitmap tmp; // subset of bitmap, if necessary
1053 const SkBitmap* bitmapPtr = &bitmap; 1077 const SkBitmap* bitmapPtr = &bitmap;
1054 SkMatrix localM; 1078 SkMatrix localM;
1055 if (srcRectPtr) { 1079 if (srcRectPtr) {
1056 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop); 1080 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop);
1057 localM.postScale(dstSize.fWidth / srcRectPtr->width(), 1081 localM.postScale(dstSize.fWidth / srcRectPtr->width(),
1058 dstSize.fHeight / srcRectPtr->height()); 1082 dstSize.fHeight / srcRectPtr->height());
1059 // In bleed mode we position and trim the bitmap based on the src re ct which is 1083 // In bleed mode we position and trim the bitmap based on the src re ct which is
1060 // already accounted for in 'm' and 'srcRect'. In clamp mode we need to chop out 1084 // already accounted for in 'm' and 'srcRect'. In clamp mode we need to chop out
1061 // the desired portion of the bitmap and then update 'm' and 'srcRec t' to 1085 // the desired portion of the bitmap and then update 'm' and 'srcRec t' to
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 GrLayerHoister::UnlockLayers(fContext, atlased, nonAtlased, recycled); 1848 GrLayerHoister::UnlockLayers(fContext, atlased, nonAtlased, recycled);
1825 1849
1826 return true; 1850 return true;
1827 } 1851 }
1828 1852
1829 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1853 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1830 // We always return a transient cache, so it is freed after each 1854 // We always return a transient cache, so it is freed after each
1831 // filter traversal. 1855 // filter traversal.
1832 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1856 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1833 } 1857 }
OLDNEW
« 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