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

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: Created 4 years, 3 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) {
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
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 }
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