| 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 10 matching lines...) Expand all Loading... |
| 21 #include "SkTextToPathIter.h" | 21 #include "SkTextToPathIter.h" |
| 22 | 22 |
| 23 GrTextContext::GrTextContext(GrContext* context, GrDrawContext* drawContext, | 23 GrTextContext::GrTextContext(GrContext* context, GrDrawContext* drawContext, |
| 24 const SkSurfaceProps& surfaceProps) | 24 const SkSurfaceProps& surfaceProps) |
| 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() { delete fFallbackTextContext; } |
| 32 SkDELETE(fFallbackTextContext); | |
| 33 } | |
| 34 | 32 |
| 35 void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& paint, | 33 void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
nt& paint, |
| 36 const SkPaint& skPaint, const SkMatrix& viewMatrix, | 34 const SkPaint& skPaint, const SkMatrix& viewMatrix, |
| 37 const char text[], size_t byteLength, | 35 const char text[], size_t byteLength, |
| 38 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ | 36 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ |
| 39 if (fContext->abandoned() || !fDrawContext) { | 37 if (fContext->abandoned() || !fDrawContext) { |
| 40 return; | 38 return; |
| 41 } | 39 } |
| 42 | 40 |
| 43 GrTextContext* textContext = this; | 41 GrTextContext* textContext = this; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 matrix[SkMatrix::kMTransX] = loc.fX; | 227 matrix[SkMatrix::kMTransX] = loc.fX; |
| 230 matrix[SkMatrix::kMTransY] = loc.fY; | 228 matrix[SkMatrix::kMTransY] = loc.fY; |
| 231 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt,
clip, *path, paint, | 229 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt,
clip, *path, paint, |
| 232 viewMatrix, &matrix, clipBou
nds, false); | 230 viewMatrix, &matrix, clipBou
nds, false); |
| 233 } | 231 } |
| 234 } | 232 } |
| 235 pos += scalarsPerPosition; | 233 pos += scalarsPerPosition; |
| 236 } | 234 } |
| 237 } | 235 } |
| 238 | 236 |
| 239 //*** change to output positions? | 237 // *** change to output positions? |
| 240 int GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCachePr
oc, | 238 int GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCachePr
oc, |
| 241 const char text[], size_t byteLength, SkVector*
stopVector) { | 239 const char text[], size_t byteLength, SkVector*
stopVector) { |
| 242 SkFixed x = 0, y = 0; | 240 SkFixed x = 0, y = 0; |
| 243 const char* stop = text + byteLength; | 241 const char* stop = text + byteLength; |
| 244 | 242 |
| 245 SkAutoKern autokern; | 243 SkAutoKern autokern; |
| 246 | 244 |
| 247 int numGlyphs = 0; | 245 int numGlyphs = 0; |
| 248 while (text < stop) { | 246 while (text < stop) { |
| 249 // don't need x, y here, since all subpixel variants will have the | 247 // don't need x, y here, since all subpixel variants will have the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 267 } | 265 } |
| 268 | 266 |
| 269 GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) { | 267 GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) { |
| 270 void* auxData; | 268 void* auxData; |
| 271 GrFontScaler* scaler = NULL; | 269 GrFontScaler* scaler = NULL; |
| 272 | 270 |
| 273 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { | 271 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { |
| 274 scaler = (GrFontScaler*)auxData; | 272 scaler = (GrFontScaler*)auxData; |
| 275 } | 273 } |
| 276 if (NULL == scaler) { | 274 if (NULL == scaler) { |
| 277 scaler = SkNEW_ARGS(GrFontScaler, (cache)); | 275 scaler = new GrFontScaler(cache); |
| 278 cache->setAuxProc(GlyphCacheAuxProc, scaler); | 276 cache->setAuxProc(GlyphCacheAuxProc, scaler); |
| 279 } | 277 } |
| 280 | 278 |
| 281 return scaler; | 279 return scaler; |
| 282 } | 280 } |
| OLD | NEW |