| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 this->onDrawBitmapNine(bitmap, center, dst, paint); | 1794 this->onDrawBitmapNine(bitmap, center, dst, paint); |
| 1795 } | 1795 } |
| 1796 | 1796 |
| 1797 void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPai
nt* paint) { | 1797 void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPai
nt* paint) { |
| 1798 if (bitmap.empty()) { | 1798 if (bitmap.empty()) { |
| 1799 return; | 1799 return; |
| 1800 } | 1800 } |
| 1801 this->onDrawSprite(bitmap, left, top, paint); | 1801 this->onDrawSprite(bitmap, left, top, paint); |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 #include "SkRSXform.h" |
| 1805 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
Rect tex[], |
| 1806 const SkColor colors[], int n, const SkRect* cull, cons
t SkPaint* paint) { |
| 1807 // this->drawImage(atlas, 0, 0, paint); |
| 1808 |
| 1809 SkPaint pnt; |
| 1810 if (paint) { |
| 1811 pnt = *paint; |
| 1812 } |
| 1813 // pnt.setStyle(SkPaint::kStroke_Style); |
| 1814 |
| 1815 SkPath path; |
| 1816 for (int i = 0; i < n; ++i) { |
| 1817 SkPoint quad[4]; |
| 1818 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); |
| 1819 |
| 1820 SkMatrix localM; |
| 1821 localM.setRSXform(xform[i]); |
| 1822 localM.preTranslate(-tex[i].left(), -tex[i].top()); |
| 1823 |
| 1824 pnt.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kCla
mp_TileMode, |
| 1825 &localM))->unref(); |
| 1826 if (colors) { |
| 1827 pnt.setColorFilter(SkColorFilter::CreateModeFilter(colors[i], |
| 1828 SkXfermode::kModulat
e_Mode))->unref(); |
| 1829 } |
| 1830 |
| 1831 path.rewind(); |
| 1832 path.addPoly(quad, 4, true); |
| 1833 this->drawPath(path, pnt); |
| 1834 } |
| 1835 } |
| 1836 |
| 1804 ////////////////////////////////////////////////////////////////////////////// | 1837 ////////////////////////////////////////////////////////////////////////////// |
| 1805 // These are the virtual drawing methods | 1838 // These are the virtual drawing methods |
| 1806 ////////////////////////////////////////////////////////////////////////////// | 1839 ////////////////////////////////////////////////////////////////////////////// |
| 1807 | 1840 |
| 1808 void SkCanvas::onDiscard() { | 1841 void SkCanvas::onDiscard() { |
| 1809 if (fSurfaceBase) { | 1842 if (fSurfaceBase) { |
| 1810 fSurfaceBase->aboutToDraw(SkSurface::kDiscard_ContentChangeMode); | 1843 fSurfaceBase->aboutToDraw(SkSurface::kDiscard_ContentChangeMode); |
| 1811 } | 1844 } |
| 1812 } | 1845 } |
| 1813 | 1846 |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2712 } | 2745 } |
| 2713 | 2746 |
| 2714 if (matrix) { | 2747 if (matrix) { |
| 2715 canvas->concat(*matrix); | 2748 canvas->concat(*matrix); |
| 2716 } | 2749 } |
| 2717 } | 2750 } |
| 2718 | 2751 |
| 2719 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2752 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2720 fCanvas->restoreToCount(fSaveCount); | 2753 fCanvas->restoreToCount(fSaveCount); |
| 2721 } | 2754 } |
| OLD | NEW |