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

Side by Side Diff: src/gpu/text/GrAtlasTextContext.cpp

Issue 1866293003: Decouple contrast boost from fake gamma. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Improve ignorePreBlend API, add storage type to enum Created 4 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 | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/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 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 #include "GrAtlasTextContext.h" 7 #include "GrAtlasTextContext.h"
8 8
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // gamma corrected masks anyways, nor color 46 // gamma corrected masks anyways, nor color
47 U8CPU lum = SkComputeLuminance(SkColorGetR(canonicalColor), 47 U8CPU lum = SkComputeLuminance(SkColorGetR(canonicalColor),
48 SkColorGetG(canonicalColor), 48 SkColorGetG(canonicalColor),
49 SkColorGetB(canonicalColor)); 49 SkColorGetB(canonicalColor));
50 // reduce to our finite number of bits 50 // reduce to our finite number of bits
51 canonicalColor = SkMaskGamma::CanonicalColor(SkColorSetRGB(lum, lum, lum )); 51 canonicalColor = SkMaskGamma::CanonicalColor(SkColorSetRGB(lum, lum, lum ));
52 } 52 }
53 return canonicalColor; 53 return canonicalColor;
54 } 54 }
55 55
56 SkPaint::FakeGamma GrAtlasTextContext::ComputeFakeGamma(GrDrawContext* dc, const GrPaint& grPaint) { 56 uint32_t GrAtlasTextContext::ComputeScalerContextFlags(GrDrawContext* dc, const GrPaint& grPaint) {
57 // If we're rendering to an sRGB render target, and we aren't forcing sRGB b lending off, 57 // If we're rendering to an sRGB render target, and we aren't forcing sRGB b lending off,
58 // then we can disable the gamma hacks. Otherwise, leave them on: 58 // then we can disable the gamma hacks. Otherwise, leave them on. In either case, we still
59 // want the contrast boost:
59 if (GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) && 60 if (GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
60 !grPaint.getDisableOutputConversionToSRGB()) { 61 !grPaint.getDisableOutputConversionToSRGB()) {
61 return SkPaint::FakeGamma::Off; 62 return SkPaint::kBoostContrast_ScalerContextFlag;
62 } else { 63 } else {
63 return SkPaint::FakeGamma::On; 64 return SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
64 } 65 }
65 } 66 }
66 67
67 // TODO if this function ever shows up in profiling, then we can compute this va lue when the 68 // TODO if this function ever shows up in profiling, then we can compute this va lue when the
68 // textblob is being built and cache it. However, for the time being textblobs mostly only have 1 69 // textblob is being built and cache it. However, for the time being textblobs mostly only have 1
69 // run so this is not a big deal to compute here. 70 // run so this is not a big deal to compute here.
70 bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) { 71 bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) {
71 SkTextBlobRunIterator it(blob); 72 SkTextBlobRunIterator it(blob);
72 for (; !it.done(); it.next()) { 73 for (; !it.done(); it.next()) {
73 if (it.isLCD()) { 74 if (it.isLCD()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 cacheBlob.reset(SkSafeRef(cache->find(key))); 121 cacheBlob.reset(SkSafeRef(cache->find(key)));
121 } 122 }
122 123
123 // Though for the time being runs in the textblob can override the paint, th ey only touch font 124 // Though for the time being runs in the textblob can override the paint, th ey only touch font
124 // info. 125 // info.
125 GrPaint grPaint; 126 GrPaint grPaint;
126 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(), &grPaint)) { 127 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(), &grPaint)) {
127 return; 128 return;
128 } 129 }
129 130
130 SkPaint::FakeGamma fakeGamma = ComputeFakeGamma(dc, grPaint); 131 uint32_t scalerContextFlags = ComputeScalerContextFlags(dc, grPaint);
131 132
132 if (cacheBlob) { 133 if (cacheBlob) {
133 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view Matrix, x, y)) { 134 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view Matrix, x, y)) {
134 // We have to remake the blob because changes may invalidate our mas ks. 135 // We have to remake the blob because changes may invalidate our mas ks.
135 // TODO we could probably get away reuse most of the time if the poi nter is unique, 136 // TODO we could probably get away reuse most of the time if the poi nter is unique,
136 // but we'd have to clear the subrun information 137 // but we'd have to clear the subrun information
137 cache->remove(cacheBlob); 138 cache->remove(cacheBlob);
138 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint))); 139 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint)));
139 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(), 140 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
140 *context->caps()->shaderCaps(), skPaint, grPaint. getColor(), 141 *context->caps()->shaderCaps(), skPaint, grPaint. getColor(),
141 fakeGamma, viewMatrix, props, 142 scalerContextFlags, viewMatrix, props,
142 blob, x, y, drawFilter); 143 blob, x, y, drawFilter);
143 } else { 144 } else {
144 cache->makeMRU(cacheBlob); 145 cache->makeMRU(cacheBlob);
145 146
146 if (CACHE_SANITY_CHECK) { 147 if (CACHE_SANITY_CHECK) {
147 int glyphCount = 0; 148 int glyphCount = 0;
148 int runCount = 0; 149 int runCount = 0;
149 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob); 150 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
150 SkAutoTUnref<GrAtlasTextBlob> sanityBlob(cache->createBlob(glyph Count, runCount)); 151 SkAutoTUnref<GrAtlasTextBlob> sanityBlob(cache->createBlob(glyph Count, runCount));
151 sanityBlob->setupKey(key, blurRec, skPaint); 152 sanityBlob->setupKey(key, blurRec, skPaint);
152 RegenerateTextBlob(sanityBlob, context->getBatchFontCache(), 153 RegenerateTextBlob(sanityBlob, context->getBatchFontCache(),
153 *context->caps()->shaderCaps(), skPaint, 154 *context->caps()->shaderCaps(), skPaint,
154 grPaint.getColor(), fakeGamma, viewMatrix, pr ops, 155 grPaint.getColor(), scalerContextFlags, viewM atrix, props,
155 blob, x, y, drawFilter); 156 blob, x, y, drawFilter);
156 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob); 157 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
157 } 158 }
158 } 159 }
159 } else { 160 } else {
160 if (canCache) { 161 if (canCache) {
161 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint))); 162 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint)));
162 } else { 163 } else {
163 cacheBlob.reset(cache->createBlob(blob)); 164 cacheBlob.reset(cache->createBlob(blob));
164 } 165 }
165 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(), 166 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
166 *context->caps()->shaderCaps(), skPaint, grPaint.getC olor(), 167 *context->caps()->shaderCaps(), skPaint, grPaint.getC olor(),
167 fakeGamma, viewMatrix, props, 168 scalerContextFlags, viewMatrix, props,
168 blob, x, y, drawFilter); 169 blob, x, y, drawFilter);
169 } 170 }
170 171
171 cacheBlob->flushCached(context, dc, blob, props, fDistanceAdjustTable, skPai nt, 172 cacheBlob->flushCached(context, dc, blob, props, fDistanceAdjustTable, skPai nt,
172 grPaint, drawFilter, clip, viewMatrix, clipBounds, x, y); 173 grPaint, drawFilter, clip, viewMatrix, clipBounds, x, y);
173 } 174 }
174 175
175 void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob, 176 void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
176 GrBatchFontCache* fontCache, 177 GrBatchFontCache* fontCache,
177 const GrShaderCaps& shaderCaps, 178 const GrShaderCaps& shaderCaps,
178 const SkPaint& skPaint, GrColor colo r, 179 const SkPaint& skPaint, GrColor colo r,
179 SkPaint::FakeGamma fakeGamma, 180 uint32_t scalerContextFlags,
180 const SkMatrix& viewMatrix, 181 const SkMatrix& viewMatrix,
181 const SkSurfaceProps& props, 182 const SkSurfaceProps& props,
182 const SkTextBlob* blob, SkScalar x, SkScalar y, 183 const SkTextBlob* blob, SkScalar x, SkScalar y,
183 SkDrawFilter* drawFilter) { 184 SkDrawFilter* drawFilter) {
184 cacheBlob->initReusableBlob(color, viewMatrix, x, y); 185 cacheBlob->initReusableBlob(color, viewMatrix, x, y);
185 186
186 // Regenerate textblob 187 // Regenerate textblob
187 SkPaint runPaint = skPaint; 188 SkPaint runPaint = skPaint;
188 SkTextBlobRunIterator it(blob); 189 SkTextBlobRunIterator it(blob);
189 for (int run = 0; !it.done(); it.next(), run++) { 190 for (int run = 0; !it.done(); it.next(), run++) {
(...skipping 11 matching lines...) Expand all
201 } 202 }
202 203
203 runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint)); 204 runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
204 205
205 cacheBlob->push_back_run(run); 206 cacheBlob->push_back_run(run);
206 207
207 if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, sh aderCaps)) { 208 if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, sh aderCaps)) {
208 switch (it.positioning()) { 209 switch (it.positioning()) {
209 case SkTextBlob::kDefault_Positioning: { 210 case SkTextBlob::kDefault_Positioning: {
210 GrTextUtils::DrawDFText(cacheBlob, run, fontCache, 211 GrTextUtils::DrawDFText(cacheBlob, run, fontCache,
211 props, runPaint, color, fakeGamma, v iewMatrix, 212 props, runPaint, color, scalerContex tFlags,
212 (const char *)it.glyphs(), textLen, 213 viewMatrix, (const char *)it.glyphs( ), textLen,
213 x + offset.x(), y + offset.y()); 214 x + offset.x(), y + offset.y());
214 break; 215 break;
215 } 216 }
216 case SkTextBlob::kHorizontal_Positioning: { 217 case SkTextBlob::kHorizontal_Positioning: {
217 SkPoint dfOffset = SkPoint::Make(x, y + offset.y()); 218 SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
218 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache, 219 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
219 props, runPaint, color, fakeGamma , viewMatrix, 220 props, runPaint, color, scalerCon textFlags,
220 (const char*)it.glyphs(), textLen , it.pos(), 221 viewMatrix, (const char*)it.glyph s(), textLen,
221 1, dfOffset); 222 it.pos(), 1, dfOffset);
222 break; 223 break;
223 } 224 }
224 case SkTextBlob::kFull_Positioning: { 225 case SkTextBlob::kFull_Positioning: {
225 SkPoint dfOffset = SkPoint::Make(x, y); 226 SkPoint dfOffset = SkPoint::Make(x, y);
226 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache, 227 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
227 props, runPaint, color, fakeGamma , viewMatrix, 228 props, runPaint, color, scalerCon textFlags,
228 (const char*)it.glyphs(), textLen , it.pos(), 229 viewMatrix, (const char*)it.glyph s(), textLen,
229 2, dfOffset); 230 it.pos(), 2, dfOffset);
230 break; 231 break;
231 } 232 }
232 } 233 }
233 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) { 234 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) {
234 cacheBlob->setRunDrawAsPaths(run); 235 cacheBlob->setRunDrawAsPaths(run);
235 } else { 236 } else {
236 switch (it.positioning()) { 237 switch (it.positioning()) {
237 case SkTextBlob::kDefault_Positioning: 238 case SkTextBlob::kDefault_Positioning:
238 GrTextUtils::DrawBmpText(cacheBlob, run, fontCache, 239 GrTextUtils::DrawBmpText(cacheBlob, run, fontCache,
239 props, runPaint, color, fakeGamma, viewMatrix, 240 props, runPaint, color, scalerConte xtFlags,
240 (const char *)it.glyphs(), textLen, 241 viewMatrix, (const char *)it.glyphs (), textLen,
241 x + offset.x(), y + offset.y()); 242 x + offset.x(), y + offset.y());
242 break; 243 break;
243 case SkTextBlob::kHorizontal_Positioning: 244 case SkTextBlob::kHorizontal_Positioning:
244 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache, 245 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
245 props, runPaint, color, fakeGamm a, viewMatrix, 246 props, runPaint, color, scalerCo ntextFlags,
246 (const char*)it.glyphs(), textLe n, it.pos(), 1, 247 viewMatrix, (const char*)it.glyp hs(), textLen,
247 SkPoint::Make(x, y + offset.y()) ); 248 it.pos(), 1, SkPoint::Make(x, y + offset.y()));
248 break; 249 break;
249 case SkTextBlob::kFull_Positioning: 250 case SkTextBlob::kFull_Positioning:
250 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache, 251 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
251 props, runPaint, color, fakeGamm a, viewMatrix, 252 props, runPaint, color, scalerCo ntextFlags,
252 (const char*)it.glyphs(), textLe n, it.pos(), 2, 253 viewMatrix, (const char*)it.glyp hs(), textLen,
253 SkPoint::Make(x, y)); 254 it.pos(), 2, SkPoint::Make(x, y) );
254 break; 255 break;
255 } 256 }
256 } 257 }
257 258
258 if (drawFilter) { 259 if (drawFilter) {
259 // A draw filter may change the paint arbitrarily, so we must re-see d in this case. 260 // A draw filter may change the paint arbitrarily, so we must re-see d in this case.
260 runPaint = skPaint; 261 runPaint = skPaint;
261 } 262 }
262 } 263 }
263 } 264 }
264 265
265 inline GrAtlasTextBlob* 266 inline GrAtlasTextBlob*
266 GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache, 267 GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
267 GrBatchFontCache* fontCache, 268 GrBatchFontCache* fontCache,
268 const GrShaderCaps& shaderCaps, 269 const GrShaderCaps& shaderCaps,
269 const GrPaint& paint, 270 const GrPaint& paint,
270 const SkPaint& skPaint, 271 const SkPaint& skPaint,
271 SkPaint::FakeGamma fakeGamma, 272 uint32_t scalerContextFlags,
272 const SkMatrix& viewMatrix, 273 const SkMatrix& viewMatrix,
273 const SkSurfaceProps& props, 274 const SkSurfaceProps& props,
274 const char text[], size_t byteLength, 275 const char text[], size_t byteLength,
275 SkScalar x, SkScalar y) { 276 SkScalar x, SkScalar y) {
276 int glyphCount = skPaint.countText(text, byteLength); 277 int glyphCount = skPaint.countText(text, byteLength);
277 278
278 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1); 279 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1);
279 blob->initThrowawayBlob(viewMatrix, x, y); 280 blob->initThrowawayBlob(viewMatrix, x, y);
280 281
281 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) { 282 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) {
282 GrTextUtils::DrawDFText(blob, 0, fontCache, props, 283 GrTextUtils::DrawDFText(blob, 0, fontCache, props, skPaint, paint.getCol or(),
283 skPaint, paint.getColor(), fakeGamma, viewMatrix , text, 284 scalerContextFlags, viewMatrix, text, byteLength , x, y);
284 byteLength, x, y);
285 } else { 285 } else {
286 GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint, 286 GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint, paint.getCo lor(),
287 paint.getColor(), fakeGamma, viewMatrix, text, byteLength, x, y); 287 scalerContextFlags, viewMatrix, text, byteLengt h, x, y);
288 } 288 }
289 return blob; 289 return blob;
290 } 290 }
291 291
292 inline GrAtlasTextBlob* 292 inline GrAtlasTextBlob*
293 GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFon tCache* fontCache, 293 GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFon tCache* fontCache,
294 const GrShaderCaps& shaderCaps, const GrPaint& paint, 294 const GrShaderCaps& shaderCaps, const GrPaint& paint,
295 const SkPaint& skPaint, SkPaint::FakeG amma fakeGamma, 295 const SkPaint& skPaint, uint32_t scale rContextFlags,
296 const SkMatrix& viewMatrix, const SkSu rfaceProps& props, 296 const SkMatrix& viewMatrix, const SkSu rfaceProps& props,
297 const char text[], size_t byteLength, 297 const char text[], size_t byteLength,
298 const SkScalar pos[], int scalarsPerPo sition, 298 const SkScalar pos[], int scalarsPerPo sition,
299 const SkPoint& offset) { 299 const SkPoint& offset) {
300 int glyphCount = skPaint.countText(text, byteLength); 300 int glyphCount = skPaint.countText(text, byteLength);
301 301
302 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1); 302 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1);
303 blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y()); 303 blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y());
304 304
305 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) { 305 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) {
306 GrTextUtils::DrawDFPosText(blob, 0, fontCache, props, 306 GrTextUtils::DrawDFPosText(blob, 0, fontCache, props,
307 skPaint, paint.getColor(), fakeGamma, viewMat rix, text, 307 skPaint, paint.getColor(), scalerContextFlags , viewMatrix, text,
308 byteLength, pos, scalarsPerPosition, offset); 308 byteLength, pos, scalarsPerPosition, offset);
309 } else { 309 } else {
310 GrTextUtils::DrawBmpPosText(blob, 0, fontCache, props, skPaint, 310 GrTextUtils::DrawBmpPosText(blob, 0, fontCache, props, skPaint,
311 paint.getColor(), fakeGamma, viewMatrix, tex t, 311 paint.getColor(), scalerContextFlags, viewMa trix, text,
312 byteLength, pos, scalarsPerPosition, offset) ; 312 byteLength, pos, scalarsPerPosition, offset) ;
313 } 313 }
314 return blob; 314 return blob;
315 } 315 }
316 316
317 void GrAtlasTextContext::drawText(GrContext* context, 317 void GrAtlasTextContext::drawText(GrContext* context,
318 GrDrawContext* dc, 318 GrDrawContext* dc,
319 const GrClip& clip, 319 const GrClip& clip,
320 const GrPaint& paint, const SkPaint& skPaint, 320 const GrPaint& paint, const SkPaint& skPaint,
321 const SkMatrix& viewMatrix, 321 const SkMatrix& viewMatrix,
322 const SkSurfaceProps& props, 322 const SkSurfaceProps& props,
323 const char text[], size_t byteLength, 323 const char text[], size_t byteLength,
324 SkScalar x, SkScalar y, const SkIRect& regionC lipBounds) { 324 SkScalar x, SkScalar y, const SkIRect& regionC lipBounds) {
325 if (context->abandoned()) { 325 if (context->abandoned()) {
326 return; 326 return;
327 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) { 327 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) {
328 SkAutoTUnref<GrAtlasTextBlob> blob( 328 SkAutoTUnref<GrAtlasTextBlob> blob(
329 CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFon tCache(), 329 CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFon tCache(),
330 *context->caps()->shaderCaps(), 330 *context->caps()->shaderCaps(),
331 paint, skPaint, 331 paint, skPaint,
332 ComputeFakeGamma(dc, paint), 332 ComputeScalerContextFlags(dc, paint),
333 viewMatrix, props, 333 viewMatrix, props,
334 text, byteLength, x, y)); 334 text, byteLength, x, y));
335 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint, 335 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
336 clip, viewMatrix, regionClipBounds, x, y); 336 clip, viewMatrix, regionClipBounds, x, y);
337 return; 337 return;
338 } 338 }
339 339
340 // fall back to drawing as a path 340 // fall back to drawing as a path
341 GrTextUtils::DrawTextAsPath(context, dc, clip, skPaint, viewMatrix, text, by teLength, x, y, 341 GrTextUtils::DrawTextAsPath(context, dc, clip, skPaint, viewMatrix, text, by teLength, x, y,
342 regionClipBounds); 342 regionClipBounds);
343 } 343 }
344 344
345 void GrAtlasTextContext::drawPosText(GrContext* context, 345 void GrAtlasTextContext::drawPosText(GrContext* context,
346 GrDrawContext* dc, 346 GrDrawContext* dc,
347 const GrClip& clip, 347 const GrClip& clip,
348 const GrPaint& paint, const SkPaint& skPain t, 348 const GrPaint& paint, const SkPaint& skPain t,
349 const SkMatrix& viewMatrix, 349 const SkMatrix& viewMatrix,
350 const SkSurfaceProps& props, 350 const SkSurfaceProps& props,
351 const char text[], size_t byteLength, 351 const char text[], size_t byteLength,
352 const SkScalar pos[], int scalarsPerPositio n, 352 const SkScalar pos[], int scalarsPerPositio n,
353 const SkPoint& offset, const SkIRect& regio nClipBounds) { 353 const SkPoint& offset, const SkIRect& regio nClipBounds) {
354 if (context->abandoned()) { 354 if (context->abandoned()) {
355 return; 355 return;
356 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) { 356 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) {
357 SkAutoTUnref<GrAtlasTextBlob> blob( 357 SkAutoTUnref<GrAtlasTextBlob> blob(
358 CreateDrawPosTextBlob(context->getTextBlobCache(), 358 CreateDrawPosTextBlob(context->getTextBlobCache(),
359 context->getBatchFontCache(), 359 context->getBatchFontCache(),
360 *context->caps()->shaderCaps(), 360 *context->caps()->shaderCaps(),
361 paint, skPaint, 361 paint, skPaint,
362 ComputeFakeGamma(dc, paint), 362 ComputeScalerContextFlags(dc, paint),
363 viewMatrix, props, 363 viewMatrix, props,
364 text, byteLength, 364 text, byteLength,
365 pos, scalarsPerPosition, 365 pos, scalarsPerPosition,
366 offset)); 366 offset));
367 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint, 367 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
368 clip, viewMatrix, regionClipBounds, offset.fX, offs et.fY); 368 clip, viewMatrix, regionClipBounds, offset.fX, offs et.fY);
369 return; 369 return;
370 } 370 }
371 371
372 // fall back to drawing as a path 372 // fall back to drawing as a path
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 int yInt = (random->nextU() % kMaxTrans) * yPos; 416 int yInt = (random->nextU() % kMaxTrans) * yPos;
417 SkScalar x = SkIntToScalar(xInt); 417 SkScalar x = SkIntToScalar(xInt);
418 SkScalar y = SkIntToScalar(yInt); 418 SkScalar y = SkIntToScalar(yInt);
419 419
420 // right now we don't handle textblobs, nor do we handle drawPosText. Since we only 420 // right now we don't handle textblobs, nor do we handle drawPosText. Since we only
421 // intend to test the batch with this unit test, that is okay. 421 // intend to test the batch with this unit test, that is okay.
422 SkAutoTUnref<GrAtlasTextBlob> blob( 422 SkAutoTUnref<GrAtlasTextBlob> blob(
423 GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(), 423 GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(),
424 context->getBatchFontCache(), 424 context->getBatchFontCache(),
425 *context->caps()->shaderCaps(), g rPaint, skPaint, 425 *context->caps()->shaderCaps(), g rPaint, skPaint,
426 GrAtlasTextContext::kTextBlobBatc hFakeGamma, 426 GrAtlasTextContext::kTextBlobBatc hScalerContextFlags,
427 viewMatrix, 427 viewMatrix,
428 gSurfaceProps, text, 428 gSurfaceProps, text,
429 static_cast<size_t>(textLen), x, y)); 429 static_cast<size_t>(textLen), x, y));
430 430
431 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain t, 431 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain t,
432 gSurfaceProps, gTextContext->dfAdjustTable(), 432 gSurfaceProps, gTextContext->dfAdjustTable(),
433 context->getBatchFontCache()); 433 context->getBatchFontCache());
434 } 434 }
435 435
436 #endif 436 #endif
OLDNEW
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698