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

Side by Side Diff: src/effects/SkColorFilters.cpp

Issue 53983005: Check that Mode is valid for ModeColorFilterEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add comment Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBlitRow.h" 10 #include "SkBlitRow.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 SkAssertResult(SkXfermode::ModeAsCoeff(mode, &filterColorCoeff, &colorCoeff) ); 179 SkAssertResult(SkXfermode::ModeAsCoeff(mode, &filterColorCoeff, &colorCoeff) );
180 return blend_term(colorCoeff, filterColor, inColor, inColor) + 180 return blend_term(colorCoeff, filterColor, inColor, inColor) +
181 blend_term(filterColorCoeff, filterColor, inColor, filterColor); 181 blend_term(filterColorCoeff, filterColor, inColor, filterColor);
182 } 182 }
183 183
184 } 184 }
185 185
186 class ModeColorFilterEffect : public GrEffect { 186 class ModeColorFilterEffect : public GrEffect {
187 public: 187 public:
188 static GrEffectRef* Create(const GrColor& c, SkXfermode::Mode mode) { 188 static GrEffectRef* Create(const GrColor& c, SkXfermode::Mode mode) {
189 // TODO: Make the effect take the coeffs rather than mode since we alrea dy do the
190 // conversion here.
191 SkXfermode::Coeff srcCoeff, dstCoeff;
192 if (!SkXfermode::ModeAsCoeff(mode, &srcCoeff, &dstCoeff)) {
193 SkDebugf("Failing to create color filter for mode %d\n", mode);
194 return NULL;
195 }
189 AutoEffectUnref effect(SkNEW_ARGS(ModeColorFilterEffect, (c, mode))); 196 AutoEffectUnref effect(SkNEW_ARGS(ModeColorFilterEffect, (c, mode)));
190 return CreateEffectRef(effect); 197 return CreateEffectRef(effect);
191 } 198 }
192 199
193 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 200 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
194 201
195 bool willUseFilterColor() const { 202 bool willUseFilterColor() const {
196 SkXfermode::Coeff dstCoeff; 203 SkXfermode::Coeff dstCoeff;
197 SkXfermode::Coeff srcCoeff; 204 SkXfermode::Coeff srcCoeff;
198 SkAssertResult(SkXfermode::ModeAsCoeff(fMode, &srcCoeff, &dstCoeff)); 205 SkAssertResult(SkXfermode::ModeAsCoeff(fMode, &srcCoeff, &dstCoeff));
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter) 839 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter)
833 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Src_SkModeColorFilter) 840 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Src_SkModeColorFilter)
834 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SrcOver_SkModeColorFilter) 841 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SrcOver_SkModeColorFilter)
835 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter) 842 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter)
836 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_JustAdd) 843 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_JustAdd)
837 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_JustMul) 844 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_JustMul)
838 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_SingleMul) 845 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_SingleMul)
839 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_NoPin) 846 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingColorFilter_NoPin)
840 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSimpleColorFilter) 847 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSimpleColorFilter)
841 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 848 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698