Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: src/gpu/GrTextContext.cpp

Issue 141863005: Add standalone drawText for GrTextContext. (Closed) Base URL: https://skia.googlesource.com/skia.git@issue2018-factory
Patch Set: Remove SkDevice* from TextContext. Fix up some SK_OVERRIDEs. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
9 #include "GrTextContext.h" 8 #include "GrTextContext.h"
9 #include "SkAutoKern.h"
10 #include "SkGlyphCache.h"
11 #include "SkGpuDevice.h"
10 12
11 GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint, 13 GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint,
12 const SkPaint& skPaint) : fPaint(paint), fSkPaint(s kPaint) { 14 const SkPaint& skPaint, const SkDeviceProperties* p roperties) :
13 fContext = context; 15 fContext(context), fPaint(paint), fSkPaint(skPaint),
16 fDeviceProperties(properties) {
14 17
15 const GrClipData* clipData = context->getClip(); 18 const GrClipData* clipData = context->getClip();
16 19
17 SkRect devConservativeBound; 20 SkRect devConservativeBound;
18 clipData->fClipStack->getConservativeBounds( 21 clipData->fClipStack->getConservativeBounds(
19 -clipData->fOrigin.fX, 22 -clipData->fOrigin.fX,
20 -clipData->fOrigin.fY, 23 -clipData->fOrigin.fY,
21 context->getRenderTarget()->width(), 24 context->getRenderTarget()->width(),
22 context->getRenderTarget()->height(), 25 context->getRenderTarget()->height(),
23 &devConservativeBound); 26 &devConservativeBound);
24 27
25 devConservativeBound.roundOut(&fClipRect); 28 devConservativeBound.roundOut(&fClipRect);
26 29
27 fDrawTarget = fContext->getTextTarget(); 30 fDrawTarget = context->getTextTarget();
28 } 31 }
32
33 //*** change to output positions?
34 void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheP roc,
35 const char text[], size_t byteLength, SkVector* stopVector) {
36 SkFixed x = 0, y = 0;
37 const char* stop = text + byteLength;
38
39 SkAutoKern autokern;
40
41 while (text < stop) {
42 // don't need x, y here, since all subpixel variants will have the
43 // same advance
44 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
45
46 x += autokern.adjust(glyph) + glyph.fAdvanceX;
47 y += glyph.fAdvanceY;
48 }
49 stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y));
50
51 SkASSERT(text == stop);
52 }
53
54 static void GlyphCacheAuxProc(void* data) {
55 GrFontScaler* scaler = (GrFontScaler*)data;
56 SkSafeUnref(scaler);
57 }
58
59 GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) {
60 void* auxData;
61 GrFontScaler* scaler = NULL;
62
63 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) {
64 scaler = (GrFontScaler*)auxData;
65 }
66 if (NULL == scaler) {
67 scaler = SkNEW_ARGS(SkGrFontScaler, (cache));
68 cache->setAuxProc(GlyphCacheAuxProc, scaler);
69 }
70
71 return scaler;
72 }
73
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698