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

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

Issue 1065293003: Start caching masks / stroke fills for textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@textblobloopergm
Patch Set: tweak Created 5 years, 8 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 | « no previous file | src/gpu/GrAtlasTextContext.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 2015 Google Inc. 2 * Copyright 2015 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 GrAtlasTextContext_DEFINED 8 #ifndef GrAtlasTextContext_DEFINED
9 #define GrAtlasTextContext_DEFINED 9 #define GrAtlasTextContext_DEFINED
10 10
11 #include "GrTextContext.h" 11 #include "GrTextContext.h"
12 12
13 #include "GrBatchAtlas.h" 13 #include "GrBatchAtlas.h"
14 #include "GrGeometryProcessor.h" 14 #include "GrGeometryProcessor.h"
15 #include "SkDescriptor.h" 15 #include "SkDescriptor.h"
16 #include "GrMemoryPool.h" 16 #include "GrMemoryPool.h"
17 #include "SkMaskFilter.h"
17 #include "SkTextBlob.h" 18 #include "SkTextBlob.h"
18 #include "SkTInternalLList.h" 19 #include "SkTInternalLList.h"
19 20
20 class GrBatchTextStrike; 21 class GrBatchTextStrike;
21 class GrPipelineBuilder; 22 class GrPipelineBuilder;
22 class GrTextBlobCache; 23 class GrTextBlobCache;
23 24
24 /* 25 /*
25 * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs. 26 * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs.
26 * TODO replace GrBitmapTextContext 27 * TODO replace GrBitmapTextContext
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 SkPath fPath; 123 SkPath fPath;
123 int fVx; 124 int fVx;
124 int fVy; 125 int fVy;
125 }; 126 };
126 127
127 SkTArray<BigGlyph> fBigGlyphs; 128 SkTArray<BigGlyph> fBigGlyphs;
128 GrColor fColor; // the original color on the paint 129 GrColor fColor; // the original color on the paint
129 SkMatrix fViewMatrix; 130 SkMatrix fViewMatrix;
130 SkScalar fX; 131 SkScalar fX;
131 SkScalar fY; 132 SkScalar fY;
132 SkPaint::Style fStyle;
133 int fRunCount; 133 int fRunCount;
134 uint32_t fUniqueID;
135 GrMemoryPool* fPool; 134 GrMemoryPool* fPool;
136 135
137 // all glyph / vertex offsets are into these pools. 136 // all glyph / vertex offsets are into these pools.
138 unsigned char* fVertices; 137 unsigned char* fVertices;
139 GrGlyph::PackedID* fGlyphIDs; 138 GrGlyph::PackedID* fGlyphIDs;
140 Run* fRuns; 139 Run* fRuns;
141 140
142 static const uint32_t& GetKey(const BitmapTextBlob& blob) { 141 struct Key {
143 return blob.fUniqueID; 142 Key() {
143 memset(this, 0, sizeof(Key));
144 }
145 uint32_t fUniqueID;
146 SkPaint::Style fStyle;
147 SkMaskFilter::BlurRec fBlurRec;
bsalomon 2015/04/08 15:38:19 As we discussed, perhaps this should be a bit here
148 struct StrokeInfo {
bsalomon 2015/04/08 15:38:19 similar here I think, style says its stroked, prob
149 SkScalar fFrameWidth;
150 SkScalar fMiterLimit;
151 uint8_t fStrokeJoin;
152 };
153 StrokeInfo fStrokeInfo;
154
155 bool operator==(const Key& other) const {
156 return 0 == memcmp(this, &other, sizeof(Key));
157 }
158 };
159 Key fKey;
160
161 static const Key& GetKey(const BitmapTextBlob& blob) {
162 return blob.fKey;
144 } 163 }
145 164
146 static uint32_t Hash(const uint32_t& key) { 165 static uint32_t Hash(const Key& key) {
147 return SkChecksum::Mix(key); 166 return SkChecksum::Murmur3(&key, sizeof(Key));
148 } 167 }
149 168
150 void operator delete(void* p) { 169 void operator delete(void* p) {
151 BitmapTextBlob* blob = reinterpret_cast<BitmapTextBlob*>(p); 170 BitmapTextBlob* blob = reinterpret_cast<BitmapTextBlob*>(p);
152 blob->fPool->release(p); 171 blob->fPool->release(p);
153 } 172 }
154 void* operator new(size_t) { 173 void* operator new(size_t) {
155 SkFAIL("All blobs are created by placement new."); 174 SkFAIL("All blobs are created by placement new.");
156 return sk_malloc_throw(0); 175 return sk_malloc_throw(0);
157 } 176 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 GrBatchTextStrike* fCurrStrike; 224 GrBatchTextStrike* fCurrStrike;
206 GrTextBlobCache* fCache; 225 GrTextBlobCache* fCache;
207 226
208 friend class GrTextBlobCache; 227 friend class GrTextBlobCache;
209 friend class BitmapTextBatch; 228 friend class BitmapTextBatch;
210 229
211 typedef GrTextContext INHERITED; 230 typedef GrTextContext INHERITED;
212 }; 231 };
213 232
214 #endif 233 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698