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

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

Issue 1759653004: enforce 16byte alignment in shader contexts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/core/SkComposeShader.cpp ('k') | src/core/SkEmptyShader.h » ('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 * 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
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
1703 class TriColorShaderContext : public SkShader::Context { 1701 class TriColorShaderContext : public SkShader::Context {
1704 public: 1702 public:
1705 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&) ; 1703 TriColorShaderContext(const SkTriColorShader& shader, const ContextRec&) ;
1706 virtual ~TriColorShaderContext(); 1704 virtual ~TriColorShaderContext();
1707 1705
1708 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int); 1706 bool setup(const SkPoint pts[], const SkColor colors[], int, int, int);
1709 1707
1710 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; 1708 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override;
1711 1709
1712 private: 1710 private:
1713 SkMatrix fDstToUnit; 1711 SkMatrix fDstToUnit;
1714 SkPMColor fColors[3]; 1712 SkPMColor fColors[3];
1715 1713
1716 typedef SkShader::Context INHERITED; 1714 typedef SkShader::Context INHERITED;
1717 }; 1715 };
1718 1716
1719 SK_TO_STRING_OVERRIDE() 1717 SK_TO_STRING_OVERRIDE()
1720 1718
1721 // For serialization. This will never be called. 1719 // For serialization. This will never be called.
1722 Factory getFactory() const override { sk_throw(); return nullptr; } 1720 Factory getFactory() const override { sk_throw(); return nullptr; }
1723 1721
1724 protected: 1722 protected:
1723 size_t onContextSize(const ContextRec&) const override;
1725 Context* onCreateContext(const ContextRec& rec, void* storage) const overrid e { 1724 Context* onCreateContext(const ContextRec& rec, void* storage) const overrid e {
1726 return new (storage) TriColorShaderContext(*this, rec); 1725 return new (storage) TriColorShaderContext(*this, rec);
1727 } 1726 }
1728 1727
1729 private: 1728 private:
1730 typedef SkShader INHERITED; 1729 typedef SkShader INHERITED;
1731 }; 1730 };
1732 1731
1733 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S kColor colors[], 1732 bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S kColor colors[],
1734 int index0, int index1, int index2) { 1733 int index0, int index1, int index2) {
(...skipping 30 matching lines...) Expand all
1765 return static_cast<int>(SkScalarPin(v, 0, 1) * 256 + 0.5); 1764 return static_cast<int>(SkScalarPin(v, 0, 1) * 256 + 0.5);
1766 } 1765 }
1767 1766
1768 1767
1769 SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS hader& shader, 1768 SkTriColorShader::TriColorShaderContext::TriColorShaderContext(const SkTriColorS hader& shader,
1770 const ContextRec& rec) 1769 const ContextRec& rec)
1771 : INHERITED(shader, rec) {} 1770 : INHERITED(shader, rec) {}
1772 1771
1773 SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {} 1772 SkTriColorShader::TriColorShaderContext::~TriColorShaderContext() {}
1774 1773
1775 size_t SkTriColorShader::contextSize(const ContextRec&) const { 1774 size_t SkTriColorShader::onContextSize(const ContextRec&) const {
1776 return sizeof(TriColorShaderContext); 1775 return SkAlign16(sizeof(TriColorShaderContext));
1777 } 1776 }
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
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 }
OLDNEW
« no previous file with comments | « src/core/SkComposeShader.cpp ('k') | src/core/SkEmptyShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698