| 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[], int scalarsPerPos, | 198 const SkScalar pos[], SkScalar constY, |
| 199 const SkPoint& offset, const SkPaint& paint) SK_OVE
RRIDE { | 199 int scalarsPerPos, const SkPaint& paint) SK_OVERRID
E { |
| 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 SkPoint min = SkPoint::Make(offset.x() + pos[0], | 212 SkScalar y = scalarsPerPos == 1 ? constY : constY + pos[1]; |
| 213 offset.y() + (2 == scalarsPerPos ? pos[1] :
0)); | 213 |
| 214 SkPoint max = min; | 214 SkPoint min, max; |
| 215 min.set(pos[0], y); |
| 216 max.set(pos[0], y); |
| 215 | 217 |
| 216 for (size_t i = 1; i < len; ++i) { | 218 for (size_t i = 1; i < len; ++i) { |
| 217 SkScalar x = offset.x() + pos[i * scalarsPerPos]; | 219 SkScalar x = pos[i * scalarsPerPos]; |
| 218 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * 2 + 1] : 0); | 220 SkScalar y = constY; |
| 221 if (2 == scalarsPerPos) { |
| 222 y += pos[i * scalarsPerPos + 1]; |
| 223 } |
| 219 | 224 |
| 220 min.set(SkMinScalar(x, min.x()), SkMinScalar(y, min.y())); | 225 min.set(SkMinScalar(x, min.x()), SkMinScalar(y, min.y())); |
| 221 max.set(SkMaxScalar(x, max.x()), SkMaxScalar(y, max.y())); | 226 max.set(SkMaxScalar(x, max.x()), SkMaxScalar(y, max.y())); |
| 222 } | 227 } |
| 223 | 228 |
| 224 SkRect bounds = SkRect::MakeLTRB(min.x(), min.y(), max.x(), max.y()); | 229 SkRect bounds = SkRect::MakeLTRB(min.x(), min.y(), max.x(), max.y()); |
| 225 | 230 |
| 226 // Math is borrowed from SkBBoxRecord | 231 // Math is borrowed from SkBBoxRecord |
| 227 SkPaint::FontMetrics metrics; | 232 SkPaint::FontMetrics metrics; |
| 228 paint.getFontMetrics(&metrics); | 233 paint.getFontMetrics(&metrics); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 static void NotSupported() { | 317 static void NotSupported() { |
| 313 SkDEBUGFAIL("this method should never be called"); | 318 SkDEBUGFAIL("this method should never be called"); |
| 314 } | 319 } |
| 315 | 320 |
| 316 static void NothingToDo() {} | 321 static void NothingToDo() {} |
| 317 | 322 |
| 318 typedef SkBaseDevice INHERITED; | 323 typedef SkBaseDevice INHERITED; |
| 319 }; | 324 }; |
| 320 | 325 |
| 321 #endif // SkGatherPixelRefsAndRects_DEFINED | 326 #endif // SkGatherPixelRefsAndRects_DEFINED |
| OLD | NEW |