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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 /** | 74 /** |
75 * Since we are providing the storage for the shader (to avoid the perf cost | 75 * Since we are providing the storage for the shader (to avoid the perf cost |
76 * of calling new) we insist that in our destructor we can account for all | 76 * of calling new) we insist that in our destructor we can account for all |
77 * owners of the shader. | 77 * owners of the shader. |
78 */ | 78 */ |
79 class SkAutoBitmapShaderInstall : SkNoncopyable { | 79 class SkAutoBitmapShaderInstall : SkNoncopyable { |
80 public: | 80 public: |
81 SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint& paint, | 81 SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint& paint, |
82 const SkMatrix* localMatrix = nullptr) | 82 const SkMatrix* localMatrix = nullptr) |
83 : fPaint(paint) /* makes a copy of the paint */ { | 83 : fPaint(paint) /* makes a copy of the paint */ { |
84 fPaint.setShader(SkCreateBitmapShader(src, SkShader::kClamp_TileMode, | 84 fPaint.setShader(SkMakeBitmapShader(src, SkShader::kClamp_TileMode, |
85 SkShader::kClamp_TileMode, | 85 SkShader::kClamp_TileMode, |
86 localMatrix, &fAllocator)); | 86 localMatrix, &fAllocator)); |
87 fPaint.getShader()->ref(); | |
87 // we deliberately left the shader with an owner-count of 2 | 88 // we deliberately left the shader with an owner-count of 2 |
88 SkASSERT(2 == fPaint.getShader()->getRefCnt()); | 89 SkASSERT(2 == fPaint.getShader()->getRefCnt()); |
89 } | 90 } |
90 | 91 |
91 ~SkAutoBitmapShaderInstall() { | 92 ~SkAutoBitmapShaderInstall() { |
92 // since fAllocator will destroy shader, we insist that owners == 2 | 93 // since fAllocator will destroy shader, we insist that owners == 2 |
93 SkASSERT(2 == fPaint.getShader()->getRefCnt()); | 94 SkASSERT(2 == fPaint.getShader()->getRefCnt()); |
94 | 95 |
95 fPaint.setShader(nullptr); // unref the shader by 1 | 96 fPaint.setShader(nullptr); // unref the shader by 1 |
96 | 97 |
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1669 SkFindAndPlaceGlyph::ProcessPosText( | 1670 SkFindAndPlaceGlyph::ProcessPosText( |
1670 paint.getTextEncoding(), text, byteLength, | 1671 paint.getTextEncoding(), text, byteLength, |
1671 offset, *fMatrix, pos, scalarsPerPosition, textAlignment, cache.get(), d rawOneGlyph); | 1672 offset, *fMatrix, pos, scalarsPerPosition, textAlignment, cache.get(), d rawOneGlyph); |
1672 } | 1673 } |
1673 | 1674 |
1674 #if defined _WIN32 && _MSC_VER >= 1300 | 1675 #if defined _WIN32 && _MSC_VER >= 1300 |
1675 #pragma warning ( pop ) | 1676 #pragma warning ( pop ) |
1676 #endif | 1677 #endif |
1677 | 1678 |
1678 /////////////////////////////////////////////////////////////////////////////// | 1679 /////////////////////////////////////////////////////////////////////////////// |
1679 | 1680 #if 0 |
1680 static SkScan::HairRCProc ChooseHairProc(bool doAntiAlias) { | 1681 static SkScan::HairRCProc ChooseHairProc(bool doAntiAlias) { |
1681 return doAntiAlias ? SkScan::AntiHairLine : SkScan::HairLine; | 1682 return doAntiAlias ? SkScan::AntiHairLine : SkScan::HairLine; |
1682 } | 1683 } |
1683 | 1684 |
1684 static bool texture_to_matrix(const VertState& state, const SkPoint verts[], | 1685 static bool texture_to_matrix(const VertState& state, const SkPoint verts[], |
1685 const SkPoint texs[], SkMatrix* matrix) { | 1686 const SkPoint texs[], SkMatrix* matrix) { |
1686 SkPoint src[3], dst[3]; | 1687 SkPoint src[3], dst[3]; |
1687 | 1688 |
1688 src[0] = texs[state.f0]; | 1689 src[0] = texs[state.f0]; |
1689 src[1] = texs[state.f1]; | 1690 src[1] = texs[state.f1]; |
1690 src[2] = texs[state.f2]; | 1691 src[2] = texs[state.f2]; |
1691 dst[0] = verts[state.f0]; | 1692 dst[0] = verts[state.f0]; |
1692 dst[1] = verts[state.f1]; | 1693 dst[1] = verts[state.f1]; |
1693 dst[2] = verts[state.f2]; | 1694 dst[2] = verts[state.f2]; |
1694 return matrix->setPolyToPoly(src, dst, 3); | 1695 return matrix->setPolyToPoly(src, dst, 3); |
1695 } | 1696 } |
1697 #endif | |
1696 | 1698 |
1697 class SkTriColorShader : public SkShader { | 1699 class SkTriColorShader : public SkShader { |
1698 public: | 1700 public: |
1699 SkTriColorShader() {} | 1701 SkTriColorShader() {} |
1700 | 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 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1810 | 1812 |
1811 #ifndef SK_IGNORE_TO_STRING | 1813 #ifndef SK_IGNORE_TO_STRING |
1812 void SkTriColorShader::toString(SkString* str) const { | 1814 void SkTriColorShader::toString(SkString* str) const { |
1813 str->append("SkTriColorShader: ("); | 1815 str->append("SkTriColorShader: ("); |
1814 | 1816 |
1815 this->INHERITED::toString(str); | 1817 this->INHERITED::toString(str); |
1816 | 1818 |
1817 str->append(")"); | 1819 str->append(")"); |
1818 } | 1820 } |
1819 #endif | 1821 #endif |
1820 | 1822 #if 0 |
f(malita)
2016/03/08 15:50:35
?
| |
1821 void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count, | 1823 void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count, |
1822 const SkPoint vertices[], const SkPoint textures[], | 1824 const SkPoint vertices[], const SkPoint textures[], |
1823 const SkColor colors[], SkXfermode* xmode, | 1825 const SkColor colors[], SkXfermode* xmode, |
1824 const uint16_t indices[], int indexCount, | 1826 const uint16_t indices[], int indexCount, |
1825 const SkPaint& paint) const { | 1827 const SkPaint& paint) const { |
1826 SkASSERT(0 == count || vertices); | 1828 SkASSERT(0 == count || vertices); |
1827 | 1829 |
1828 // abort early if there is nothing to draw | 1830 // abort early if there is nothing to draw |
1829 if (count < 3 || (indices && indexCount < 3) || fRC->isEmpty()) { | 1831 if (count < 3 || (indices && indexCount < 3) || fRC->isEmpty()) { |
1830 return; | 1832 return; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1939 SkScan::HairRCProc hairProc = ChooseHairProc(paint.isAntiAlias()); | 1941 SkScan::HairRCProc hairProc = ChooseHairProc(paint.isAntiAlias()); |
1940 const SkRasterClip& clip = *fRC; | 1942 const SkRasterClip& clip = *fRC; |
1941 while (vertProc(&state)) { | 1943 while (vertProc(&state)) { |
1942 SkPoint array[] = { | 1944 SkPoint array[] = { |
1943 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2], devV erts[state.f0] | 1945 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2], devV erts[state.f0] |
1944 }; | 1946 }; |
1945 hairProc(array, 4, clip, blitter.get()); | 1947 hairProc(array, 4, clip, blitter.get()); |
1946 } | 1948 } |
1947 } | 1949 } |
1948 } | 1950 } |
1951 #endif | |
1949 | 1952 |
1950 /////////////////////////////////////////////////////////////////////////////// | 1953 /////////////////////////////////////////////////////////////////////////////// |
1951 /////////////////////////////////////////////////////////////////////////////// | 1954 /////////////////////////////////////////////////////////////////////////////// |
1952 | 1955 |
1953 #ifdef SK_DEBUG | 1956 #ifdef SK_DEBUG |
1954 | 1957 |
1955 void SkDraw::validate() const { | 1958 void SkDraw::validate() const { |
1956 SkASSERT(fMatrix != nullptr); | 1959 SkASSERT(fMatrix != nullptr); |
1957 SkASSERT(fClip != nullptr); | 1960 SkASSERT(fClip != nullptr); |
1958 SkASSERT(fRC != nullptr); | 1961 SkASSERT(fRC != nullptr); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2057 mask->fImage = SkMask::AllocImage(size); | 2060 mask->fImage = SkMask::AllocImage(size); |
2058 memset(mask->fImage, 0, mask->computeImageSize()); | 2061 memset(mask->fImage, 0, mask->computeImageSize()); |
2059 } | 2062 } |
2060 | 2063 |
2061 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2064 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2062 draw_into_mask(*mask, devPath, style); | 2065 draw_into_mask(*mask, devPath, style); |
2063 } | 2066 } |
2064 | 2067 |
2065 return true; | 2068 return true; |
2066 } | 2069 } |
OLD | NEW |