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

Side by Side Diff: src/effects/gradients/Sk4fGradientBase.cpp

Issue 2397473003: Harden degenerate gradient context handling (Closed)
Patch Set: Created 4 years, 2 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/effects/gradients/Sk4fGradientBase.h ('k') | src/effects/gradients/SkGradientShader.cpp » ('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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
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 "Sk4fGradientBase.h" 8 #include "Sk4fGradientBase.h"
9 9
10 #include <functional> 10 #include <functional>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 if (shader.fColorsAreOpaque && this->getPaintAlpha() == SK_AlphaOPAQUE) { 152 if (shader.fColorsAreOpaque && this->getPaintAlpha() == SK_AlphaOPAQUE) {
153 fFlags |= kOpaqueAlpha_Flag; 153 fFlags |= kOpaqueAlpha_Flag;
154 } 154 }
155 155
156 fColorsArePremul = 156 fColorsArePremul =
157 (shader.fGradFlags & SkGradientShader::kInterpolateColorsInPremul_Flag) 157 (shader.fGradFlags & SkGradientShader::kInterpolateColorsInPremul_Flag)
158 || shader.fColorsAreOpaque; 158 || shader.fColorsAreOpaque;
159 } 159 }
160 160
161 bool SkGradientShaderBase::
162 GradientShaderBase4fContext::isValid() const {
163 return fDstToPos.isFinite();
164 }
165
161 void SkGradientShaderBase:: 166 void SkGradientShaderBase::
162 GradientShaderBase4fContext::buildIntervals(const SkGradientShaderBase& shader, 167 GradientShaderBase4fContext::buildIntervals(const SkGradientShaderBase& shader,
163 const ContextRec& rec, bool reverse) { 168 const ContextRec& rec, bool reverse) {
164 // The main job here is to build a specialized interval list: a different 169 // The main job here is to build a specialized interval list: a different
165 // representation of the color stops data, optimized for efficient scan line 170 // representation of the color stops data, optimized for efficient scan line
166 // access during shading. 171 // access during shading.
167 // 172 //
168 // [{P0,C0} , {P1,C1}) [{P1,C2} , {P2,c3}) ... [{Pn,C2n} , {Pn+1,C2n+1}) 173 // [{P0,C0} , {P1,C1}) [{P1,C2} , {P2,c3}) ... [{Pn,C2n} , {Pn+1,C2n+1})
169 // 174 //
170 // The list may be inverted when requested (such that e.g. points are sorted 175 // The list may be inverted when requested (such that e.g. points are sorted
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 fDc = DstTraits<dstType>::load(i->fDc); 428 fDc = DstTraits<dstType>::load(i->fDc);
424 } 429 }
425 430
426 const Interval* fFirstInterval; 431 const Interval* fFirstInterval;
427 const Interval* fLastInterval; 432 const Interval* fLastInterval;
428 const Interval* fInterval; 433 const Interval* fInterval;
429 SkScalar fPrevT; 434 SkScalar fPrevT;
430 Sk4f fCc; 435 Sk4f fCc;
431 Sk4f fDc; 436 Sk4f fDc;
432 }; 437 };
OLDNEW
« no previous file with comments | « src/effects/gradients/Sk4fGradientBase.h ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698