Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1202)

Side by Side Diff: experimental/PdfViewer/SkPdfRenderer.cpp

Issue 22624002: pdfviewer: absolute minimal; to al least render (even if poorly) ICC based color spaces, based on R… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 SkDoubleToScalar(0), 1579 SkDoubleToScalar(0),
1580 SkDoubleToScalar(1)); 1580 SkDoubleToScalar(1));
1581 1581
1582 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix); 1582 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix);
1583 } 1583 }
1584 } 1584 }
1585 return kPartial_PdfResult; // TODO(edisonn): Implement fully DrawText befor e returing OK. 1585 return kPartial_PdfResult; // TODO(edisonn): Implement fully DrawText befor e returing OK.
1586 } 1586 }
1587 1587
1588 static PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo rOperator* colorOperator) { 1588 static PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo rOperator* colorOperator) {
1589 colorOperator->fColorSpace = pdfContext->fObjectStack.top()->strRef(); pd fContext->fObjectStack.pop(); 1589 SkPdfObject* name = pdfContext->fObjectStack.top(); pdfContext->fObjectSt ack.pop();
1590 return kOK_PdfResult; 1590
1591 //Next, get the ColorSpace Dictionary from the Resource Dictionary:
1592 SkPdfDictionary* colorSpaceResource = pdfContext->fGraphicsState.fResources- >ColorSpace(pdfContext->fPdfDoc);
1593
1594 SkPdfObject* colorSpace = pdfContext->fPdfDoc->resolveReference(colorSpaceRe source->get(name));
1595
1596 if (colorSpace == NULL) {
1597 colorOperator->fColorSpace = name->strRef();
1598 } else {
1599 #ifdef PDF_TRACE
1600 printf("CS = %s\n", colorSpace->toString(0, 0).c_str());
1601 #endif // PDF_TRACE
1602 if (colorSpace->isName()) {
1603 colorOperator->fColorSpace = colorSpace->strRef();
1604 } else if (colorSpace->isArray()) {
1605 int cnt = colorSpace->size();
1606 if (cnt == 0) {
1607 return kIgnoreError_PdfResult;
1608 }
1609 SkPdfObject* type = colorSpace->objAtAIndex(0);
1610 type = pdfContext->fPdfDoc->resolveReference(type);
1611
1612 if (type->isName("ICCBased")) {
1613 if (cnt != 2) {
1614 return kIgnoreError_PdfResult;
1615 }
1616 SkPdfObject* prop = colorSpace->objAtAIndex(1);
1617 prop = pdfContext->fPdfDoc->resolveReference(prop);
1618 #ifdef PDF_TRACE
1619 printf("ICCBased prop = %s\n", prop->toString(0, 0).c_str());
1620 #endif // PDF_TRACE
1621 // TODO(edisonn): hack
1622 if (prop && prop->isDictionary() && prop->get("N") && prop->get ("N")->isInteger() && prop->get("N")->intValue() == 3) {
1623 colorOperator->setColorSpace(&strings_DeviceRGB);
1624 return kPartial_PdfResult;
1625 }
1626 return kNYI_PdfResult;
1627 }
1628 }
1629 }
1630
1631 return kPartial_PdfResult;
1591 } 1632 }
1592 1633
1593 static PdfResult PdfOp_CS(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) { 1634 static PdfResult PdfOp_CS(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1594 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking ); 1635 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking );
1595 } 1636 }
1596 1637
1597 static PdfResult PdfOp_cs(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) { 1638 static PdfResult PdfOp_cs(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1598 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing); 1639 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing);
1599 } 1640 }
1600 1641
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 2663
2623 rect = SkRect::MakeWH(width, height); 2664 rect = SkRect::MakeWH(width, height);
2624 2665
2625 setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(hei ght)); 2666 setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(hei ght));
2626 2667
2627 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*output))); 2668 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*output)));
2628 SkCanvas canvas(device); 2669 SkCanvas canvas(device);
2629 2670
2630 return renderer.renderPage(page, &canvas, rect); 2671 return renderer.renderPage(page, &canvas, rect);
2631 } 2672 }
OLDNEW
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698