OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 } | 1741 } |
1742 } | 1742 } |
1743 | 1743 |
1744 SkMatrix matrix; | 1744 SkMatrix matrix; |
1745 matrix.setTranslate(x, y); | 1745 matrix.setTranslate(x, y); |
1746 this->internalDrawBitmap(bitmap, matrix, paint); | 1746 this->internalDrawBitmap(bitmap, matrix, paint); |
1747 } | 1747 } |
1748 | 1748 |
1749 // this one is non-virtual, so it can be called safely by other canvas apis | 1749 // this one is non-virtual, so it can be called safely by other canvas apis |
1750 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, | 1750 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
1751 const SkRect& dst, const SkPaint* paint) { | 1751 const SkRect& dst, const SkPaint* paint, |
| 1752 DrawBitmapRectFlags flags) { |
1752 if (bitmap.width() == 0 || bitmap.height() == 0 || dst.isEmpty()) { | 1753 if (bitmap.width() == 0 || bitmap.height() == 0 || dst.isEmpty()) { |
1753 return; | 1754 return; |
1754 } | 1755 } |
1755 | 1756 |
1756 CHECK_LOCKCOUNT_BALANCE(bitmap); | 1757 CHECK_LOCKCOUNT_BALANCE(bitmap); |
1757 | 1758 |
1758 if (NULL == paint || paint->canComputeFastBounds()) { | 1759 if (NULL == paint || paint->canComputeFastBounds()) { |
1759 SkRect storage; | 1760 SkRect storage; |
1760 const SkRect* bounds = &dst; | 1761 const SkRect* bounds = &dst; |
1761 if (paint) { | 1762 if (paint) { |
1762 bounds = &paint->computeFastBounds(dst, &storage); | 1763 bounds = &paint->computeFastBounds(dst, &storage); |
1763 } | 1764 } |
1764 if (this->quickReject(*bounds)) { | 1765 if (this->quickReject(*bounds)) { |
1765 return; | 1766 return; |
1766 } | 1767 } |
1767 } | 1768 } |
1768 | 1769 |
1769 SkLazyPaint lazy; | 1770 SkLazyPaint lazy; |
1770 if (NULL == paint) { | 1771 if (NULL == paint) { |
1771 paint = lazy.init(); | 1772 paint = lazy.init(); |
1772 } | 1773 } |
1773 | 1774 |
1774 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type) | 1775 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type) |
1775 | 1776 |
1776 while (iter.next()) { | 1777 while (iter.next()) { |
1777 iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint()); | 1778 iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(), fla
gs); |
1778 } | 1779 } |
1779 | 1780 |
1780 LOOPER_END | 1781 LOOPER_END |
1781 } | 1782 } |
1782 | 1783 |
1783 void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, | 1784 void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
1784 const SkRect& dst, const SkPaint* paint) { | 1785 const SkRect& dst, const SkPaint* paint, |
| 1786 DrawBitmapRectFlags flags) { |
1785 SkDEBUGCODE(bitmap.validate();) | 1787 SkDEBUGCODE(bitmap.validate();) |
1786 this->internalDrawBitmapRect(bitmap, src, dst, paint); | 1788 this->internalDrawBitmapRect(bitmap, src, dst, paint, flags); |
1787 } | 1789 } |
1788 | 1790 |
1789 void SkCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix, | 1791 void SkCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix, |
1790 const SkPaint* paint) { | 1792 const SkPaint* paint) { |
1791 SkDEBUGCODE(bitmap.validate();) | 1793 SkDEBUGCODE(bitmap.validate();) |
1792 this->internalDrawBitmap(bitmap, matrix, paint); | 1794 this->internalDrawBitmap(bitmap, matrix, paint); |
1793 } | 1795 } |
1794 | 1796 |
1795 void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap, | 1797 void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap, |
1796 const SkIRect& center, const SkRect& dst, | 1798 const SkIRect& center, const SkRect& dst, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 | 1848 |
1847 s.fTop = srcY[y]; | 1849 s.fTop = srcY[y]; |
1848 s.fBottom = srcY[y+1]; | 1850 s.fBottom = srcY[y+1]; |
1849 d.fTop = dstY[y]; | 1851 d.fTop = dstY[y]; |
1850 d.fBottom = dstY[y+1]; | 1852 d.fBottom = dstY[y+1]; |
1851 for (int x = 0; x < 3; x++) { | 1853 for (int x = 0; x < 3; x++) { |
1852 s.fLeft = srcX[x]; | 1854 s.fLeft = srcX[x]; |
1853 s.fRight = srcX[x+1]; | 1855 s.fRight = srcX[x+1]; |
1854 d.fLeft = dstX[x]; | 1856 d.fLeft = dstX[x]; |
1855 d.fRight = dstX[x+1]; | 1857 d.fRight = dstX[x+1]; |
1856 this->internalDrawBitmapRect(bitmap, &s, d, paint); | 1858 this->internalDrawBitmapRect(bitmap, &s, d, paint, |
| 1859 kNone_DrawBitmapRectflag); |
1857 } | 1860 } |
1858 } | 1861 } |
1859 } | 1862 } |
1860 | 1863 |
1861 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 1864 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
1862 const SkRect& dst, const SkPaint* paint) { | 1865 const SkRect& dst, const SkPaint* paint) { |
1863 SkDEBUGCODE(bitmap.validate();) | 1866 SkDEBUGCODE(bitmap.validate();) |
1864 | 1867 |
1865 // Need a device entry-point, so gpu can use a mesh | 1868 // Need a device entry-point, so gpu can use a mesh |
1866 this->internalDrawBitmapNine(bitmap, center, dst, paint); | 1869 this->internalDrawBitmapNine(bitmap, center, dst, paint); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2213 return *paint; | 2216 return *paint; |
2214 } | 2217 } |
2215 | 2218 |
2216 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2219 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
2217 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2220 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2218 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2221 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
2219 | 2222 |
2220 /////////////////////////////////////////////////////////////////////////////// | 2223 /////////////////////////////////////////////////////////////////////////////// |
2221 | 2224 |
2222 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2225 SkCanvas::ClipVisitor::~ClipVisitor() { } |
OLD | NEW |