OLD | NEW |
---|---|
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 Loading... | |
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) { | |
bungeman-skia
2016/08/22 19:28:18
Is the check for CW really needed? What's the outp
| |
131 //SkPDFUtils::AppendRectangle(rect, content); | |
bungeman-skia
2016/08/22 19:28:18
Either this should be written and used or the comm
| |
132 SkPDFUtils::AppendScalar(rect.left(), content); | |
133 content->writeText(" "); | |
134 SkPDFUtils::AppendScalar(rect.top(), content); | |
135 content->writeText(" "); | |
136 SkPDFUtils::AppendScalar(rect.width(), content); | |
137 content->writeText(" "); | |
138 SkPDFUtils::AppendScalar(rect.height(), content); | |
139 content->writeText(" re\n"); | |
140 return; | |
141 } | |
142 } | |
143 | |
125 enum SkipFillState { | 144 enum SkipFillState { |
126 kEmpty_SkipFillState, | 145 kEmpty_SkipFillState, |
127 kSingleLine_SkipFillState, | 146 kSingleLine_SkipFillState, |
128 kNonSingleLine_SkipFillState, | 147 kNonSingleLine_SkipFillState, |
129 }; | 148 }; |
130 SkipFillState fillState = kEmpty_SkipFillState; | 149 SkipFillState fillState = kEmpty_SkipFillState; |
131 //if (paintStyle != SkPaint::kFill_Style) { | 150 //if (paintStyle != SkPaint::kFill_Style) { |
132 // fillState = kNonSingleLine_SkipFillState; | 151 // fillState = kNonSingleLine_SkipFillState; |
133 //} | 152 //} |
134 SkPoint lastMovePt = SkPoint::Make(0,0); | 153 SkPoint lastMovePt = SkPoint::Make(0,0); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 uint8_t c = static_cast<uint8_t>(cin[i]); | 491 uint8_t c = static_cast<uint8_t>(cin[i]); |
473 static const char gHex[] = "0123456789ABCDEF"; | 492 static const char gHex[] = "0123456789ABCDEF"; |
474 char hexValue[2]; | 493 char hexValue[2]; |
475 hexValue[0] = gHex[(c >> 4) & 0xF]; | 494 hexValue[0] = gHex[(c >> 4) & 0xF]; |
476 hexValue[1] = gHex[ c & 0xF]; | 495 hexValue[1] = gHex[ c & 0xF]; |
477 wStream->write(hexValue, 2); | 496 wStream->write(hexValue, 2); |
478 } | 497 } |
479 wStream->writeText(">"); | 498 wStream->writeText(">"); |
480 } | 499 } |
481 } | 500 } |
OLD | NEW |