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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1299703003: Stop ping ponging AA in SkGpuDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak Created 5 years, 4 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 "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 srcRect.fRight >= width && srcRect.fBottom >= height) { 1025 srcRect.fRight >= width && srcRect.fBottom >= height) {
1026 constraint = SkCanvas::kFast_SrcRectConstraint; 1026 constraint = SkCanvas::kFast_SrcRectConstraint;
1027 } 1027 }
1028 1028
1029 // If the render target is not msaa and draw is antialiased, we call 1029 // If the render target is not msaa and draw is antialiased, we call
1030 // drawRect instead of drawing on the render target directly. 1030 // drawRect instead of drawing on the render target directly.
1031 // FIXME: the tiled bitmap code path doesn't currently support 1031 // FIXME: the tiled bitmap code path doesn't currently support
1032 // anti-aliased edges, we work around that for now by drawing directly 1032 // anti-aliased edges, we work around that for now by drawing directly
1033 // if the image size exceeds maximum texture size. 1033 // if the image size exceeds maximum texture size.
1034 int maxTextureSize = fContext->caps()->maxTextureSize(); 1034 int maxTextureSize = fContext->caps()->maxTextureSize();
1035 bool directDraw = fRenderTarget->isUnifiedMultisampled() || 1035 bool drawAA = !fRenderTarget->isUnifiedMultisampled() &&
1036 !paint.isAntiAlias() || 1036 paint.isAntiAlias() &&
1037 bitmap.width() > maxTextureSize || 1037 bitmap.width() <= maxTextureSize &&
1038 bitmap.height() > maxTextureSize; 1038 bitmap.height() <= maxTextureSize;
1039 1039
1040 // we check whether dst rect are pixel aligned 1040 if (paint.getMaskFilter() || drawAA) {
1041 if (!directDraw) {
1042 bool staysRect = draw.fMatrix->rectStaysRect();
1043
1044 if (staysRect) {
1045 SkRect rect;
1046 SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHei ght);
1047 draw.fMatrix->mapRect(&rect, dstRect);
1048 const SkScalar *scalars = rect.asScalars();
1049 bool isDstPixelAligned = true;
1050 for (int i = 0; i < 4; i++) {
1051 if (!SkScalarIsInt(scalars[i])) {
1052 isDstPixelAligned = false;
1053 break;
1054 }
1055 }
1056
1057 if (isDstPixelAligned)
1058 directDraw = true;
1059 }
1060 }
1061
1062 if (paint.getMaskFilter() || !directDraw) {
1063 // Convert the bitmap to a shader so that the rect can be drawn 1041 // Convert the bitmap to a shader so that the rect can be drawn
1064 // through drawRect, which supports mask filters. 1042 // through drawRect, which supports mask filters.
1065 SkBitmap tmp; // subset of bitmap, if necessary 1043 SkBitmap tmp; // subset of bitmap, if necessary
1066 const SkBitmap* bitmapPtr = &bitmap; 1044 const SkBitmap* bitmapPtr = &bitmap;
1067 SkMatrix srcRectToDstRect; 1045 SkMatrix srcRectToDstRect;
1068 if (srcRectPtr) { 1046 if (srcRectPtr) {
1069 srcRectToDstRect.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop) ; 1047 srcRectToDstRect.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop) ;
1070 srcRectToDstRect.postScale(dstSize.fWidth / srcRectPtr->width(), 1048 srcRectToDstRect.postScale(dstSize.fWidth / srcRectPtr->width(),
1071 dstSize.fHeight / srcRectPtr->height()); 1049 dstSize.fHeight / srcRectPtr->height());
1072 // In bleed mode we position and trim the bitmap based on the src re ct which is 1050 // In bleed mode we position and trim the bitmap based on the src re ct which is
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 #endif 1900 #endif
1923 } 1901 }
1924 1902
1925 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1903 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1926 // We always return a transient cache, so it is freed after each 1904 // We always return a transient cache, so it is freed after each
1927 // filter traversal. 1905 // filter traversal.
1928 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1906 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1929 } 1907 }
1930 1908
1931 #endif 1909 #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