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 "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 GrBitmapTextureAdjuster adjuster(&bitmap); | 881 GrBitmapTextureAdjuster adjuster(&bitmap); |
882 // We can use kFast here because we know texture-backed bitmaps don't su
pport extractSubset. | 882 // We can use kFast here because we know texture-backed bitmaps don't su
pport extractSubset. |
883 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S
rcRectConstraint, | 883 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S
rcRectConstraint, |
884 viewMatrix, fClip, paint); | 884 viewMatrix, fClip, paint); |
885 return; | 885 return; |
886 } | 886 } |
887 int maxTileSize = fContext->caps()->maxTileSize(); | 887 int maxTileSize = fContext->caps()->maxTileSize(); |
888 | 888 |
889 // The tile code path doesn't currently support AA, so if the paint asked fo
r aa and we could | 889 // The tile code path doesn't currently support AA, so if the paint asked fo
r aa and we could |
890 // draw untiled, then we bypass checking for tiling purely for optimization
reasons. | 890 // draw untiled, then we bypass checking for tiling purely for optimization
reasons. |
891 bool drawAA = !fRenderTarget->isUnifiedMultisampled() && | 891 bool drawAA = !fDrawContext->isUnifiedMultisampled() && |
892 paint.isAntiAlias() && | 892 paint.isAntiAlias() && |
893 bitmap.width() <= maxTileSize && | 893 bitmap.width() <= maxTileSize && |
894 bitmap.height() <= maxTileSize; | 894 bitmap.height() <= maxTileSize; |
895 | 895 |
896 bool skipTileCheck = drawAA || paint.getMaskFilter(); | 896 bool skipTileCheck = drawAA || paint.getMaskFilter(); |
897 | 897 |
898 if (!skipTileCheck) { | 898 if (!skipTileCheck) { |
899 SkRect srcRect = SkRect::MakeIWH(bitmap.width(), bitmap.height()); | 899 SkRect srcRect = SkRect::MakeIWH(bitmap.width(), bitmap.height()); |
900 int tileSize; | 900 int tileSize; |
901 SkIRect clippedSrcRect; | 901 SkIRect clippedSrcRect; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 LogDrawScaleFactor(viewMatrix, origPaint.getFilterQuality()); | 981 LogDrawScaleFactor(viewMatrix, origPaint.getFilterQuality()); |
982 | 982 |
983 // The following pixel lock is technically redundant, but it is desirable | 983 // The following pixel lock is technically redundant, but it is desirable |
984 // to lock outside of the tile loop to prevent redecoding the whole image | 984 // to lock outside of the tile loop to prevent redecoding the whole image |
985 // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that | 985 // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that |
986 // is larger than the limit of the discardable memory pool. | 986 // is larger than the limit of the discardable memory pool. |
987 SkAutoLockPixels alp(bitmap); | 987 SkAutoLockPixels alp(bitmap); |
988 | 988 |
989 const SkPaint* paint = &origPaint; | 989 const SkPaint* paint = &origPaint; |
990 SkPaint tempPaint; | 990 SkPaint tempPaint; |
991 if (origPaint.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled()) { | 991 if (origPaint.isAntiAlias() && !fDrawContext->isUnifiedMultisampled()) { |
992 // Drop antialiasing to avoid seams at tile boundaries. | 992 // Drop antialiasing to avoid seams at tile boundaries. |
993 tempPaint = origPaint; | 993 tempPaint = origPaint; |
994 tempPaint.setAntiAlias(false); | 994 tempPaint.setAntiAlias(false); |
995 paint = &tempPaint; | 995 paint = &tempPaint; |
996 } | 996 } |
997 SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect); | 997 SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect); |
998 | 998 |
999 int nx = bitmap.width() / tileSize; | 999 int nx = bitmap.width() / tileSize; |
1000 int ny = bitmap.height() / tileSize; | 1000 int ny = bitmap.height() / tileSize; |
1001 for (int x = 0; x <= nx; x++) { | 1001 for (int x = 0; x <= nx; x++) { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 src = &tmpSrc; | 1257 src = &tmpSrc; |
1258 srcToDstMatrix.mapRect(&tmpDst, *src); | 1258 srcToDstMatrix.mapRect(&tmpDst, *src); |
1259 dst = &tmpDst; | 1259 dst = &tmpDst; |
1260 } | 1260 } |
1261 } | 1261 } |
1262 | 1262 |
1263 int maxTileSize = fContext->caps()->maxTileSize(); | 1263 int maxTileSize = fContext->caps()->maxTileSize(); |
1264 | 1264 |
1265 // The tile code path doesn't currently support AA, so if the paint asked fo
r aa and we could | 1265 // The tile code path doesn't currently support AA, so if the paint asked fo
r aa and we could |
1266 // draw untiled, then we bypass checking for tiling purely for optimization
reasons. | 1266 // draw untiled, then we bypass checking for tiling purely for optimization
reasons. |
1267 bool drawAA = !fRenderTarget->isUnifiedMultisampled() && | 1267 bool drawAA = !fDrawContext->isUnifiedMultisampled() && |
1268 paint.isAntiAlias() && | 1268 paint.isAntiAlias() && |
1269 bitmap.width() <= maxTileSize && | 1269 bitmap.width() <= maxTileSize && |
1270 bitmap.height() <= maxTileSize; | 1270 bitmap.height() <= maxTileSize; |
1271 | 1271 |
1272 bool skipTileCheck = drawAA || paint.getMaskFilter(); | 1272 bool skipTileCheck = drawAA || paint.getMaskFilter(); |
1273 | 1273 |
1274 if (!skipTileCheck) { | 1274 if (!skipTileCheck) { |
1275 int tileSize; | 1275 int tileSize; |
1276 SkIRect clippedSrcRect; | 1276 SkIRect clippedSrcRect; |
1277 | 1277 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 } | 1419 } |
1420 } | 1420 } |
1421 | 1421 |
1422 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
er, | 1422 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
er, |
1423 const SkIRect& center, const SkRect& dst, con
st SkPaint& paint) { | 1423 const SkIRect& center, const SkRect& dst, con
st SkPaint& paint) { |
1424 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerNine", fContext); | 1424 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerNine", fContext); |
1425 | 1425 |
1426 CHECK_SHOULD_DRAW(draw); | 1426 CHECK_SHOULD_DRAW(draw); |
1427 | 1427 |
1428 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() || | 1428 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() || |
1429 fRenderTarget->isUnifiedMultisampled(); | 1429 fDrawContext->isUnifiedMultisampled(); |
1430 bool doBicubic; | 1430 bool doBicubic; |
1431 GrTextureParams::FilterMode textureFilterMode = | 1431 GrTextureParams::FilterMode textureFilterMode = |
1432 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix,
SkMatrix::I(), | 1432 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix,
SkMatrix::I(), |
1433 &doBicubic); | 1433 &doBicubic); |
1434 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture
FilterMode) { | 1434 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture
FilterMode) { |
1435 SkNinePatchIter iter(producer->width(), producer->height(), center, dst)
; | 1435 SkNinePatchIter iter(producer->width(), producer->height(), center, dst)
; |
1436 | 1436 |
1437 SkRect srcR, dstR; | 1437 SkRect srcR, dstR; |
1438 while (iter.next(&srcR, &dstR)) { | 1438 while (iter.next(&srcR, &dstR)) { |
1439 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_
SrcRectConstraint, | 1439 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_
SrcRectConstraint, |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 } | 1849 } |
1850 | 1850 |
1851 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1851 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1852 ASSERT_SINGLE_OWNER | 1852 ASSERT_SINGLE_OWNER |
1853 // We always return a transient cache, so it is freed after each | 1853 // We always return a transient cache, so it is freed after each |
1854 // filter traversal. | 1854 // filter traversal. |
1855 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1855 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1856 } | 1856 } |
1857 | 1857 |
1858 #endif | 1858 #endif |
OLD | NEW |