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

Side by Side Diff: src/core/SkBBoxRecord.cpp

Issue 22585002: Add SkCanvas::drawPosTextBounded. (Closed) Base URL: http://skia.googlecode.com/svn/trunk
Patch Set: spelling correction Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBBoxRecord.h ('k') | src/core/SkCanvas.cpp » ('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 /* 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
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) {
tomhudson 2013/08/07 15:48:39 Is it worth putting in an SkASSERT here that the b
182 if (this->transformBounds(bbox, &paint)) {
183 INHERITED::drawPosText(text, byteLength, pos, paint);
184 }
185 }
186
179 void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[], 187 void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[],
180 SkScalar constY, const SkPaint& paint) { 188 SkScalar constY, const SkPaint& paint) {
181 SkRect bbox; 189 SkRect bbox;
182 size_t numChars = paint.countText(text, byteLength); 190 size_t numChars = paint.countText(text, byteLength);
183 if (numChars > 0) { 191 if (numChars > 0) {
184 bbox.fLeft = xpos[0]; 192 bbox.fLeft = xpos[0];
185 bbox.fRight = xpos[numChars - 1]; 193 bbox.fRight = xpos[numChars - 1];
186 // if we had a guarantee that these will be monotonically increasing, th is could be sped up 194 // if we had a guarantee that these will be monotonically increasing, th is could be sped up
187 for (size_t i = 1; i < numChars; ++i) { 195 for (size_t i = 1; i < numChars; ++i) {
188 if (xpos[i] < bbox.fLeft) { 196 if (xpos[i] < bbox.fLeft) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 283 }
276 284
277 if (!outBounds.isEmpty() && !this->quickReject(outBounds)) { 285 if (!outBounds.isEmpty() && !this->quickReject(outBounds)) {
278 this->getTotalMatrix().mapRect(&outBounds); 286 this->getTotalMatrix().mapRect(&outBounds);
279 this->handleBBox(outBounds); 287 this->handleBBox(outBounds);
280 return true; 288 return true;
281 } 289 }
282 290
283 return false; 291 return false;
284 } 292 }
OLDNEW
« no previous file with comments | « src/core/SkBBoxRecord.h ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698