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

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient.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/SkSweepGradient.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "SkTwoPointConicalGradient.h" 8 #include "SkTwoPointConicalGradient.h"
9 9
10 struct TwoPtRadialContext { 10 struct TwoPtRadialContext {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // TODO(junov): Compute whether the cone fills the plane crbug.com/222380 209 // TODO(junov): Compute whether the cone fills the plane crbug.com/222380
210 return false; 210 return false;
211 } 211 }
212 212
213 size_t SkTwoPointConicalGradient::onContextSize(const ContextRec&) const { 213 size_t SkTwoPointConicalGradient::onContextSize(const ContextRec&) const {
214 return sizeof(TwoPointConicalGradientContext); 214 return sizeof(TwoPointConicalGradientContext);
215 } 215 }
216 216
217 SkShader::Context* SkTwoPointConicalGradient::onCreateContext(const ContextRec& rec, 217 SkShader::Context* SkTwoPointConicalGradient::onCreateContext(const ContextRec& rec,
218 void* storage) con st { 218 void* storage) con st {
219 return new (storage) TwoPointConicalGradientContext(*this, rec); 219 return CheckedCreateContext<TwoPointConicalGradientContext>(storage, *this, rec);
220 } 220 }
221 221
222 SkTwoPointConicalGradient::TwoPointConicalGradientContext::TwoPointConicalGradie ntContext( 222 SkTwoPointConicalGradient::TwoPointConicalGradientContext::TwoPointConicalGradie ntContext(
223 const SkTwoPointConicalGradient& shader, const ContextRec& rec) 223 const SkTwoPointConicalGradient& shader, const ContextRec& rec)
224 : INHERITED(shader, rec) 224 : INHERITED(shader, rec)
225 { 225 {
226 // in general, we might discard based on computed-radius, so clear 226 // in general, we might discard based on computed-radius, so clear
227 // this flag (todo: sometimes we can detect that we never discard...) 227 // this flag (todo: sometimes we can detect that we never discard...)
228 fFlags &= ~kOpaqueAlpha_Flag; 228 fFlags &= ~kOpaqueAlpha_Flag;
229 } 229 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 str->appendScalar(fCenter2.fY); 389 str->appendScalar(fCenter2.fY);
390 str->append(") radius2: "); 390 str->append(") radius2: ");
391 str->appendScalar(fRadius2); 391 str->appendScalar(fRadius2);
392 str->append(" "); 392 str->append(" ");
393 393
394 this->INHERITED::toString(str); 394 this->INHERITED::toString(str);
395 395
396 str->append(")"); 396 str->append(")");
397 } 397 }
398 #endif 398 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkSweepGradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698