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

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, 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 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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } else { 1054 } else {
1055 SkASSERT(dstSizePtr); 1055 SkASSERT(dstSizePtr);
1056 srcRect = *srcRectPtr; 1056 srcRect = *srcRectPtr;
1057 dstSize = *dstSizePtr; 1057 dstSize = *dstSizePtr;
1058 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && 1058 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
1059 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) { 1059 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) {
1060 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag); 1060 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag);
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 if (paint.getMaskFilter()){ 1064 // 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
1065 // or the image size exceeds maximum texture size
1066 // we must call drawRect instead draw on render target directly
1067 int maxTextureSize = fContext->getMaxTextureSize();
1068 bool directDraw = fRenderTarget->isMultisampled() ||
1069 !paint.isAntiAlias() ||
1070 bitmap.width() > maxTextureSize ||
1071 bitmap.height() > maxTextureSize;
1072
1073 // we check whether dst rect are pixel aligned
1074 if (!directDraw) {
1075 bool staysRect = fContext->getMatrix().rectStaysRect();
1076
1077 if (staysRect) {
1078 SkRect rect;
1079 SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHei ght);
1080 fContext->getMatrix().mapRect(&rect, dstRect);
1081 const SkScalar *scalars = rect.asScalars();
1082 bool isDstPixelAligned = true;
1083 for (int i = 0; i < 4; i++) {
1084 if (!SkScalarIsInt(scalars[i])) {
1085 isDstPixelAligned = false;
1086 break;
1087 }
1088 }
1089
1090 if (isDstPixelAligned)
1091 directDraw = true;
1092 }
1093 }
1094
1095 if (paint.getMaskFilter() || !directDraw) {
1065 // Convert the bitmap to a shader so that the rect can be drawn 1096 // Convert the bitmap to a shader so that the rect can be drawn
1066 // through drawRect, which supports mask filters. 1097 // through drawRect, which supports mask filters.
1067 SkBitmap tmp; // subset of bitmap, if necessary 1098 SkBitmap tmp; // subset of bitmap, if necessary
1068 const SkBitmap* bitmapPtr = &bitmap; 1099 const SkBitmap* bitmapPtr = &bitmap;
1069 SkMatrix localM; 1100 SkMatrix localM;
1070 if (srcRectPtr) { 1101 if (srcRectPtr) {
1071 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop); 1102 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop);
1072 localM.postScale(dstSize.fWidth / srcRectPtr->width(), 1103 localM.postScale(dstSize.fWidth / srcRectPtr->width(),
1073 dstSize.fHeight / srcRectPtr->height()); 1104 dstSize.fHeight / srcRectPtr->height());
1074 // In bleed mode we position and trim the bitmap based on the src re ct which is 1105 // In bleed mode we position and trim the bitmap based on the src re ct which is
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 return true; 1869 return true;
1839 } 1870 }
1840 1871
1841 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1872 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1842 // We always return a transient cache, so it is freed after each 1873 // We always return a transient cache, so it is freed after each
1843 // filter traversal. 1874 // filter traversal.
1844 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1875 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1845 } 1876 }
1846 1877
1847 #endif 1878 #endif
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