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

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

Issue 20362002: make the filter mode for GrTextureAccess an enum so we can plumb down (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fall back to mipmaps for HQ sampling (for now) Created 7 years, 5 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/gpu/GrTextureAccess.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.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/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
11 #include "effects/GrSimpleTextureEffect.h" 11 #include "effects/GrSimpleTextureEffect.h"
12 12
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrTextContext.h" 14 #include "GrTextContext.h"
15 15
16 #include "SkGrTexturePixelRef.h" 16 #include "SkGrTexturePixelRef.h"
17 17
18 #include "SkColorFilter.h" 18 #include "SkColorFilter.h"
19 #include "SkDeviceImageFilterProxy.h" 19 #include "SkDeviceImageFilterProxy.h"
20 #include "SkDrawProcs.h" 20 #include "SkDrawProcs.h"
21 #include "SkGlyphCache.h" 21 #include "SkGlyphCache.h"
22 #include "SkImageFilter.h" 22 #include "SkImageFilter.h"
23 #include "SkPathEffect.h" 23 #include "SkPathEffect.h"
24 #include "SkRRect.h" 24 #include "SkRRect.h"
25 #include "SkStroke.h" 25 #include "SkStroke.h"
26 #include "SkUtils.h" 26 #include "SkUtils.h"
27 #include "SkErrorInternals.h"
27 28
28 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 29 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1
29 30
30 #if 0 31 #if 0
31 extern bool (*gShouldDrawProc)(); 32 extern bool (*gShouldDrawProc)();
32 #define CHECK_SHOULD_DRAW(draw, forceI) \ 33 #define CHECK_SHOULD_DRAW(draw, forceI) \
33 do { \ 34 do { \
34 if (gShouldDrawProc && !gShouldDrawProc()) return; \ 35 if (gShouldDrawProc && !gShouldDrawProc()) return; \
35 this->prepareDraw(draw, forceI); \ 36 this->prepareDraw(draw, forceI); \
36 } while (0) 37 } while (0)
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 drawMatrix.setConcat(fContext->getMatrix(), newM); 1128 drawMatrix.setConcat(fContext->getMatrix(), newM);
1128 SkDraw transformedDraw(draw); 1129 SkDraw transformedDraw(draw);
1129 transformedDraw.fMatrix = &drawMatrix; 1130 transformedDraw.fMatrix = &drawMatrix;
1130 1131
1131 this->drawRect(transformedDraw, srcRect, paintWithTexture); 1132 this->drawRect(transformedDraw, srcRect, paintWithTexture);
1132 1133
1133 return; 1134 return;
1134 } 1135 }
1135 1136
1136 GrTextureParams params; 1137 GrTextureParams params;
1137 params.setBilerp(paint.isFilterBitmap()); 1138 SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel();
1139 GrTextureParams::FilterMode textureFilterMode;
1140 switch(paintFilterLevel) {
1141 case SkPaint::kNone_FilterLevel:
1142 textureFilterMode = GrTextureParams::kNone_FilterMode;
1143 break;
1144 case SkPaint::kLow_FilterLevel:
1145 textureFilterMode = GrTextureParams::kBilerp_FilterMode;
1146 break;
1147 case SkPaint::kMedium_FilterLevel:
1148 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
1149 break;
1150 case SkPaint::kHigh_FilterLevel:
1151 SkErrorInternals::SetError( kInvalidPaint_SkError,
1152 "Sorry, I don't yet support high quality "
1153 "filtering on the GPU. Falling back to "
1154 "MIPMaps.");
1155 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
1156 break;
1157 }
1158
1159 params.setFilterMode(textureFilterMode);
1138 1160
1139 if (!this->shouldTileBitmap(bitmap, params, srcRectPtr)) { 1161 if (!this->shouldTileBitmap(bitmap, params, srcRectPtr)) {
1140 // take the simple case 1162 // take the simple case
1141 this->internalDrawBitmap(bitmap, srcRect, m, params, paint); 1163 this->internalDrawBitmap(bitmap, srcRect, m, params, paint);
1142 } else { 1164 } else {
1143 this->drawTiledBitmap(bitmap, srcRect, m, params, paint); 1165 this->drawTiledBitmap(bitmap, srcRect, m, params, paint);
1144 } 1166 }
1145 } 1167 }
1146 1168
1147 // Break 'bitmap' into several tiles to draw it since it has already 1169 // Break 'bitmap' into several tiles to draw it since it has already
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 SkRect dstRect(srcRect); 1293 SkRect dstRect(srcRect);
1272 SkRect paintRect; 1294 SkRect paintRect;
1273 SkScalar wInv = SkScalarInvert(SkIntToScalar(bitmap.width())); 1295 SkScalar wInv = SkScalarInvert(SkIntToScalar(bitmap.width()));
1274 SkScalar hInv = SkScalarInvert(SkIntToScalar(bitmap.height())); 1296 SkScalar hInv = SkScalarInvert(SkIntToScalar(bitmap.height()));
1275 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), 1297 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv),
1276 SkScalarMul(srcRect.fTop, hInv), 1298 SkScalarMul(srcRect.fTop, hInv),
1277 SkScalarMul(srcRect.fRight, wInv), 1299 SkScalarMul(srcRect.fRight, wInv),
1278 SkScalarMul(srcRect.fBottom, hInv)); 1300 SkScalarMul(srcRect.fBottom, hInv));
1279 1301
1280 bool needsTextureDomain = false; 1302 bool needsTextureDomain = false;
1281 if (params.isBilerp()) { 1303 if (params.filterMode() != GrTextureParams::kNone_FilterMode) {
1282 // Need texture domain if drawing a sub rect. 1304 // Need texture domain if drawing a sub rect.
1283 needsTextureDomain = srcRect.width() < bitmap.width() || 1305 needsTextureDomain = srcRect.width() < bitmap.width() ||
1284 srcRect.height() < bitmap.height(); 1306 srcRect.height() < bitmap.height();
1285 if (needsTextureDomain && m.rectStaysRect() && fContext->getMatrix().rec tStaysRect()) { 1307 if (needsTextureDomain && m.rectStaysRect() && fContext->getMatrix().rec tStaysRect()) {
1286 // sampling is axis-aligned 1308 // sampling is axis-aligned
1287 SkRect transformedRect; 1309 SkRect transformedRect;
1288 SkMatrix srcToDeviceMatrix(m); 1310 SkMatrix srcToDeviceMatrix(m);
1289 srcToDeviceMatrix.postConcat(fContext->getMatrix()); 1311 srcToDeviceMatrix.postConcat(fContext->getMatrix());
1290 srcToDeviceMatrix.mapRect(&transformedRect, srcRect); 1312 srcToDeviceMatrix.mapRect(&transformedRect, srcRect);
1291 1313
(...skipping 24 matching lines...) Expand all
1316 top = paintRect.top() + border; 1338 top = paintRect.top() + border;
1317 bottom = paintRect.bottom() - border; 1339 bottom = paintRect.bottom() - border;
1318 } else { 1340 } else {
1319 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); 1341 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
1320 } 1342 }
1321 textureDomain.setLTRB(left, top, right, bottom); 1343 textureDomain.setLTRB(left, top, right, bottom);
1322 effect.reset(GrTextureDomainEffect::Create(texture, 1344 effect.reset(GrTextureDomainEffect::Create(texture,
1323 SkMatrix::I(), 1345 SkMatrix::I(),
1324 textureDomain, 1346 textureDomain,
1325 GrTextureDomainEffect::kClamp _WrapMode, 1347 GrTextureDomainEffect::kClamp _WrapMode,
1326 params.isBilerp())); 1348 params.filterMode()));
1327 } else { 1349 } else {
1328 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param s)); 1350 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param s));
1329 } 1351 }
1330 1352
1331 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring 1353 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
1332 // the rest from the SkPaint. 1354 // the rest from the SkPaint.
1333 GrPaint grPaint; 1355 GrPaint grPaint;
1334 grPaint.addColorEffect(effect); 1356 grPaint.addColorEffect(effect);
1335 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); 1357 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config());
1336 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) { 1358 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 GrTexture* texture, 1776 GrTexture* texture,
1755 bool needClear) 1777 bool needClear)
1756 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { 1778 : SkDevice(make_bitmap(context, texture->asRenderTarget())) {
1757 1779
1758 GrAssert(texture && texture->asRenderTarget()); 1780 GrAssert(texture && texture->asRenderTarget());
1759 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1781 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1760 // cache. We pass true for the third argument so that it will get unlocked. 1782 // cache. We pass true for the third argument so that it will get unlocked.
1761 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1783 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1762 fNeedClear = needClear; 1784 fNeedClear = needClear;
1763 } 1785 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextureAccess.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698