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

Side by Side Diff: src/effects/gradients/SkLinearGradient.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
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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkLinearGradient.h" 9 #include "SkLinearGradient.h"
10 #include "SkRefCnt.h" 10 #include "SkRefCnt.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 size_t SkLinearGradient::onContextSize(const ContextRec& rec) const { 77 size_t SkLinearGradient::onContextSize(const ContextRec& rec) const {
78 return use_4f_context(rec, fGradFlags) 78 return use_4f_context(rec, fGradFlags)
79 ? sizeof(LinearGradient4fContext) 79 ? sizeof(LinearGradient4fContext)
80 : sizeof(LinearGradientContext); 80 : sizeof(LinearGradientContext);
81 } 81 }
82 82
83 SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void * storage) const { 83 SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void * storage) const {
84 return use_4f_context(rec, fGradFlags) 84 return use_4f_context(rec, fGradFlags)
85 ? static_cast<SkShader::Context*>(new (storage) LinearGradient4fContext( *this, rec)) 85 ? CheckedCreateContext<LinearGradient4fContext>(storage, *this, rec)
86 : static_cast<SkShader::Context*>(new (storage) LinearGradientContext(*t his, rec)); 86 : CheckedCreateContext< LinearGradientContext>(storage, *this, rec);
87 } 87 }
88 88
89 // This swizzles SkColor into the same component order as SkPMColor, but does no t actually 89 // This swizzles SkColor into the same component order as SkPMColor, but does no t actually
90 // "pre" multiply the color components. 90 // "pre" multiply the color components.
91 // 91 //
92 // This allows us to map directly to Sk4f, and eventually scale down to bytes to output a 92 // This allows us to map directly to Sk4f, and eventually scale down to bytes to output a
93 // SkPMColor from the floats, without having to swizzle each time. 93 // SkPMColor from the floats, without having to swizzle each time.
94 // 94 //
95 static uint32_t SkSwizzle_Color_to_PMColor(SkColor c) { 95 static uint32_t SkSwizzle_Color_to_PMColor(SkColor c) {
96 return SkPackARGB32NoCheck(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c), S kColorGetB(c)); 96 return SkPackARGB32NoCheck(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c), S kColorGetB(c));
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); 760 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r);
761 } 761 }
762 } else { 762 } else {
763 if (fApplyAlphaAfterInterp) { 763 if (fApplyAlphaAfterInterp) {
764 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); 764 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r);
765 } else { 765 } else {
766 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); 766 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er);
767 } 767 }
768 } 768 }
769 } 769 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShaderPriv.h ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698