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

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

Issue 2269593003: SkPDF: paths as rects when possible (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-22 (Monday) 15:43:33 EDT Created 4 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
« no previous file with comments | « no previous file | no next file » | 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 8
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkFixed.h" 10 #include "SkFixed.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 content->writeText(" re\n"); 115 content->writeText(" re\n");
116 } 116 }
117 117
118 // static 118 // static
119 void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle, 119 void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
120 bool doConsumeDegerates, SkWStream* content) { 120 bool doConsumeDegerates, SkWStream* content) {
121 // Filling a path with no area results in a drawing in PDF renderers but 121 // Filling a path with no area results in a drawing in PDF renderers but
122 // Chrome expects to be able to draw some such entities with no visible 122 // Chrome expects to be able to draw some such entities with no visible
123 // result, so we detect those cases and discard the drawing for them. 123 // result, so we detect those cases and discard the drawing for them.
124 // Specifically: moveTo(X), lineTo(Y) and moveTo(X), lineTo(X), lineTo(Y). 124 // Specifically: moveTo(X), lineTo(Y) and moveTo(X), lineTo(X), lineTo(Y).
125
126 SkRect rect;
127 bool isClosed;
128 SkPath::Direction direction;
129 if (path.isRect(&rect, &isClosed, &direction)) {
130 if (isClosed && SkPath::kCW_Direction == direction) {
131 SkPDFUtils::AppendScalar(rect.left(), content);
132 content->writeText(" ");
133 SkPDFUtils::AppendScalar(rect.top(), content);
134 content->writeText(" ");
135 SkPDFUtils::AppendScalar(rect.width(), content);
136 content->writeText(" ");
137 SkPDFUtils::AppendScalar(rect.height(), content);
138 content->writeText(" re\n");
139 return;
140 }
141 }
142
125 enum SkipFillState { 143 enum SkipFillState {
126 kEmpty_SkipFillState, 144 kEmpty_SkipFillState,
127 kSingleLine_SkipFillState, 145 kSingleLine_SkipFillState,
128 kNonSingleLine_SkipFillState, 146 kNonSingleLine_SkipFillState,
129 }; 147 };
130 SkipFillState fillState = kEmpty_SkipFillState; 148 SkipFillState fillState = kEmpty_SkipFillState;
131 //if (paintStyle != SkPaint::kFill_Style) { 149 //if (paintStyle != SkPaint::kFill_Style) {
132 // fillState = kNonSingleLine_SkipFillState; 150 // fillState = kNonSingleLine_SkipFillState;
133 //} 151 //}
134 SkPoint lastMovePt = SkPoint::Make(0,0); 152 SkPoint lastMovePt = SkPoint::Make(0,0);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 uint8_t c = static_cast<uint8_t>(cin[i]); 490 uint8_t c = static_cast<uint8_t>(cin[i]);
473 static const char gHex[] = "0123456789ABCDEF"; 491 static const char gHex[] = "0123456789ABCDEF";
474 char hexValue[2]; 492 char hexValue[2];
475 hexValue[0] = gHex[(c >> 4) & 0xF]; 493 hexValue[0] = gHex[(c >> 4) & 0xF];
476 hexValue[1] = gHex[ c & 0xF]; 494 hexValue[1] = gHex[ c & 0xF];
477 wStream->write(hexValue, 2); 495 wStream->write(hexValue, 2);
478 } 496 }
479 wStream->writeText(">"); 497 wStream->writeText(">");
480 } 498 }
481 } 499 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698