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

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

Issue 1711223003: Only use fake gamma with linear devices. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Formatting. Created 4 years, 10 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/GrStencilAndCoverTextContext.cpp ('k') | no next file » | 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 #include "GrTextUtils.h" 8 #include "GrTextUtils.h"
9 9
10 #include "GrAtlasTextBlob.h" 10 #include "GrAtlasTextBlob.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (text == nullptr || byteLength == 0) { 50 if (text == nullptr || byteLength == 0) {
51 return; 51 return;
52 } 52 }
53 53
54 // Ensure the blob is set for bitmaptext 54 // Ensure the blob is set for bitmaptext
55 blob->setHasBitmap(); 55 blob->setHasBitmap();
56 56
57 GrBatchTextStrike* currStrike = nullptr; 57 GrBatchTextStrike* currStrike = nullptr;
58 58
59 // Get GrFontScaler from cache 59 // Get GrFontScaler from cache
60 SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix , false); 60 SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma:: On,
61 skPaint, &viewMatrix);
61 GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache); 62 GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
62 63
63 SkFindAndPlaceGlyph::ProcessText( 64 SkFindAndPlaceGlyph::ProcessText(
64 skPaint.getTextEncoding(), text, byteLength, 65 skPaint.getTextEncoding(), text, byteLength,
65 {x, y}, viewMatrix, skPaint.getTextAlign(), 66 {x, y}, viewMatrix, skPaint.getTextAlign(),
66 cache, 67 cache,
67 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 68 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
68 position += rounding; 69 position += rounding;
69 BmpAppendGlyph( 70 BmpAppendGlyph(
70 blob, runIndex, fontCache, &currStrike, glyph, 71 blob, runIndex, fontCache, &currStrike, glyph,
(...skipping 20 matching lines...) Expand all
91 if (text == nullptr || byteLength == 0) { 92 if (text == nullptr || byteLength == 0) {
92 return; 93 return;
93 } 94 }
94 95
95 // Ensure the blob is set for bitmaptext 96 // Ensure the blob is set for bitmaptext
96 blob->setHasBitmap(); 97 blob->setHasBitmap();
97 98
98 GrBatchTextStrike* currStrike = nullptr; 99 GrBatchTextStrike* currStrike = nullptr;
99 100
100 // Get GrFontScaler from cache 101 // Get GrFontScaler from cache
101 SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix , false); 102 SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma:: On,
103 skPaint, &viewMatrix);
102 GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache); 104 GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
103 105
104 SkFindAndPlaceGlyph::ProcessPosText( 106 SkFindAndPlaceGlyph::ProcessPosText(
105 skPaint.getTextEncoding(), text, byteLength, 107 skPaint.getTextEncoding(), text, byteLength,
106 offset, viewMatrix, pos, scalarsPerPosition, 108 offset, viewMatrix, pos, scalarsPerPosition,
107 skPaint.getTextAlign(), cache, 109 skPaint.getTextAlign(), cache,
108 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 110 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
109 position += rounding; 111 position += rounding;
110 BmpAppendGlyph( 112 BmpAppendGlyph(
111 blob, runIndex, fontCache, &currStrike, glyph, 113 blob, runIndex, fontCache, &currStrike, glyph,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 SkScalar x, SkScalar y) { 253 SkScalar x, SkScalar y) {
252 SkASSERT(byteLength == 0 || text != nullptr); 254 SkASSERT(byteLength == 0 || text != nullptr);
253 255
254 // nothing to draw 256 // nothing to draw
255 if (text == nullptr || byteLength == 0) { 257 if (text == nullptr || byteLength == 0) {
256 return; 258 return;
257 } 259 }
258 260
259 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); 261 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
260 SkAutoDescriptor desc; 262 SkAutoDescriptor desc;
261 skPaint.getScalerContextDescriptor(&desc, props, nullptr, true); 263 skPaint.getScalerContextDescriptor(&desc, props, SkPaint::FakeGamma::Off, nu llptr);
262 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(skPaint.getTypeface (), 264 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(skPaint.getTypeface (),
263 desc.getDesc()); 265 desc.getDesc());
264 266
265 SkTArray<SkScalar> positions; 267 SkTArray<SkScalar> positions;
266 268
267 const char* textPtr = text; 269 const char* textPtr = text;
268 SkFixed stopX = 0; 270 SkFixed stopX = 0;
269 SkFixed stopY = 0; 271 SkFixed stopY = 0;
270 SkFixed origin = 0; 272 SkFixed origin = 0;
271 switch (skPaint.getTextAlign()) { 273 switch (skPaint.getTextAlign()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 334
333 // Setup distance field paint and text ratio 335 // Setup distance field paint and text ratio
334 SkScalar textRatio; 336 SkScalar textRatio;
335 SkPaint dfPaint(origPaint); 337 SkPaint dfPaint(origPaint);
336 GrTextUtils::InitDistanceFieldPaint(blob, &dfPaint, &textRatio, viewMatrix); 338 GrTextUtils::InitDistanceFieldPaint(blob, &dfPaint, &textRatio, viewMatrix);
337 blob->setHasDistanceField(); 339 blob->setHasDistanceField();
338 blob->setSubRunHasDistanceFields(runIndex, origPaint.isLCDRenderText()); 340 blob->setSubRunHasDistanceFields(runIndex, origPaint.isLCDRenderText());
339 341
340 GrBatchTextStrike* currStrike = nullptr; 342 GrBatchTextStrike* currStrike = nullptr;
341 343
342 SkGlyphCache* cache = blob->setupCache(runIndex, props, dfPaint, nullptr, tr ue); 344 SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma:: Off,
345 dfPaint, nullptr);
343 SkDrawCacheProc glyphCacheProc = dfPaint.getDrawCacheProc(); 346 SkDrawCacheProc glyphCacheProc = dfPaint.getDrawCacheProc();
344 GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache); 347 GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
345 348
346 const char* stop = text + byteLength; 349 const char* stop = text + byteLength;
347 350
348 if (SkPaint::kLeft_Align == dfPaint.getTextAlign()) { 351 if (SkPaint::kLeft_Align == dfPaint.getTextAlign()) {
349 while (text < stop) { 352 while (text < stop) {
350 const char* lastText = text; 353 const char* lastText = text;
351 // the last 2 parameters are ignored 354 // the last 2 parameters are ignored
352 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 355 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 if (cache->getAuxProcData(glyph_cache_aux_proc, &auxData)) { 575 if (cache->getAuxProcData(glyph_cache_aux_proc, &auxData)) {
573 scaler = (GrFontScaler*)auxData; 576 scaler = (GrFontScaler*)auxData;
574 } 577 }
575 if (nullptr == scaler) { 578 if (nullptr == scaler) {
576 scaler = new GrFontScaler(cache); 579 scaler = new GrFontScaler(cache);
577 cache->setAuxProc(glyph_cache_aux_proc, scaler); 580 cache->setAuxProc(glyph_cache_aux_proc, scaler);
578 } 581 }
579 582
580 return scaler; 583 return scaler;
581 } 584 }
OLDNEW
« no previous file with comments | « src/gpu/text/GrStencilAndCoverTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698