OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBBoxRecord.h" | 9 #include "SkBBoxRecord.h" |
10 | 10 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // pad on left and right by half of max vertical glyph extents | 169 // pad on left and right by half of max vertical glyph extents |
170 SkScalar pad = (metrics.fTop - metrics.fBottom) / 2; | 170 SkScalar pad = (metrics.fTop - metrics.fBottom) / 2; |
171 bbox.fLeft += pad; | 171 bbox.fLeft += pad; |
172 bbox.fRight -= pad; | 172 bbox.fRight -= pad; |
173 | 173 |
174 if (this->transformBounds(bbox, &paint)) { | 174 if (this->transformBounds(bbox, &paint)) { |
175 INHERITED::drawPosText(text, byteLength, pos, paint); | 175 INHERITED::drawPosText(text, byteLength, pos, paint); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 void SkBBoxRecord::drawPosTextBounded(const void* text, size_t byteLength, | |
180 const SkPoint pos[], const SkRect& bbox, | |
181 const SkPaint& paint) { | |
182 if (this->transformBounds(bbox, &paint)) { | |
183 INHERITED::drawPosText(text, byteLength, pos, paint); | |
184 } | |
185 } | |
186 | |
187 void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], | 179 void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], |
188 SkScalar constY, const SkPaint& paint) { | 180 SkScalar constY, const SkPaint& paint) { |
189 SkRect bbox; | 181 SkRect bbox; |
190 size_t numChars = paint.countText(text, byteLength); | 182 size_t numChars = paint.countText(text, byteLength); |
191 if (numChars > 0) { | 183 if (numChars > 0) { |
192 bbox.fLeft = xpos[0]; | 184 bbox.fLeft = xpos[0]; |
193 bbox.fRight = xpos[numChars - 1]; | 185 bbox.fRight = xpos[numChars - 1]; |
194 // if we had a guarantee that these will be monotonically increasing, th
is could be sped up | 186 // if we had a guarantee that these will be monotonically increasing, th
is could be sped up |
195 for (size_t i = 1; i < numChars; ++i) { | 187 for (size_t i = 1; i < numChars; ++i) { |
196 if (xpos[i] < bbox.fLeft) { | 188 if (xpos[i] < bbox.fLeft) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 275 } |
284 | 276 |
285 if (!outBounds.isEmpty() && !this->quickReject(outBounds)) { | 277 if (!outBounds.isEmpty() && !this->quickReject(outBounds)) { |
286 this->getTotalMatrix().mapRect(&outBounds); | 278 this->getTotalMatrix().mapRect(&outBounds); |
287 this->handleBBox(outBounds); | 279 this->handleBBox(outBounds); |
288 return true; | 280 return true; |
289 } | 281 } |
290 | 282 |
291 return false; | 283 return false; |
292 } | 284 } |
OLD | NEW |