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

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

Issue 1076593002: Start canonicalizing color for all A8 textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@atcachemasks
Patch Set: adding gm 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
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
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 struct BigGlyph { 120 struct BigGlyph {
121 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx), fVy(vy) {} 121 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx), fVy(vy) {}
122 SkPath fPath; 122 SkPath fPath;
123 int fVx; 123 int fVx;
124 int fVy; 124 int fVy;
125 }; 125 };
126 #ifdef SK_DEBUG 126 #ifdef SK_DEBUG
127 mutable SkScalar fTotalXError; 127 mutable SkScalar fTotalXError;
128 mutable SkScalar fTotalYError; 128 mutable SkScalar fTotalYError;
129 #endif 129 #endif
130 SkColor fPaintColor;
130 SkTArray<BigGlyph> fBigGlyphs; 131 SkTArray<BigGlyph> fBigGlyphs;
131 GrColor fColor; // the original color on the paint
132 SkMatrix fViewMatrix; 132 SkMatrix fViewMatrix;
133 SkScalar fX; 133 SkScalar fX;
134 SkScalar fY; 134 SkScalar fY;
135 int fRunCount; 135 int fRunCount;
136 SkMaskFilter::BlurRec fBlurRec; 136 SkMaskFilter::BlurRec fBlurRec;
137 struct StrokeInfo { 137 struct StrokeInfo {
138 SkScalar fFrameWidth; 138 SkScalar fFrameWidth;
139 SkScalar fMiterLimit; 139 SkScalar fMiterLimit;
140 SkPaint::Join fJoin; 140 SkPaint::Join fJoin;
141 }; 141 };
142 StrokeInfo fStrokeInfo; 142 StrokeInfo fStrokeInfo;
143 GrMemoryPool* fPool; 143 GrMemoryPool* fPool;
144 144
145 // all glyph / vertex offsets are into these pools. 145 // all glyph / vertex offsets are into these pools.
146 unsigned char* fVertices; 146 unsigned char* fVertices;
147 GrGlyph::PackedID* fGlyphIDs; 147 GrGlyph::PackedID* fGlyphIDs;
148 Run* fRuns; 148 Run* fRuns;
149 149
150 struct Key { 150 struct Key {
151 Key() { 151 Key() {
152 memset(this, 0, sizeof(Key)); 152 memset(this, 0, sizeof(Key));
153 } 153 }
154 uint32_t fUniqueID; 154 uint32_t fUniqueID;
155 SkPaint::Style fStyle; 155 SkPaint::Style fStyle;
156 bool fHasBlur; 156 bool fHasBlur;
reed1 2015/04/13 17:05:51 I know there is a memset(0) at the beginning (btw
157 // Color may affect the gamma of the mask we generate, but in a fair ly limited way.
158 // There are a certain number of buckets, and within those buckets w e can reassign the
bsalomon 2015/04/13 15:16:38 Replace second sentence with Each color is assign
159 // color as desired. This functionality is currently only supported for A8
160 SkColor fCanonicalColor;
157 161
158 bool operator==(const Key& other) const { 162 bool operator==(const Key& other) const {
159 return 0 == memcmp(this, &other, sizeof(Key)); 163 return 0 == memcmp(this, &other, sizeof(Key));
160 } 164 }
161 }; 165 };
162 Key fKey; 166 Key fKey;
163 167
164 static const Key& GetKey(const BitmapTextBlob& blob) { 168 static const Key& GetKey(const BitmapTextBlob& blob) {
165 return blob.fKey; 169 return blob.fKey;
166 } 170 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 SkScalar transX, SkScalar transY); 204 SkScalar transX, SkScalar transY);
201 205
202 // We have to flush SkTextBlobs differently from drawText / drawPosText 206 // We have to flush SkTextBlobs differently from drawText / drawPosText
203 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget *, const SkPaint&, 207 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget *, const SkPaint&,
204 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie wMatrix, 208 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie wMatrix,
205 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans X, SkScalar transY); 209 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans X, SkScalar transY);
206 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, 210 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&,
207 const GrPaint&, const GrClip&, const SkMatrix& viewMatrix); 211 const GrPaint&, const GrClip&, const SkMatrix& viewMatrix);
208 212
209 void internalDrawText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const Sk Paint&, 213 void internalDrawText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const Sk Paint&,
210 const SkMatrix& viewMatrix, const char text[], size_t byteLength, 214 GrColor color, const SkMatrix& viewMatrix,
215 const char text[], size_t byteLength,
211 SkScalar x, SkScalar y, const SkIRect& clipRect); 216 SkScalar x, SkScalar y, const SkIRect& clipRect);
212 void internalDrawPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const SkPaint&, 217 void internalDrawPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const SkPaint&,
213 const SkMatrix& viewMatrix, 218 GrColor color, const SkMatrix& viewMatrix,
214 const char text[], size_t byteLength, 219 const char text[], size_t byteLength,
215 const SkScalar pos[], int scalarsPerPosition, 220 const SkScalar pos[], int scalarsPerPosition,
216 const SkPoint& offset, const SkIRect& clipRect); 221 const SkPoint& offset, const SkIRect& clipRect);
217 222
218 // sets up the descriptor on the blob and returns a detached cache. Client must attach 223 // sets up the descriptor on the blob and returns a detached cache. Client must attach
224 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd);
219 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix& viewMa trix); 225 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix& viewMa trix);
220 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran sY, 226 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran sY,
221 const BitmapTextBlob&, const SkPaint&, 227 const BitmapTextBlob&, const SkPaint&,
222 const SkMaskFilter::BlurRec&, 228 const SkMaskFilter::BlurRec&,
223 const SkMatrix& viewMatrix, SkScalar x , SkScalar y); 229 const SkMatrix& viewMatrix, SkScalar x , SkScalar y);
224 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, const S kMatrix& viewMatrix, 230 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, GrColor ,
231 const SkMatrix& viewMatrix,
225 const SkTextBlob* blob, SkScalar x, SkScalar y, 232 const SkTextBlob* blob, SkScalar x, SkScalar y,
226 SkDrawFilter* drawFilter, const SkIRect& clipRect); 233 SkDrawFilter* drawFilter, const SkIRect& clipRect);
234 inline static bool HasLCD(const SkTextBlob*);
227 235
228 GrBatchTextStrike* fCurrStrike; 236 GrBatchTextStrike* fCurrStrike;
229 GrTextBlobCache* fCache; 237 GrTextBlobCache* fCache;
230 238
231 friend class GrTextBlobCache; 239 friend class GrTextBlobCache;
232 friend class BitmapTextBatch; 240 friend class BitmapTextBatch;
233 241
234 typedef GrTextContext INHERITED; 242 typedef GrTextContext INHERITED;
235 }; 243 };
236 244
237 #endif 245 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698