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

Side by Side Diff: src/pdf/SkPDFTypes.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 | « src/pdf/SkPDFTypes.h ('k') | src/pdf/SkPDFUtils.h » ('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 "SkDeflate.h" 8 #include "SkDeflate.h"
9 #include "SkPDFTypes.h" 9 #include "SkPDFTypes.h"
10 #include "SkPDFUtils.h" 10 #include "SkPDFUtils.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 } 112 }
113 113
114 void SkPDFUnion::emitObject(SkWStream* stream, 114 void SkPDFUnion::emitObject(SkWStream* stream,
115 const SkPDFObjNumMap& objNumMap, 115 const SkPDFObjNumMap& objNumMap,
116 const SkPDFSubstituteMap& substitutes) const { 116 const SkPDFSubstituteMap& substitutes) const {
117 switch (fType) { 117 switch (fType) {
118 case Type::kInt: 118 case Type::kInt:
119 stream->writeDecAsText(fIntValue); 119 stream->writeDecAsText(fIntValue);
120 return; 120 return;
121 case Type::kColorComponent:
122 SkPDFUtils::AppendColorComponent(SkToU8(fIntValue), stream);
123 return;
121 case Type::kBool: 124 case Type::kBool:
122 stream->writeText(fBoolValue ? "true" : "false"); 125 stream->writeText(fBoolValue ? "true" : "false");
123 return; 126 return;
124 case Type::kScalar: 127 case Type::kScalar:
125 SkPDFUtils::AppendScalar(fScalarValue, stream); 128 SkPDFUtils::AppendScalar(fScalarValue, stream);
126 return; 129 return;
127 case Type::kName: 130 case Type::kName:
128 stream->writeText("/"); 131 stream->writeText("/");
129 SkASSERT(is_valid_name(fStaticString)); 132 SkASSERT(is_valid_name(fStaticString));
130 stream->writeText(fStaticString); 133 stream->writeText(fStaticString);
(...skipping 21 matching lines...) Expand all
152 return; 155 return;
153 default: 156 default:
154 SkDEBUGFAIL("SkPDFUnion::emitObject with bad type"); 157 SkDEBUGFAIL("SkPDFUnion::emitObject with bad type");
155 } 158 }
156 } 159 }
157 160
158 void SkPDFUnion::addResources(SkPDFObjNumMap* objNumMap, 161 void SkPDFUnion::addResources(SkPDFObjNumMap* objNumMap,
159 const SkPDFSubstituteMap& substituteMap) const { 162 const SkPDFSubstituteMap& substituteMap) const {
160 switch (fType) { 163 switch (fType) {
161 case Type::kInt: 164 case Type::kInt:
165 case Type::kColorComponent:
162 case Type::kBool: 166 case Type::kBool:
163 case Type::kScalar: 167 case Type::kScalar:
164 case Type::kName: 168 case Type::kName:
165 case Type::kString: 169 case Type::kString:
166 case Type::kNameSkS: 170 case Type::kNameSkS:
167 case Type::kStringSkS: 171 case Type::kStringSkS:
168 return; // These have no resources. 172 return; // These have no resources.
169 case Type::kObjRef: { 173 case Type::kObjRef: {
170 SkPDFObject* obj = substituteMap.getSubstitute(fObject); 174 SkPDFObject* obj = substituteMap.getSubstitute(fObject);
171 objNumMap->addObjectRecursively(obj, substituteMap); 175 objNumMap->addObjectRecursively(obj, substituteMap);
172 return; 176 return;
173 } 177 }
174 case Type::kObject: 178 case Type::kObject:
175 fObject->addResources(objNumMap, substituteMap); 179 fObject->addResources(objNumMap, substituteMap);
176 return; 180 return;
177 default: 181 default:
178 SkDEBUGFAIL("SkPDFUnion::addResources with bad type"); 182 SkDEBUGFAIL("SkPDFUnion::addResources with bad type");
179 } 183 }
180 } 184 }
181 185
182 SkPDFUnion SkPDFUnion::Int(int32_t value) { 186 SkPDFUnion SkPDFUnion::Int(int32_t value) {
183 SkPDFUnion u(Type::kInt); 187 SkPDFUnion u(Type::kInt);
184 u.fIntValue = value; 188 u.fIntValue = value;
185 return u; 189 return u;
186 } 190 }
187 191
192 SkPDFUnion SkPDFUnion::ColorComponent(uint8_t value) {
193 SkPDFUnion u(Type::kColorComponent);
194 u.fIntValue = value;
195 return u;
196 }
197
188 SkPDFUnion SkPDFUnion::Bool(bool value) { 198 SkPDFUnion SkPDFUnion::Bool(bool value) {
189 SkPDFUnion u(Type::kBool); 199 SkPDFUnion u(Type::kBool);
190 u.fBoolValue = value; 200 u.fBoolValue = value;
191 return u; 201 return u;
192 } 202 }
193 203
194 SkPDFUnion SkPDFUnion::Scalar(SkScalar value) { 204 SkPDFUnion SkPDFUnion::Scalar(SkScalar value) {
195 SkPDFUnion u(Type::kScalar); 205 SkPDFUnion u(Type::kScalar);
196 u.fScalarValue = value; 206 u.fScalarValue = value;
197 return u; 207 return u;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 303 }
294 304
295 void SkPDFArray::append(SkPDFUnion&& value) { 305 void SkPDFArray::append(SkPDFUnion&& value) {
296 fValues.emplace_back(std::move(value)); 306 fValues.emplace_back(std::move(value));
297 } 307 }
298 308
299 void SkPDFArray::appendInt(int32_t value) { 309 void SkPDFArray::appendInt(int32_t value) {
300 this->append(SkPDFUnion::Int(value)); 310 this->append(SkPDFUnion::Int(value));
301 } 311 }
302 312
313 void SkPDFArray::appendColorComponent(uint8_t value) {
314 this->append(SkPDFUnion::ColorComponent(value));
315 }
316
303 void SkPDFArray::appendBool(bool value) { 317 void SkPDFArray::appendBool(bool value) {
304 this->append(SkPDFUnion::Bool(value)); 318 this->append(SkPDFUnion::Bool(value));
305 } 319 }
306 320
307 void SkPDFArray::appendScalar(SkScalar value) { 321 void SkPDFArray::appendScalar(SkScalar value) {
308 this->append(SkPDFUnion::Scalar(value)); 322 this->append(SkPDFUnion::Scalar(value));
309 } 323 }
310 324
311 void SkPDFArray::appendName(const char name[]) { 325 void SkPDFArray::appendName(const char name[]) {
312 this->append(SkPDFUnion::Name(SkString(name))); 326 this->append(SkPDFUnion::Name(SkString(name)));
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 578
565 void SkPDFImageDumpStats() { 579 void SkPDFImageDumpStats() {
566 SkDebugf("\ntotal PDF drawImage/drawBitmap calls: %d\n" 580 SkDebugf("\ntotal PDF drawImage/drawBitmap calls: %d\n"
567 "total PDF jpeg images: %d\n" 581 "total PDF jpeg images: %d\n"
568 "total PDF regular images: %d\n", 582 "total PDF regular images: %d\n",
569 gDrawImageCalls.load(), 583 gDrawImageCalls.load(),
570 gJpegImageObjects.load(), 584 gJpegImageObjects.load(),
571 gRegularImageObjects.load()); 585 gRegularImageObjects.load());
572 } 586 }
573 #endif // SK_PDF_IMAGE_STATS 587 #endif // SK_PDF_IMAGE_STATS
OLDNEW
« no previous file with comments | « src/pdf/SkPDFTypes.h ('k') | src/pdf/SkPDFUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698