| 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 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 dst[0] = verts[state.f0]; | 1691 dst[0] = verts[state.f0]; |
| 1692 dst[1] = verts[state.f1]; | 1692 dst[1] = verts[state.f1]; |
| 1693 dst[2] = verts[state.f2]; | 1693 dst[2] = verts[state.f2]; |
| 1694 return matrix->setPolyToPoly(src, dst, 3); | 1694 return matrix->setPolyToPoly(src, dst, 3); |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 class SkTriColorShader : public SkShader { | 1697 class SkTriColorShader : public SkShader { |
| 1698 public: | 1698 public: |
| 1699 SkTriColorShader() {} | 1699 SkTriColorShader() {} |
| 1700 | 1700 |
| 1701 size_t contextSize(const ContextRec&) const override; |
| 1702 |
| 1701 class TriColorShaderContext : public SkShader::Context { | 1703 class TriColorShaderContext : public SkShader::Context { |
| 1702 public: | 1704 public: |
| 1703 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&)
; | 1705 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&)
; |
| 1704 virtual ~TriColorShaderContext(); | 1706 virtual ~TriColorShaderContext(); |
| 1705 | 1707 |
| 1706 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int); | 1708 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int); |
| 1707 | 1709 |
| 1708 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; | 1710 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; |
| 1709 | 1711 |
| 1710 private: | 1712 private: |
| 1711 SkMatrix fDstToUnit; | 1713 SkMatrix fDstToUnit; |
| 1712 SkPMColor fColors[3]; | 1714 SkPMColor fColors[3]; |
| 1713 | 1715 |
| 1714 typedef SkShader::Context INHERITED; | 1716 typedef SkShader::Context INHERITED; |
| 1715 }; | 1717 }; |
| 1716 | 1718 |
| 1717 SK_TO_STRING_OVERRIDE() | 1719 SK_TO_STRING_OVERRIDE() |
| 1718 | 1720 |
| 1719 // For serialization. This will never be called. | 1721 // For serialization. This will never be called. |
| 1720 Factory getFactory() const override { sk_throw(); return nullptr; } | 1722 Factory getFactory() const override { sk_throw(); return nullptr; } |
| 1721 | 1723 |
| 1722 protected: | 1724 protected: |
| 1723 size_t onContextSize(const ContextRec&) const override; | |
| 1724 Context* onCreateContext(const ContextRec& rec, void* storage) const overrid
e { | 1725 Context* onCreateContext(const ContextRec& rec, void* storage) const overrid
e { |
| 1725 return new (storage) TriColorShaderContext(*this, rec); | 1726 return new (storage) TriColorShaderContext(*this, rec); |
| 1726 } | 1727 } |
| 1727 | 1728 |
| 1728 private: | 1729 private: |
| 1729 typedef SkShader INHERITED; | 1730 typedef SkShader INHERITED; |
| 1730 }; | 1731 }; |
| 1731 | 1732 |
| 1732 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S
kColor colors[], | 1733 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S
kColor colors[], |
| 1733 int index0, int index1, int
index2) { | 1734 int index0, int index1, int
index2) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1764 return static_cast<int>(SkScalarPin(v, 0, 1) * 256 + 0.5); | 1765 return static_cast<int>(SkScalarPin(v, 0, 1) * 256 + 0.5); |
| 1765 } | 1766 } |
| 1766 | 1767 |
| 1767 | 1768 |
| 1768 SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS
hader& shader, | 1769 SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS
hader& shader, |
| 1769 const ContextRec&
rec) | 1770 const ContextRec&
rec) |
| 1770 : INHERITED(shader, rec) {} | 1771 : INHERITED(shader, rec) {} |
| 1771 | 1772 |
| 1772 SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {} | 1773 SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {} |
| 1773 | 1774 |
| 1774 size_t SkTriColorShader::onContextSize(const ContextRec&) const { | 1775 size_t SkTriColorShader::contextSize(const ContextRec&) const { |
| 1775 return SkAlign16(sizeof(TriColorShaderContext)); | 1776 return sizeof(TriColorShaderContext); |
| 1776 } | 1777 } |
| 1777 | |
| 1778 void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor
dstC[], int count) { | 1778 void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor
dstC[], int count) { |
| 1779 const int alphaScale = Sk255To256(this->getPaintAlpha()); | 1779 const int alphaScale = Sk255To256(this->getPaintAlpha()); |
| 1780 | 1780 |
| 1781 SkPoint src; | 1781 SkPoint src; |
| 1782 | 1782 |
| 1783 for (int i = 0; i < count; i++) { | 1783 for (int i = 0; i < count; i++) { |
| 1784 fDstToUnit.mapXY(SkIntToScalar(x), SkIntToScalar(y), &src); | 1784 fDstToUnit.mapXY(SkIntToScalar(x), SkIntToScalar(y), &src); |
| 1785 x += 1; | 1785 x += 1; |
| 1786 | 1786 |
| 1787 int scale1 = ScalarTo256(src.fX); | 1787 int scale1 = ScalarTo256(src.fX); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 mask->fImage = SkMask::AllocImage(size); | 2057 mask->fImage = SkMask::AllocImage(size); |
| 2058 memset(mask->fImage, 0, mask->computeImageSize()); | 2058 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2059 } | 2059 } |
| 2060 | 2060 |
| 2061 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2061 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2062 draw_into_mask(*mask, devPath, style); | 2062 draw_into_mask(*mask, devPath, style); |
| 2063 } | 2063 } |
| 2064 | 2064 |
| 2065 return true; | 2065 return true; |
| 2066 } | 2066 } |
| OLD | NEW |