Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: src/core/SkCanvas.cpp

Issue 19977003: drawBitmap* cleanup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed bugs Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 return fSaveLayerCount > 0; 948 return fSaveLayerCount > 0;
949 } 949 }
950 950
951 ///////////////////////////////////////////////////////////////////////////// 951 /////////////////////////////////////////////////////////////////////////////
952 952
953 // can't draw it if its empty, or its too big for a fixed-point width or height 953 // can't draw it if its empty, or its too big for a fixed-point width or height
954 static bool reject_bitmap(const SkBitmap& bitmap) { 954 static bool reject_bitmap(const SkBitmap& bitmap) {
955 return bitmap.width() <= 0 || bitmap.height() <= 0; 955 return bitmap.width() <= 0 || bitmap.height() <= 0;
956 } 956 }
957 957
958 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, const SkIRect* srcRect , 958 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
959 const SkMatrix& matrix, const SkPaint* paint) { 959 const SkMatrix& matrix, const SkPaint* paint) {
960 if (reject_bitmap(bitmap)) { 960 if (reject_bitmap(bitmap)) {
961 return; 961 return;
962 } 962 }
963 963
964 SkLazyPaint lazy; 964 SkLazyPaint lazy;
965 if (NULL == paint) { 965 if (NULL == paint) {
966 paint = lazy.init(); 966 paint = lazy.init();
967 } 967 }
968 this->commonDrawBitmap(bitmap, srcRect, matrix, *paint); 968
969 SkDEBUGCODE(bitmap.validate();)
970 CHECK_LOCKCOUNT_BALANCE(bitmap);
971
972 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type)
973
974 while (iter.next()) {
975 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint());
976 }
977
978 LOOPER_END
969 } 979 }
970 980
971 void SkCanvas::internalDrawDevice(SkDevice* srcDev, int x, int y, 981 void SkCanvas::internalDrawDevice(SkDevice* srcDev, int x, int y,
972 const SkPaint* paint) { 982 const SkPaint* paint) {
973 SkPaint tmp; 983 SkPaint tmp;
974 if (NULL == paint) { 984 if (NULL == paint) {
975 tmp.setDither(true); 985 tmp.setDither(true);
976 paint = &tmp; 986 paint = &tmp;
977 } 987 }
978 988
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 if (paint) { 1736 if (paint) {
1727 (void)paint->computeFastBounds(bounds, &bounds); 1737 (void)paint->computeFastBounds(bounds, &bounds);
1728 } 1738 }
1729 if (this->quickReject(bounds)) { 1739 if (this->quickReject(bounds)) {
1730 return; 1740 return;
1731 } 1741 }
1732 } 1742 }
1733 1743
1734 SkMatrix matrix; 1744 SkMatrix matrix;
1735 matrix.setTranslate(x, y); 1745 matrix.setTranslate(x, y);
1736 this->internalDrawBitmap(bitmap, NULL, matrix, paint); 1746 this->internalDrawBitmap(bitmap, matrix, paint);
1737 } 1747 }
1738 1748
1739 // 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
1740 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 1750 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
1741 const SkRect& dst, const SkPaint* paint) { 1751 const SkRect& dst, const SkPaint* paint) {
1742 if (bitmap.width() == 0 || bitmap.height() == 0 || dst.isEmpty()) { 1752 if (bitmap.width() == 0 || bitmap.height() == 0 || dst.isEmpty()) {
1743 return; 1753 return;
1744 } 1754 }
1745 1755
1746 CHECK_LOCKCOUNT_BALANCE(bitmap); 1756 CHECK_LOCKCOUNT_BALANCE(bitmap);
(...skipping 25 matching lines...) Expand all
1772 1782
1773 void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 1783 void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
1774 const SkRect& dst, const SkPaint* paint) { 1784 const SkRect& dst, const SkPaint* paint) {
1775 SkDEBUGCODE(bitmap.validate();) 1785 SkDEBUGCODE(bitmap.validate();)
1776 this->internalDrawBitmapRect(bitmap, src, dst, paint); 1786 this->internalDrawBitmapRect(bitmap, src, dst, paint);
1777 } 1787 }
1778 1788
1779 void SkCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix, 1789 void SkCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
1780 const SkPaint* paint) { 1790 const SkPaint* paint) {
1781 SkDEBUGCODE(bitmap.validate();) 1791 SkDEBUGCODE(bitmap.validate();)
1782 this->internalDrawBitmap(bitmap, NULL, matrix, paint); 1792 this->internalDrawBitmap(bitmap, matrix, paint);
1783 }
1784
1785 void SkCanvas::commonDrawBitmap(const SkBitmap& bitmap, const SkIRect* srcRect,
1786 const SkMatrix& matrix, const SkPaint& paint) {
1787 SkDEBUGCODE(bitmap.validate();)
1788 CHECK_LOCKCOUNT_BALANCE(bitmap);
1789
1790 LOOPER_BEGIN(paint, SkDrawFilter::kBitmap_Type)
1791
1792 while (iter.next()) {
1793 iter.fDevice->drawBitmap(iter, bitmap, srcRect, matrix, looper.paint());
1794 }
1795
1796 LOOPER_END
1797 } 1793 }
1798 1794
1799 void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap, 1795 void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
1800 const SkIRect& center, const SkRect& dst, 1796 const SkIRect& center, const SkRect& dst,
1801 const SkPaint* paint) { 1797 const SkPaint* paint) {
1802 if (NULL == paint || paint->canComputeFastBounds()) { 1798 if (NULL == paint || paint->canComputeFastBounds()) {
1803 SkRect storage; 1799 SkRect storage;
1804 const SkRect* bounds = &dst; 1800 const SkRect* bounds = &dst;
1805 if (paint) { 1801 if (paint) {
1806 bounds = &paint->computeFastBounds(dst, &storage); 1802 bounds = &paint->computeFastBounds(dst, &storage);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 return *paint; 2213 return *paint;
2218 } 2214 }
2219 2215
2220 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2216 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2221 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2217 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2222 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2218 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2223 2219
2224 /////////////////////////////////////////////////////////////////////////////// 2220 ///////////////////////////////////////////////////////////////////////////////
2225 2221
2226 SkCanvas::ClipVisitor::~ClipVisitor() { } 2222 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698