OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPdfRenderer.h" | 8 #include "SkPdfRenderer.h" |
9 | 9 |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 SkPdfNativeObject::kArray_PdfObjectType, pdfCo
ntext); | 1775 SkPdfNativeObject::kArray_PdfObjectType, pdfCo
ntext); |
1776 return kIgnoreError_SkPdfResult; | 1776 return kIgnoreError_SkPdfResult; |
1777 } | 1777 } |
1778 | 1778 |
1779 for( int i=0; i<static_cast<int>(array->size()); i++ ) | 1779 for( int i=0; i<static_cast<int>(array->size()); i++ ) |
1780 { | 1780 { |
1781 if (!(*array)[i]) { | 1781 if (!(*array)[i]) { |
1782 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, | 1782 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, |
1783 "element [i] is null, no element should be
null", | 1783 "element [i] is null, no element should be
null", |
1784 array, | 1784 array, |
1785 SkPdfNativeObject::_kAnyString_PdfObjectTy
pe || | 1785 SkPdfNativeObject::_kAnyString_PdfObjectTy
pe | |
1786 SkPdfNativeObject::_kNumber_PdfObj
ectType, | 1786 SkPdfNativeObject::_kNumber_PdfObj
ectType, |
1787 pdfContext); | 1787 pdfContext); |
1788 } else if( (*array)[i]->isAnyString()) { | 1788 } else if( (*array)[i]->isAnyString()) { |
1789 SkPdfNativeObject* obj = (*array)[i]; | 1789 SkPdfNativeObject* obj = (*array)[i]; |
1790 DrawText(pdfContext, obj, canvas); | 1790 DrawText(pdfContext, obj, canvas); |
1791 } else if ((*array)[i]->isNumber()) { | 1791 } else if ((*array)[i]->isNumber()) { |
1792 double dx = (*array)[i]->numberValue(); | 1792 double dx = (*array)[i]->numberValue(); |
1793 SkMatrix matrix; | 1793 SkMatrix matrix; |
1794 matrix.setAll(SkDoubleToScalar(1), | 1794 matrix.setAll(SkDoubleToScalar(1), |
1795 SkDoubleToScalar(0), | 1795 SkDoubleToScalar(0), |
1796 // TODO(edisonn): use writing mode, vertical/horizonta
l. | 1796 // TODO(edisonn): use writing mode, vertical/horizonta
l. |
1797 SkDoubleToScalar(-dx), // amount is substracted!!! | 1797 SkDoubleToScalar(-dx), // amount is substracted!!! |
1798 SkDoubleToScalar(0), | 1798 SkDoubleToScalar(0), |
1799 SkDoubleToScalar(1), | 1799 SkDoubleToScalar(1), |
1800 SkDoubleToScalar(0), | 1800 SkDoubleToScalar(0), |
1801 SkDoubleToScalar(0), | 1801 SkDoubleToScalar(0), |
1802 SkDoubleToScalar(0), | 1802 SkDoubleToScalar(0), |
1803 SkDoubleToScalar(1)); | 1803 SkDoubleToScalar(1)); |
1804 | 1804 |
1805 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix); | 1805 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix); |
1806 } else { | 1806 } else { |
1807 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, "wrong ty
pe", (*array)[i], | 1807 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, "wrong ty
pe", (*array)[i], |
1808 SkPdfNativeObject::kArray_PdfObjectType || | 1808 SkPdfNativeObject::kArray_PdfObjectType | |
1809 SkPdfNativeObject::_kNumber_PdfObj
ectType, | 1809 SkPdfNativeObject::_kNumber_PdfObj
ectType, |
1810 pdfContext); | 1810 pdfContext); |
1811 } | 1811 } |
1812 } | 1812 } |
1813 return kPartial_SkPdfResult; // TODO(edisonn): Implement fully DrawText bef
ore returing OK. | 1813 return kPartial_SkPdfResult; // TODO(edisonn): Implement fully DrawText bef
ore returing OK. |
1814 } | 1814 } |
1815 | 1815 |
1816 static SkPdfResult PdfOp_CS_cs(SkPdfContext* pdfContext, SkCanvas* canvas, | 1816 static SkPdfResult PdfOp_CS_cs(SkPdfContext* pdfContext, SkCanvas* canvas, |
1817 SkPdfColorOperator* colorOperator) { | 1817 SkPdfColorOperator* colorOperator) { |
1818 EXPECT_OPERANDS("CS/cs", pdfContext, 1); | 1818 EXPECT_OPERANDS("CS/cs", pdfContext, 1); |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 skpdfGraphicsStateApplyFont(pdfContext, gs->Font(pdfContext->fPdfDoc)); | 2514 skpdfGraphicsStateApplyFont(pdfContext, gs->Font(pdfContext->fPdfDoc)); |
2515 } | 2515 } |
2516 | 2516 |
2517 if (gs->has_BM()) { | 2517 if (gs->has_BM()) { |
2518 if (gs->isBMAName(pdfContext->fPdfDoc)) { | 2518 if (gs->isBMAName(pdfContext->fPdfDoc)) { |
2519 skpdfGraphicsStateApplyBM_name(pdfContext, gs->getBMAsName(pdfContex
t->fPdfDoc)); | 2519 skpdfGraphicsStateApplyBM_name(pdfContext, gs->getBMAsName(pdfContex
t->fPdfDoc)); |
2520 } else if (gs->isBMAArray(pdfContext->fPdfDoc)) { | 2520 } else if (gs->isBMAArray(pdfContext->fPdfDoc)) { |
2521 skpdfGraphicsStateApplyBM_array(pdfContext, gs->getBMAsArray(pdfCont
ext->fPdfDoc)); | 2521 skpdfGraphicsStateApplyBM_array(pdfContext, gs->getBMAsArray(pdfCont
ext->fPdfDoc)); |
2522 } else { | 2522 } else { |
2523 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, "wrong ty
pe", gs->get("BM"), | 2523 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, "wrong ty
pe", gs->get("BM"), |
2524 SkPdfNativeObject::kArray_PdfObjectType || | 2524 SkPdfNativeObject::kArray_PdfObjectType | |
2525 SkPdfNativeObject::kName_PdfObject
Type, pdfContext); | 2525 SkPdfNativeObject::kName_PdfObject
Type, pdfContext); |
2526 } | 2526 } |
2527 } | 2527 } |
2528 | 2528 |
2529 if (gs->has_SMask()) { | 2529 if (gs->has_SMask()) { |
2530 if (gs->isSMaskAName(pdfContext->fPdfDoc)) { | 2530 if (gs->isSMaskAName(pdfContext->fPdfDoc)) { |
2531 skpdfGraphicsStateApplySMask_name(pdfContext, gs->getSMaskAsName(pdf
Context->fPdfDoc)); | 2531 skpdfGraphicsStateApplySMask_name(pdfContext, gs->getSMaskAsName(pdf
Context->fPdfDoc)); |
2532 } else if (gs->isSMaskADictionary(pdfContext->fPdfDoc)) { | 2532 } else if (gs->isSMaskADictionary(pdfContext->fPdfDoc)) { |
2533 skpdfGraphicsStateApplySMask_dict(pdfContext, | 2533 skpdfGraphicsStateApplySMask_dict(pdfContext, |
2534 gs->getSMaskAsDictionary(pdfContex
t->fPdfDoc)); | 2534 gs->getSMaskAsDictionary(pdfContex
t->fPdfDoc)); |
2535 } else { | 2535 } else { |
2536 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, | 2536 SkPdfReportUnexpectedType(kIgnoreError_SkPdfIssueSeverity, |
2537 "wrong type", | 2537 "wrong type", |
2538 gs->get("BM"), | 2538 gs->get("BM"), |
2539 SkPdfNativeObject::kDictionary_PdfObjectTy
pe || | 2539 SkPdfNativeObject::kDictionary_PdfObjectTy
pe | |
2540 SkPdfNativeObject::kName_PdfObject
Type, | 2540 SkPdfNativeObject::kName_PdfObject
Type, |
2541 pdfContext); | 2541 pdfContext); |
2542 } | 2542 } |
2543 } | 2543 } |
2544 | 2544 |
2545 if (gs->has_ca()) { | 2545 if (gs->has_ca()) { |
2546 skpdfGraphicsStateApply_ca(pdfContext, gs->ca(pdfContext->fPdfDoc)); | 2546 skpdfGraphicsStateApply_ca(pdfContext, gs->ca(pdfContext->fPdfDoc)); |
2547 } | 2547 } |
2548 | 2548 |
2549 if (gs->has_CA()) { | 2549 if (gs->has_CA()) { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3150 | 3150 |
3151 rect = SkRect::MakeWH(width, height); | 3151 rect = SkRect::MakeWH(width, height); |
3152 | 3152 |
3153 setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(hei
ght)); | 3153 setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(hei
ght)); |
3154 | 3154 |
3155 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*output))); | 3155 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*output))); |
3156 SkCanvas canvas(device); | 3156 SkCanvas canvas(device); |
3157 | 3157 |
3158 return renderer.renderPage(page, &canvas, rect); | 3158 return renderer.renderPage(page, &canvas, rect); |
3159 } | 3159 } |
OLD | NEW |