OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef SkGatherPixelRefsAndRects_DEFINED | 8 #ifndef SkGatherPixelRefsAndRects_DEFINED |
9 #define SkGatherPixelRefsAndRects_DEFINED | 9 #define SkGatherPixelRefsAndRects_DEFINED |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 SkScalar pad = (metrics.fBottom - metrics.fTop) / 2; | 190 SkScalar pad = (metrics.fBottom - metrics.fTop) / 2; |
191 bounds.fLeft -= pad; | 191 bounds.fLeft -= pad; |
192 bounds.fRight += pad; | 192 bounds.fRight += pad; |
193 bounds.offset(x, y); | 193 bounds.offset(x, y); |
194 | 194 |
195 this->drawRect(draw, bounds, paint); | 195 this->drawRect(draw, bounds, paint); |
196 } | 196 } |
197 virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, | 197 virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, |
198 const SkScalar pos[], SkScalar constY, | 198 const SkScalar pos[], int scalarsPerPos, |
199 int scalarsPerPos, const SkPaint& paint) SK_OVERRID
E { | 199 const SkPoint& offset, const SkPaint& paint) SK_OVE
RRIDE { |
200 SkBitmap bitmap; | 200 SkBitmap bitmap; |
201 if (!GetBitmapFromPaint(paint, &bitmap)) { | 201 if (!GetBitmapFromPaint(paint, &bitmap)) { |
202 return; | 202 return; |
203 } | 203 } |
204 | 204 |
205 if (0 == len) { | 205 if (0 == len) { |
206 return; | 206 return; |
207 } | 207 } |
208 | 208 |
209 // Similar to SkDraw asserts. | 209 // Similar to SkDraw asserts. |
210 SkASSERT(scalarsPerPos == 1 || scalarsPerPos == 2); | 210 SkASSERT(scalarsPerPos == 1 || scalarsPerPos == 2); |
211 | 211 |
212 SkScalar y = scalarsPerPos == 1 ? constY : constY + pos[1]; | 212 SkPoint min = SkPoint::Make(offset.x() + pos[0], |
213 | 213 offset.y() + (2 == scalarsPerPos ? pos[1] :
0)); |
214 SkPoint min, max; | 214 SkPoint max = min; |
215 min.set(pos[0], y); | |
216 max.set(pos[0], y); | |
217 | 215 |
218 for (size_t i = 1; i < len; ++i) { | 216 for (size_t i = 1; i < len; ++i) { |
219 SkScalar x = pos[i * scalarsPerPos]; | 217 SkScalar x = offset.x() + pos[i * scalarsPerPos]; |
220 SkScalar y = constY; | 218 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * 2 + 1] : 0); |
221 if (2 == scalarsPerPos) { | |
222 y += pos[i * scalarsPerPos + 1]; | |
223 } | |
224 | 219 |
225 min.set(SkMinScalar(x, min.x()), SkMinScalar(y, min.y())); | 220 min.set(SkMinScalar(x, min.x()), SkMinScalar(y, min.y())); |
226 max.set(SkMaxScalar(x, max.x()), SkMaxScalar(y, max.y())); | 221 max.set(SkMaxScalar(x, max.x()), SkMaxScalar(y, max.y())); |
227 } | 222 } |
228 | 223 |
229 SkRect bounds = SkRect::MakeLTRB(min.x(), min.y(), max.x(), max.y()); | 224 SkRect bounds = SkRect::MakeLTRB(min.x(), min.y(), max.x(), max.y()); |
230 | 225 |
231 // Math is borrowed from SkBBoxRecord | 226 // Math is borrowed from SkBBoxRecord |
232 SkPaint::FontMetrics metrics; | 227 SkPaint::FontMetrics metrics; |
233 paint.getFontMetrics(&metrics); | 228 paint.getFontMetrics(&metrics); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 static void NotSupported() { | 312 static void NotSupported() { |
318 SkDEBUGFAIL("this method should never be called"); | 313 SkDEBUGFAIL("this method should never be called"); |
319 } | 314 } |
320 | 315 |
321 static void NothingToDo() {} | 316 static void NothingToDo() {} |
322 | 317 |
323 typedef SkBaseDevice INHERITED; | 318 typedef SkBaseDevice INHERITED; |
324 }; | 319 }; |
325 | 320 |
326 #endif // SkGatherPixelRefsAndRects_DEFINED | 321 #endif // SkGatherPixelRefsAndRects_DEFINED |
OLD | NEW |