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 "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 clipPath.addRect(bounds); | 346 clipPath.addRect(bounds); |
347 | 347 |
348 return Op(clipPath, invPath, kIntersect_SkPathOp, outPath); | 348 return Op(clipPath, invPath, kIntersect_SkPathOp, outPath); |
349 } | 349 } |
350 | 350 |
351 #ifdef SK_PDF_USE_PATHOPS_CLIPPING | 351 #ifdef SK_PDF_USE_PATHOPS_CLIPPING |
352 // Sanity check the numerical values of the SkRegion ops and PathOps ops | 352 // Sanity check the numerical values of the SkRegion ops and PathOps ops |
353 // enums so region_op_to_pathops_op can do a straight passthrough cast. | 353 // enums so region_op_to_pathops_op can do a straight passthrough cast. |
354 // If these are failing, it may be necessary to make region_op_to_pathops_op | 354 // If these are failing, it may be necessary to make region_op_to_pathops_op |
355 // do more. | 355 // do more. |
356 SK_COMPILE_ASSERT(SkRegion::kDifference_Op == (int)kDifference_SkPathOp, | 356 static_assert(SkRegion::kDifference_Op == (int)kDifference_SkPathOp, "region_pat
hop_mismatch"); |
357 region_pathop_mismatch); | 357 static_assert(SkRegion::kIntersect_Op == (int)kIntersect_SkPathOp, "region_patho
p_mismatch"); |
358 SK_COMPILE_ASSERT(SkRegion::kIntersect_Op == (int)kIntersect_SkPathOp, | 358 static_assert(SkRegion::kUnion_Op == (int)kUnion_SkPathOp, "region_pathop_mismat
ch"); |
359 region_pathop_mismatch); | 359 static_assert(SkRegion::kXOR_Op == (int)kXOR_SkPathOp, "region_pathop_mismatch")
; |
360 SK_COMPILE_ASSERT(SkRegion::kUnion_Op == (int)kUnion_SkPathOp, | 360 static_assert(SkRegion::kReverseDifference_Op == (int)kReverseDifference_SkPathO
p, |
361 region_pathop_mismatch); | 361 "region_pathop_mismatch"); |
362 SK_COMPILE_ASSERT(SkRegion::kXOR_Op == (int)kXOR_SkPathOp, | |
363 region_pathop_mismatch); | |
364 SK_COMPILE_ASSERT(SkRegion::kReverseDifference_Op == | |
365 (int)kReverseDifference_SkPathOp, | |
366 region_pathop_mismatch); | |
367 | 362 |
368 static SkPathOp region_op_to_pathops_op(SkRegion::Op op) { | 363 static SkPathOp region_op_to_pathops_op(SkRegion::Op op) { |
369 SkASSERT(op >= 0); | 364 SkASSERT(op >= 0); |
370 SkASSERT(op <= SkRegion::kReverseDifference_Op); | 365 SkASSERT(op <= SkRegion::kReverseDifference_Op); |
371 return (SkPathOp)op; | 366 return (SkPathOp)op; |
372 } | 367 } |
373 | 368 |
374 /* Uses Path Ops to calculate a vector SkPath clip from a clip stack. | 369 /* Uses Path Ops to calculate a vector SkPath clip from a clip stack. |
375 * Returns true if successful, or false if not successful. | 370 * Returns true if successful, or false if not successful. |
376 * If successful, the resulting clip is stored in outClipPath. | 371 * If successful, the resulting clip is stored in outClipPath. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 547 |
553 if (state.fTextScaleX) { | 548 if (state.fTextScaleX) { |
554 if (state.fTextScaleX != currentEntry()->fTextScaleX) { | 549 if (state.fTextScaleX != currentEntry()->fTextScaleX) { |
555 SkScalar pdfScale = SkScalarMul(state.fTextScaleX, | 550 SkScalar pdfScale = SkScalarMul(state.fTextScaleX, |
556 SkIntToScalar(100)); | 551 SkIntToScalar(100)); |
557 SkPDFUtils::AppendScalar(pdfScale, fContentStream); | 552 SkPDFUtils::AppendScalar(pdfScale, fContentStream); |
558 fContentStream->writeText(" Tz\n"); | 553 fContentStream->writeText(" Tz\n"); |
559 currentEntry()->fTextScaleX = state.fTextScaleX; | 554 currentEntry()->fTextScaleX = state.fTextScaleX; |
560 } | 555 } |
561 if (state.fTextFill != currentEntry()->fTextFill) { | 556 if (state.fTextFill != currentEntry()->fTextFill) { |
562 SK_COMPILE_ASSERT(SkPaint::kFill_Style == 0, enum_must_match_value); | 557 static_assert(SkPaint::kFill_Style == 0, "enum_must_match_value"); |
563 SK_COMPILE_ASSERT(SkPaint::kStroke_Style == 1, | 558 static_assert(SkPaint::kStroke_Style == 1, "enum_must_match_value"); |
564 enum_must_match_value); | 559 static_assert(SkPaint::kStrokeAndFill_Style == 2, "enum_must_match_v
alue"); |
565 SK_COMPILE_ASSERT(SkPaint::kStrokeAndFill_Style == 2, | |
566 enum_must_match_value); | |
567 fContentStream->writeDecAsText(state.fTextFill); | 560 fContentStream->writeDecAsText(state.fTextFill); |
568 fContentStream->writeText(" Tr\n"); | 561 fContentStream->writeText(" Tr\n"); |
569 currentEntry()->fTextFill = state.fTextFill; | 562 currentEntry()->fTextFill = state.fTextFill; |
570 } | 563 } |
571 } | 564 } |
572 } | 565 } |
573 | 566 |
574 static bool not_supported_for_layers(const SkPaint& layerPaint) { | 567 static bool not_supported_for_layers(const SkPaint& layerPaint) { |
575 // PDF does not support image filters, so render them on CPU. | 568 // PDF does not support image filters, so render them on CPU. |
576 // Note that this rendering is done at "screen" resolution (100dpi), not | 569 // Note that this rendering is done at "screen" resolution (100dpi), not |
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 return; | 2195 return; |
2203 } | 2196 } |
2204 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); | 2197 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); |
2205 if (!image) { | 2198 if (!image) { |
2206 return; | 2199 return; |
2207 } | 2200 } |
2208 | 2201 |
2209 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2202 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2210 &content.entry()->fContent); | 2203 &content.entry()->fContent); |
2211 } | 2204 } |
OLD | NEW |