| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2011 Google Inc. | 2  * Copyright 2011 Google Inc. | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #include "SkData.h" |  | 
| 9 #include "SkPDFFormXObject.h" | 8 #include "SkPDFFormXObject.h" | 
| 10 #include "SkPDFGraphicState.h" | 9 #include "SkPDFGraphicState.h" | 
| 11 #include "SkPDFUtils.h" | 10 #include "SkPDFUtils.h" | 
|  | 11 #include "SkStream.h" | 
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" | 
| 13 | 13 | 
| 14 static const char* blend_mode_from_xfermode(SkXfermode::Mode mode) { | 14 static const char* blend_mode_from_xfermode(SkXfermode::Mode mode) { | 
| 15     switch (mode) { | 15     switch (mode) { | 
| 16         case SkXfermode::kSrcOver_Mode:    return "Normal"; | 16         case SkXfermode::kSrcOver_Mode:    return "Normal"; | 
| 17         case SkXfermode::kMultiply_Mode:   return "Multiply"; | 17         case SkXfermode::kMultiply_Mode:   return "Multiply"; | 
| 18         case SkXfermode::kScreen_Mode:     return "Screen"; | 18         case SkXfermode::kScreen_Mode:     return "Screen"; | 
| 19         case SkXfermode::kOverlay_Mode:    return "Overlay"; | 19         case SkXfermode::kOverlay_Mode:    return "Overlay"; | 
| 20         case SkXfermode::kDarken_Mode:     return "Darken"; | 20         case SkXfermode::kDarken_Mode:     return "Darken"; | 
| 21         case SkXfermode::kLighten_Mode:    return "Lighten"; | 21         case SkXfermode::kLighten_Mode:    return "Lighten"; | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 114     static SkPDFStream* invertFunction = NULL; | 114     static SkPDFStream* invertFunction = NULL; | 
| 115     if (!invertFunction) { | 115     if (!invertFunction) { | 
| 116         // Acrobat crashes if we use a type 0 function, kpdf crashes if we use | 116         // Acrobat crashes if we use a type 0 function, kpdf crashes if we use | 
| 117         // a type 2 function, so we use a type 4 function. | 117         // a type 2 function, so we use a type 4 function. | 
| 118         SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); | 118         SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); | 
| 119         domainAndRange->reserve(2); | 119         domainAndRange->reserve(2); | 
| 120         domainAndRange->appendInt(0); | 120         domainAndRange->appendInt(0); | 
| 121         domainAndRange->appendInt(1); | 121         domainAndRange->appendInt(1); | 
| 122 | 122 | 
| 123         static const char psInvert[] = "{1 exch sub}"; | 123         static const char psInvert[] = "{1 exch sub}"; | 
| 124         // Do not copy the trailing '\0' into the SkData. | 124         SkAutoTUnref<SkMemoryStream> psInvertStream( | 
| 125         SkAutoTUnref<SkData> psInvertStream( | 125             new SkMemoryStream(&psInvert, strlen(psInvert), true)); | 
| 126                 SkData::NewWithCopy(psInvert, strlen(psInvert))); |  | 
| 127 | 126 | 
| 128         invertFunction = new SkPDFStream(psInvertStream.get()); | 127         invertFunction = new SkPDFStream(psInvertStream.get()); | 
| 129         invertFunction->insertInt("FunctionType", 4); | 128         invertFunction->insertInt("FunctionType", 4); | 
| 130         invertFunction->insert("Domain", domainAndRange.get()); | 129         invertFunction->insert("Domain", domainAndRange.get()); | 
| 131         invertFunction->insert("Range", domainAndRange.get()); | 130         invertFunction->insert("Range", domainAndRange.get()); | 
| 132     } | 131     } | 
| 133     return invertFunction; | 132     return invertFunction; | 
| 134 } | 133 } | 
| 135 | 134 | 
| 136 // static | 135 // static | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 278     } | 277     } | 
| 279     if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || | 278     if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || | 
| 280             blend_mode_from_xfermode(bXfermodeName) == NULL) { | 279             blend_mode_from_xfermode(bXfermodeName) == NULL) { | 
| 281         bXfermodeName = SkXfermode::kSrcOver_Mode; | 280         bXfermodeName = SkXfermode::kSrcOver_Mode; | 
| 282     } | 281     } | 
| 283     const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); | 282     const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); | 
| 284     SkASSERT(bXfermodeString != NULL); | 283     SkASSERT(bXfermodeString != NULL); | 
| 285 | 284 | 
| 286     return strcmp(aXfermodeString, bXfermodeString) == 0; | 285     return strcmp(aXfermodeString, bXfermodeString) == 0; | 
| 287 } | 286 } | 
| OLD | NEW | 
|---|