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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 bitmap.height() <= fContext->caps()->maxTileSize())); | 1138 bitmap.height() <= fContext->caps()->maxTileSize())); |
1139 | 1139 |
1140 GrTexture* texture; | 1140 GrTexture* texture; |
1141 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect(
) | 1141 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect(
) |
1142 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; | 1142 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; |
1143 AutoBitmapTexture abt(fContext, bitmap, params, gammaTreatment, &texture); | 1143 AutoBitmapTexture abt(fContext, bitmap, params, gammaTreatment, &texture); |
1144 if (nullptr == texture) { | 1144 if (nullptr == texture) { |
1145 return; | 1145 return; |
1146 } | 1146 } |
1147 | 1147 |
| 1148 SkColorSpace* dstColorSpace = nullptr; // XFORMTODO |
| 1149 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(bitmap.co
lorSpace(), |
| 1150 dstColorS
pace); |
1148 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; | 1151 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; |
1149 SkRect paintRect; | 1152 SkRect paintRect; |
1150 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); | 1153 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); |
1151 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); | 1154 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); |
1152 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), | 1155 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), |
1153 SkScalarMul(srcRect.fTop, hInv), | 1156 SkScalarMul(srcRect.fTop, hInv), |
1154 SkScalarMul(srcRect.fRight, wInv), | 1157 SkScalarMul(srcRect.fRight, wInv), |
1155 SkScalarMul(srcRect.fBottom, hInv)); | 1158 SkScalarMul(srcRect.fBottom, hInv)); |
1156 | 1159 |
1157 SkMatrix texMatrix; | 1160 SkMatrix texMatrix; |
(...skipping 24 matching lines...) Expand all Loading... |
1182 } | 1185 } |
1183 if (srcRect.height() > SK_Scalar1) { | 1186 if (srcRect.height() > SK_Scalar1) { |
1184 SkScalar border = SK_ScalarHalf / texture->height(); | 1187 SkScalar border = SK_ScalarHalf / texture->height(); |
1185 top = paintRect.top() + border; | 1188 top = paintRect.top() + border; |
1186 bottom = paintRect.bottom() - border; | 1189 bottom = paintRect.bottom() - border; |
1187 } else { | 1190 } else { |
1188 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); | 1191 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); |
1189 } | 1192 } |
1190 textureDomain.setLTRB(left, top, right, bottom); | 1193 textureDomain.setLTRB(left, top, right, bottom); |
1191 if (bicubic) { | 1194 if (bicubic) { |
1192 fp = GrBicubicEffect::Make(texture, texMatrix, textureDomain); | 1195 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texM
atrix, |
| 1196 textureDomain); |
1193 } else { | 1197 } else { |
1194 fp = GrTextureDomainEffect::Make(texture, texMatrix, textureDomain, | 1198 fp = GrTextureDomainEffect::Make(texture, std::move(colorSpaceXform)
, texMatrix, |
1195 GrTextureDomain::kClamp_Mode, param
s.filterMode()); | 1199 textureDomain, GrTextureDomain::kCl
amp_Mode, |
| 1200 params.filterMode()); |
1196 } | 1201 } |
1197 } else if (bicubic) { | 1202 } else if (bicubic) { |
1198 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); | 1203 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); |
1199 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; | 1204 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; |
1200 fp = GrBicubicEffect::Make(texture, texMatrix, tileModes); | 1205 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texMatri
x, tileModes); |
1201 } else { | 1206 } else { |
1202 fp = GrSimpleTextureEffect::Make(texture, texMatrix, params); | 1207 fp = GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform), te
xMatrix, params); |
1203 } | 1208 } |
1204 | 1209 |
1205 GrPaint grPaint; | 1210 GrPaint grPaint; |
1206 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo
ve(fp), | 1211 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo
ve(fp), |
1207 kAlpha_8_SkColorType == bitmap.colorType(), | 1212 kAlpha_8_SkColorType == bitmap.colorType(), |
1208 this->surfaceProps().isGammaCorrect(), &grP
aint)) { | 1213 this->surfaceProps().isGammaCorrect(), &grP
aint)) { |
1209 return; | 1214 return; |
1210 } | 1215 } |
1211 | 1216 |
1212 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { | 1217 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 | 1284 |
1280 SkASSERT(result->isTextureBacked()); | 1285 SkASSERT(result->isTextureBacked()); |
1281 sk_sp<GrTexture> texture = result->asTextureRef(fContext); | 1286 sk_sp<GrTexture> texture = result->asTextureRef(fContext); |
1282 | 1287 |
1283 SkPaint tmpUnfiltered(paint); | 1288 SkPaint tmpUnfiltered(paint); |
1284 tmpUnfiltered.setImageFilter(nullptr); | 1289 tmpUnfiltered.setImageFilter(nullptr); |
1285 | 1290 |
1286 bool alphaOnly = kAlpha_8_GrPixelConfig == texture->config(); | 1291 bool alphaOnly = kAlpha_8_GrPixelConfig == texture->config(); |
1287 | 1292 |
1288 GrPaint grPaint; | 1293 GrPaint grPaint; |
1289 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), SkM
atrix::I())); | 1294 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul
lptr, |
| 1295 SkMatrix::I())); |
1290 if (alphaOnly) { | 1296 if (alphaOnly) { |
1291 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); | 1297 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); |
1292 } else { | 1298 } else { |
1293 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); | 1299 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); |
1294 } | 1300 } |
1295 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move
(fp), | 1301 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move
(fp), |
1296 this->surfaceProps().isGammaCorrect(), &g
rPaint)) { | 1302 this->surfaceProps().isGammaCorrect(), &g
rPaint)) { |
1297 return; | 1303 return; |
1298 } | 1304 } |
1299 | 1305 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 return; | 1419 return; |
1414 } | 1420 } |
1415 | 1421 |
1416 const SkImageInfo ii = dev->imageInfo(); | 1422 const SkImageInfo ii = dev->imageInfo(); |
1417 int w = ii.width(); | 1423 int w = ii.width(); |
1418 int h = ii.height(); | 1424 int h = ii.height(); |
1419 | 1425 |
1420 SkASSERT(!paint.getImageFilter()); | 1426 SkASSERT(!paint.getImageFilter()); |
1421 | 1427 |
1422 GrPaint grPaint; | 1428 GrPaint grPaint; |
1423 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(devTex.get(), SkMa
trix::I())); | 1429 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(devTex.get(), null
ptr, |
| 1430 SkMatrix::I())); |
1424 if (GrPixelConfigIsAlphaOnly(devTex->config())) { | 1431 if (GrPixelConfigIsAlphaOnly(devTex->config())) { |
1425 // Can this happen? | 1432 // Can this happen? |
1426 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); | 1433 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); |
1427 } else { | 1434 } else { |
1428 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); | 1435 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); |
1429 } | 1436 } |
1430 | 1437 |
1431 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, std::move(fp), | 1438 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, std::move(fp), |
1432 this->surfaceProps().isGammaCorrect(), &g
rPaint)) { | 1439 this->surfaceProps().isGammaCorrect(), &g
rPaint)) { |
1433 return; | 1440 return; |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 } | 1869 } |
1863 | 1870 |
1864 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1871 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1865 ASSERT_SINGLE_OWNER | 1872 ASSERT_SINGLE_OWNER |
1866 // We always return a transient cache, so it is freed after each | 1873 // We always return a transient cache, so it is freed after each |
1867 // filter traversal. | 1874 // filter traversal. |
1868 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1875 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1869 } | 1876 } |
1870 | 1877 |
1871 #endif | 1878 #endif |
OLD | NEW |