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

Side by Side Diff: src/pdf/SkPDFDevice.cpp

Issue 2151863003: SkPdf: smaller color serialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkFixed - 2016-07-15 (Friday) 15:45:32 EDT Created 4 years, 5 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
« no previous file with comments | « bench/PDFBench.cpp ('k') | src/pdf/SkPDFShader.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 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 "SkAnnotationKeys.h" 10 #include "SkAnnotationKeys.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // kSrcOver_Mode. http://crbug.com/473572 44 // kSrcOver_Mode. http://crbug.com/473572
45 static void replace_srcmode_on_opaque_paint(SkPaint* paint) { 45 static void replace_srcmode_on_opaque_paint(SkPaint* paint) {
46 if (kSrcOver_SkXfermodeInterpretation 46 if (kSrcOver_SkXfermodeInterpretation
47 == SkInterpretXfermode(*paint, false)) { 47 == SkInterpretXfermode(*paint, false)) {
48 paint->setXfermode(nullptr); 48 paint->setXfermode(nullptr);
49 } 49 }
50 } 50 }
51 51
52 static void emit_pdf_color(SkColor color, SkWStream* result) { 52 static void emit_pdf_color(SkColor color, SkWStream* result) {
53 SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere. 53 SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere.
54 SkScalar colorScale = SkScalarInvert(0xFF); 54 SkPDFUtils::AppendColorComponent(SkColorGetR(color), result);
55 SkPDFUtils::AppendScalar(SkColorGetR(color) * colorScale, result);
56 result->writeText(" "); 55 result->writeText(" ");
57 SkPDFUtils::AppendScalar(SkColorGetG(color) * colorScale, result); 56 SkPDFUtils::AppendColorComponent(SkColorGetG(color), result);
58 result->writeText(" "); 57 result->writeText(" ");
59 SkPDFUtils::AppendScalar(SkColorGetB(color) * colorScale, result); 58 SkPDFUtils::AppendColorComponent(SkColorGetB(color), result);
60 result->writeText(" "); 59 result->writeText(" ");
61 } 60 }
62 61
63 static SkPaint calculate_text_paint(const SkPaint& paint) { 62 static SkPaint calculate_text_paint(const SkPaint& paint) {
64 SkPaint result = paint; 63 SkPaint result = paint;
65 if (result.isFakeBoldText()) { 64 if (result.isFakeBoldText()) {
66 SkScalar fakeBoldScale = SkScalarInterpFunc(result.getTextSize(), 65 SkScalar fakeBoldScale = SkScalarInterpFunc(result.getTextSize(),
67 kStdFakeBoldInterpKeys, 66 kStdFakeBoldInterpKeys,
68 kStdFakeBoldInterpValues, 67 kStdFakeBoldInterpValues,
69 kStdFakeBoldInterpLength); 68 kStdFakeBoldInterpLength);
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 if (!pdfimage) { 2120 if (!pdfimage) {
2122 return; 2121 return;
2123 } 2122 }
2124 fDocument->serialize(pdfimage); // serialize images early. 2123 fDocument->serialize(pdfimage); // serialize images early.
2125 fDocument->canon()->addPDFBitmap(key, pdfimage); 2124 fDocument->canon()->addPDFBitmap(key, pdfimage);
2126 } 2125 }
2127 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> 2126 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject>
2128 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), 2127 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()),
2129 &content.entry()->fContent); 2128 &content.entry()->fContent);
2130 } 2129 }
OLDNEW
« no previous file with comments | « bench/PDFBench.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698