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

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: Fixing comments 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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 return false; 1396 return false;
1396 } 1397 }
1397 #endif 1398 #endif
1398 1399
1399 SK_DEVELOPER_TO_STRING() 1400 SK_DEVELOPER_TO_STRING()
1400 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) 1401 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
1401 1402
1402 protected: 1403 protected:
1403 SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { 1404 SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
1404 fMode = (SkXfermode::Mode)buffer.read32(); 1405 fMode = (SkXfermode::Mode)buffer.read32();
1405 1406 bool modeIsValid = SkIsValidMode(fMode);
1406 const ProcCoeff& rec = gProcCoeffs[fMode]; 1407 if (modeIsValid) {
1407 // these may be valid, or may be CANNOT_USE_COEFF 1408 const ProcCoeff& rec = gProcCoeffs[fMode];
1408 fSrcCoeff = rec.fSC; 1409 // these may be valid, or may be CANNOT_USE_COEFF
1409 fDstCoeff = rec.fDC; 1410 fSrcCoeff = rec.fSC;
1410 // now update our function-ptr in the super class 1411 fDstCoeff = rec.fDC;
1411 this->INHERITED::setProc(rec.fProc); 1412 // now update our function-ptr in the super class
1413 this->INHERITED::setProc(rec.fProc);
1414 } else {
1415 fSrcCoeff = fDstCoeff = CANNOT_USE_COEFF;
1416 }
1417 buffer.validate(modeIsValid &&
1418 (SkIsValidCoeff(fSrcCoeff) || (fSrcCoeff == CANNOT_USE_C OEFF)) &&
1419 (SkIsValidCoeff(fDstCoeff) || (fDstCoeff == CANNOT_USE_C OEFF)));
1412 } 1420 }
1413 1421
1414 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { 1422 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
1415 this->INHERITED::flatten(buffer); 1423 this->INHERITED::flatten(buffer);
1416 buffer.write32(fMode); 1424 buffer.write32(fMode);
1417 } 1425 }
1418 1426
1419 private: 1427 private:
1420 Mode fMode; 1428 Mode fMode;
1421 Coeff fSrcCoeff, fDstCoeff; 1429 Coeff fSrcCoeff, fDstCoeff;
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 return proc16; 1982 return proc16;
1975 } 1983 }
1976 1984
1977 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1985 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1978 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1986 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1979 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) 1987 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
1980 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) 1988 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
1981 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) 1989 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
1982 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) 1990 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
1983 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1991 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698