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

Side by Side Diff: src/gpu/GrStencilAndCoverTextContext.h

Issue 1374853004: Fix caching of nvpr glyphs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: MSVC warnings Created 5 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/GrPathRange.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.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 2014 Google Inc. 2 * Copyright 2014 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 #ifndef GrStencilAndCoverTextContext_DEFINED 8 #ifndef GrStencilAndCoverTextContext_DEFINED
9 #define GrStencilAndCoverTextContext_DEFINED 9 #define GrStencilAndCoverTextContext_DEFINED
10 10
11 #include "GrTextContext.h" 11 #include "GrTextContext.h"
12 #include "GrDrawTarget.h" 12 #include "GrDrawTarget.h"
13 #include "GrStrokeInfo.h" 13 #include "GrStrokeInfo.h"
14 #include "SkTHash.h" 14 #include "SkTHash.h"
15 #include "SkTInternalLList.h" 15 #include "SkTInternalLList.h"
16 #include "SkTLList.h" 16 #include "SkTLList.h"
17 17
18 class GrTextStrike; 18 class GrTextStrike;
19 class GrPath; 19 class GrPath;
20 class GrPathRange;
21 class SkSurfaceProps; 20 class SkSurfaceProps;
22 21
23 /* 22 /*
24 * This class implements text rendering using stencil and cover path rendering 23 * This class implements text rendering using stencil and cover path rendering
25 * (by the means of GrDrawTarget::drawPath). 24 * (by the means of GrDrawTarget::drawPath).
26 * This class exposes the functionality through GrTextContext interface. 25 * This class exposes the functionality through GrTextContext interface.
27 */ 26 */
28 class GrStencilAndCoverTextContext : public GrTextContext { 27 class GrStencilAndCoverTextContext : public GrTextContext {
29 public: 28 public:
30 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps &); 29 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps &);
(...skipping 22 matching lines...) Expand all
53 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x, SkScalar y, 52 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x, SkScalar y,
54 SkDrawFilter*, const SkIRect& clipBounds) override; 53 SkDrawFilter*, const SkIRect& clipBounds) override;
55 54
56 class FallbackBlobBuilder; 55 class FallbackBlobBuilder;
57 56
58 class TextRun { 57 class TextRun {
59 public: 58 public:
60 TextRun(const SkPaint& fontAndStroke); 59 TextRun(const SkPaint& fontAndStroke);
61 ~TextRun(); 60 ~TextRun();
62 61
63 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar y, 62 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar y);
64 GrContext*, const SkSurfaceProps*);
65 63
66 void setPosText(const char text[], size_t byteLength, 64 void setPosText(const char text[], size_t byteLength, const SkScalar pos [],
67 const SkScalar pos[], int scalarsPerPosition, const SkPo int& offset, 65 int scalarsPerPosition, const SkPoint& offset);
68 GrContext*, const SkSurfaceProps*);
69 66
70 void draw(GrDrawContext*, GrPipelineBuilder*, GrColor, const SkMatrix&, 67 void draw(GrContext*, GrDrawContext*, GrPipelineBuilder*, GrColor, const SkMatrix&,
71 SkScalar x, SkScalar y, const SkIRect& clipBounds, 68 SkScalar x, SkScalar y, const SkIRect& clipBounds,
72 GrTextContext* fallbackTextContext, const SkPaint& originalSkP aint) const; 69 GrTextContext* fallbackTextContext, const SkPaint& originalSkP aint) const;
73 70
74 int cpuMemorySize() const; 71 void releaseGlyphCache() const;
72
73 size_t computeSizeInCache() const;
75 74
76 private: 75 private:
77 GrPathRange* createGlyphs(GrContext*, SkGlyphCache*); 76 SkGlyphCache* getGlyphCache() const;
78 77 GrPathRange* createGlyphs(GrContext*) const;
79 void appendGlyph(const SkGlyph&, const SkPoint&, FallbackBlobBuilder*); 78 void appendGlyph(const SkGlyph&, const SkPoint&, FallbackBlobBuilder*);
80 79
81 GrStrokeInfo fStroke; 80 GrStrokeInfo fStroke;
82 SkPaint fFont; 81 SkPaint fFont;
83 SkScalar fTextRatio; 82 SkScalar fTextRatio;
84 float fTextInverseRatio; 83 float fTextInverseRatio;
85 bool fUsingRawGlyphPaths; 84 bool fUsingRawGlyphPaths;
85 GrUniqueKey fGlyphPathsKey;
86 int fTotalGlyphCount; 86 int fTotalGlyphCount;
87 SkAutoTUnref<GrPathRangeDraw> fDraw; 87 SkAutoTUnref<GrPathRangeDraw> fDraw;
88 SkAutoTUnref<const SkTextBlob> fFallbackTextBlob; 88 SkAutoTUnref<const SkTextBlob> fFallbackTextBlob;
89 mutable SkGlyphCache* fDetachedGlyphCache;
90 mutable uint32_t fLastDrawnGlyphsID;
89 mutable SkMatrix fLocalMatrixTemplate; 91 mutable SkMatrix fLocalMatrixTemplate;
90 }; 92 };
91 93
92 // Text blobs/caches. 94 // Text blobs/caches.
93 95
94 class TextBlob : public SkTLList<TextRun> { 96 class TextBlob : public SkTLList<TextRun> {
95 public: 97 public:
96 typedef SkTArray<uint32_t, true> Key; 98 typedef SkTArray<uint32_t, true> Key;
97 99
98 static const Key& GetKey(const TextBlob* blob) { return blob->key(); } 100 static const Key& GetKey(const TextBlob* blob) { return blob->key(); }
99 101
100 static uint32_t Hash(const Key& key) { 102 static uint32_t Hash(const Key& key) {
101 SkASSERT(key.count() > 1); // 1-length keys should be using the blob -id hash map. 103 SkASSERT(key.count() > 1); // 1-length keys should be using the blob -id hash map.
102 return SkChecksum::Murmur3(key.begin(), sizeof(uint32_t) * key.count ()); 104 return SkChecksum::Murmur3(key.begin(), sizeof(uint32_t) * key.count ());
103 } 105 }
104 106
105 TextBlob(uint32_t blobId, const SkTextBlob* skBlob, const SkPaint& skPai nt, 107 TextBlob(uint32_t blobId, const SkTextBlob* skBlob, const SkPaint& skPai nt)
106 GrContext* ctx, const SkSurfaceProps* props) 108 : fKey(&blobId, 1) { this->init(skBlob, skPaint); }
107 : fKey(&blobId, 1) { this->init(skBlob, skPaint, ctx, props); }
108 109
109 TextBlob(const Key& key, const SkTextBlob* skBlob, const SkPaint& skPain t, 110 TextBlob(const Key& key, const SkTextBlob* skBlob, const SkPaint& skPain t)
110 GrContext* ctx, const SkSurfaceProps* props)
111 : fKey(key) { 111 : fKey(key) {
112 // 1-length keys are unterstood to be the blob id and must use the o ther constructor. 112 // 1-length keys are unterstood to be the blob id and must use the o ther constructor.
113 SkASSERT(fKey.count() > 1); 113 SkASSERT(fKey.count() > 1);
114 this->init(skBlob, skPaint, ctx, props); 114 this->init(skBlob, skPaint);
115 } 115 }
116 116
117 const Key& key() const { return fKey; } 117 const Key& key() const { return fKey; }
118 118
119 int cpuMemorySize() const { return fCpuMemorySize; } 119 size_t cpuMemorySize() const { return fCpuMemorySize; }
120 120
121 private: 121 private:
122 void init(const SkTextBlob*, const SkPaint&, GrContext*, const SkSurface Props*); 122 void init(const SkTextBlob*, const SkPaint&);
123 123
124 const SkSTArray<1, uint32_t, true> fKey; 124 const SkSTArray<1, uint32_t, true> fKey;
125 int fCpuMemorySize; 125 size_t fCpuMemorySize;
126 126
127 SK_DECLARE_INTERNAL_LLIST_INTERFACE(TextBlob); 127 SK_DECLARE_INTERNAL_LLIST_INTERFACE(TextBlob);
128 }; 128 };
129 129
130 const TextBlob& findOrCreateTextBlob(const SkTextBlob*, const SkPaint&); 130 const TextBlob& findOrCreateTextBlob(const SkTextBlob*, const SkPaint&);
131 void purgeToFit(const TextBlob&); 131 void purgeToFit(const TextBlob&);
132 132
133 SkTHashMap<uint32_t, TextBlob*> fBlobIdCache; 133 SkTHashMap<uint32_t, TextBlob*> fBlobIdCache;
134 SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache; 134 SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache;
135 SkTInternalLList<TextBlob> fLRUList; 135 SkTInternalLList<TextBlob> fLRUList;
136 int fCacheSize; 136 size_t fCacheSize;
137 137
138 typedef GrTextContext INHERITED; 138 typedef GrTextContext INHERITED;
139 }; 139 };
140 140
141 #endif 141 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPathRange.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698