OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
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 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkBounder.h" | 11 #include "SkBounder.h" |
12 #include "SkDevice.h" | 12 #include "SkDevice.h" |
13 #include "SkDeviceImageFilterProxy.h" | 13 #include "SkDeviceImageFilterProxy.h" |
14 #include "SkDraw.h" | 14 #include "SkDraw.h" |
15 #include "SkDrawFilter.h" | 15 #include "SkDrawFilter.h" |
16 #include "SkDrawLooper.h" | 16 #include "SkDrawLooper.h" |
17 #include "SkMetaData.h" | 17 #include "SkMetaData.h" |
| 18 #include "SkPathOps.h" |
18 #include "SkPicture.h" | 19 #include "SkPicture.h" |
19 #include "SkRasterClip.h" | 20 #include "SkRasterClip.h" |
20 #include "SkRRect.h" | 21 #include "SkRRect.h" |
21 #include "SkScalarCompare.h" | 22 #include "SkScalarCompare.h" |
22 #include "SkSurface_Base.h" | 23 #include "SkSurface_Base.h" |
23 #include "SkTemplates.h" | 24 #include "SkTemplates.h" |
24 #include "SkTextFormatParams.h" | 25 #include "SkTextFormatParams.h" |
25 #include "SkTLazy.h" | 26 #include "SkTLazy.h" |
26 #include "SkUtils.h" | 27 #include "SkUtils.h" |
27 | 28 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 502 |
502 #define LOOPER_END } | 503 #define LOOPER_END } |
503 | 504 |
504 //////////////////////////////////////////////////////////////////////////// | 505 //////////////////////////////////////////////////////////////////////////// |
505 | 506 |
506 SkDevice* SkCanvas::init(SkDevice* device) { | 507 SkDevice* SkCanvas::init(SkDevice* device) { |
507 fBounder = NULL; | 508 fBounder = NULL; |
508 fLocalBoundsCompareType.setEmpty(); | 509 fLocalBoundsCompareType.setEmpty(); |
509 fLocalBoundsCompareTypeDirty = true; | 510 fLocalBoundsCompareTypeDirty = true; |
510 fAllowSoftClip = true; | 511 fAllowSoftClip = true; |
| 512 fAllowSimplifyClip = false; |
511 fDeviceCMDirty = false; | 513 fDeviceCMDirty = false; |
512 fSaveLayerCount = 0; | 514 fSaveLayerCount = 0; |
513 fMetaData = NULL; | 515 fMetaData = NULL; |
514 | 516 |
515 fMCRec = (MCRec*)fMCStack.push_back(); | 517 fMCRec = (MCRec*)fMCStack.push_back(); |
516 new (fMCRec) MCRec(NULL, 0); | 518 new (fMCRec) MCRec(NULL, 0); |
517 | 519 |
518 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL)); | 520 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL)); |
519 fMCRec->fTopLayer = fMCRec->fLayer; | 521 fMCRec->fTopLayer = fMCRec->fLayer; |
520 fMCRec->fNext = NULL; | 522 fMCRec->fNext = NULL; |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 // bounds to empty if that is the case. (see SkRect::set(pts, count)) | 1236 // bounds to empty if that is the case. (see SkRect::set(pts, count)) |
1235 if (devPath.getBounds().isEmpty()) { | 1237 if (devPath.getBounds().isEmpty()) { |
1236 // resetting the path will remove any NaN or other wanky values | 1238 // resetting the path will remove any NaN or other wanky values |
1237 // that might upset our scan converter. | 1239 // that might upset our scan converter. |
1238 devPath.reset(); | 1240 devPath.reset(); |
1239 } | 1241 } |
1240 | 1242 |
1241 // if we called path.swap() we could avoid a deep copy of this path | 1243 // if we called path.swap() we could avoid a deep copy of this path |
1242 fClipStack.clipDevPath(devPath, op, doAA); | 1244 fClipStack.clipDevPath(devPath, op, doAA); |
1243 | 1245 |
| 1246 if (fAllowSimplifyClip) { |
| 1247 devPath.reset(); |
| 1248 devPath.setFillType(SkPath::kInverseEvenOdd_FillType); |
| 1249 const SkClipStack* clipStack = getClipStack(); |
| 1250 SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart)
; |
| 1251 const SkClipStack::Element* element; |
| 1252 while ((element = iter.next())) { |
| 1253 SkClipStack::Element::Type type = element->getType(); |
| 1254 if (type == SkClipStack::Element::kEmpty_Type) { |
| 1255 continue; |
| 1256 } |
| 1257 SkPath operand; |
| 1258 if (type == SkClipStack::Element::kRect_Type) { |
| 1259 operand.addRect(element->getRect()); |
| 1260 } else if (type == SkClipStack::Element::kPath_Type) { |
| 1261 operand = element->getPath(); |
| 1262 } else { |
| 1263 SkDEBUGFAIL("Unexpected type."); |
| 1264 } |
| 1265 SkRegion::Op elementOp = element->getOp(); |
| 1266 if (elementOp == SkRegion::kReplace_Op) { |
| 1267 devPath = operand; |
| 1268 } else { |
| 1269 Op(devPath, operand, (SkPathOp) elementOp, &devPath); |
| 1270 } |
| 1271 } |
| 1272 op = SkRegion::kReplace_Op; |
| 1273 } |
| 1274 |
1244 return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA); | 1275 return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA); |
1245 } | 1276 } |
1246 | 1277 |
1247 bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) { | 1278 bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) { |
1248 AutoValidateClip avc(this); | 1279 AutoValidateClip avc(this); |
1249 | 1280 |
1250 fDeviceCMDirty = true; | 1281 fDeviceCMDirty = true; |
1251 fLocalBoundsCompareTypeDirty = true; | 1282 fLocalBoundsCompareTypeDirty = true; |
1252 | 1283 |
1253 // todo: signal fClipStack that we have a region, and therefore (I guess) | 1284 // todo: signal fClipStack that we have a region, and therefore (I guess) |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 return *paint; | 2159 return *paint; |
2129 } | 2160 } |
2130 | 2161 |
2131 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2162 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
2132 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2163 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2133 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2164 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
2134 | 2165 |
2135 /////////////////////////////////////////////////////////////////////////////// | 2166 /////////////////////////////////////////////////////////////////////////////// |
2136 | 2167 |
2137 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2168 SkCanvas::ClipVisitor::~ClipVisitor() { } |
OLD | NEW |