| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
| 9 | 9 |
| 10 #include "SkAdvancedTypefaceMetrics.h" | 10 #include "SkAdvancedTypefaceMetrics.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // enums so region_op_to_pathops_op can do a straight passthrough cast. | 169 // enums so region_op_to_pathops_op can do a straight passthrough cast. |
| 170 // If these are failing, it may be necessary to make region_op_to_pathops_op | 170 // If these are failing, it may be necessary to make region_op_to_pathops_op |
| 171 // do more. | 171 // do more. |
| 172 static_assert(SkRegion::kDifference_Op == (int)kDifference_SkPathOp, "region_pat
hop_mismatch"); | 172 static_assert(SkRegion::kDifference_Op == (int)kDifference_SkPathOp, "region_pat
hop_mismatch"); |
| 173 static_assert(SkRegion::kIntersect_Op == (int)kIntersect_SkPathOp, "region_patho
p_mismatch"); | 173 static_assert(SkRegion::kIntersect_Op == (int)kIntersect_SkPathOp, "region_patho
p_mismatch"); |
| 174 static_assert(SkRegion::kUnion_Op == (int)kUnion_SkPathOp, "region_pathop_mismat
ch"); | 174 static_assert(SkRegion::kUnion_Op == (int)kUnion_SkPathOp, "region_pathop_mismat
ch"); |
| 175 static_assert(SkRegion::kXOR_Op == (int)kXOR_SkPathOp, "region_pathop_mismatch")
; | 175 static_assert(SkRegion::kXOR_Op == (int)kXOR_SkPathOp, "region_pathop_mismatch")
; |
| 176 static_assert(SkRegion::kReverseDifference_Op == (int)kReverseDifference_SkPathO
p, | 176 static_assert(SkRegion::kReverseDifference_Op == (int)kReverseDifference_SkPathO
p, |
| 177 "region_pathop_mismatch"); | 177 "region_pathop_mismatch"); |
| 178 | 178 |
| 179 static SkPathOp region_op_to_pathops_op(SkRegion::Op op) { | 179 static SkPathOp region_op_to_pathops_op(SkCanvas::ClipOp op) { |
| 180 SkASSERT(op >= 0); | 180 SkASSERT(op >= 0); |
| 181 SkASSERT(op <= SkRegion::kReverseDifference_Op); | 181 SkASSERT(op <= SkCanvas::kReverseDifference_Op); |
| 182 return (SkPathOp)op; | 182 return (SkPathOp)op; |
| 183 } | 183 } |
| 184 | 184 |
| 185 /* Uses Path Ops to calculate a vector SkPath clip from a clip stack. | 185 /* Uses Path Ops to calculate a vector SkPath clip from a clip stack. |
| 186 * Returns true if successful, or false if not successful. | 186 * Returns true if successful, or false if not successful. |
| 187 * If successful, the resulting clip is stored in outClipPath. | 187 * If successful, the resulting clip is stored in outClipPath. |
| 188 * If not successful, outClipPath is undefined, and a fallback method | 188 * If not successful, outClipPath is undefined, and a fallback method |
| 189 * should be used. | 189 * should be used. |
| 190 */ | 190 */ |
| 191 static bool get_clip_stack_path(const SkMatrix& transform, | 191 static bool get_clip_stack_path(const SkMatrix& transform, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 202 SkPath entryPath; | 202 SkPath entryPath; |
| 203 if (SkClipStack::Element::kEmpty_Type == clipEntry->getType()) { | 203 if (SkClipStack::Element::kEmpty_Type == clipEntry->getType()) { |
| 204 outClipPath->reset(); | 204 outClipPath->reset(); |
| 205 outClipPath->setFillType(SkPath::kInverseWinding_FillType); | 205 outClipPath->setFillType(SkPath::kInverseWinding_FillType); |
| 206 continue; | 206 continue; |
| 207 } else { | 207 } else { |
| 208 clipEntry->asPath(&entryPath); | 208 clipEntry->asPath(&entryPath); |
| 209 } | 209 } |
| 210 entryPath.transform(transform); | 210 entryPath.transform(transform); |
| 211 | 211 |
| 212 if (SkRegion::kReplace_Op == clipEntry->getOp()) { | 212 if (SkCanvas::kReplace_Op == clipEntry->getOp()) { |
| 213 *outClipPath = entryPath; | 213 *outClipPath = entryPath; |
| 214 } else { | 214 } else { |
| 215 SkPathOp op = region_op_to_pathops_op(clipEntry->getOp()); | 215 SkPathOp op = region_op_to_pathops_op(clipEntry->getOp()); |
| 216 if (!Op(*outClipPath, entryPath, op, outClipPath)) { | 216 if (!Op(*outClipPath, entryPath, op, outClipPath)) { |
| 217 return false; | 217 return false; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 if (outClipPath->isInverseFillType()) { | 222 if (outClipPath->isInverseFillType()) { |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 if (clipStack == nullptr) { | 1746 if (clipStack == nullptr) { |
| 1747 if (clipRegion == fExistingClipRegion) { | 1747 if (clipRegion == fExistingClipRegion) { |
| 1748 clipStack = &fExistingClipStack; | 1748 clipStack = &fExistingClipStack; |
| 1749 } else { | 1749 } else { |
| 1750 // GraphicStackState::updateClip expects the clip stack to have | 1750 // GraphicStackState::updateClip expects the clip stack to have |
| 1751 // fExistingClip as a prefix, so start there, then set the clip | 1751 // fExistingClip as a prefix, so start there, then set the clip |
| 1752 // to the passed region. | 1752 // to the passed region. |
| 1753 synthesizedClipStack = fExistingClipStack; | 1753 synthesizedClipStack = fExistingClipStack; |
| 1754 SkPath clipPath; | 1754 SkPath clipPath; |
| 1755 clipRegion.getBoundaryPath(&clipPath); | 1755 clipRegion.getBoundaryPath(&clipPath); |
| 1756 synthesizedClipStack.clipDevPath(clipPath, SkRegion::kReplace_Op, | 1756 synthesizedClipStack.clipDevPath(clipPath, SkCanvas::kReplace_Op, |
| 1757 false); | 1757 false); |
| 1758 clipStack = &synthesizedClipStack; | 1758 clipStack = &synthesizedClipStack; |
| 1759 } | 1759 } |
| 1760 } | 1760 } |
| 1761 | 1761 |
| 1762 SkXfermode::Mode xfermode = SkXfermode::kSrcOver_Mode; | 1762 SkXfermode::Mode xfermode = SkXfermode::kSrcOver_Mode; |
| 1763 if (paint.getXfermode()) { | 1763 if (paint.getXfermode()) { |
| 1764 paint.getXfermode()->asMode(&xfermode); | 1764 paint.getXfermode()->asMode(&xfermode); |
| 1765 } | 1765 } |
| 1766 | 1766 |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 } | 2309 } |
| 2310 | 2310 |
| 2311 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { | 2311 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { |
| 2312 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), | 2312 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), |
| 2313 image->makeNonTextureImage()); | 2313 image->makeNonTextureImage()); |
| 2314 } | 2314 } |
| 2315 | 2315 |
| 2316 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { | 2316 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { |
| 2317 return nullptr; | 2317 return nullptr; |
| 2318 } | 2318 } |
| OLD | NEW |