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

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: Serialization with strings as ID Created 7 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 | 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 "SkValidationUtils.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 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 return false; 1403 return false;
1403 } 1404 }
1404 #endif 1405 #endif
1405 1406
1406 SK_DEVELOPER_TO_STRING() 1407 SK_DEVELOPER_TO_STRING()
1407 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) 1408 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
1408 1409
1409 protected: 1410 protected:
1410 SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { 1411 SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
1411 fMode = (SkXfermode::Mode)buffer.read32(); 1412 fMode = (SkXfermode::Mode)buffer.read32();
1412 1413 bool modeIsValid = SkIsValidMode(fMode);
1413 const ProcCoeff& rec = gProcCoeffs[fMode]; 1414 if (modeIsValid) {
1414 // these may be valid, or may be CANNOT_USE_COEFF 1415 const ProcCoeff& rec = gProcCoeffs[fMode];
1415 fSrcCoeff = rec.fSC; 1416 // these may be valid, or may be CANNOT_USE_COEFF
1416 fDstCoeff = rec.fDC; 1417 fSrcCoeff = rec.fSC;
1417 // now update our function-ptr in the super class 1418 fDstCoeff = rec.fDC;
1418 this->INHERITED::setProc(rec.fProc); 1419 // now update our function-ptr in the super class
1420 this->INHERITED::setProc(rec.fProc);
1421 } else {
1422 fSrcCoeff = fDstCoeff = CANNOT_USE_COEFF;
1423 }
1424 buffer.validate(modeIsValid &&
1425 (SkIsValidCoeff(fSrcCoeff) || (fSrcCoeff == CANNOT_USE_C OEFF)) &&
1426 (SkIsValidCoeff(fDstCoeff) || (fDstCoeff == CANNOT_USE_C OEFF)));
1419 } 1427 }
1420 1428
1421 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { 1429 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
1422 this->INHERITED::flatten(buffer); 1430 this->INHERITED::flatten(buffer);
1423 buffer.write32(fMode); 1431 buffer.write32(fMode);
1424 } 1432 }
1425 1433
1426 private: 1434 private:
1427 Mode fMode; 1435 Mode fMode;
1428 Coeff fSrcCoeff, fDstCoeff; 1436 Coeff fSrcCoeff, fDstCoeff;
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 return proc16; 1989 return proc16;
1982 } 1990 }
1983 1991
1984 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1992 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1985 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1993 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1986 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) 1994 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
1987 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) 1995 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
1988 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) 1996 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
1989 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) 1997 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
1990 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1998 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698