OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 { CompositeSourceAtop, SkXfermode::kSrcATop_Mode }, | 54 { CompositeSourceAtop, SkXfermode::kSrcATop_Mode }, |
55 { CompositeDestinationOver, SkXfermode::kDstOver_Mode }, | 55 { CompositeDestinationOver, SkXfermode::kDstOver_Mode }, |
56 { CompositeDestinationIn, SkXfermode::kDstIn_Mode }, | 56 { CompositeDestinationIn, SkXfermode::kDstIn_Mode }, |
57 { CompositeDestinationOut, SkXfermode::kDstOut_Mode }, | 57 { CompositeDestinationOut, SkXfermode::kDstOut_Mode }, |
58 { CompositeDestinationAtop, SkXfermode::kDstATop_Mode }, | 58 { CompositeDestinationAtop, SkXfermode::kDstATop_Mode }, |
59 { CompositeXOR, SkXfermode::kXor_Mode }, | 59 { CompositeXOR, SkXfermode::kXor_Mode }, |
60 { CompositePlusDarker, SkXfermode::kDarken_Mode }, | 60 { CompositePlusDarker, SkXfermode::kDarken_Mode }, |
61 { CompositePlusLighter, SkXfermode::kPlus_Mode } | 61 { CompositePlusLighter, SkXfermode::kPlus_Mode } |
62 }; | 62 }; |
63 | 63 |
64 SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op) | 64 COMPILE_ASSERT((BlendModeNormal == 0 |
| 65 && BlendModeMultiply == 1 |
| 66 && BlendModeScreen == 2 |
| 67 && BlendModeOverlay == 3 |
| 68 && BlendModeDarken == 4 |
| 69 && BlendModeLighten == 5 |
| 70 && BlendModeColorDodge == 6 |
| 71 && BlendModeColorBurn == 7 |
| 72 && BlendModeHardLight == 8 |
| 73 && BlendModeSoftLight == 9 |
| 74 && BlendModeDifference == 10 |
| 75 && BlendModeExclusion == 11 |
| 76 && BlendModeHue == 12 |
| 77 && BlendModeSaturation == 13 |
| 78 && BlendModeColor == 14 |
| 79 && BlendModeLuminosity == 15), |
| 80 KeepBlendOpsAndSkXfermodesInSync); |
| 81 |
| 82 static const uint8_t gMapBlendOpsToXfermodeModes[] = { |
| 83 SkXfermode::kClear_Mode, // BlendModeNormal |
| 84 SkXfermode::kMultiply_Mode, // BlendModeMultiply |
| 85 SkXfermode::kScreen_Mode, // BlendModeScreen |
| 86 SkXfermode::kOverlay_Mode, // BlendModeOverlay |
| 87 SkXfermode::kDarken_Mode, // BlendModeDarken |
| 88 SkXfermode::kLighten_Mode, // BlendModeLighten |
| 89 SkXfermode::kColorDodge_Mode, // BlendModeColorDodge |
| 90 SkXfermode::kColorBurn_Mode, // BlendModeColorBurn |
| 91 SkXfermode::kHardLight_Mode, // BlendModeHardLight |
| 92 SkXfermode::kSoftLight_Mode, // BlendModeSoftLight |
| 93 SkXfermode::kDifference_Mode, // BlendModeDifference |
| 94 SkXfermode::kExclusion_Mode, // BlendModeExclusion |
| 95 SkXfermode::kHue_Mode, // BlendModeHue |
| 96 SkXfermode::kSaturation_Mode, // BlendModeSaturation |
| 97 SkXfermode::kColor_Mode, // BlendModeColor |
| 98 SkXfermode::kLuminosity_Mode // BlendModeLuminosity |
| 99 }; |
| 100 |
| 101 SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op, BlendMode
blendMode) |
65 { | 102 { |
| 103 if (blendMode != BlendModeNormal) { |
| 104 if ((uint8_t)blendMode >= SK_ARRAY_COUNT(gMapBlendOpsToXfermodeModes)) { |
| 105 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown Bl
endMode %d\n", blendMode)); |
| 106 return SkXfermode::kSrcOver_Mode; |
| 107 } |
| 108 return (SkXfermode::Mode)gMapBlendOpsToXfermodeModes[(uint8_t)blendMode]
; |
| 109 } |
| 110 |
66 const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes; | 111 const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes; |
67 | 112 |
68 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToXfermodeModes); i++
) { | 113 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToXfermodeModes); i++
) { |
69 if (table[i].mCompositOp == op) | 114 if (table[i].mCompositOp == op) |
70 return (SkXfermode::Mode)table[i].m_xfermodeMode; | 115 return (SkXfermode::Mode)table[i].m_xfermodeMode; |
71 } | 116 } |
72 | 117 |
73 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown CompositeO
perator %d\n", op)); | 118 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown CompositeO
perator %d\n", op)); |
74 return SkXfermode::kSrcOver_Mode; // fall-back | 119 return SkXfermode::kSrcOver_Mode; // fall-back |
75 } | 120 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 205 |
161 GraphicsContext* scratchContext() | 206 GraphicsContext* scratchContext() |
162 { | 207 { |
163 static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr(); | 208 static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr(); |
164 // We don't bother checking for failure creating the ImageBuffer, since our | 209 // We don't bother checking for failure creating the ImageBuffer, since our |
165 // ImageBuffer initializer won't fail. | 210 // ImageBuffer initializer won't fail. |
166 return scratch->context(); | 211 return scratch->context(); |
167 } | 212 } |
168 | 213 |
169 } // namespace WebCore | 214 } // namespace WebCore |
OLD | NEW |