| 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 "Couldn't convert bitmap to texture."); | 989 "Couldn't convert bitmap to texture."); |
| 990 return; | 990 return; |
| 991 } | 991 } |
| 992 | 992 |
| 993 | 993 |
| 994 GrPaint grPaint; | 994 GrPaint grPaint; |
| 995 | 995 |
| 996 // Create and insert texture effect | 996 // Create and insert texture effect |
| 997 SkAutoTUnref<const GrFragmentProcessor> fp; | 997 SkAutoTUnref<const GrFragmentProcessor> fp; |
| 998 if (doBicubic) { | 998 if (doBicubic) { |
| 999 fp.reset(GrBicubicEffect::Create(grPaint.getProcessorDataManager(), text
ure, | 999 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tm)); |
| 1000 SkMatrix::I(), | |
| 1001 tm)); | |
| 1002 } else { | 1000 } else { |
| 1003 fp.reset(GrSimpleTextureEffect::Create(grPaint.getProcessorDataManager()
, texture, | 1001 fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params)); |
| 1004 SkMatrix::I(), params)); | |
| 1005 } | 1002 } |
| 1006 | 1003 |
| 1007 if (kAlpha_8_SkColorType == bitmapPtr->colorType()) { | 1004 if (kAlpha_8_SkColorType == bitmapPtr->colorType()) { |
| 1008 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); | 1005 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| 1009 } else { | 1006 } else { |
| 1010 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); | 1007 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| 1011 } | 1008 } |
| 1012 | 1009 |
| 1013 if (!SkPaintToGrPaintReplaceShader(context, paint, fp, &grPaint)) { | 1010 if (!SkPaintToGrPaintReplaceShader(context, paint, fp, &grPaint)) { |
| 1014 return; | 1011 return; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 } | 1320 } |
| 1324 if (srcRect.height() > SK_Scalar1) { | 1321 if (srcRect.height() > SK_Scalar1) { |
| 1325 SkScalar border = SK_ScalarHalf / texture->height(); | 1322 SkScalar border = SK_ScalarHalf / texture->height(); |
| 1326 top = paintRect.top() + border; | 1323 top = paintRect.top() + border; |
| 1327 bottom = paintRect.bottom() - border; | 1324 bottom = paintRect.bottom() - border; |
| 1328 } else { | 1325 } else { |
| 1329 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); | 1326 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); |
| 1330 } | 1327 } |
| 1331 textureDomain.setLTRB(left, top, right, bottom); | 1328 textureDomain.setLTRB(left, top, right, bottom); |
| 1332 if (bicubic) { | 1329 if (bicubic) { |
| 1333 fp.reset(GrBicubicEffect::Create(grPaint.getProcessorDataManager(),
texture, | 1330 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDoma
in)); |
| 1334 SkMatrix::I(), textureDomain)); | |
| 1335 } else { | 1331 } else { |
| 1336 fp.reset(GrTextureDomainEffect::Create(grPaint.getProcessorDataManag
er(), | 1332 fp.reset(GrTextureDomainEffect::Create(texture, |
| 1337 texture, | |
| 1338 SkMatrix::I(), | 1333 SkMatrix::I(), |
| 1339 textureDomain, | 1334 textureDomain, |
| 1340 GrTextureDomain::kClamp_Mode, | 1335 GrTextureDomain::kClamp_Mode, |
| 1341 params.filterMode())); | 1336 params.filterMode())); |
| 1342 } | 1337 } |
| 1343 } else if (bicubic) { | 1338 } else if (bicubic) { |
| 1344 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); | 1339 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); |
| 1345 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; | 1340 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; |
| 1346 fp.reset(GrBicubicEffect::Create(grPaint.getProcessorDataManager(), text
ure, SkMatrix::I(), | 1341 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes)); |
| 1347 tileModes)); | |
| 1348 } else { | 1342 } else { |
| 1349 fp.reset(GrSimpleTextureEffect::Create(grPaint.getProcessorDataManager()
, texture, | 1343 fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params)); |
| 1350 SkMatrix::I(), params)); | |
| 1351 } | 1344 } |
| 1352 | 1345 |
| 1353 if (kAlpha_8_SkColorType == bitmap.colorType()) { | 1346 if (kAlpha_8_SkColorType == bitmap.colorType()) { |
| 1354 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); | 1347 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| 1355 } else { | 1348 } else { |
| 1356 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); | 1349 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| 1357 } | 1350 } |
| 1358 | 1351 |
| 1359 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { | 1352 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { |
| 1360 return; | 1353 return; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 top += offset.y(); | 1418 top += offset.y(); |
| 1426 } else { | 1419 } else { |
| 1427 return; | 1420 return; |
| 1428 } | 1421 } |
| 1429 SkASSERT(!GrPixelConfigIsAlphaOnly(texture->config())); | 1422 SkASSERT(!GrPixelConfigIsAlphaOnly(texture->config())); |
| 1430 alphaOnly = false; | 1423 alphaOnly = false; |
| 1431 } | 1424 } |
| 1432 | 1425 |
| 1433 GrPaint grPaint; | 1426 GrPaint grPaint; |
| 1434 SkAutoTUnref<const GrFragmentProcessor> fp( | 1427 SkAutoTUnref<const GrFragmentProcessor> fp( |
| 1435 GrSimpleTextureEffect::Create(grPaint.getProcessorDataManager(), texture
, SkMatrix::I())); | 1428 GrSimpleTextureEffect::Create(texture, SkMatrix::I())); |
| 1436 if (alphaOnly) { | 1429 if (alphaOnly) { |
| 1437 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); | 1430 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| 1438 } else { | 1431 } else { |
| 1439 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); | 1432 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| 1440 } | 1433 } |
| 1441 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { | 1434 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { |
| 1442 return; | 1435 return; |
| 1443 } | 1436 } |
| 1444 | 1437 |
| 1445 fDrawContext->drawNonAARectToRect(fRenderTarget, | 1438 fDrawContext->drawNonAARectToRect(fRenderTarget, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 h = filteredBitmap.height(); | 1537 h = filteredBitmap.height(); |
| 1545 x += offset.fX; | 1538 x += offset.fX; |
| 1546 y += offset.fY; | 1539 y += offset.fY; |
| 1547 } else { | 1540 } else { |
| 1548 return; | 1541 return; |
| 1549 } | 1542 } |
| 1550 } | 1543 } |
| 1551 | 1544 |
| 1552 GrPaint grPaint; | 1545 GrPaint grPaint; |
| 1553 SkAutoTUnref<const GrFragmentProcessor> fp( | 1546 SkAutoTUnref<const GrFragmentProcessor> fp( |
| 1554 GrSimpleTextureEffect::Create(grPaint.getProcessorDataManager(), devTex,
SkMatrix::I())); | 1547 GrSimpleTextureEffect::Create(devTex, SkMatrix::I())); |
| 1555 if (GrPixelConfigIsAlphaOnly(devTex->config())) { | 1548 if (GrPixelConfigIsAlphaOnly(devTex->config())) { |
| 1556 // Can this happen? | 1549 // Can this happen? |
| 1557 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); | 1550 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| 1558 } else { | 1551 } else { |
| 1559 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); | 1552 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| 1560 } | 1553 } |
| 1561 | 1554 |
| 1562 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { | 1555 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { |
| 1563 return; | 1556 return; |
| 1564 } | 1557 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 #endif | 1994 #endif |
| 2002 } | 1995 } |
| 2003 | 1996 |
| 2004 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1997 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 2005 // We always return a transient cache, so it is freed after each | 1998 // We always return a transient cache, so it is freed after each |
| 2006 // filter traversal. | 1999 // filter traversal. |
| 2007 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2000 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 2008 } | 2001 } |
| 2009 | 2002 |
| 2010 #endif | 2003 #endif |
| OLD | NEW |