OLD | NEW |
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/GrTextureDomainEffect.h" | 11 #include "effects/GrTextureDomainEffect.h" |
11 #include "effects/GrSimpleTextureEffect.h" | 12 #include "effects/GrSimpleTextureEffect.h" |
12 | 13 |
13 #include "GrContext.h" | 14 #include "GrContext.h" |
14 #include "GrBitmapTextContext.h" | 15 #include "GrBitmapTextContext.h" |
15 #if SK_DISTANCEFIELD_FONTS | 16 #if SK_DISTANCEFIELD_FONTS |
16 #include "GrDistanceFieldTextContext.h" | 17 #include "GrDistanceFieldTextContext.h" |
17 #endif | 18 #endif |
18 | 19 |
19 #include "SkGrTexturePixelRef.h" | 20 #include "SkGrTexturePixelRef.h" |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 | 1051 |
1051 void SkGpuDevice::drawBitmap(const SkDraw& draw, | 1052 void SkGpuDevice::drawBitmap(const SkDraw& draw, |
1052 const SkBitmap& bitmap, | 1053 const SkBitmap& bitmap, |
1053 const SkMatrix& m, | 1054 const SkMatrix& m, |
1054 const SkPaint& paint) { | 1055 const SkPaint& paint) { |
1055 // We cannot call drawBitmapRect here since 'm' could be anything | 1056 // We cannot call drawBitmapRect here since 'm' could be anything |
1056 this->drawBitmapCommon(draw, bitmap, NULL, m, paint, | 1057 this->drawBitmapCommon(draw, bitmap, NULL, m, paint, |
1057 SkCanvas::kNone_DrawBitmapRectFlag); | 1058 SkCanvas::kNone_DrawBitmapRectFlag); |
1058 } | 1059 } |
1059 | 1060 |
1060 // This method outsets 'iRect' by 1 all around and then clamps its extents to | 1061 // This method outsets 'iRect' by 'outset' all around and then clamps its extent
s to |
1061 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner | 1062 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner |
1062 // of 'iRect' for all possible outsets/clamps. | 1063 // of 'iRect' for all possible outsets/clamps. |
1063 static inline void clamped_unit_outset_with_offset(SkIRect* iRect, SkPoint* offs
et, | 1064 static inline void clamped_outset_with_offset(SkIRect* iRect, |
1064 const SkIRect& clamp) { | 1065 int outset, |
1065 iRect->outset(1, 1); | 1066 SkPoint* offset, |
| 1067 const SkIRect& clamp) { |
| 1068 iRect->outset(outset, outset); |
1066 | 1069 |
1067 if (iRect->fLeft < clamp.fLeft) { | 1070 int leftClampDelta = clamp.fLeft - iRect->fLeft; |
| 1071 if (leftClampDelta > 0) { |
| 1072 offset->fX -= outset - leftClampDelta; |
1068 iRect->fLeft = clamp.fLeft; | 1073 iRect->fLeft = clamp.fLeft; |
1069 } else { | 1074 } else { |
1070 offset->fX -= SK_Scalar1; | 1075 offset->fX -= outset; |
1071 } | 1076 } |
1072 if (iRect->fTop < clamp.fTop) { | 1077 |
| 1078 int topClampDelta = clamp.fTop - iRect->fTop; |
| 1079 if (topClampDelta > 0) { |
| 1080 offset->fY -= outset - topClampDelta; |
1073 iRect->fTop = clamp.fTop; | 1081 iRect->fTop = clamp.fTop; |
1074 } else { | 1082 } else { |
1075 offset->fY -= SK_Scalar1; | 1083 offset->fY -= outset; |
1076 } | 1084 } |
1077 | 1085 |
1078 if (iRect->fRight > clamp.fRight) { | 1086 if (iRect->fRight > clamp.fRight) { |
1079 iRect->fRight = clamp.fRight; | 1087 iRect->fRight = clamp.fRight; |
1080 } | 1088 } |
1081 if (iRect->fBottom > clamp.fBottom) { | 1089 if (iRect->fBottom > clamp.fBottom) { |
1082 iRect->fBottom = clamp.fBottom; | 1090 iRect->fBottom = clamp.fBottom; |
1083 } | 1091 } |
1084 } | 1092 } |
1085 | 1093 |
1086 void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, | 1094 void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, |
1087 const SkBitmap& bitmap, | 1095 const SkBitmap& bitmap, |
1088 const SkRect* srcRectPtr, | 1096 const SkRect* srcRectPtr, |
1089 const SkMatrix& m, | 1097 const SkMatrix& m, |
1090 const SkPaint& paint, | 1098 const SkPaint& paint, |
1091 SkCanvas::DrawBitmapRectFlags flags) { | 1099 SkCanvas::DrawBitmapRectFlags flags) { |
1092 CHECK_SHOULD_DRAW(draw, false); | 1100 CHECK_SHOULD_DRAW(draw, false); |
1093 | 1101 |
1094 SkRect srcRect; | 1102 SkRect srcRect; |
| 1103 // If there is no src rect, or the src rect contains the entire bitmap then
we're effectively |
| 1104 // in the (easier) bleed case, so update flags. |
1095 if (NULL == srcRectPtr) { | 1105 if (NULL == srcRectPtr) { |
1096 srcRect.set(0, 0, SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.he
ight())); | 1106 srcRect.set(0, 0, SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.he
ight())); |
| 1107 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBi
tmapRectFlag); |
1097 } else { | 1108 } else { |
1098 srcRect = *srcRectPtr; | 1109 srcRect = *srcRectPtr; |
| 1110 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && |
| 1111 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height
()) { |
| 1112 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr
awBitmapRectFlag); |
| 1113 } |
1099 } | 1114 } |
1100 | 1115 |
1101 if (paint.getMaskFilter()){ | 1116 if (paint.getMaskFilter()){ |
1102 // Convert the bitmap to a shader so that the rect can be drawn | 1117 // Convert the bitmap to a shader so that the rect can be drawn |
1103 // through drawRect, which supports mask filters. | 1118 // through drawRect, which supports mask filters. |
1104 SkMatrix newM(m); | 1119 SkMatrix newM(m); |
1105 SkBitmap tmp; // subset of bitmap, if necessary | 1120 SkBitmap tmp; // subset of bitmap, if necessary |
1106 const SkBitmap* bitmapPtr = &bitmap; | 1121 const SkBitmap* bitmapPtr = &bitmap; |
1107 if (NULL != srcRectPtr) { | 1122 if (NULL != srcRectPtr) { |
1108 // In bleed mode we position and trim the bitmap based on the src re
ct which is | 1123 // In bleed mode we position and trim the bitmap based on the src re
ct which is |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 this->drawRect(transformedDraw, srcRect, paintWithTexture); | 1156 this->drawRect(transformedDraw, srcRect, paintWithTexture); |
1142 | 1157 |
1143 return; | 1158 return; |
1144 } | 1159 } |
1145 | 1160 |
1146 fContext->concatMatrix(m); | 1161 fContext->concatMatrix(m); |
1147 | 1162 |
1148 GrTextureParams params; | 1163 GrTextureParams params; |
1149 SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel(); | 1164 SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel(); |
1150 GrTextureParams::FilterMode textureFilterMode; | 1165 GrTextureParams::FilterMode textureFilterMode; |
| 1166 |
| 1167 int tileFilterPad; |
| 1168 bool doBicubic = false; |
| 1169 |
1151 switch(paintFilterLevel) { | 1170 switch(paintFilterLevel) { |
1152 case SkPaint::kNone_FilterLevel: | 1171 case SkPaint::kNone_FilterLevel: |
| 1172 tileFilterPad = 0; |
1153 textureFilterMode = GrTextureParams::kNone_FilterMode; | 1173 textureFilterMode = GrTextureParams::kNone_FilterMode; |
1154 break; | 1174 break; |
1155 case SkPaint::kLow_FilterLevel: | 1175 case SkPaint::kLow_FilterLevel: |
| 1176 tileFilterPad = 1; |
1156 textureFilterMode = GrTextureParams::kBilerp_FilterMode; | 1177 textureFilterMode = GrTextureParams::kBilerp_FilterMode; |
1157 break; | 1178 break; |
1158 case SkPaint::kMedium_FilterLevel: | 1179 case SkPaint::kMedium_FilterLevel: |
| 1180 tileFilterPad = 1; |
1159 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 1181 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
1160 break; | 1182 break; |
1161 case SkPaint::kHigh_FilterLevel: | 1183 case SkPaint::kHigh_FilterLevel: |
1162 // Fall back to mips for now | 1184 if (flags & SkCanvas::kBleed_DrawBitmapRectFlag) { |
1163 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 1185 // We will install an effect that does the filtering in the shad
er. |
| 1186 textureFilterMode = GrTextureParams::kNone_FilterMode; |
| 1187 tileFilterPad = GrBicubicEffect::kFilterTexelPad; |
| 1188 doBicubic = true; |
| 1189 } else { |
| 1190 // We don't yet support doing bicubic filtering with an interior
clamp. Fall back |
| 1191 // to MIPs |
| 1192 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 1193 tileFilterPad = 1; |
| 1194 } |
1164 break; | 1195 break; |
1165 default: | 1196 default: |
1166 SkErrorInternals::SetError( kInvalidPaint_SkError, | 1197 SkErrorInternals::SetError( kInvalidPaint_SkError, |
1167 "Sorry, I don't understand the filtering
" | 1198 "Sorry, I don't understand the filtering
" |
1168 "mode you asked for. Falling back to " | 1199 "mode you asked for. Falling back to " |
1169 "MIPMaps."); | 1200 "MIPMaps."); |
| 1201 tileFilterPad = 1; |
1170 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 1202 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
1171 break; | 1203 break; |
1172 | |
1173 } | 1204 } |
1174 | 1205 |
1175 params.setFilterMode(textureFilterMode); | 1206 params.setFilterMode(textureFilterMode); |
1176 | 1207 |
1177 int maxTileSize = fContext->getMaxTextureSize(); | 1208 int maxTileSize = fContext->getMaxTextureSize() - 2 * tileFilterPad; |
1178 if (SkPaint::kNone_FilterLevel != paint.getFilterLevel()) { | |
1179 // We may need a skosh more room if we have to bump out the tile | |
1180 // by 1 pixel all around | |
1181 maxTileSize -= 2; | |
1182 } | |
1183 int tileSize; | 1209 int tileSize; |
1184 | 1210 |
1185 SkIRect clippedSrcRect; | 1211 SkIRect clippedSrcRect; |
1186 if (this->shouldTileBitmap(bitmap, params, srcRectPtr, maxTileSize, &tileSiz
e, | 1212 if (this->shouldTileBitmap(bitmap, params, srcRectPtr, maxTileSize, &tileSiz
e, |
1187 &clippedSrcRect)) { | 1213 &clippedSrcRect)) { |
1188 this->drawTiledBitmap(bitmap, srcRect, clippedSrcRect, params, paint, fl
ags, tileSize); | 1214 this->drawTiledBitmap(bitmap, srcRect, clippedSrcRect, params, paint, fl
ags, tileSize, |
| 1215 doBicubic); |
1189 } else { | 1216 } else { |
1190 // take the simple case | 1217 // take the simple case |
1191 this->internalDrawBitmap(bitmap, srcRect, params, paint, flags); | 1218 this->internalDrawBitmap(bitmap, srcRect, params, paint, flags, doBicubi
c); |
1192 } | 1219 } |
1193 } | 1220 } |
1194 | 1221 |
1195 // Break 'bitmap' into several tiles to draw it since it has already | 1222 // Break 'bitmap' into several tiles to draw it since it has already |
1196 // been determined to be too large to fit in VRAM | 1223 // been determined to be too large to fit in VRAM |
1197 void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, | 1224 void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, |
1198 const SkRect& srcRect, | 1225 const SkRect& srcRect, |
1199 const SkIRect& clippedSrcIRect, | 1226 const SkIRect& clippedSrcIRect, |
1200 const GrTextureParams& params, | 1227 const GrTextureParams& params, |
1201 const SkPaint& paint, | 1228 const SkPaint& paint, |
1202 SkCanvas::DrawBitmapRectFlags flags, | 1229 SkCanvas::DrawBitmapRectFlags flags, |
1203 int tileSize) { | 1230 int tileSize, |
| 1231 bool bicubic) { |
1204 SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect); | 1232 SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect); |
1205 | 1233 |
1206 int nx = bitmap.width() / tileSize; | 1234 int nx = bitmap.width() / tileSize; |
1207 int ny = bitmap.height() / tileSize; | 1235 int ny = bitmap.height() / tileSize; |
1208 for (int x = 0; x <= nx; x++) { | 1236 for (int x = 0; x <= nx; x++) { |
1209 for (int y = 0; y <= ny; y++) { | 1237 for (int y = 0; y <= ny; y++) { |
1210 SkRect tileR; | 1238 SkRect tileR; |
1211 tileR.set(SkIntToScalar(x * tileSize), | 1239 tileR.set(SkIntToScalar(x * tileSize), |
1212 SkIntToScalar(y * tileSize), | 1240 SkIntToScalar(y * tileSize), |
1213 SkIntToScalar((x + 1) * tileSize), | 1241 SkIntToScalar((x + 1) * tileSize), |
1214 SkIntToScalar((y + 1) * tileSize)); | 1242 SkIntToScalar((y + 1) * tileSize)); |
1215 | 1243 |
1216 if (!SkRect::Intersects(tileR, clippedSrcRect)) { | 1244 if (!SkRect::Intersects(tileR, clippedSrcRect)) { |
1217 continue; | 1245 continue; |
1218 } | 1246 } |
1219 | 1247 |
1220 if (!tileR.intersect(srcRect)) { | 1248 if (!tileR.intersect(srcRect)) { |
1221 continue; | 1249 continue; |
1222 } | 1250 } |
1223 | 1251 |
1224 SkBitmap tmpB; | 1252 SkBitmap tmpB; |
1225 SkIRect iTileR; | 1253 SkIRect iTileR; |
1226 tileR.roundOut(&iTileR); | 1254 tileR.roundOut(&iTileR); |
1227 SkPoint offset = SkPoint::Make(SkIntToScalar(iTileR.fLeft), | 1255 SkPoint offset = SkPoint::Make(SkIntToScalar(iTileR.fLeft), |
1228 SkIntToScalar(iTileR.fTop)); | 1256 SkIntToScalar(iTileR.fTop)); |
1229 | 1257 |
1230 if (SkPaint::kNone_FilterLevel != paint.getFilterLevel()) { | 1258 if (SkPaint::kNone_FilterLevel != paint.getFilterLevel() || bicubic)
{ |
1231 SkIRect iClampRect; | 1259 SkIRect iClampRect; |
1232 | 1260 |
1233 if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) { | 1261 if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) { |
1234 // In bleed mode we want to always expand the tile on all ed
ges | 1262 // In bleed mode we want to always expand the tile on all ed
ges |
1235 // but stay within the bitmap bounds | 1263 // but stay within the bitmap bounds |
1236 iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height()
); | 1264 iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height()
); |
1237 } else { | 1265 } else { |
| 1266 SkASSERT(!bicubic); // Bicubic is not supported with non-ble
ed yet. |
| 1267 |
1238 // In texture-domain/clamp mode we only want to expand the | 1268 // In texture-domain/clamp mode we only want to expand the |
1239 // tile on edges interior to "srcRect" (i.e., we want to | 1269 // tile on edges interior to "srcRect" (i.e., we want to |
1240 // not bleed across the original clamped edges) | 1270 // not bleed across the original clamped edges) |
1241 srcRect.roundOut(&iClampRect); | 1271 srcRect.roundOut(&iClampRect); |
1242 } | 1272 } |
1243 | 1273 int outset = bicubic ? GrBicubicEffect::kFilterTexelPad : 1; |
1244 clamped_unit_outset_with_offset(&iTileR, &offset, iClampRect); | 1274 clamped_outset_with_offset(&iTileR, outset, &offset, iClampRect)
; |
1245 } | 1275 } |
1246 | 1276 |
1247 if (bitmap.extractSubset(&tmpB, iTileR)) { | 1277 if (bitmap.extractSubset(&tmpB, iTileR)) { |
1248 // now offset it to make it "local" to our tmp bitmap | 1278 // now offset it to make it "local" to our tmp bitmap |
1249 tileR.offset(-offset.fX, -offset.fY); | 1279 tileR.offset(-offset.fX, -offset.fY); |
1250 SkMatrix tmpM; | 1280 SkMatrix tmpM; |
1251 tmpM.setTranslate(offset.fX, offset.fY); | 1281 tmpM.setTranslate(offset.fX, offset.fY); |
1252 GrContext::AutoMatrix am; | 1282 GrContext::AutoMatrix am; |
1253 am.setPreConcat(fContext, tmpM); | 1283 am.setPreConcat(fContext, tmpM); |
1254 this->internalDrawBitmap(tmpB, tileR, params, paint, flags); | 1284 this->internalDrawBitmap(tmpB, tileR, params, paint, flags, bicu
bic); |
1255 } | 1285 } |
1256 } | 1286 } |
1257 } | 1287 } |
1258 } | 1288 } |
1259 | 1289 |
1260 static bool has_aligned_samples(const SkRect& srcRect, | 1290 static bool has_aligned_samples(const SkRect& srcRect, |
1261 const SkRect& transformedRect) { | 1291 const SkRect& transformedRect) { |
1262 // detect pixel disalignment | 1292 // detect pixel disalignment |
1263 if (SkScalarAbs(SkScalarRoundToScalar(transformedRect.left()) - | 1293 if (SkScalarAbs(SkScalarRoundToScalar(transformedRect.left()) - |
1264 transformedRect.left()) < COLOR_BLEED_TOLERANCE && | 1294 transformedRect.left()) < COLOR_BLEED_TOLERANCE && |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 * This is called by drawBitmap(), which has to handle images that may be too | 1333 * This is called by drawBitmap(), which has to handle images that may be too |
1304 * large to be represented by a single texture. | 1334 * large to be represented by a single texture. |
1305 * | 1335 * |
1306 * internalDrawBitmap assumes that the specified bitmap will fit in a texture | 1336 * internalDrawBitmap assumes that the specified bitmap will fit in a texture |
1307 * and that non-texture portion of the GrPaint has already been setup. | 1337 * and that non-texture portion of the GrPaint has already been setup. |
1308 */ | 1338 */ |
1309 void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, | 1339 void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
1310 const SkRect& srcRect, | 1340 const SkRect& srcRect, |
1311 const GrTextureParams& params, | 1341 const GrTextureParams& params, |
1312 const SkPaint& paint, | 1342 const SkPaint& paint, |
1313 SkCanvas::DrawBitmapRectFlags flags) { | 1343 SkCanvas::DrawBitmapRectFlags flags, |
| 1344 bool bicubic) { |
1314 SkASSERT(bitmap.width() <= fContext->getMaxTextureSize() && | 1345 SkASSERT(bitmap.width() <= fContext->getMaxTextureSize() && |
1315 bitmap.height() <= fContext->getMaxTextureSize()); | 1346 bitmap.height() <= fContext->getMaxTextureSize()); |
1316 | 1347 |
1317 GrTexture* texture; | 1348 GrTexture* texture; |
1318 SkAutoCachedTexture act(this, bitmap, ¶ms, &texture); | 1349 SkAutoCachedTexture act(this, bitmap, ¶ms, &texture); |
1319 if (NULL == texture) { | 1350 if (NULL == texture) { |
1320 return; | 1351 return; |
1321 } | 1352 } |
1322 | 1353 |
1323 SkRect dstRect(srcRect); | 1354 SkRect dstRect(srcRect); |
1324 SkRect paintRect; | 1355 SkRect paintRect; |
1325 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); | 1356 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); |
1326 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); | 1357 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); |
1327 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), | 1358 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), |
1328 SkScalarMul(srcRect.fTop, hInv), | 1359 SkScalarMul(srcRect.fTop, hInv), |
1329 SkScalarMul(srcRect.fRight, wInv), | 1360 SkScalarMul(srcRect.fRight, wInv), |
1330 SkScalarMul(srcRect.fBottom, hInv)); | 1361 SkScalarMul(srcRect.fBottom, hInv)); |
1331 | 1362 |
1332 bool needsTextureDomain = false; | 1363 bool needsTextureDomain = false; |
1333 if (!(flags & SkCanvas::kBleed_DrawBitmapRectFlag) && | 1364 if (!(flags & SkCanvas::kBleed_DrawBitmapRectFlag) && |
1334 params.filterMode() != GrTextureParams::kNone_FilterMode) { | 1365 params.filterMode() != GrTextureParams::kNone_FilterMode) { |
| 1366 SkASSERT(!bicubic); |
1335 // Need texture domain if drawing a sub rect. | 1367 // Need texture domain if drawing a sub rect. |
1336 needsTextureDomain = srcRect.width() < bitmap.width() || | 1368 needsTextureDomain = srcRect.width() < bitmap.width() || |
1337 srcRect.height() < bitmap.height(); | 1369 srcRect.height() < bitmap.height(); |
1338 if (needsTextureDomain && fContext->getMatrix().rectStaysRect()) { | 1370 if (needsTextureDomain && fContext->getMatrix().rectStaysRect()) { |
1339 const SkMatrix& matrix = fContext->getMatrix(); | 1371 const SkMatrix& matrix = fContext->getMatrix(); |
1340 // sampling is axis-aligned | 1372 // sampling is axis-aligned |
1341 SkRect transformedRect; | 1373 SkRect transformedRect; |
1342 matrix.mapRect(&transformedRect, srcRect); | 1374 matrix.mapRect(&transformedRect, srcRect); |
1343 | 1375 |
1344 if (has_aligned_samples(srcRect, transformedRect)) { | 1376 if (has_aligned_samples(srcRect, transformedRect)) { |
(...skipping 24 matching lines...) Expand all Loading... |
1369 bottom = paintRect.bottom() - border; | 1401 bottom = paintRect.bottom() - border; |
1370 } else { | 1402 } else { |
1371 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); | 1403 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); |
1372 } | 1404 } |
1373 textureDomain.setLTRB(left, top, right, bottom); | 1405 textureDomain.setLTRB(left, top, right, bottom); |
1374 effect.reset(GrTextureDomainEffect::Create(texture, | 1406 effect.reset(GrTextureDomainEffect::Create(texture, |
1375 SkMatrix::I(), | 1407 SkMatrix::I(), |
1376 textureDomain, | 1408 textureDomain, |
1377 GrTextureDomainEffect::kClamp
_WrapMode, | 1409 GrTextureDomainEffect::kClamp
_WrapMode, |
1378 params.filterMode())); | 1410 params.filterMode())); |
| 1411 } else if (bicubic) { |
| 1412 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), params)); |
1379 } else { | 1413 } else { |
1380 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param
s)); | 1414 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param
s)); |
1381 } | 1415 } |
1382 | 1416 |
1383 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring | 1417 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring |
1384 // the rest from the SkPaint. | 1418 // the rest from the SkPaint. |
1385 GrPaint grPaint; | 1419 GrPaint grPaint; |
1386 grPaint.addColorEffect(effect); | 1420 grPaint.addColorEffect(effect); |
1387 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); | 1421 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); |
1388 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) { | 1422 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 GrTexture* texture, | 1881 GrTexture* texture, |
1848 bool needClear) | 1882 bool needClear) |
1849 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1883 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1850 | 1884 |
1851 SkASSERT(texture && texture->asRenderTarget()); | 1885 SkASSERT(texture && texture->asRenderTarget()); |
1852 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1886 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1853 // cache. We pass true for the third argument so that it will get unlocked. | 1887 // cache. We pass true for the third argument so that it will get unlocked. |
1854 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1888 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1855 fNeedClear = needClear; | 1889 fNeedClear = needClear; |
1856 } | 1890 } |
OLD | NEW |