OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
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 #include "GrClipMaskManager.h" | 9 #include "GrClipMaskManager.h" |
10 #include "GrAAConvexPathRenderer.h" | 10 #include "GrAAConvexPathRenderer.h" |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 // Intersect and reverse difference require modifying pixels outside
of the geometry | 1014 // Intersect and reverse difference require modifying pixels outside
of the geometry |
1015 // that is being "drawn". In both cases we erase all the pixels outs
ide of the geometry | 1015 // that is being "drawn". In both cases we erase all the pixels outs
ide of the geometry |
1016 // but leave the pixels inside the geometry alone. For reverse diffe
rence we invert all | 1016 // but leave the pixels inside the geometry alone. For reverse diffe
rence we invert all |
1017 // the pixels before clearing the ones outside the geometry. | 1017 // the pixels before clearing the ones outside the geometry. |
1018 if (SkRegion::kReverseDifference_Op == op) { | 1018 if (SkRegion::kReverseDifference_Op == op) { |
1019 SkRect temp = SkRect::Make(clipSpaceIBounds); | 1019 SkRect temp = SkRect::Make(clipSpaceIBounds); |
1020 // invert the entire scene | 1020 // invert the entire scene |
1021 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); | 1021 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); |
1022 } | 1022 } |
1023 | 1023 |
1024 if (Element::kRect_Type == element->getType()) { | 1024 SkPath clipPath; |
1025 // convert the rect to a path so we can invert the fill | 1025 element->asPath(&clipPath); |
1026 SkPath temp; | 1026 clipPath.toggleInverseFillType(); |
1027 temp.addRect(element->getRect()); | 1027 helper.draw(clipPath, stroke, SkRegion::kReplace_Op, element->isAA()
, 0x00); |
1028 temp.setFillType(SkPath::kInverseEvenOdd_FillType); | |
1029 | |
1030 helper.draw(temp, stroke, SkRegion::kReplace_Op, | |
1031 element->isAA(), | |
1032 0x00); | |
1033 } else { | |
1034 SkASSERT(Element::kPath_Type == element->getType()); | |
1035 SkPath clipPath = element->getPath(); | |
1036 clipPath.toggleInverseFillType(); | |
1037 helper.draw(clipPath, stroke, | |
1038 SkRegion::kReplace_Op, | |
1039 element->isAA(), | |
1040 0x00); | |
1041 } | |
1042 | 1028 |
1043 continue; | 1029 continue; |
1044 } | 1030 } |
1045 | 1031 |
1046 // The other ops (union, xor, diff) only affect pixels inside | 1032 // The other ops (union, xor, diff) only affect pixels inside |
1047 // the geometry so they can just be drawn normally | 1033 // the geometry so they can just be drawn normally |
1048 if (Element::kRect_Type == element->getType()) { | 1034 if (Element::kRect_Type == element->getType()) { |
1049 helper.draw(element->getRect(), op, element->isAA(), 0xFF); | 1035 helper.draw(element->getRect(), op, element->isAA(), 0xFF); |
1050 } else { | 1036 } else { |
1051 SkASSERT(Element::kPath_Type == element->getType()); | 1037 SkPath path; |
1052 helper.draw(element->getPath(), stroke, op, element->isAA(), 0xFF); | 1038 element->asPath(&path); |
| 1039 helper.draw(path, stroke, op, element->isAA(), 0xFF); |
1053 } | 1040 } |
1054 } | 1041 } |
1055 | 1042 |
1056 helper.toTexture(result); | 1043 helper.toTexture(result); |
1057 | 1044 |
1058 fCurrClipMaskType = kAlpha_ClipMaskType; | 1045 fCurrClipMaskType = kAlpha_ClipMaskType; |
1059 return result; | 1046 return result; |
1060 } | 1047 } |
1061 | 1048 |
1062 //////////////////////////////////////////////////////////////////////////////// | 1049 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 23 matching lines...) Expand all Loading... |
1086 | 1073 |
1087 // TODO: dynamically attach a stencil buffer | 1074 // TODO: dynamically attach a stencil buffer |
1088 int stencilBits = 0; | 1075 int stencilBits = 0; |
1089 GrStencilBuffer* stencilBuffer = | 1076 GrStencilBuffer* stencilBuffer = |
1090 drawState.getRenderTarget()->getStencilBuffer(); | 1077 drawState.getRenderTarget()->getStencilBuffer(); |
1091 if (NULL != stencilBuffer) { | 1078 if (NULL != stencilBuffer) { |
1092 stencilBits = stencilBuffer->bits(); | 1079 stencilBits = stencilBuffer->bits(); |
1093 this->adjustStencilParams(settings, clipMode, stencilBits); | 1080 this->adjustStencilParams(settings, clipMode, stencilBits); |
1094 } | 1081 } |
1095 } | 1082 } |
OLD | NEW |