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

Unified Diff: src/core/SkXfermode.cpp

Issue 79543009: move SkProcCoeffXfermode unflatten constructor into .cpp, and range-check its mode (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkXfermode.cpp
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index a22035e804331482b924bd977a8274e0e7cbd026..3cb03703bb06956e9f02c071cf836f88a28d2d5d 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -1343,6 +1343,22 @@ GrEffectRef* XferEffect::TestCreate(SkRandom* rand,
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+SkProcCoeffXfermode::SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
tfarina 2013/11/21 23:45:07 Does SkProcCoeffXfermode deserve its own cpp file?
+ uint32_t mode32 = buffer.read32() % SK_ARRAY_COUNT(gProcCoeffs);
+ if (mode32 >= SK_ARRAY_COUNT(gProcCoeffs)) {
+ // out of range, just set to something harmless
+ mode32 = SkXfermode::kSrcOut_Mode;
+ }
+ fMode = (SkXfermode::Mode)mode32;
+
+ const ProcCoeff& rec = gProcCoeffs[fMode];
+ // these may be valid, or may be CANNOT_USE_COEFF
+ fSrcCoeff = rec.fSC;
+ fDstCoeff = rec.fDC;
+ // now update our function-ptr in the super class
+ this->INHERITED::setProc(rec.fProc);
+}
+
bool SkProcCoeffXfermode::asMode(Mode* mode) const {
if (mode) {
*mode = fMode;
« no previous file with comments | « no previous file | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698