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

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

Issue 1865953003: sRGB text fake-gamma progress (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrTextUtils.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 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) {
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:
59 if (GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
60 !grPaint.getDisableOutputConversionToSRGB()) {
61 return SkPaint::FakeGamma::Off;
62 } else {
63 return SkPaint::FakeGamma::On;
64 }
65 }
66
56 // TODO if this function ever shows up in profiling, then we can compute this va lue when the 67 // TODO if this function ever shows up in profiling, then we can compute this va lue when the
57 // textblob is being built and cache it. However, for the time being textblobs mostly only have 1 68 // textblob is being built and cache it. However, for the time being textblobs mostly only have 1
58 // run so this is not a big deal to compute here. 69 // run so this is not a big deal to compute here.
59 bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) { 70 bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) {
60 SkTextBlobRunIterator it(blob); 71 SkTextBlobRunIterator it(blob);
61 for (; !it.done(); it.next()) { 72 for (; !it.done(); it.next()) {
62 if (it.isLCD()) { 73 if (it.isLCD()) {
63 return true; 74 return true;
64 } 75 }
65 } 76 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 cacheBlob.reset(SkSafeRef(cache->find(key))); 120 cacheBlob.reset(SkSafeRef(cache->find(key)));
110 } 121 }
111 122
112 // Though for the time being runs in the textblob can override the paint, th ey only touch font 123 // Though for the time being runs in the textblob can override the paint, th ey only touch font
113 // info. 124 // info.
114 GrPaint grPaint; 125 GrPaint grPaint;
115 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(), &grPaint)) { 126 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(), &grPaint)) {
116 return; 127 return;
117 } 128 }
118 129
130 SkPaint::FakeGamma fakeGamma = ComputeFakeGamma(dc, grPaint);
131
119 if (cacheBlob) { 132 if (cacheBlob) {
120 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view Matrix, x, y)) { 133 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view Matrix, x, y)) {
121 // We have to remake the blob because changes may invalidate our mas ks. 134 // We have to remake the blob because changes may invalidate our mas ks.
122 // TODO we could probably get away reuse most of the time if the poi nter is unique, 135 // TODO we could probably get away reuse most of the time if the poi nter is unique,
123 // but we'd have to clear the subrun information 136 // but we'd have to clear the subrun information
124 cache->remove(cacheBlob); 137 cache->remove(cacheBlob);
125 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint))); 138 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint)));
126 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(), 139 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
127 *context->caps()->shaderCaps(), skPaint, grPaint. getColor(), 140 *context->caps()->shaderCaps(), skPaint, grPaint. getColor(),
128 viewMatrix, props, 141 fakeGamma, viewMatrix, props,
129 blob, x, y, drawFilter); 142 blob, x, y, drawFilter);
130 } else { 143 } else {
131 cache->makeMRU(cacheBlob); 144 cache->makeMRU(cacheBlob);
132 145
133 if (CACHE_SANITY_CHECK) { 146 if (CACHE_SANITY_CHECK) {
134 int glyphCount = 0; 147 int glyphCount = 0;
135 int runCount = 0; 148 int runCount = 0;
136 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob); 149 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
137 SkAutoTUnref<GrAtlasTextBlob> sanityBlob(cache->createBlob(glyph Count, runCount)); 150 SkAutoTUnref<GrAtlasTextBlob> sanityBlob(cache->createBlob(glyph Count, runCount));
138 sanityBlob->setupKey(key, blurRec, skPaint); 151 sanityBlob->setupKey(key, blurRec, skPaint);
139 RegenerateTextBlob(sanityBlob, context->getBatchFontCache(), 152 RegenerateTextBlob(sanityBlob, context->getBatchFontCache(),
140 *context->caps()->shaderCaps(), skPaint, 153 *context->caps()->shaderCaps(), skPaint,
141 grPaint.getColor(), viewMatrix, props, 154 grPaint.getColor(), fakeGamma, viewMatrix, pr ops,
142 blob, x, y, drawFilter); 155 blob, x, y, drawFilter);
143 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob); 156 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
144 } 157 }
145 } 158 }
146 } else { 159 } else {
147 if (canCache) { 160 if (canCache) {
148 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint))); 161 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint)));
149 } else { 162 } else {
150 cacheBlob.reset(cache->createBlob(blob)); 163 cacheBlob.reset(cache->createBlob(blob));
151 } 164 }
152 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(), 165 RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
153 *context->caps()->shaderCaps(), skPaint, grPaint.getC olor(), 166 *context->caps()->shaderCaps(), skPaint, grPaint.getC olor(),
154 viewMatrix, props, 167 fakeGamma, viewMatrix, props,
155 blob, x, y, drawFilter); 168 blob, x, y, drawFilter);
156 } 169 }
157 170
158 cacheBlob->flushCached(context, dc, blob, props, fDistanceAdjustTable, skPai nt, 171 cacheBlob->flushCached(context, dc, blob, props, fDistanceAdjustTable, skPai nt,
159 grPaint, drawFilter, clip, viewMatrix, clipBounds, x, y); 172 grPaint, drawFilter, clip, viewMatrix, clipBounds, x, y);
160 } 173 }
161 174
162 void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob, 175 void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
163 GrBatchFontCache* fontCache, 176 GrBatchFontCache* fontCache,
164 const GrShaderCaps& shaderCaps, 177 const GrShaderCaps& shaderCaps,
165 const SkPaint& skPaint, GrColor colo r, 178 const SkPaint& skPaint, GrColor colo r,
179 SkPaint::FakeGamma fakeGamma,
166 const SkMatrix& viewMatrix, 180 const SkMatrix& viewMatrix,
167 const SkSurfaceProps& props, 181 const SkSurfaceProps& props,
168 const SkTextBlob* blob, SkScalar x, SkScalar y, 182 const SkTextBlob* blob, SkScalar x, SkScalar y,
169 SkDrawFilter* drawFilter) { 183 SkDrawFilter* drawFilter) {
170 cacheBlob->initReusableBlob(color, viewMatrix, x, y); 184 cacheBlob->initReusableBlob(color, viewMatrix, x, y);
171 185
172 // Regenerate textblob 186 // Regenerate textblob
173 SkPaint runPaint = skPaint; 187 SkPaint runPaint = skPaint;
174 SkTextBlobRunIterator it(blob); 188 SkTextBlobRunIterator it(blob);
175 for (int run = 0; !it.done(); it.next(), run++) { 189 for (int run = 0; !it.done(); it.next(), run++) {
(...skipping 11 matching lines...) Expand all
187 } 201 }
188 202
189 runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint)); 203 runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
190 204
191 cacheBlob->push_back_run(run); 205 cacheBlob->push_back_run(run);
192 206
193 if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, sh aderCaps)) { 207 if (GrTextUtils::CanDrawAsDistanceFields(runPaint, viewMatrix, props, sh aderCaps)) {
194 switch (it.positioning()) { 208 switch (it.positioning()) {
195 case SkTextBlob::kDefault_Positioning: { 209 case SkTextBlob::kDefault_Positioning: {
196 GrTextUtils::DrawDFText(cacheBlob, run, fontCache, 210 GrTextUtils::DrawDFText(cacheBlob, run, fontCache,
197 props, runPaint, color, viewMatrix, 211 props, runPaint, color, fakeGamma, v iewMatrix,
198 (const char *)it.glyphs(), textLen, 212 (const char *)it.glyphs(), textLen,
199 x + offset.x(), y + offset.y()); 213 x + offset.x(), y + offset.y());
200 break; 214 break;
201 } 215 }
202 case SkTextBlob::kHorizontal_Positioning: { 216 case SkTextBlob::kHorizontal_Positioning: {
203 SkPoint dfOffset = SkPoint::Make(x, y + offset.y()); 217 SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
204 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache, 218 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
205 props, runPaint, color, viewMatri x, 219 props, runPaint, color, fakeGamma , viewMatrix,
206 (const char*)it.glyphs(), textLen , it.pos(), 220 (const char*)it.glyphs(), textLen , it.pos(),
207 1, dfOffset); 221 1, dfOffset);
208 break; 222 break;
209 } 223 }
210 case SkTextBlob::kFull_Positioning: { 224 case SkTextBlob::kFull_Positioning: {
211 SkPoint dfOffset = SkPoint::Make(x, y); 225 SkPoint dfOffset = SkPoint::Make(x, y);
212 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache, 226 GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
213 props, runPaint, color, viewMatri x, 227 props, runPaint, color, fakeGamma , viewMatrix,
214 (const char*)it.glyphs(), textLen , it.pos(), 228 (const char*)it.glyphs(), textLen , it.pos(),
215 2, dfOffset); 229 2, dfOffset);
216 break; 230 break;
217 } 231 }
218 } 232 }
219 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) { 233 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) {
220 cacheBlob->setRunDrawAsPaths(run); 234 cacheBlob->setRunDrawAsPaths(run);
221 } else { 235 } else {
222 switch (it.positioning()) { 236 switch (it.positioning()) {
223 case SkTextBlob::kDefault_Positioning: 237 case SkTextBlob::kDefault_Positioning:
224 GrTextUtils::DrawBmpText(cacheBlob, run, fontCache, 238 GrTextUtils::DrawBmpText(cacheBlob, run, fontCache,
225 props, runPaint, color, viewMatrix, 239 props, runPaint, color, fakeGamma, viewMatrix,
226 (const char *)it.glyphs(), textLen, 240 (const char *)it.glyphs(), textLen,
227 x + offset.x(), y + offset.y()); 241 x + offset.x(), y + offset.y());
228 break; 242 break;
229 case SkTextBlob::kHorizontal_Positioning: 243 case SkTextBlob::kHorizontal_Positioning:
230 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache, 244 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
231 props, runPaint, color, viewMatr ix, 245 props, runPaint, color, fakeGamm a, viewMatrix,
232 (const char*)it.glyphs(), textLe n, it.pos(), 1, 246 (const char*)it.glyphs(), textLe n, it.pos(), 1,
233 SkPoint::Make(x, y + offset.y()) ); 247 SkPoint::Make(x, y + offset.y()) );
234 break; 248 break;
235 case SkTextBlob::kFull_Positioning: 249 case SkTextBlob::kFull_Positioning:
236 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache, 250 GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
237 props, runPaint, color, viewMatr ix, 251 props, runPaint, color, fakeGamm a, viewMatrix,
238 (const char*)it.glyphs(), textLe n, it.pos(), 2, 252 (const char*)it.glyphs(), textLe n, it.pos(), 2,
239 SkPoint::Make(x, y)); 253 SkPoint::Make(x, y));
240 break; 254 break;
241 } 255 }
242 } 256 }
243 257
244 if (drawFilter) { 258 if (drawFilter) {
245 // A draw filter may change the paint arbitrarily, so we must re-see d in this case. 259 // A draw filter may change the paint arbitrarily, so we must re-see d in this case.
246 runPaint = skPaint; 260 runPaint = skPaint;
247 } 261 }
248 } 262 }
249 } 263 }
250 264
251 inline GrAtlasTextBlob* 265 inline GrAtlasTextBlob*
252 GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache, 266 GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
253 GrBatchFontCache* fontCache, 267 GrBatchFontCache* fontCache,
254 const GrShaderCaps& shaderCaps, 268 const GrShaderCaps& shaderCaps,
255 const GrPaint& paint, 269 const GrPaint& paint,
256 const SkPaint& skPaint, 270 const SkPaint& skPaint,
271 SkPaint::FakeGamma fakeGamma,
257 const SkMatrix& viewMatrix, 272 const SkMatrix& viewMatrix,
258 const SkSurfaceProps& props, 273 const SkSurfaceProps& props,
259 const char text[], size_t byteLength, 274 const char text[], size_t byteLength,
260 SkScalar x, SkScalar y) { 275 SkScalar x, SkScalar y) {
261 int glyphCount = skPaint.countText(text, byteLength); 276 int glyphCount = skPaint.countText(text, byteLength);
262 277
263 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1); 278 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1);
264 blob->initThrowawayBlob(viewMatrix, x, y); 279 blob->initThrowawayBlob(viewMatrix, x, y);
265 280
266 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) { 281 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) {
267 GrTextUtils::DrawDFText(blob, 0, fontCache, props, 282 GrTextUtils::DrawDFText(blob, 0, fontCache, props,
268 skPaint, paint.getColor(), viewMatrix, text, 283 skPaint, paint.getColor(), fakeGamma, viewMatrix , text,
269 byteLength, x, y); 284 byteLength, x, y);
270 } else { 285 } else {
271 GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint, 286 GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint,
272 paint.getColor(), viewMatrix, text, byteLength, x, y); 287 paint.getColor(), fakeGamma, viewMatrix, text, byteLength, x, y);
273 } 288 }
274 return blob; 289 return blob;
275 } 290 }
276 291
277 inline GrAtlasTextBlob* 292 inline GrAtlasTextBlob*
278 GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFon tCache* fontCache, 293 GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFon tCache* fontCache,
279 const GrShaderCaps& shaderCaps, const GrPaint& paint, 294 const GrShaderCaps& shaderCaps, const GrPaint& paint,
280 const SkPaint& skPaint, 295 const SkPaint& skPaint, SkPaint::FakeG amma fakeGamma,
281 const SkMatrix& viewMatrix, const SkSu rfaceProps& props, 296 const SkMatrix& viewMatrix, const SkSu rfaceProps& props,
282 const char text[], size_t byteLength, 297 const char text[], size_t byteLength,
283 const SkScalar pos[], int scalarsPerPo sition, 298 const SkScalar pos[], int scalarsPerPo sition,
284 const SkPoint& offset) { 299 const SkPoint& offset) {
285 int glyphCount = skPaint.countText(text, byteLength); 300 int glyphCount = skPaint.countText(text, byteLength);
286 301
287 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1); 302 GrAtlasTextBlob* blob = blobCache->createBlob(glyphCount, 1);
288 blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y()); 303 blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y());
289 304
290 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) { 305 if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderC aps)) {
291 GrTextUtils::DrawDFPosText(blob, 0, fontCache, props, 306 GrTextUtils::DrawDFPosText(blob, 0, fontCache, props,
292 skPaint, paint.getColor(), viewMatrix, text, 307 skPaint, paint.getColor(), fakeGamma, viewMat rix, text,
293 byteLength, pos, scalarsPerPosition, offset); 308 byteLength, pos, scalarsPerPosition, offset);
294 } else { 309 } else {
295 GrTextUtils::DrawBmpPosText(blob, 0, fontCache, props, skPaint, 310 GrTextUtils::DrawBmpPosText(blob, 0, fontCache, props, skPaint,
296 paint.getColor(), viewMatrix, text, 311 paint.getColor(), fakeGamma, viewMatrix, tex t,
297 byteLength, pos, scalarsPerPosition, offset) ; 312 byteLength, pos, scalarsPerPosition, offset) ;
298 } 313 }
299 return blob; 314 return blob;
300 } 315 }
301 316
302 void GrAtlasTextContext::drawText(GrContext* context, 317 void GrAtlasTextContext::drawText(GrContext* context,
303 GrDrawContext* dc, 318 GrDrawContext* dc,
304 const GrClip& clip, 319 const GrClip& clip,
305 const GrPaint& paint, const SkPaint& skPaint, 320 const GrPaint& paint, const SkPaint& skPaint,
306 const SkMatrix& viewMatrix, 321 const SkMatrix& viewMatrix,
307 const SkSurfaceProps& props, 322 const SkSurfaceProps& props,
308 const char text[], size_t byteLength, 323 const char text[], size_t byteLength,
309 SkScalar x, SkScalar y, const SkIRect& regionC lipBounds) { 324 SkScalar x, SkScalar y, const SkIRect& regionC lipBounds) {
310 if (context->abandoned()) { 325 if (context->abandoned()) {
311 return; 326 return;
312 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) { 327 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) {
313 SkAutoTUnref<GrAtlasTextBlob> blob( 328 SkAutoTUnref<GrAtlasTextBlob> blob(
314 CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFon tCache(), 329 CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFon tCache(),
315 *context->caps()->shaderCaps(), 330 *context->caps()->shaderCaps(),
316 paint, skPaint, 331 paint, skPaint,
332 ComputeFakeGamma(dc, paint),
317 viewMatrix, props, 333 viewMatrix, props,
318 text, byteLength, x, y)); 334 text, byteLength, x, y));
319 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint, 335 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
320 clip, viewMatrix, regionClipBounds, x, y); 336 clip, viewMatrix, regionClipBounds, x, y);
321 return; 337 return;
322 } 338 }
323 339
324 // fall back to drawing as a path 340 // fall back to drawing as a path
325 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,
326 regionClipBounds); 342 regionClipBounds);
327 } 343 }
328 344
329 void GrAtlasTextContext::drawPosText(GrContext* context, 345 void GrAtlasTextContext::drawPosText(GrContext* context,
330 GrDrawContext* dc, 346 GrDrawContext* dc,
331 const GrClip& clip, 347 const GrClip& clip,
332 const GrPaint& paint, const SkPaint& skPain t, 348 const GrPaint& paint, const SkPaint& skPain t,
333 const SkMatrix& viewMatrix, 349 const SkMatrix& viewMatrix,
334 const SkSurfaceProps& props, 350 const SkSurfaceProps& props,
335 const char text[], size_t byteLength, 351 const char text[], size_t byteLength,
336 const SkScalar pos[], int scalarsPerPositio n, 352 const SkScalar pos[], int scalarsPerPositio n,
337 const SkPoint& offset, const SkIRect& regio nClipBounds) { 353 const SkPoint& offset, const SkIRect& regio nClipBounds) {
338 if (context->abandoned()) { 354 if (context->abandoned()) {
339 return; 355 return;
340 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) { 356 } else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shade rCaps())) {
341 SkAutoTUnref<GrAtlasTextBlob> blob( 357 SkAutoTUnref<GrAtlasTextBlob> blob(
342 CreateDrawPosTextBlob(context->getTextBlobCache(), 358 CreateDrawPosTextBlob(context->getTextBlobCache(),
343 context->getBatchFontCache(), 359 context->getBatchFontCache(),
344 *context->caps()->shaderCaps(), 360 *context->caps()->shaderCaps(),
345 paint, skPaint, viewMatrix, props, 361 paint, skPaint,
362 ComputeFakeGamma(dc, paint),
363 viewMatrix, props,
346 text, byteLength, 364 text, byteLength,
347 pos, scalarsPerPosition, 365 pos, scalarsPerPosition,
348 offset)); 366 offset));
349 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint, 367 blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
350 clip, viewMatrix, regionClipBounds, offset.fX, offs et.fY); 368 clip, viewMatrix, regionClipBounds, offset.fX, offs et.fY);
351 return; 369 return;
352 } 370 }
353 371
354 // fall back to drawing as a path 372 // fall back to drawing as a path
355 GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, skPaint, viewMatrix , text, 373 GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, skPaint, viewMatrix , text,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 int yInt = (random->nextU() % kMaxTrans) * yPos; 416 int yInt = (random->nextU() % kMaxTrans) * yPos;
399 SkScalar x = SkIntToScalar(xInt); 417 SkScalar x = SkIntToScalar(xInt);
400 SkScalar y = SkIntToScalar(yInt); 418 SkScalar y = SkIntToScalar(yInt);
401 419
402 // 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
403 // 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.
404 SkAutoTUnref<GrAtlasTextBlob> blob( 422 SkAutoTUnref<GrAtlasTextBlob> blob(
405 GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(), 423 GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(),
406 context->getBatchFontCache(), 424 context->getBatchFontCache(),
407 *context->caps()->shaderCaps(), g rPaint, skPaint, 425 *context->caps()->shaderCaps(), g rPaint, skPaint,
426 GrAtlasTextContext::kTextBlobBatc hFakeGamma,
408 viewMatrix, 427 viewMatrix,
409 gSurfaceProps, text, 428 gSurfaceProps, text,
410 static_cast<size_t>(textLen), x, y)); 429 static_cast<size_t>(textLen), x, y));
411 430
412 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,
413 gSurfaceProps, gTextContext->dfAdjustTable(), 432 gSurfaceProps, gTextContext->dfAdjustTable(),
414 context->getBatchFontCache()); 433 context->getBatchFontCache());
415 } 434 }
416 435
417 #endif 436 #endif
OLDNEW
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrTextUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698