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 "GrBlurUtils.h" | 9 #include "GrBlurUtils.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 : fFallbackTextContext(NULL) | 25 : fFallbackTextContext(NULL) |
26 , fContext(context) | 26 , fContext(context) |
27 , fSurfaceProps(surfaceProps) | 27 , fSurfaceProps(surfaceProps) |
28 , fDrawContext(drawContext) { | 28 , fDrawContext(drawContext) { |
29 } | 29 } |
30 | 30 |
31 GrTextContext::~GrTextContext() { | 31 GrTextContext::~GrTextContext() { |
32 SkDELETE(fFallbackTextContext); | 32 SkDELETE(fFallbackTextContext); |
33 } | 33 } |
34 | 34 |
35 void GrTextContext::init(GrRenderTarget* rt, const GrClip& clip, const GrPaint&
grPaint, | |
36 const SkPaint& skPaint, const SkIRect& regionClipBounds
) { | |
37 fClip = clip; | |
38 | |
39 fRenderTarget.reset(SkRef(rt)); | |
40 | |
41 fRegionClipBounds = regionClipBounds; | |
42 fClip.getConservativeBounds(fRenderTarget->width(), fRenderTarget->height(),
&fClipRect); | |
43 | |
44 fPaint = grPaint; | |
45 fSkPaint = skPaint; | |
46 } | |
47 | |
48 void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& paint, | 35 void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& paint, |
49 const SkPaint& skPaint, const SkMatrix& viewMatrix, | 36 const SkPaint& skPaint, const SkMatrix& viewMatrix, |
50 const char text[], size_t byteLength, | 37 const char text[], size_t byteLength, |
51 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ | 38 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ |
52 if (fContext->abandoned() || !fDrawContext) { | 39 if (fContext->abandoned() || !fDrawContext) { |
53 return; | 40 return; |
54 } | 41 } |
55 | 42 |
56 GrTextContext* textContext = this; | 43 GrTextContext* textContext = this; |
57 do { | 44 do { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 127 |
141 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ
e)) { | 128 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ
e)) { |
142 // A false return from filter() means we should abort the current dr
aw. | 129 // A false return from filter() means we should abort the current dr
aw. |
143 runPaint = skPaint; | 130 runPaint = skPaint; |
144 continue; | 131 continue; |
145 } | 132 } |
146 | 133 |
147 runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint)); | 134 runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint)); |
148 | 135 |
149 GrPaint grPaint; | 136 GrPaint grPaint; |
150 if (!SkPaint2GrPaint(fContext, fRenderTarget, runPaint, viewMatrix, true
, &grPaint)) { | 137 if (!SkPaint2GrPaint(fContext, rt, runPaint, viewMatrix, true, &grPaint)
) { |
151 return; | 138 return; |
152 } | 139 } |
153 | 140 |
154 switch (it.positioning()) { | 141 switch (it.positioning()) { |
155 case SkTextBlob::kDefault_Positioning: | 142 case SkTextBlob::kDefault_Positioning: |
156 this->drawText(rt, clip, grPaint, runPaint, viewMatrix, (const char
*)it.glyphs(), | 143 this->drawText(rt, clip, grPaint, runPaint, viewMatrix, (const char
*)it.glyphs(), |
157 textLen, x + offset.x(), y + offset.y(), clipBounds); | 144 textLen, x + offset.x(), y + offset.y(), clipBounds); |
158 break; | 145 break; |
159 case SkTextBlob::kHorizontal_Positioning: | 146 case SkTextBlob::kHorizontal_Positioning: |
160 this->drawPosText(rt, clip, grPaint, runPaint, viewMatrix, (const ch
ar*)it.glyphs(), | 147 this->drawPosText(rt, clip, grPaint, runPaint, viewMatrix, (const ch
ar*)it.glyphs(), |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { | 273 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { |
287 scaler = (GrFontScaler*)auxData; | 274 scaler = (GrFontScaler*)auxData; |
288 } | 275 } |
289 if (NULL == scaler) { | 276 if (NULL == scaler) { |
290 scaler = SkNEW_ARGS(GrFontScaler, (cache)); | 277 scaler = SkNEW_ARGS(GrFontScaler, (cache)); |
291 cache->setAuxProc(GlyphCacheAuxProc, scaler); | 278 cache->setAuxProc(GlyphCacheAuxProc, scaler); |
292 } | 279 } |
293 | 280 |
294 return scaler; | 281 return scaler; |
295 } | 282 } |
OLD | NEW |