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

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 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 | « expectations/gm/ignored-tests.txt ('k') | 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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 } else { 1055 } else {
1056 SkASSERT(dstSizePtr); 1056 SkASSERT(dstSizePtr);
1057 srcRect = *srcRectPtr; 1057 srcRect = *srcRectPtr;
1058 dstSize = *dstSizePtr; 1058 dstSize = *dstSizePtr;
1059 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && 1059 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
1060 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) { 1060 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) {
1061 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag); 1061 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag);
1062 } 1062 }
1063 } 1063 }
1064 1064
1065 if (paint.getMaskFilter()){ 1065 // If the render target is not msaa and draw is antialiased, we call
1066 // drawRect instead of drawing on the render target directly.
1067 // FIXME: the tiled bitmap code path doesn't currently support
1068 // anti-aliased edges, we work around that for now by drawing directly
1069 // if the image size exceeds maximum texture size.
1070 int maxTextureSize = fContext->getMaxTextureSize();
1071 bool directDraw = fRenderTarget->isMultisampled() ||
1072 !paint.isAntiAlias() ||
1073 bitmap.width() > maxTextureSize ||
1074 bitmap.height() > maxTextureSize;
1075
1076 // we check whether dst rect are pixel aligned
1077 if (!directDraw) {
1078 bool staysRect = fContext->getMatrix().rectStaysRect();
1079
1080 if (staysRect) {
1081 SkRect rect;
1082 SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHei ght);
1083 fContext->getMatrix().mapRect(&rect, dstRect);
1084 const SkScalar *scalars = rect.asScalars();
1085 bool isDstPixelAligned = true;
1086 for (int i = 0; i < 4; i++) {
1087 if (!SkScalarIsInt(scalars[i])) {
1088 isDstPixelAligned = false;
1089 break;
1090 }
1091 }
1092
1093 if (isDstPixelAligned)
1094 directDraw = true;
1095 }
1096 }
1097
1098 if (paint.getMaskFilter() || !directDraw) {
1066 // Convert the bitmap to a shader so that the rect can be drawn 1099 // Convert the bitmap to a shader so that the rect can be drawn
1067 // through drawRect, which supports mask filters. 1100 // through drawRect, which supports mask filters.
1068 SkBitmap tmp; // subset of bitmap, if necessary 1101 SkBitmap tmp; // subset of bitmap, if necessary
1069 const SkBitmap* bitmapPtr = &bitmap; 1102 const SkBitmap* bitmapPtr = &bitmap;
1070 SkMatrix localM; 1103 SkMatrix localM;
1071 if (srcRectPtr) { 1104 if (srcRectPtr) {
1072 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop); 1105 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop);
1073 localM.postScale(dstSize.fWidth / srcRectPtr->width(), 1106 localM.postScale(dstSize.fWidth / srcRectPtr->width(),
1074 dstSize.fHeight / srcRectPtr->height()); 1107 dstSize.fHeight / srcRectPtr->height());
1075 // In bleed mode we position and trim the bitmap based on the src re ct which is 1108 // In bleed mode we position and trim the bitmap based on the src re ct which is
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 return true; 1879 return true;
1847 } 1880 }
1848 1881
1849 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1882 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1850 // We always return a transient cache, so it is freed after each 1883 // We always return a transient cache, so it is freed after each
1851 // filter traversal. 1884 // filter traversal.
1852 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1885 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1853 } 1886 }
1854 1887
1855 #endif 1888 #endif
OLDNEW
« 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