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

Side by Side Diff: src/core/SkXfermode.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adding validation helper file Created 7 years, 3 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 | Annotate | Revision Log
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 "SkXfermode.h" 10 #include "SkXfermode.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkFlattenableBuffers.h" 12 #include "SkFlattenableBuffers.h"
13 #include "SkMathPriv.h" 13 #include "SkMathPriv.h"
14 #include "SkString.h" 14 #include "SkString.h"
15 #include "SkValidation.h"
15 16
16 SK_DEFINE_INST_COUNT(SkXfermode) 17 SK_DEFINE_INST_COUNT(SkXfermode)
17 18
18 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) 19 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b)
19 20
20 #if 0 21 #if 0
21 // idea for higher precision blends in xfer procs (and slightly faster) 22 // idea for higher precision blends in xfer procs (and slightly faster)
22 // see DstATop as a probable caller 23 // see DstATop as a probable caller
23 static U8CPU mulmuldiv255round(U8CPU a, U8CPU b, U8CPU c, U8CPU d) { 24 static U8CPU mulmuldiv255round(U8CPU a, U8CPU b, U8CPU c, U8CPU d) {
24 SkASSERT(a <= 255); 25 SkASSERT(a <= 255);
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 protected: 1432 protected:
1432 SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { 1433 SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
1433 fMode = (SkXfermode::Mode)buffer.read32(); 1434 fMode = (SkXfermode::Mode)buffer.read32();
1434 1435
1435 const ProcCoeff& rec = gProcCoeffs[fMode]; 1436 const ProcCoeff& rec = gProcCoeffs[fMode];
1436 // these may be valid, or may be CANNOT_USE_COEFF 1437 // these may be valid, or may be CANNOT_USE_COEFF
1437 fSrcCoeff = rec.fSC; 1438 fSrcCoeff = rec.fSC;
1438 fDstCoeff = rec.fDC; 1439 fDstCoeff = rec.fDC;
1439 // now update our function-ptr in the super class 1440 // now update our function-ptr in the super class
1440 this->INHERITED::setProc(rec.fProc); 1441 this->INHERITED::setProc(rec.fProc);
1442
1443 buffer.validateData(IsValidMode(fMode) &&
1444 IsValidCoeff(fSrcCoeff) &&
1445 IsValidCoeff(fDstCoeff));
1441 } 1446 }
1442 1447
1443 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { 1448 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
1444 this->INHERITED::flatten(buffer); 1449 this->INHERITED::flatten(buffer);
1445 buffer.write32(fMode); 1450 buffer.write32(fMode);
1446 } 1451 }
1447 1452
1448 private: 1453 private:
1449 Mode fMode; 1454 Mode fMode;
1450 Coeff fSrcCoeff, fDstCoeff; 1455 Coeff fSrcCoeff, fDstCoeff;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 return proc16; 1968 return proc16;
1964 } 1969 }
1965 1970
1966 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1971 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1967 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1968 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) 1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
1969 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) 1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
1970 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) 1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
1971 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) 1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
1972 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1977 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698