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 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 // must be pushed upstack. | 1539 // must be pushed upstack. |
1540 AutoBitmapTexture abt(fContext, src, NULL, &texture); | 1540 AutoBitmapTexture abt(fContext, src, NULL, &texture); |
1541 if (!texture) { | 1541 if (!texture) { |
1542 return false; | 1542 return false; |
1543 } | 1543 } |
1544 | 1544 |
1545 return this->filterTexture(fContext, texture, src.width(), src.height(), | 1545 return this->filterTexture(fContext, texture, src.width(), src.height(), |
1546 filter, ctx, result, offset); | 1546 filter, ctx, result, offset); |
1547 } | 1547 } |
1548 | 1548 |
1549 static bool wrap_as_bm(const SkImage* image, SkBitmap* bm) { | 1549 static bool wrap_as_bm(GrContext* ctx, const SkImage* image, SkBitmap* bm) { |
1550 GrTexture* tex = as_IB(image)->getTexture(); | 1550 SkAutoTUnref<GrTexture> tex(as_IB(image)->asTextureRef(ctx, kUntiled_SkImage
UsageType)); |
1551 if (tex) { | 1551 if (tex) { |
1552 GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpa
que(), bm); | 1552 GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpa
que(), bm); |
1553 return true; | 1553 return true; |
1554 } else { | 1554 } else { |
1555 return as_IB(image)->getROPixels(bm); | 1555 return as_IB(image)->getROPixels(bm); |
1556 } | 1556 } |
1557 } | 1557 } |
1558 | 1558 |
1559 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
, SkScalar y, | 1559 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
, SkScalar y, |
1560 const SkPaint& paint) { | 1560 const SkPaint& paint) { |
1561 SkBitmap bm; | 1561 SkBitmap bm; |
1562 if (wrap_as_bm(image, &bm)) { | 1562 if (wrap_as_bm(this->context(), image, &bm)) { |
1563 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); | 1563 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); |
1564 } | 1564 } |
1565 } | 1565 } |
1566 | 1566 |
1567 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, | 1567 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, |
1568 const SkRect& dst, const SkPaint& paint, | 1568 const SkRect& dst, const SkPaint& paint, |
1569 SkCanvas::SrcRectConstraint constraint) { | 1569 SkCanvas::SrcRectConstraint constraint) { |
1570 SkBitmap bm; | 1570 SkBitmap bm; |
1571 if (wrap_as_bm(image, &bm)) { | 1571 if (wrap_as_bm(this->context(), image, &bm)) { |
1572 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); | 1572 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); |
1573 } | 1573 } |
1574 } | 1574 } |
1575 | 1575 |
1576 /////////////////////////////////////////////////////////////////////////////// | 1576 /////////////////////////////////////////////////////////////////////////////// |
1577 | 1577 |
1578 // must be in SkCanvas::VertexMode order | 1578 // must be in SkCanvas::VertexMode order |
1579 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { | 1579 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { |
1580 kTriangles_GrPrimitiveType, | 1580 kTriangles_GrPrimitiveType, |
1581 kTriangleStrip_GrPrimitiveType, | 1581 kTriangleStrip_GrPrimitiveType, |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 #endif | 1900 #endif |
1901 } | 1901 } |
1902 | 1902 |
1903 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1903 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1904 // We always return a transient cache, so it is freed after each | 1904 // We always return a transient cache, so it is freed after each |
1905 // filter traversal. | 1905 // filter traversal. |
1906 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1906 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1907 } | 1907 } |
1908 | 1908 |
1909 #endif | 1909 #endif |
OLD | NEW |