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 25 matching lines...) Expand all Loading... |
36 #include "SkPictureData.h" | 36 #include "SkPictureData.h" |
37 #include "SkRecord.h" | 37 #include "SkRecord.h" |
38 #include "SkRRect.h" | 38 #include "SkRRect.h" |
39 #include "SkStroke.h" | 39 #include "SkStroke.h" |
40 #include "SkSurface.h" | 40 #include "SkSurface.h" |
41 #include "SkTLazy.h" | 41 #include "SkTLazy.h" |
42 #include "SkUtils.h" | 42 #include "SkUtils.h" |
43 #include "SkVertState.h" | 43 #include "SkVertState.h" |
44 #include "SkXfermode.h" | 44 #include "SkXfermode.h" |
45 #include "SkErrorInternals.h" | 45 #include "SkErrorInternals.h" |
| 46 #include "SkImage_Base.h" |
| 47 #include "SkImagePriv.h" |
46 | 48 |
47 #if SK_SUPPORT_GPU | 49 #if SK_SUPPORT_GPU |
48 | 50 |
49 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; | 51 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; |
50 | 52 |
51 #if 0 | 53 #if 0 |
52 extern bool (*gShouldDrawProc)(); | 54 extern bool (*gShouldDrawProc)(); |
53 #define CHECK_SHOULD_DRAW(draw) \ | 55 #define CHECK_SHOULD_DRAW(draw) \ |
54 do { \ | 56 do { \ |
55 if (gShouldDrawProc && !gShouldDrawProc()) return; \ | 57 if (gShouldDrawProc && !gShouldDrawProc()) return; \ |
(...skipping 30 matching lines...) Expand all Loading... |
86 AutoBitmapTexture() {} | 88 AutoBitmapTexture() {} |
87 | 89 |
88 AutoBitmapTexture(GrContext* context, | 90 AutoBitmapTexture(GrContext* context, |
89 const SkBitmap& bitmap, | 91 const SkBitmap& bitmap, |
90 const GrTextureParams* params, | 92 const GrTextureParams* params, |
91 GrTexture** texture) { | 93 GrTexture** texture) { |
92 SkASSERT(texture); | 94 SkASSERT(texture); |
93 *texture = this->set(context, bitmap, params); | 95 *texture = this->set(context, bitmap, params); |
94 } | 96 } |
95 | 97 |
| 98 AutoBitmapTexture(GrContext* context, |
| 99 SkImage& image, |
| 100 const GrTextureParams* params, |
| 101 GrTexture** texture) { |
| 102 SkASSERT(texture); |
| 103 *texture = this->set(context, image, params); |
| 104 } |
| 105 |
96 GrTexture* set(GrContext* context, | 106 GrTexture* set(GrContext* context, |
97 const SkBitmap& bitmap, | 107 const SkBitmap& bitmap, |
98 const GrTextureParams* params) { | 108 const GrTextureParams* params) { |
99 // Either get the texture directly from the bitmap, or else use the cach
e and | 109 // Either get the texture directly from the bitmap, or else use the cach
e and |
100 // remember to unref it. | 110 // remember to unref it. |
101 if (GrTexture* bmpTexture = bitmap.getTexture()) { | 111 if (GrTexture* bmpTexture = bitmap.getTexture()) { |
102 fTexture.reset(NULL); | 112 fTexture.reset(NULL); |
103 return bmpTexture; | 113 return bmpTexture; |
104 } else { | 114 } else { |
105 fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params)); | 115 fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params)); |
106 return fTexture.get(); | 116 return fTexture.get(); |
107 } | 117 } |
108 } | 118 } |
109 | 119 |
| 120 GrTexture* set(GrContext* context, |
| 121 SkImage& image, |
| 122 const GrTextureParams* params) { |
| 123 if (GrTexture* bmpTexture = image.getTexture()) { |
| 124 fTexture.reset(NULL); |
| 125 return bmpTexture; |
| 126 } else { |
| 127 SkBitmap bitmap; |
| 128 as_IB(&image)->getROPixels(&bitmap); |
| 129 fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params)); |
| 130 return fTexture.get(); |
| 131 } |
| 132 } |
| 133 |
110 private: | 134 private: |
111 SkAutoTUnref<GrTexture> fTexture; | 135 SkAutoTUnref<GrTexture> fTexture; |
112 }; | 136 }; |
113 | 137 |
114 /////////////////////////////////////////////////////////////////////////////// | 138 /////////////////////////////////////////////////////////////////////////////// |
115 | 139 |
116 struct GrSkDrawProcs : public SkDrawProcs { | 140 struct GrSkDrawProcs : public SkDrawProcs { |
117 public: | 141 public: |
118 GrContext* fContext; | 142 GrContext* fContext; |
119 GrTextContext* fTextContext; | 143 GrTextContext* fTextContext; |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 tempPaint.setPorterDuffXPFactory(kOne_GrBlendCoeff, kISC_GrBlendCoeff); | 712 tempPaint.setPorterDuffXPFactory(kOne_GrBlendCoeff, kISC_GrBlendCoeff); |
689 } | 713 } |
690 | 714 |
691 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. | 715 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. |
692 SkMatrix translate; | 716 SkMatrix translate; |
693 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 717 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
694 context->drawPath(tempPaint, translate, devPath, strokeInfo); | 718 context->drawPath(tempPaint, translate, devPath, strokeInfo); |
695 return mask; | 719 return mask; |
696 } | 720 } |
697 | 721 |
698 SkBitmap wrap_texture(GrTexture* texture) { | 722 static SkImage* wrap_texture(GrTexture* texture) { |
699 SkBitmap result; | 723 SkBitmap result; |
700 result.setInfo(texture->surfacePriv().info()); | 724 result.setInfo(texture->surfacePriv().info()); |
701 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); | 725 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); |
702 return result; | 726 return SkNewImageFromBitmapTexture(result, texture->desc().fSampleCnt, |
| 727 SkSurface::kYes_Budgeted); |
703 } | 728 } |
704 | 729 |
705 }; | 730 }; |
706 | 731 |
707 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 732 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
708 const SkPaint& paint, const SkMatrix* prePathMatrix, | 733 const SkPaint& paint, const SkMatrix* prePathMatrix, |
709 bool pathIsMutable) { | 734 bool pathIsMutable) { |
710 CHECK_FOR_ANNOTATION(paint); | 735 CHECK_FOR_ANNOTATION(paint); |
711 CHECK_SHOULD_DRAW(draw); | 736 CHECK_SHOULD_DRAW(draw); |
712 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); | 737 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : | 1427 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : |
1403 SkColor2GrColor(paint.getColor()); | 1428 SkColor2GrColor(paint.getColor()); |
1404 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint)
; | 1429 SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint)
; |
1405 | 1430 |
1406 fContext->drawNonAARectToRect(grPaint, viewMatrix, dstRect, paintRect); | 1431 fContext->drawNonAARectToRect(grPaint, viewMatrix, dstRect, paintRect); |
1407 } | 1432 } |
1408 | 1433 |
1409 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, | 1434 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
1410 const SkImageFilter* filter, | 1435 const SkImageFilter* filter, |
1411 const SkImageFilter::Context& ctx, | 1436 const SkImageFilter::Context& ctx, |
1412 SkBitmap* result, SkIPoint* offset) { | 1437 SkAutoTUnref<SkImage>& result, SkIPoint* offset)
{ |
1413 SkASSERT(filter); | 1438 SkASSERT(filter); |
1414 | 1439 |
1415 // FIXME: plumb actual surface props such that we don't have to lie about th
e flags here | 1440 // FIXME: plumb actual surface props such that we don't have to lie about th
e flags here |
1416 // (https://code.google.com/p/skia/issues/detail?id=3148). | 1441 // (https://code.google.com/p/skia/issues/detail?id=3148). |
1417 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().
pixelGeometry())); | 1442 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().
pixelGeometry())); |
1418 | 1443 |
1419 if (filter->canFilterImageGPU()) { | 1444 if (filter->canFilterImageGPU()) { |
1420 // Save the render target and set it to NULL, so we don't accidentally d
raw to it in the | 1445 // Save the render target and set it to NULL, so we don't accidentally d
raw to it in the |
1421 // filter. Also set the clip wide open and the matrix to identity. | 1446 // filter. Also set the clip wide open and the matrix to identity. |
1422 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); | 1447 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); |
1423 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result
, offset); | 1448 SkAutoTUnref<SkImage> src(wrap_texture(texture)); |
| 1449 return filter->filterImageGPU(&proxy, *src, ctx, result, offset); |
1424 } else { | 1450 } else { |
1425 return false; | 1451 return false; |
1426 } | 1452 } |
1427 } | 1453 } |
1428 | 1454 |
1429 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, | 1455 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
1430 int left, int top, const SkPaint& paint) { | 1456 int left, int top, const SkPaint& paint) { |
1431 // drawSprite is defined to be in device coords. | 1457 // drawSprite is defined to be in device coords. |
1432 CHECK_SHOULD_DRAW(draw); | 1458 CHECK_SHOULD_DRAW(draw); |
1433 | 1459 |
1434 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); | 1460 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); |
1435 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { | 1461 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { |
1436 return; | 1462 return; |
1437 } | 1463 } |
1438 | 1464 |
1439 int w = bitmap.width(); | 1465 int w = bitmap.width(); |
1440 int h = bitmap.height(); | 1466 int h = bitmap.height(); |
1441 | 1467 |
1442 GrTexture* texture; | 1468 GrTexture* texture; |
1443 // draw sprite uses the default texture params | 1469 // draw sprite uses the default texture params |
1444 AutoBitmapTexture abt(fContext, bitmap, NULL, &texture); | 1470 AutoBitmapTexture abt(fContext, bitmap, NULL, &texture); |
1445 | 1471 |
1446 SkImageFilter* filter = paint.getImageFilter(); | 1472 SkImageFilter* filter = paint.getImageFilter(); |
1447 // This bitmap will own the filtered result as a texture. | 1473 // This bitmap will own the filtered result as a texture. |
1448 SkBitmap filteredBitmap; | 1474 SkAutoTUnref<SkImage> filteredImage; |
1449 | 1475 |
1450 if (filter) { | 1476 if (filter) { |
1451 SkIPoint offset = SkIPoint::Make(0, 0); | 1477 SkIPoint offset = SkIPoint::Make(0, 0); |
1452 SkMatrix matrix(*draw.fMatrix); | 1478 SkMatrix matrix(*draw.fMatrix); |
1453 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 1479 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
1454 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); | 1480 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); |
1455 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1481 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1456 // This cache is transient, and is freed (along with all its contained | 1482 // This cache is transient, and is freed (along with all its contained |
1457 // textures) when it goes out of scope. | 1483 // textures) when it goes out of scope. |
1458 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1484 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1459 if (this->filterTexture(fContext, texture, filter, ctx, &filteredBitmap, | 1485 if (this->filterTexture(fContext, texture, filter, ctx, filteredImage, |
1460 &offset)) { | 1486 &offset)) { |
1461 texture = (GrTexture*) filteredBitmap.getTexture(); | 1487 texture = filteredImage->getTexture(); |
1462 w = filteredBitmap.width(); | 1488 w = filteredImage->width(); |
1463 h = filteredBitmap.height(); | 1489 h = filteredImage->height(); |
1464 left += offset.x(); | 1490 left += offset.x(); |
1465 top += offset.y(); | 1491 top += offset.y(); |
1466 } else { | 1492 } else { |
1467 return; | 1493 return; |
1468 } | 1494 } |
1469 } | 1495 } |
1470 | 1496 |
1471 GrPaint grPaint; | 1497 GrPaint grPaint; |
1472 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); | 1498 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); |
1473 | 1499 |
1474 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai
nt.getColor()), | 1500 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai
nt.getColor()), |
1475 false, &grPaint); | 1501 false, &grPaint); |
1476 | 1502 |
1477 fContext->drawNonAARectToRect(grPaint, | 1503 fContext->drawNonAARectToRect(grPaint, |
1478 SkMatrix::I(), | 1504 SkMatrix::I(), |
1479 SkRect::MakeXYWH(SkIntToScalar(left), | 1505 SkRect::MakeXYWH(SkIntToScalar(left), |
1480 SkIntToScalar(top), | 1506 SkIntToScalar(top), |
1481 SkIntToScalar(w), | 1507 SkIntToScalar(w), |
1482 SkIntToScalar(h)), | 1508 SkIntToScalar(h)), |
1483 SkRect::MakeXYWH(0, | 1509 SkRect::MakeXYWH(0, |
1484 0, | 1510 0, |
1485 SK_Scalar1 * w / texture->wid
th(), | 1511 SK_Scalar1 * w / texture->wid
th(), |
1486 SK_Scalar1 * h / texture->hei
ght())); | 1512 SK_Scalar1 * h / texture->hei
ght())); |
1487 } | 1513 } |
1488 | 1514 |
| 1515 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage& image, |
| 1516 int left, int top, const SkPaint& paint) { |
| 1517 |
| 1518 GrTexture* texture = image.getTexture(); |
| 1519 if (NULL == texture) { |
| 1520 INHERITED::drawImage(draw, image, left, top, paint); |
| 1521 return; |
| 1522 } |
| 1523 |
| 1524 CHECK_SHOULD_DRAW(draw); |
| 1525 int w = image.width(); |
| 1526 int h = image.height(); |
| 1527 |
| 1528 GrPaint grPaint; |
| 1529 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); |
| 1530 |
| 1531 SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(pai
nt.getColor()), |
| 1532 false, &grPaint); |
| 1533 |
| 1534 fContext->drawNonAARectToRect(grPaint, |
| 1535 SkMatrix::I(), |
| 1536 SkRect::MakeXYWH(SkIntToScalar(left), |
| 1537 SkIntToScalar(top), |
| 1538 SkIntToScalar(w), |
| 1539 SkIntToScalar(h)), |
| 1540 SkRect::MakeXYWH(0, |
| 1541 0, |
| 1542 SK_Scalar1 * w / texture->wid
th(), |
| 1543 SK_Scalar1 * h / texture->hei
ght())); |
| 1544 |
| 1545 } |
| 1546 |
| 1547 |
1489 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap, | 1548 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap, |
1490 const SkRect* src, const SkRect& dst, | 1549 const SkRect* src, const SkRect& dst, |
1491 const SkPaint& paint, | 1550 const SkPaint& paint, |
1492 SkCanvas::DrawBitmapRectFlags flags) { | 1551 SkCanvas::DrawBitmapRectFlags flags) { |
1493 SkMatrix matrix; | 1552 SkMatrix matrix; |
1494 SkRect bitmapBounds, tmpSrc; | 1553 SkRect bitmapBounds, tmpSrc; |
1495 | 1554 |
1496 bitmapBounds.set(0, 0, | 1555 bitmapBounds.set(0, 0, |
1497 SkIntToScalar(bitmap.width()), | 1556 SkIntToScalar(bitmap.width()), |
1498 SkIntToScalar(bitmap.height())); | 1557 SkIntToScalar(bitmap.height())); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 GrTexture* devTex; | 1608 GrTexture* devTex; |
1550 if (NULL == (devTex = devRT->asTexture())) { | 1609 if (NULL == (devTex = devRT->asTexture())) { |
1551 return; | 1610 return; |
1552 } | 1611 } |
1553 | 1612 |
1554 const SkImageInfo ii = dev->imageInfo(); | 1613 const SkImageInfo ii = dev->imageInfo(); |
1555 int w = ii.width(); | 1614 int w = ii.width(); |
1556 int h = ii.height(); | 1615 int h = ii.height(); |
1557 | 1616 |
1558 SkImageFilter* filter = paint.getImageFilter(); | 1617 SkImageFilter* filter = paint.getImageFilter(); |
1559 // This bitmap will own the filtered result as a texture. | 1618 SkAutoTUnref<SkImage> filteredImage; |
1560 SkBitmap filteredBitmap; | |
1561 | 1619 |
1562 if (filter) { | 1620 if (filter) { |
1563 SkIPoint offset = SkIPoint::Make(0, 0); | 1621 SkIPoint offset = SkIPoint::Make(0, 0); |
1564 SkMatrix matrix(*draw.fMatrix); | 1622 SkMatrix matrix(*draw.fMatrix); |
1565 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1623 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
1566 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); | 1624 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); |
1567 // This cache is transient, and is freed (along with all its contained | 1625 // This cache is transient, and is freed (along with all its contained |
1568 // textures) when it goes out of scope. | 1626 // textures) when it goes out of scope. |
1569 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1627 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1570 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1628 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1571 if (this->filterTexture(fContext, devTex, filter, ctx, &filteredBitmap, | 1629 if (this->filterTexture(fContext, devTex, filter, ctx, filteredImage, |
1572 &offset)) { | 1630 &offset)) { |
1573 devTex = filteredBitmap.getTexture(); | 1631 devTex = filteredImage->getTexture(); |
1574 w = filteredBitmap.width(); | 1632 w = filteredImage->width(); |
1575 h = filteredBitmap.height(); | 1633 h = filteredImage->height(); |
1576 x += offset.fX; | 1634 x += offset.fX; |
1577 y += offset.fY; | 1635 y += offset.fY; |
1578 } else { | 1636 } else { |
1579 return; | 1637 return; |
1580 } | 1638 } |
1581 } | 1639 } |
1582 | 1640 |
1583 GrPaint grPaint; | 1641 GrPaint grPaint; |
1584 grPaint.addColorTextureProcessor(devTex, SkMatrix::I()); | 1642 grPaint.addColorTextureProcessor(devTex, SkMatrix::I()); |
1585 | 1643 |
(...skipping 10 matching lines...) Expand all Loading... |
1596 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), | 1654 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), |
1597 SK_Scalar1 * h / devTex->height()); | 1655 SK_Scalar1 * h / devTex->height()); |
1598 | 1656 |
1599 fContext->drawNonAARectToRect(grPaint, SkMatrix::I(), dstRect, srcRect); | 1657 fContext->drawNonAARectToRect(grPaint, SkMatrix::I(), dstRect, srcRect); |
1600 } | 1658 } |
1601 | 1659 |
1602 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { | 1660 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { |
1603 return filter->canFilterImageGPU(); | 1661 return filter->canFilterImageGPU(); |
1604 } | 1662 } |
1605 | 1663 |
1606 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, | 1664 bool SkGpuDevice::filterImage(const SkImageFilter* filter, SkImage& src, |
1607 const SkImageFilter::Context& ctx, | 1665 const SkImageFilter::Context& ctx, |
1608 SkBitmap* result, SkIPoint* offset) { | 1666 SkAutoTUnref<SkImage>& result, SkIPoint* offset) { |
1609 // want explicitly our impl, so guard against a subclass of us overriding it | 1667 // want explicitly our impl, so guard against a subclass of us overriding it |
1610 if (!this->SkGpuDevice::canHandleImageFilter(filter)) { | 1668 if (!this->SkGpuDevice::canHandleImageFilter(filter)) { |
1611 return false; | 1669 return false; |
1612 } | 1670 } |
1613 | 1671 |
1614 SkAutoLockPixels alp(src, !src.getTexture()); | 1672 //TODO: SkAutoLockPixels alp(src, !src.getTexture()); |
1615 if (!src.getTexture() && !src.readyToDraw()) { | 1673 //TODO: if !src->readyToDraw() |
1616 return false; | |
1617 } | |
1618 | 1674 |
1619 GrTexture* texture; | 1675 GrTexture* texture; |
1620 // We assume here that the filter will not attempt to tile the src. Otherwis
e, this cache lookup | 1676 // We assume here that the filter will not attempt to tile the src. Otherwis
e, this cache lookup |
1621 // must be pushed upstack. | 1677 // must be pushed upstack. |
1622 AutoBitmapTexture abt(fContext, src, NULL, &texture); | 1678 AutoBitmapTexture abt(fContext, src, NULL, &texture); |
| 1679 if (!texture) { |
| 1680 return false; |
| 1681 } |
1623 | 1682 |
1624 return this->filterTexture(fContext, texture, filter, ctx, result, offset); | 1683 return this->filterTexture(fContext, texture, filter, ctx, result, offset); |
1625 } | 1684 } |
1626 | 1685 |
1627 /////////////////////////////////////////////////////////////////////////////// | 1686 /////////////////////////////////////////////////////////////////////////////// |
1628 | 1687 |
1629 // must be in SkCanvas::VertexMode order | 1688 // must be in SkCanvas::VertexMode order |
1630 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { | 1689 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { |
1631 kTriangles_GrPrimitiveType, | 1690 kTriangles_GrPrimitiveType, |
1632 kTriangleStrip_GrPrimitiveType, | 1691 kTriangleStrip_GrPrimitiveType, |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 #endif | 1963 #endif |
1905 } | 1964 } |
1906 | 1965 |
1907 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1966 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1908 // We always return a transient cache, so it is freed after each | 1967 // We always return a transient cache, so it is freed after each |
1909 // filter traversal. | 1968 // filter traversal. |
1910 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1969 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1911 } | 1970 } |
1912 | 1971 |
1913 #endif | 1972 #endif |
OLD | NEW |