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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 { CompositeSourceAtop, SkXfermode::kSrcATop_Mode }, | 53 { CompositeSourceAtop, SkXfermode::kSrcATop_Mode }, |
54 { CompositeDestinationOver, SkXfermode::kDstOver_Mode }, | 54 { CompositeDestinationOver, SkXfermode::kDstOver_Mode }, |
55 { CompositeDestinationIn, SkXfermode::kDstIn_Mode }, | 55 { CompositeDestinationIn, SkXfermode::kDstIn_Mode }, |
56 { CompositeDestinationOut, SkXfermode::kDstOut_Mode }, | 56 { CompositeDestinationOut, SkXfermode::kDstOut_Mode }, |
57 { CompositeDestinationAtop, SkXfermode::kDstATop_Mode }, | 57 { CompositeDestinationAtop, SkXfermode::kDstATop_Mode }, |
58 { CompositeXOR, SkXfermode::kXor_Mode }, | 58 { CompositeXOR, SkXfermode::kXor_Mode }, |
59 { CompositePlusDarker, SkXfermode::kDarken_Mode }, | 59 { CompositePlusDarker, SkXfermode::kDarken_Mode }, |
60 { CompositePlusLighter, SkXfermode::kPlus_Mode } | 60 { CompositePlusLighter, SkXfermode::kPlus_Mode } |
61 }; | 61 }; |
62 | 62 |
63 SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op) | 63 static const struct BlendOpToXfermodeMode { |
64 uint8_t mBlendOp; | |
65 uint8_t m_xfermodeMode; | |
66 } gMapBlendOpsToXfermodeModes[] = { | |
67 { BlendModeMultiply, SkXfermode::kMultiply_Mode }, | |
68 { BlendModeScreen, SkXfermode::kScreen_Mode }, | |
69 { BlendModeOverlay, SkXfermode::kOverlay_Mode }, | |
70 { BlendModeDarken, SkXfermode::kDarken_Mode }, | |
71 { BlendModeLighten, SkXfermode::kLighten_Mode }, | |
72 { BlendModeColorDodge, SkXfermode::kColorDodge_Mode }, | |
73 { BlendModeColorBurn, SkXfermode::kColorBurn_Mode }, | |
74 { BlendModeHardLight, SkXfermode::kHardLight_Mode }, | |
75 { BlendModeSoftLight, SkXfermode::kSoftLight_Mode }, | |
76 { BlendModeDifference, SkXfermode::kDifference_Mode }, | |
77 { BlendModeExclusion, SkXfermode::kExclusion_Mode }, | |
78 { BlendModeHue, SkXfermode::kHue_Mode }, | |
79 { BlendModeSaturation, SkXfermode::kSaturation_Mode }, | |
80 { BlendModeColor, SkXfermode::kColor_Mode }, | |
81 { BlendModeLuminosity, SkXfermode::kLuminosity_Mode } | |
82 }; | |
Stephen Chennney
2013/04/08 16:07:02
This should be implemented as an array. If the Ble
rosca
2013/04/08 19:53:25
I followed the example of CompositOpToXfermodeMode
| |
83 | |
84 SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op, BlendMode blendMode) | |
64 { | 85 { |
86 if (blendMode != BlendModeNormal) { | |
Stephen Chennney
2013/04/08 16:07:02
Is BlendModeNormal == 0? If so, suitably adjust my
| |
87 const BlendOpToXfermodeMode* table = gMapBlendOpsToXfermodeModes; | |
88 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapBlendOpsToXfermodeModes); i+ +) { | |
89 if (table[i].mBlendOp == blendMode) | |
90 return (SkXfermode::Mode)table[i].m_xfermodeMode; | |
91 } | |
92 } | |
93 | |
65 const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes; | 94 const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes; |
66 | 95 |
67 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToXfermodeModes); i++ ) { | 96 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToXfermodeModes); i++ ) { |
68 if (table[i].mCompositOp == op) | 97 if (table[i].mCompositOp == op) |
69 return (SkXfermode::Mode)table[i].m_xfermodeMode; | 98 return (SkXfermode::Mode)table[i].m_xfermodeMode; |
70 } | 99 } |
71 | 100 |
72 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown CompositeO perator %d\n", op)); | 101 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown CompositeO perator %d\n", op)); |
73 return SkXfermode::kSrcOver_Mode; // fall-back | 102 return SkXfermode::kSrcOver_Mode; // fall-back |
74 } | 103 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 | 188 |
160 GraphicsContext* scratchContext() | 189 GraphicsContext* scratchContext() |
161 { | 190 { |
162 static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr(); | 191 static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr(); |
163 // We don't bother checking for failure creating the ImageBuffer, since our | 192 // We don't bother checking for failure creating the ImageBuffer, since our |
164 // ImageBuffer initializer won't fail. | 193 // ImageBuffer initializer won't fail. |
165 return scratch->context(); | 194 return scratch->context(); |
166 } | 195 } |
167 | 196 |
168 } // namespace WebCore | 197 } // namespace WebCore |
OLD | NEW |