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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 SkXfermode::kDifference_Mode, // WebBlendModeDifference | 72 SkXfermode::kDifference_Mode, // WebBlendModeDifference |
73 SkXfermode::kExclusion_Mode, // WebBlendModeExclusion | 73 SkXfermode::kExclusion_Mode, // WebBlendModeExclusion |
74 SkXfermode::kHue_Mode, // WebBlendModeHue | 74 SkXfermode::kHue_Mode, // WebBlendModeHue |
75 SkXfermode::kSaturation_Mode, // WebBlendModeSaturation | 75 SkXfermode::kSaturation_Mode, // WebBlendModeSaturation |
76 SkXfermode::kColor_Mode, // WebBlendModeColor | 76 SkXfermode::kColor_Mode, // WebBlendModeColor |
77 SkXfermode::kLuminosity_Mode // WebBlendModeLuminosity | 77 SkXfermode::kLuminosity_Mode // WebBlendModeLuminosity |
78 }; | 78 }; |
79 | 79 |
80 SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op, WebBlendM
ode blendMode) | 80 SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op, WebBlendM
ode blendMode) |
81 { | 81 { |
| 82 ASSERT(op == CompositeSourceOver || blendMode == WebBlendModeNormal); |
82 if (blendMode != WebBlendModeNormal) { | 83 if (blendMode != WebBlendModeNormal) { |
83 if (static_cast<uint8_t>(blendMode) >= SK_ARRAY_COUNT(gMapBlendOpsToXfer
modeModes)) { | 84 if (static_cast<uint8_t>(blendMode) >= SK_ARRAY_COUNT(gMapBlendOpsToXfer
modeModes)) { |
84 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown We
bBlendMode %d\n", blendMode)); | 85 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown We
bBlendMode %d\n", blendMode)); |
85 return SkXfermode::kSrcOver_Mode; | 86 return SkXfermode::kSrcOver_Mode; |
86 } | 87 } |
87 return gMapBlendOpsToXfermodeModes[static_cast<uint8_t>(blendMode)]; | 88 return gMapBlendOpsToXfermodeModes[static_cast<uint8_t>(blendMode)]; |
88 } | 89 } |
89 | 90 |
90 const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes; | 91 const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes; |
91 if (static_cast<uint8_t>(op) >= SK_ARRAY_COUNT(gMapCompositOpsToXfermodeMode
s)) { | 92 if (static_cast<uint8_t>(op) >= SK_ARRAY_COUNT(gMapCompositOpsToXfermodeMode
s)) { |
92 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown Compos
iteOperator %d\n", op)); | 93 SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown Compos
iteOperator %d\n", op)); |
93 return SkXfermode::kSrcOver_Mode; | 94 return SkXfermode::kSrcOver_Mode; |
94 } | 95 } |
95 SkASSERT(table[static_cast<uint8_t>(op)].mCompositOp == op); | 96 SkASSERT(table[static_cast<uint8_t>(op)].mCompositOp == op); |
96 return table[static_cast<uint8_t>(op)].m_xfermodeMode; | 97 return table[static_cast<uint8_t>(op)].m_xfermodeMode; |
97 } | 98 } |
98 | 99 |
| 100 CompositeOperator compositeOperatorFromSkia(SkXfermode::Mode xferMode) |
| 101 { |
| 102 switch (xferMode) { |
| 103 case SkXfermode::kClear_Mode: |
| 104 return CompositeClear; |
| 105 case SkXfermode::kSrc_Mode: |
| 106 return CompositeCopy; |
| 107 case SkXfermode::kSrcOver_Mode: |
| 108 return CompositeSourceOver; |
| 109 case SkXfermode::kSrcIn_Mode: |
| 110 return CompositeSourceIn; |
| 111 case SkXfermode::kSrcOut_Mode: |
| 112 return CompositeSourceOut; |
| 113 case SkXfermode::kSrcATop_Mode: |
| 114 return CompositeSourceAtop; |
| 115 case SkXfermode::kDstOver_Mode: |
| 116 return CompositeDestinationOver; |
| 117 case SkXfermode::kDstIn_Mode: |
| 118 return CompositeDestinationIn; |
| 119 case SkXfermode::kDstOut_Mode: |
| 120 return CompositeDestinationOut; |
| 121 case SkXfermode::kDstATop_Mode: |
| 122 return CompositeDestinationAtop; |
| 123 case SkXfermode::kXor_Mode: |
| 124 return CompositeXOR; |
| 125 case SkXfermode::kPlus_Mode: |
| 126 return CompositePlusLighter; |
| 127 default: |
| 128 break; |
| 129 } |
| 130 return CompositeSourceOver; |
| 131 } |
| 132 |
| 133 WebBlendMode blendModeFromSkia(SkXfermode::Mode xferMode) |
| 134 { |
| 135 switch (xferMode) { |
| 136 case SkXfermode::kSrcOver_Mode: |
| 137 return WebBlendModeNormal; |
| 138 case SkXfermode::kMultiply_Mode: |
| 139 return WebBlendModeMultiply; |
| 140 case SkXfermode::kScreen_Mode: |
| 141 return WebBlendModeScreen; |
| 142 case SkXfermode::kOverlay_Mode: |
| 143 return WebBlendModeOverlay; |
| 144 case SkXfermode::kDarken_Mode: |
| 145 return WebBlendModeDarken; |
| 146 case SkXfermode::kLighten_Mode: |
| 147 return WebBlendModeLighten; |
| 148 case SkXfermode::kColorDodge_Mode: |
| 149 return WebBlendModeColorDodge; |
| 150 case SkXfermode::kColorBurn_Mode: |
| 151 return WebBlendModeColorBurn; |
| 152 case SkXfermode::kHardLight_Mode: |
| 153 return WebBlendModeHardLight; |
| 154 case SkXfermode::kSoftLight_Mode: |
| 155 return WebBlendModeSoftLight; |
| 156 case SkXfermode::kDifference_Mode: |
| 157 return WebBlendModeDifference; |
| 158 case SkXfermode::kExclusion_Mode: |
| 159 return WebBlendModeExclusion; |
| 160 case SkXfermode::kHue_Mode: |
| 161 return WebBlendModeHue; |
| 162 case SkXfermode::kSaturation_Mode: |
| 163 return WebBlendModeSaturation; |
| 164 case SkXfermode::kColor_Mode: |
| 165 return WebBlendModeColor; |
| 166 case SkXfermode::kLuminosity_Mode: |
| 167 return WebBlendModeLuminosity; |
| 168 default: |
| 169 break; |
| 170 } |
| 171 return WebBlendModeNormal; |
| 172 } |
| 173 |
99 bool SkPathContainsPoint(const SkPath& originalPath, const FloatPoint& point, Sk
Path::FillType ft) | 174 bool SkPathContainsPoint(const SkPath& originalPath, const FloatPoint& point, Sk
Path::FillType ft) |
100 { | 175 { |
101 SkRect bounds = originalPath.getBounds(); | 176 SkRect bounds = originalPath.getBounds(); |
102 | 177 |
103 // We can immediately return false if the point is outside the bounding | 178 // We can immediately return false if the point is outside the bounding |
104 // rect. We don't use bounds.contains() here, since it would exclude | 179 // rect. We don't use bounds.contains() here, since it would exclude |
105 // points on the right and bottom edges of the bounding rect, and we want | 180 // points on the right and bottom edges of the bounding rect, and we want |
106 // to include them. | 181 // to include them. |
107 SkScalar fX = SkFloatToScalar(point.x()); | 182 SkScalar fX = SkFloatToScalar(point.x()); |
108 SkScalar fY = SkFloatToScalar(point.y()); | 183 SkScalar fY = SkFloatToScalar(point.y()); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // though - that's why it's not always on. | 354 // though - that's why it's not always on. |
280 SkScalar widthExpansion, heightExpansion; | 355 SkScalar widthExpansion, heightExpansion; |
281 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) | 356 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) |
282 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total
Matrix[SkMatrix::kMSkewX]; | 357 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total
Matrix[SkMatrix::kMSkewX]; |
283 else | 358 else |
284 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota
lMatrix[SkMatrix::kMScaleY]; | 359 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota
lMatrix[SkMatrix::kMScaleY]; |
285 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; | 360 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; |
286 } | 361 } |
287 | 362 |
288 } // namespace blink | 363 } // namespace blink |
OLD | NEW |