OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 #define __STDC_LIMIT_MACROS | 7 #define __STDC_LIMIT_MACROS |
8 | 8 |
9 #include "SkDraw.h" | 9 #include "SkDraw.h" |
10 #include "SkBlitter.h" | 10 #include "SkBlitter.h" |
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 Base* operator->() const { return get(); } | 1781 Base* operator->() const { return get(); } |
1782 Base& operator*() const { return *get(); } | 1782 Base& operator*() const { return *get(); } |
1783 | 1783 |
1784 private: | 1784 private: |
1785 mutable Variants fVariants; | 1785 mutable Variants fVariants; |
1786 }; | 1786 }; |
1787 | 1787 |
1788 // PositionReaderInterface reads a point from the pos vector. | 1788 // PositionReaderInterface reads a point from the pos vector. |
1789 // * HorizontalPositions - assumes a common Y for many X values. | 1789 // * HorizontalPositions - assumes a common Y for many X values. |
1790 // * ArbitraryPositions - a list of (X,Y) pairs. | 1790 // * ArbitraryPositions - a list of (X,Y) pairs. |
1791 class PositionReaderInterface : SkNoncopyable { | 1791 class PositionReaderInterface { |
1792 public: | 1792 public: |
1793 virtual ~PositionReaderInterface() { } | 1793 virtual ~PositionReaderInterface() { } |
1794 virtual SkPoint nextPoint() = 0; | 1794 virtual SkPoint nextPoint() = 0; |
1795 }; | 1795 }; |
1796 | 1796 |
1797 class HorizontalPositions final : public PositionReaderInterface { | 1797 class HorizontalPositions final : public PositionReaderInterface { |
1798 public: | 1798 public: |
1799 HorizontalPositions(const SkScalar* positions) | 1799 explicit HorizontalPositions(const SkScalar* positions) |
1800 : fPositions(positions) { } | 1800 : fPositions(positions) { } |
1801 | 1801 |
1802 SkPoint nextPoint() override { | 1802 SkPoint nextPoint() override { |
1803 SkScalar x = *fPositions++; | 1803 SkScalar x = *fPositions++; |
1804 return {x, 0}; | 1804 return {x, 0}; |
1805 } | 1805 } |
1806 private: | 1806 private: |
1807 const SkScalar* fPositions; | 1807 const SkScalar* fPositions; |
1808 }; | 1808 }; |
1809 | 1809 |
1810 class ArbitraryPositions final : public PositionReaderInterface { | 1810 class ArbitraryPositions final : public PositionReaderInterface { |
1811 public: | 1811 public: |
1812 ArbitraryPositions(const SkScalar* positions) | 1812 explicit ArbitraryPositions(const SkScalar* positions) |
1813 : fPositions(positions) { } | 1813 : fPositions(positions) { } |
1814 SkPoint nextPoint() override { | 1814 SkPoint nextPoint() override { |
1815 SkPoint to_return {fPositions[0], fPositions[1]}; | 1815 SkPoint to_return {fPositions[0], fPositions[1]}; |
1816 fPositions += 2; | 1816 fPositions += 2; |
1817 return to_return; | 1817 return to_return; |
1818 } | 1818 } |
1819 | 1819 |
1820 private: | 1820 private: |
1821 const SkScalar* fPositions; | 1821 const SkScalar* fPositions; |
1822 }; | 1822 }; |
1823 | 1823 |
1824 typedef PolymorphicVariant<PositionReaderInterface, HorizontalPositions, Arbitra
ryPositions> | 1824 typedef PolymorphicVariant<PositionReaderInterface, HorizontalPositions, Arbitra
ryPositions> |
1825 PositionReader; | 1825 PositionReader; |
1826 | 1826 |
1827 // MapperInterface given a point map it through the matrix. There are several sh
ortcut variants. | 1827 // MapperInterface given a point map it through the matrix. There are several sh
ortcut variants. |
1828 // * TranslationMapper - assumes a translation only matrix. | 1828 // * TranslationMapper - assumes a translation only matrix. |
1829 // * XScaleMapper - assumes an X scaling and a translation. | 1829 // * XScaleMapper - assumes an X scaling and a translation. |
1830 // * GeneralMapper - Does all other matricies. | 1830 // * GeneralMapper - Does all other matricies. |
1831 class MapperInterface : SkNoncopyable { | 1831 class MapperInterface { |
1832 public: | 1832 public: |
1833 virtual ~MapperInterface() {} | 1833 virtual ~MapperInterface() {} |
1834 virtual SkPoint map(SkPoint position) const = 0; | 1834 virtual SkPoint map(SkPoint position) const = 0; |
1835 }; | 1835 }; |
1836 | 1836 |
1837 class TranslationMapper final : public MapperInterface { | 1837 class TranslationMapper final : public MapperInterface { |
1838 public: | 1838 public: |
1839 TranslationMapper(const SkMatrix& matrix, const SkPoint origin) | 1839 TranslationMapper(const SkMatrix& matrix, const SkPoint origin) |
1840 : fTranslate(matrix.mapXY(origin.fX, origin.fY)) { } | 1840 : fTranslate(matrix.mapXY(origin.fX, origin.fY)) { } |
1841 SkPoint map(SkPoint position) const override { | 1841 SkPoint map(SkPoint position) const override { |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2658 mask->fImage = SkMask::AllocImage(size); | 2658 mask->fImage = SkMask::AllocImage(size); |
2659 memset(mask->fImage, 0, mask->computeImageSize()); | 2659 memset(mask->fImage, 0, mask->computeImageSize()); |
2660 } | 2660 } |
2661 | 2661 |
2662 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2662 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2663 draw_into_mask(*mask, devPath, style); | 2663 draw_into_mask(*mask, devPath, style); |
2664 } | 2664 } |
2665 | 2665 |
2666 return true; | 2666 return true; |
2667 } | 2667 } |
OLD | NEW |