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

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

Issue 282293004: Centralize decision about whether to do bicubic filtering, and fallbacks to mip, bilerp, or nearest (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/gpu/effects/GrBicubicEffect.h » ('j') | 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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 // the view matrix rather than a local matrix. 1163 // the view matrix rather than a local matrix.
1164 SkMatrix m; 1164 SkMatrix m;
1165 m.setScale(dstSize.fWidth / srcRect.width(), 1165 m.setScale(dstSize.fWidth / srcRect.width(),
1166 dstSize.fHeight / srcRect.height()); 1166 dstSize.fHeight / srcRect.height());
1167 fContext->concatMatrix(m); 1167 fContext->concatMatrix(m);
1168 1168
1169 GrTextureParams params; 1169 GrTextureParams params;
1170 SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel(); 1170 SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel();
1171 GrTextureParams::FilterMode textureFilterMode; 1171 GrTextureParams::FilterMode textureFilterMode;
1172 1172
1173 int tileFilterPad;
1174 bool doBicubic = false; 1173 bool doBicubic = false;
1175 1174
1176 switch(paintFilterLevel) { 1175 switch(paintFilterLevel) {
1177 case SkPaint::kNone_FilterLevel: 1176 case SkPaint::kNone_FilterLevel:
1178 tileFilterPad = 0;
1179 textureFilterMode = GrTextureParams::kNone_FilterMode; 1177 textureFilterMode = GrTextureParams::kNone_FilterMode;
1180 break; 1178 break;
1181 case SkPaint::kLow_FilterLevel: 1179 case SkPaint::kLow_FilterLevel:
1182 tileFilterPad = 1;
1183 textureFilterMode = GrTextureParams::kBilerp_FilterMode; 1180 textureFilterMode = GrTextureParams::kBilerp_FilterMode;
1184 break; 1181 break;
1185 case SkPaint::kMedium_FilterLevel: 1182 case SkPaint::kMedium_FilterLevel:
1186 tileFilterPad = 1;
1187 if (fContext->getMatrix().getMinScale() < SK_Scalar1) { 1183 if (fContext->getMatrix().getMinScale() < SK_Scalar1) {
1188 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 1184 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
1189 } else { 1185 } else {
1190 // Don't trigger MIP level generation unnecessarily. 1186 // Don't trigger MIP level generation unnecessarily.
1191 textureFilterMode = GrTextureParams::kBilerp_FilterMode; 1187 textureFilterMode = GrTextureParams::kBilerp_FilterMode;
1192 } 1188 }
1193 break; 1189 break;
1194 case SkPaint::kHigh_FilterLevel: 1190 case SkPaint::kHigh_FilterLevel:
1195 // Minification can look bad with the bicubic effect. 1191 // Minification can look bad with the bicubic effect.
1196 if (fContext->getMatrix().getMinScale() >= SK_Scalar1) { 1192 doBicubic =
1197 // We will install an effect that does the filtering in the shad er. 1193 GrBicubicEffect::ShouldUseBicubic(fContext->getMatrix(), &textur eFilterMode);
1198 textureFilterMode = GrTextureParams::kNone_FilterMode;
1199 tileFilterPad = GrBicubicEffect::kFilterTexelPad;
1200 doBicubic = true;
1201 } else {
1202 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
1203 tileFilterPad = 1;
1204 }
1205 break; 1194 break;
1206 default: 1195 default:
1207 SkErrorInternals::SetError( kInvalidPaint_SkError, 1196 SkErrorInternals::SetError( kInvalidPaint_SkError,
1208 "Sorry, I don't understand the filtering " 1197 "Sorry, I don't understand the filtering "
1209 "mode you asked for. Falling back to " 1198 "mode you asked for. Falling back to "
1210 "MIPMaps."); 1199 "MIPMaps.");
1211 tileFilterPad = 1;
1212 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 1200 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
1213 break; 1201 break;
1214 } 1202 }
1215 1203
1204 int tileFilterPad;
1205 if (doBicubic) {
1206 tileFilterPad = GrBicubicEffect::kFilterTexelPad;
1207 } else if (GrTextureParams::kNone_FilterMode == textureFilterMode) {
1208 tileFilterPad = 0;
1209 } else {
1210 tileFilterPad = 1;
1211 }
1216 params.setFilterMode(textureFilterMode); 1212 params.setFilterMode(textureFilterMode);
1217 1213
1218 int maxTileSize = fContext->getMaxTextureSize() - 2 * tileFilterPad; 1214 int maxTileSize = fContext->getMaxTextureSize() - 2 * tileFilterPad;
1219 int tileSize; 1215 int tileSize;
1220 1216
1221 SkIRect clippedSrcRect; 1217 SkIRect clippedSrcRect;
1222 if (this->shouldTileBitmap(bitmap, params, srcRectPtr, maxTileSize, &tileSiz e, 1218 if (this->shouldTileBitmap(bitmap, params, srcRectPtr, maxTileSize, &tileSiz e,
1223 &clippedSrcRect)) { 1219 &clippedSrcRect)) {
1224 this->drawTiledBitmap(bitmap, srcRect, clippedSrcRect, params, paint, fl ags, tileSize, 1220 this->drawTiledBitmap(bitmap, srcRect, clippedSrcRect, params, paint, fl ags, tileSize,
1225 doBicubic); 1221 doBicubic);
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict ure, i); 1986 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict ure, i);
1991 1987
1992 if (NULL != layer->getTexture()) { 1988 if (NULL != layer->getTexture()) {
1993 fContext->unlockScratchTexture(layer->getTexture()); 1989 fContext->unlockScratchTexture(layer->getTexture());
1994 layer->setTexture(NULL); 1990 layer->setTexture(NULL);
1995 } 1991 }
1996 } 1992 }
1997 1993
1998 return true; 1994 return true;
1999 } 1995 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/gpu/effects/GrBicubicEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698