OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "GrTextContext.h" | 8 #include "GrTextContext.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 fDrawTarget = fContext->getTextTarget(); | 33 fDrawTarget = fContext->getTextTarget(); |
34 | 34 |
35 fPaint = grPaint; | 35 fPaint = grPaint; |
36 fSkPaint = skPaint; | 36 fSkPaint = skPaint; |
37 } | 37 } |
38 | 38 |
39 bool GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& paint, | 39 bool GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& paint, |
40 const SkPaint& skPaint, const SkMatrix& viewMatrix, | 40 const SkPaint& skPaint, const SkMatrix& viewMatrix, |
41 const char text[], size_t byteLength, | 41 const char text[], size_t byteLength, |
42 SkScalar x, SkScalar y) { | 42 SkScalar x, SkScalar y) { |
| 43 if (!fContext->getTextTarget()) { |
| 44 return false; |
| 45 } |
43 | 46 |
44 GrTextContext* textContext = this; | 47 GrTextContext* textContext = this; |
45 do { | 48 do { |
46 if (textContext->canDraw(skPaint, viewMatrix)) { | 49 if (textContext->canDraw(skPaint, viewMatrix)) { |
47 textContext->onDrawText(rt, clip, paint, skPaint, viewMatrix, text,
byteLength, x, y); | 50 textContext->onDrawText(rt, clip, paint, skPaint, viewMatrix, text,
byteLength, x, y); |
48 return true; | 51 return true; |
49 } | 52 } |
50 textContext = textContext->fFallbackTextContext; | 53 textContext = textContext->fFallbackTextContext; |
51 } while (textContext); | 54 } while (textContext); |
52 | 55 |
53 return false; | 56 return false; |
54 } | 57 } |
55 | 58 |
56 bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr
Paint& paint, | 59 bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr
Paint& paint, |
57 const SkPaint& skPaint, const SkMatrix& viewMatr
ix, | 60 const SkPaint& skPaint, const SkMatrix& viewMatr
ix, |
58 const char text[], size_t byteLength, | 61 const char text[], size_t byteLength, |
59 const SkScalar pos[], int scalarsPerPosition, | 62 const SkScalar pos[], int scalarsPerPosition, |
60 const SkPoint& offset) { | 63 const SkPoint& offset) { |
| 64 if (!fContext->getTextTarget()) { |
| 65 return false; |
| 66 } |
61 | 67 |
62 GrTextContext* textContext = this; | 68 GrTextContext* textContext = this; |
63 do { | 69 do { |
64 if (textContext->canDraw(skPaint, viewMatrix)) { | 70 if (textContext->canDraw(skPaint, viewMatrix)) { |
65 textContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix, tex
t, byteLength, pos, | 71 textContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix, tex
t, byteLength, pos, |
66 scalarsPerPosition, offset); | 72 scalarsPerPosition, offset); |
67 return true; | 73 return true; |
68 } | 74 } |
69 textContext = textContext->fFallbackTextContext; | 75 textContext = textContext->fFallbackTextContext; |
70 } while (textContext); | 76 } while (textContext); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { | 116 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { |
111 scaler = (GrFontScaler*)auxData; | 117 scaler = (GrFontScaler*)auxData; |
112 } | 118 } |
113 if (NULL == scaler) { | 119 if (NULL == scaler) { |
114 scaler = SkNEW_ARGS(GrFontScaler, (cache)); | 120 scaler = SkNEW_ARGS(GrFontScaler, (cache)); |
115 cache->setAuxProc(GlyphCacheAuxProc, scaler); | 121 cache->setAuxProc(GlyphCacheAuxProc, scaler); |
116 } | 122 } |
117 | 123 |
118 return scaler; | 124 return scaler; |
119 } | 125 } |
OLD | NEW |