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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (pdfContext->fGraphicsState.fCurFontSize != 0) { | 381 if (pdfContext->fGraphicsState.fCurFontSize != 0) { |
382 paint.setTextSize(SkDoubleToScalar(pdfContext->fGraphicsState.fCurFontSi
ze)); | 382 paint.setTextSize(SkDoubleToScalar(pdfContext->fGraphicsState.fCurFontSi
ze)); |
383 } | 383 } |
384 | 384 |
385 // if (fCurFont && fCurFont->GetFontScale() != 0) { | 385 // if (fCurFont && fCurFont->GetFontScale() != 0) { |
386 // paint.setTextScaleX(SkFloatToScalar(fCurFont->GetFontScale() / 100.0))
; | 386 // paint.setTextScaleX(SkFloatToScalar(fCurFont->GetFontScale() / 100.0))
; |
387 // } | 387 // } |
388 | 388 |
389 pdfContext->fGraphicsState.applyGraphicsState(&paint, false); | 389 pdfContext->fGraphicsState.applyGraphicsState(&paint, false); |
390 | 390 |
391 canvas->save(); | |
392 | |
393 skfont->drawText(decoded, &paint, pdfContext, canvas); | 391 skfont->drawText(decoded, &paint, pdfContext, canvas); |
394 canvas->restore(); | |
395 | 392 |
396 return kOK_PdfResult; | 393 return kOK_PdfResult; |
397 } | 394 } |
398 | 395 |
399 // TODO(edisonn): create header files with declarations! | 396 // TODO(edisonn): create header files with declarations! |
400 PdfResult PdfOp_q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo
per); | 397 PdfResult PdfOp_q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo
per); |
401 PdfResult PdfOp_Q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo
per); | 398 PdfResult PdfOp_Q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo
per); |
402 PdfResult PdfOp_Tw(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo
oper); | 399 PdfResult PdfOp_Tw(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo
oper); |
403 PdfResult PdfOp_Tc(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo
oper); | 400 PdfResult PdfOp_Tc(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo
oper); |
404 | 401 |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 } | 1571 } |
1575 return kPartial_PdfResult; // TODO(edisonn): Implement fully DrawText befor
e returing OK. | 1572 return kPartial_PdfResult; // TODO(edisonn): Implement fully DrawText befor
e returing OK. |
1576 } | 1573 } |
1577 | 1574 |
1578 static PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo
rOperator* colorOperator) { | 1575 static PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo
rOperator* colorOperator) { |
1579 SkPdfObject* name = pdfContext->fObjectStack.top(); pdfContext->fObjectSt
ack.pop(); | 1576 SkPdfObject* name = pdfContext->fObjectStack.top(); pdfContext->fObjectSt
ack.pop(); |
1580 | 1577 |
1581 //Next, get the ColorSpace Dictionary from the Resource Dictionary: | 1578 //Next, get the ColorSpace Dictionary from the Resource Dictionary: |
1582 SkPdfDictionary* colorSpaceResource = pdfContext->fGraphicsState.fResources-
>ColorSpace(pdfContext->fPdfDoc); | 1579 SkPdfDictionary* colorSpaceResource = pdfContext->fGraphicsState.fResources-
>ColorSpace(pdfContext->fPdfDoc); |
1583 | 1580 |
1584 SkPdfObject* colorSpace = pdfContext->fPdfDoc->resolveReference(colorSpaceRe
source->get(name)); | 1581 SkPdfObject* colorSpace = colorSpaceResource ? pdfContext->fPdfDoc->resolveR
eference(colorSpaceResource->get(name)) : name; |
1585 | 1582 |
1586 if (colorSpace == NULL) { | 1583 if (colorSpace == NULL) { |
1587 colorOperator->fColorSpace = name->strRef(); | 1584 colorOperator->fColorSpace = name->strRef(); |
1588 } else { | 1585 } else { |
1589 #ifdef PDF_TRACE | 1586 #ifdef PDF_TRACE |
1590 printf("CS = %s\n", colorSpace->toString(0, 0).c_str()); | 1587 printf("CS = %s\n", colorSpace->toString(0, 0).c_str()); |
1591 #endif // PDF_TRACE | 1588 #endif // PDF_TRACE |
1592 if (colorSpace->isName()) { | 1589 if (colorSpace->isName()) { |
1593 colorOperator->fColorSpace = colorSpace->strRef(); | 1590 colorOperator->fColorSpace = colorSpace->strRef(); |
1594 } else if (colorSpace->isArray()) { | 1591 } else if (colorSpace->isArray()) { |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 | 2650 |
2654 rect = SkRect::MakeWH(width, height); | 2651 rect = SkRect::MakeWH(width, height); |
2655 | 2652 |
2656 setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(hei
ght)); | 2653 setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(hei
ght)); |
2657 | 2654 |
2658 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*output))); | 2655 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*output))); |
2659 SkCanvas canvas(device); | 2656 SkCanvas canvas(device); |
2660 | 2657 |
2661 return renderer.renderPage(page, &canvas, rect); | 2658 return renderer.renderPage(page, &canvas, rect); |
2662 } | 2659 } |
OLD | NEW |