| 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 | 10 |
| 11 #include "SkAutoKern.h" | 11 #include "SkAutoKern.h" |
| 12 #include "SkGlyphCache.h" | 12 #include "SkGlyphCache.h" |
| 13 #include "SkGr.h" | 13 #include "SkGr.h" |
| 14 | 14 |
| 15 GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint, | 15 GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& prope
rties) : |
| 16 const SkPaint& skPaint, const SkDeviceProperties& p
roperties) : | 16 fContext(context), fDeviceProperties(properties), fD
rawTarget(NULL) { |
| 17 fContext(context), fPaint(paint), fSkPaint(skPaint), | 17 } |
| 18 fDeviceProperties(properties) { | |
| 19 | 18 |
| 20 const GrClipData* clipData = context->getClip(); | 19 void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) { |
| 20 const GrClipData* clipData = fContext->getClip(); |
| 21 | 21 |
| 22 SkRect devConservativeBound; | 22 SkRect devConservativeBound; |
| 23 clipData->fClipStack->getConservativeBounds( | 23 clipData->fClipStack->getConservativeBounds( |
| 24 -clipData->fOrigin.fX, | 24 -clipData->fOrigin.fX, |
| 25 -clipData->fOrigin.fY, | 25 -clipData->fOrigin.fY, |
| 26 context->getRenderTarget()->width(), | 26 fContext->getRenderTarget()->width(), |
| 27 context->getRenderTarget()->height(), | 27 fContext->getRenderTarget()->height(), |
| 28 &devConservativeBound); | 28 &devConservativeBound); |
| 29 | 29 |
| 30 devConservativeBound.roundOut(&fClipRect); | 30 devConservativeBound.roundOut(&fClipRect); |
| 31 | 31 |
| 32 fDrawTarget = context->getTextTarget(); | 32 fDrawTarget = fContext->getTextTarget(); |
| 33 |
| 34 fPaint = grPaint; |
| 35 fSkPaint = skPaint; |
| 33 } | 36 } |
| 34 | 37 |
| 35 //*** change to output positions? | 38 //*** change to output positions? |
| 36 void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheP
roc, | 39 void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheP
roc, |
| 37 const char text[], size_t byteLength, SkVector*
stopVector) { | 40 const char text[], size_t byteLength, SkVector*
stopVector) { |
| 38 SkFixed x = 0, y = 0; | 41 SkFixed x = 0, y = 0; |
| 39 const char* stop = text + byteLength; | 42 const char* stop = text + byteLength; |
| 40 | 43 |
| 41 SkAutoKern autokern; | 44 SkAutoKern autokern; |
| 42 | 45 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 65 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { | 68 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { |
| 66 scaler = (GrFontScaler*)auxData; | 69 scaler = (GrFontScaler*)auxData; |
| 67 } | 70 } |
| 68 if (NULL == scaler) { | 71 if (NULL == scaler) { |
| 69 scaler = SkNEW_ARGS(SkGrFontScaler, (cache)); | 72 scaler = SkNEW_ARGS(SkGrFontScaler, (cache)); |
| 70 cache->setAuxProc(GlyphCacheAuxProc, scaler); | 73 cache->setAuxProc(GlyphCacheAuxProc, scaler); |
| 71 } | 74 } |
| 72 | 75 |
| 73 return scaler; | 76 return scaler; |
| 74 } | 77 } |
| OLD | NEW |