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

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: One more Mac compile error. 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
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "GrTextContext.h"
9 #include "GrContext.h"
8 10
9 #include "GrTextContext.h" 11 #include "SkAutoKern.h"
12 #include "SkGlyphCache.h"
13 #include "SkGr.h"
10 14
11 GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint, 15 GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint,
12 const SkPaint& skPaint) : fPaint(paint), fSkPaint(s kPaint) { 16 const SkPaint& skPaint, const SkDeviceProperties& p roperties) :
13 fContext = context; 17 fContext(context), fPaint(paint), fSkPaint(skPaint),
18 fDeviceProperties(properties) {
14 19
15 const GrClipData* clipData = context->getClip(); 20 const GrClipData* clipData = context->getClip();
16 21
17 SkRect devConservativeBound; 22 SkRect devConservativeBound;
18 clipData->fClipStack->getConservativeBounds( 23 clipData->fClipStack->getConservativeBounds(
19 -clipData->fOrigin.fX, 24 -clipData->fOrigin.fX,
20 -clipData->fOrigin.fY, 25 -clipData->fOrigin.fY,
21 context->getRenderTarget()->width(), 26 context->getRenderTarget()->width(),
22 context->getRenderTarget()->height(), 27 context->getRenderTarget()->height(),
23 &devConservativeBound); 28 &devConservativeBound);
24 29
25 devConservativeBound.roundOut(&fClipRect); 30 devConservativeBound.roundOut(&fClipRect);
26 31
27 fDrawTarget = fContext->getTextTarget(); 32 fDrawTarget = context->getTextTarget();
28 } 33 }
34
35 //*** change to output positions?
36 void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheP roc,
37 const char text[], size_t byteLength, SkVector* stopVector) {
38 SkFixed x = 0, y = 0;
39 const char* stop = text + byteLength;
40
41 SkAutoKern autokern;
42
43 while (text < stop) {
44 // don't need x, y here, since all subpixel variants will have the
45 // same advance
46 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
47
48 x += autokern.adjust(glyph) + glyph.fAdvanceX;
49 y += glyph.fAdvanceY;
50 }
51 stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y));
52
53 SkASSERT(text == stop);
54 }
55
56 static void GlyphCacheAuxProc(void* data) {
57 GrFontScaler* scaler = (GrFontScaler*)data;
58 SkSafeUnref(scaler);
59 }
60
61 GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) {
62 void* auxData;
63 GrFontScaler* scaler = NULL;
64
65 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) {
66 scaler = (GrFontScaler*)auxData;
67 }
68 if (NULL == scaler) {
69 scaler = SkNEW_ARGS(SkGrFontScaler, (cache));
70 cache->setAuxProc(GlyphCacheAuxProc, scaler);
71 }
72
73 return scaler;
74 }
75
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698