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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/SkPdfRenderer.cpp
===================================================================
--- experimental/PdfViewer/SkPdfRenderer.cpp (revision 10617)
+++ experimental/PdfViewer/SkPdfRenderer.cpp (working copy)
@@ -1586,8 +1586,49 @@
}
static PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOperator* colorOperator) {
- colorOperator->fColorSpace = pdfContext->fObjectStack.top()->strRef(); pdfContext->fObjectStack.pop();
- return kOK_PdfResult;
+ SkPdfObject* name = pdfContext->fObjectStack.top(); pdfContext->fObjectStack.pop();
+
+ //Next, get the ColorSpace Dictionary from the Resource Dictionary:
+ SkPdfDictionary* colorSpaceResource = pdfContext->fGraphicsState.fResources->ColorSpace(pdfContext->fPdfDoc);
+
+ SkPdfObject* colorSpace = pdfContext->fPdfDoc->resolveReference(colorSpaceResource->get(name));
+
+ if (colorSpace == NULL) {
+ colorOperator->fColorSpace = name->strRef();
+ } else {
+#ifdef PDF_TRACE
+ printf("CS = %s\n", colorSpace->toString(0, 0).c_str());
+#endif // PDF_TRACE
+ if (colorSpace->isName()) {
+ colorOperator->fColorSpace = colorSpace->strRef();
+ } else if (colorSpace->isArray()) {
+ int cnt = colorSpace->size();
+ if (cnt == 0) {
+ return kIgnoreError_PdfResult;
+ }
+ SkPdfObject* type = colorSpace->objAtAIndex(0);
+ type = pdfContext->fPdfDoc->resolveReference(type);
+
+ if (type->isName("ICCBased")) {
+ if (cnt != 2) {
+ return kIgnoreError_PdfResult;
+ }
+ SkPdfObject* prop = colorSpace->objAtAIndex(1);
+ prop = pdfContext->fPdfDoc->resolveReference(prop);
+#ifdef PDF_TRACE
+ printf("ICCBased prop = %s\n", prop->toString(0, 0).c_str());
+#endif // PDF_TRACE
+ // TODO(edisonn): hack
+ if (prop && prop->isDictionary() && prop->get("N") && prop->get("N")->isInteger() && prop->get("N")->intValue() == 3) {
+ colorOperator->setColorSpace(&strings_DeviceRGB);
+ return kPartial_PdfResult;
+ }
+ return kNYI_PdfResult;
+ }
+ }
+ }
+
+ return kPartial_PdfResult;
}
static PdfResult PdfOp_CS(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** looper) {
« 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