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

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

Issue 650273003: Change GrTextContext fallbacks to be a linked list chain. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix include Created 6 years, 2 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/GrTextContext.h ('k') | src/gpu/SkGpuDevice.h » ('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" 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 "GrFontScaler.h" 13 #include "GrFontScaler.h"
14 14
15 GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& prope rties) : 15 GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& prope rties) :
16 fFallbackTextContext(NULL),
16 fContext(context), fDeviceProperties(properties), fD rawTarget(NULL) { 17 fContext(context), fDeviceProperties(properties), fD rawTarget(NULL) {
17 } 18 }
18 19
20 GrTextContext::~GrTextContext() {
21 SkDELETE(fFallbackTextContext);
22 }
23
19 void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) { 24 void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) {
20 const GrClipData* clipData = fContext->getClip(); 25 const GrClipData* clipData = fContext->getClip();
21 26
22 SkRect devConservativeBound; 27 SkRect devConservativeBound;
23 clipData->fClipStack->getConservativeBounds( 28 clipData->fClipStack->getConservativeBounds(
24 -clipData->fOrigin.fX, 29 -clipData->fOrigin.fX,
25 -clipData->fOrigin.fY, 30 -clipData->fOrigin.fY,
26 fContext->getRenderTarget()->width(), 31 fContext->getRenderTarget()->width(),
27 fContext->getRenderTarget()->height(), 32 fContext->getRenderTarget()->height(),
28 &devConservativeBound); 33 &devConservativeBound);
29 34
30 devConservativeBound.roundOut(&fClipRect); 35 devConservativeBound.roundOut(&fClipRect);
31 36
32 fDrawTarget = fContext->getTextTarget(); 37 fDrawTarget = fContext->getTextTarget();
33 38
34 fPaint = grPaint; 39 fPaint = grPaint;
35 fSkPaint = skPaint; 40 fSkPaint = skPaint;
36 } 41 }
37 42
43 bool GrTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
44 const char text[], size_t byteLength,
45 SkScalar x, SkScalar y) {
46
47 GrTextContext* textContext = this;
48 do {
49 if (textContext->canDraw(skPaint)) {
50 textContext->onDrawText(paint, skPaint, text, byteLength, x, y);
51 return true;
52 }
53 textContext = textContext->fFallbackTextContext;
54 } while (textContext);
55
56 return false;
57 }
58
59 bool GrTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
60 const char text[], size_t byteLength,
61 const SkScalar pos[], int scalarsPerPosition,
62 const SkPoint& offset) {
63
64 GrTextContext* textContext = this;
65 do {
66 if (textContext->canDraw(skPaint)) {
67 textContext->onDrawPosText(paint, skPaint, text, byteLength, pos, sc alarsPerPosition,
68 offset);
69 return true;
70 }
71 textContext = textContext->fFallbackTextContext;
72 } while (textContext);
73
74 return false;
75 }
76
77
38 //*** change to output positions? 78 //*** change to output positions?
39 void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheP roc, 79 void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheP roc,
40 const char text[], size_t byteLength, SkVector* stopVector) { 80 const char text[], size_t byteLength, SkVector* stopVector) {
41 SkFixed x = 0, y = 0; 81 SkFixed x = 0, y = 0;
42 const char* stop = text + byteLength; 82 const char* stop = text + byteLength;
43 83
44 SkAutoKern autokern; 84 SkAutoKern autokern;
45 85
46 while (text < stop) { 86 while (text < stop) {
47 // don't need x, y here, since all subpixel variants will have the 87 // don't need x, y here, since all subpixel variants will have the
(...skipping 20 matching lines...) Expand all
68 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { 108 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) {
69 scaler = (GrFontScaler*)auxData; 109 scaler = (GrFontScaler*)auxData;
70 } 110 }
71 if (NULL == scaler) { 111 if (NULL == scaler) {
72 scaler = SkNEW_ARGS(GrFontScaler, (cache)); 112 scaler = SkNEW_ARGS(GrFontScaler, (cache));
73 cache->setAuxProc(GlyphCacheAuxProc, scaler); 113 cache->setAuxProc(GlyphCacheAuxProc, scaler);
74 } 114 }
75 115
76 return scaler; 116 return scaler;
77 } 117 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextContext.h ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698