| 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 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 drawTestCase(canvas, "Center Align", 4 * kTextHeight, paint); | 52 drawTestCase(canvas, "Center Align", 4 * kTextHeight, paint); |
| 53 | 53 |
| 54 paint.setTextAlign(SkPaint::kLeft_Align); | 54 paint.setTextAlign(SkPaint::kLeft_Align); |
| 55 drawTestCase(canvas, "Left Align", 7 * kTextHeight, paint); | 55 drawTestCase(canvas, "Left Align", 7 * kTextHeight, paint); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void drawTestCase(SkCanvas* canvas, const char* text, SkScalar y, const SkPa
int& paint) { | 58 void drawTestCase(SkCanvas* canvas, const char* text, SkScalar y, const SkPa
int& paint) { |
| 59 SkScalar widths[kMaxStringLength]; | 59 SkScalar widths[kMaxStringLength]; |
| 60 SkScalar posX[kMaxStringLength]; | 60 SkScalar posX[kMaxStringLength]; |
| 61 SkPoint pos[kMaxStringLength]; | 61 SkPoint pos[kMaxStringLength]; |
| 62 int length = strlen(text); | 62 int length = SkToInt(strlen(text)); |
| 63 SkASSERT(length <= kMaxStringLength); | 63 SkASSERT(length <= kMaxStringLength); |
| 64 | 64 |
| 65 paint.getTextWidths(text, length, widths); | 65 paint.getTextWidths(text, length, widths); |
| 66 | 66 |
| 67 float originX; | 67 float originX; |
| 68 switch (paint.getTextAlign()) { | 68 switch (paint.getTextAlign()) { |
| 69 case SkPaint::kRight_Align: originX = 1; break; | 69 case SkPaint::kRight_Align: originX = 1; break; |
| 70 case SkPaint::kCenter_Align: originX = 0.5f; break; | 70 case SkPaint::kCenter_Align: originX = 0.5f; break; |
| 71 case SkPaint::kLeft_Align: originX = 0; break; | 71 case SkPaint::kLeft_Align: originX = 0; break; |
| 72 default: SkFAIL("Invalid paint origin"); return; | 72 default: SkFAIL("Invalid paint origin"); return; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 ////////////////////////////////////////////////////////////////////////////// | 91 ////////////////////////////////////////////////////////////////////////////// |
| 92 | 92 |
| 93 static GM* GlyphPosAlignFactory(void*) { | 93 static GM* GlyphPosAlignFactory(void*) { |
| 94 return new GlyphPosAlignGM(); | 94 return new GlyphPosAlignGM(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 static GMRegistry reg(GlyphPosAlignFactory); | 97 static GMRegistry reg(GlyphPosAlignFactory); |
| 98 | 98 |
| 99 } | 99 } |
| OLD | NEW |