| 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/GrBicubicEffect.h" |
| (...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes))
; | 1379 effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes))
; |
| 1380 } else { | 1380 } else { |
| 1381 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param
s)); | 1381 effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), param
s)); |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring | 1384 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring |
| 1385 // the rest from the SkPaint. | 1385 // the rest from the SkPaint. |
| 1386 GrPaint grPaint; | 1386 GrPaint grPaint; |
| 1387 grPaint.addColorEffect(effect); | 1387 grPaint.addColorEffect(effect); |
| 1388 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); | 1388 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); |
| 1389 SkPaint2GrPaintNoShader(this->context(), paint, alphaOnly, false, &grPaint); | 1389 GrColor grColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) : |
| 1390 SkColor2GrColor(paint.getColor()); |
| 1391 SkPaint2GrPaintNoShader(this->context(), paint, grColor, false, &grPaint); |
| 1390 | 1392 |
| 1391 fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL); | 1393 fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL); |
| 1392 } | 1394 } |
| 1393 | 1395 |
| 1394 static bool filter_texture(SkBaseDevice* device, GrContext* context, | 1396 static bool filter_texture(SkBaseDevice* device, GrContext* context, |
| 1395 GrTexture* texture, const SkImageFilter* filter, | 1397 GrTexture* texture, const SkImageFilter* filter, |
| 1396 int w, int h, const SkImageFilter::Context& ctx, | 1398 int w, int h, const SkImageFilter::Context& ctx, |
| 1397 SkBitmap* result, SkIPoint* offset) { | 1399 SkBitmap* result, SkIPoint* offset) { |
| 1398 SkASSERT(filter); | 1400 SkASSERT(filter); |
| 1399 SkDeviceImageFilterProxy proxy(device); | 1401 SkDeviceImageFilterProxy proxy(device); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 left += offset.x(); | 1447 left += offset.x(); |
| 1446 top += offset.y(); | 1448 top += offset.y(); |
| 1447 } else { | 1449 } else { |
| 1448 return; | 1450 return; |
| 1449 } | 1451 } |
| 1450 } | 1452 } |
| 1451 | 1453 |
| 1452 GrPaint grPaint; | 1454 GrPaint grPaint; |
| 1453 grPaint.addColorTextureEffect(texture, SkMatrix::I()); | 1455 grPaint.addColorTextureEffect(texture, SkMatrix::I()); |
| 1454 | 1456 |
| 1455 SkPaint2GrPaintNoShader(this->context(), paint, true, false, &grPaint); | 1457 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai
nt.getColor()), |
| 1458 false, &grPaint); |
| 1456 | 1459 |
| 1457 fContext->drawRectToRect(grPaint, | 1460 fContext->drawRectToRect(grPaint, |
| 1458 SkRect::MakeXYWH(SkIntToScalar(left), | 1461 SkRect::MakeXYWH(SkIntToScalar(left), |
| 1459 SkIntToScalar(top), | 1462 SkIntToScalar(top), |
| 1460 SkIntToScalar(w), | 1463 SkIntToScalar(w), |
| 1461 SkIntToScalar(h)), | 1464 SkIntToScalar(h)), |
| 1462 SkRect::MakeXYWH(0, | 1465 SkRect::MakeXYWH(0, |
| 1463 0, | 1466 0, |
| 1464 SK_Scalar1 * w / texture->width(), | 1467 SK_Scalar1 * w / texture->width(), |
| 1465 SK_Scalar1 * h / texture->height()
)); | 1468 SK_Scalar1 * h / texture->height()
)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 x += offset.fX; | 1556 x += offset.fX; |
| 1554 y += offset.fY; | 1557 y += offset.fY; |
| 1555 } else { | 1558 } else { |
| 1556 return; | 1559 return; |
| 1557 } | 1560 } |
| 1558 } | 1561 } |
| 1559 | 1562 |
| 1560 GrPaint grPaint; | 1563 GrPaint grPaint; |
| 1561 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); | 1564 grPaint.addColorTextureEffect(devTex, SkMatrix::I()); |
| 1562 | 1565 |
| 1563 SkPaint2GrPaintNoShader(this->context(), paint, true, false, &grPaint); | 1566 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai
nt.getColor()), |
| 1567 false, &grPaint); |
| 1564 | 1568 |
| 1565 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), | 1569 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), |
| 1566 SkIntToScalar(y), | 1570 SkIntToScalar(y), |
| 1567 SkIntToScalar(w), | 1571 SkIntToScalar(w), |
| 1568 SkIntToScalar(h)); | 1572 SkIntToScalar(h)); |
| 1569 | 1573 |
| 1570 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate | 1574 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate |
| 1571 // scratch texture). | 1575 // scratch texture). |
| 1572 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), | 1576 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), |
| 1573 SK_Scalar1 * h / devTex->height()); | 1577 SK_Scalar1 * h / devTex->height()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 pts[i + 5] = vertices[state.f0]; | 1643 pts[i + 5] = vertices[state.f0]; |
| 1640 i += 6; | 1644 i += 6; |
| 1641 } | 1645 } |
| 1642 draw.drawPoints(SkCanvas::kLines_PointMode, i, pts, copy, true); | 1646 draw.drawPoints(SkCanvas::kLines_PointMode, i, pts, copy, true); |
| 1643 return; | 1647 return; |
| 1644 } | 1648 } |
| 1645 | 1649 |
| 1646 GrPaint grPaint; | 1650 GrPaint grPaint; |
| 1647 // we ignore the shader if texs is null. | 1651 // we ignore the shader if texs is null. |
| 1648 if (NULL == texs) { | 1652 if (NULL == texs) { |
| 1649 SkPaint2GrPaintNoShader(this->context(), paint, false, NULL == colors, &
grPaint); | 1653 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColor(paint.ge
tColor()), |
| 1654 NULL == colors, &grPaint); |
| 1650 } else { | 1655 } else { |
| 1651 SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint); | 1656 SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint); |
| 1652 } | 1657 } |
| 1653 | 1658 |
| 1654 #if 0 | 1659 #if 0 |
| 1655 if (NULL != xmode && NULL != texs && NULL != colors) { | 1660 if (NULL != xmode && NULL != texs && NULL != colors) { |
| 1656 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { | 1661 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { |
| 1657 SkDebugf("Unsupported vertex-color/texture xfer mode.\n"); | 1662 SkDebugf("Unsupported vertex-color/texture xfer mode.\n"); |
| 1658 return; | 1663 return; |
| 1659 } | 1664 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2011 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
| 2007 | 2012 |
| 2008 if (NULL != layer->getTexture()) { | 2013 if (NULL != layer->getTexture()) { |
| 2009 fContext->unlockScratchTexture(layer->getTexture()); | 2014 fContext->unlockScratchTexture(layer->getTexture()); |
| 2010 layer->setTexture(NULL); | 2015 layer->setTexture(NULL); |
| 2011 } | 2016 } |
| 2012 } | 2017 } |
| 2013 | 2018 |
| 2014 return true; | 2019 return true; |
| 2015 } | 2020 } |
| OLD | NEW |