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

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

Issue 1885613002: sRGB support for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Break long line 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
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 "GrAtlasTextBlob.h" 8 #include "GrAtlasTextBlob.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return false; 250 return false;
251 } 251 }
252 252
253 inline GrDrawBatch* GrAtlasTextBlob::createBatch( 253 inline GrDrawBatch* GrAtlasTextBlob::createBatch(
254 const Run::SubRunInfo& info, 254 const Run::SubRunInfo& info,
255 int glyphCount, int run, int subRu n, 255 int glyphCount, int run, int subRu n,
256 const SkMatrix& viewMatrix, SkScal ar x, SkScalar y, 256 const SkMatrix& viewMatrix, SkScal ar x, SkScalar y,
257 GrColor color, 257 GrColor color,
258 const SkPaint& skPaint, const SkSu rfaceProps& props, 258 const SkPaint& skPaint, const SkSu rfaceProps& props,
259 const GrDistanceFieldAdjustTable* distanceAdjustTable, 259 const GrDistanceFieldAdjustTable* distanceAdjustTable,
260 bool useSRGBDistanceTable,
260 GrBatchFontCache* cache) { 261 GrBatchFontCache* cache) {
261 GrMaskFormat format = info.maskFormat(); 262 GrMaskFormat format = info.maskFormat();
262 GrColor subRunColor; 263 GrColor subRunColor;
263 if (kARGB_GrMaskFormat == format) { 264 if (kARGB_GrMaskFormat == format) {
264 uint8_t paintAlpha = skPaint.getAlpha(); 265 uint8_t paintAlpha = skPaint.getAlpha();
265 subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAl pha); 266 subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAl pha);
266 } else { 267 } else {
267 subRunColor = color; 268 subRunColor = color;
268 } 269 }
269 270
270 GrAtlasTextBatch* batch; 271 GrAtlasTextBatch* batch;
271 if (info.drawAsDistanceFields()) { 272 if (info.drawAsDistanceFields()) {
272 SkColor filteredColor; 273 SkColor filteredColor;
273 SkColorFilter* colorFilter = skPaint.getColorFilter(); 274 SkColorFilter* colorFilter = skPaint.getColorFilter();
274 if (colorFilter) { 275 if (colorFilter) {
275 filteredColor = colorFilter->filterColor(skPaint.getColor()); 276 filteredColor = colorFilter->filterColor(skPaint.getColor());
276 } else { 277 } else {
277 filteredColor = skPaint.getColor(); 278 filteredColor = skPaint.getColor();
278 } 279 }
279 bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); 280 bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
280 batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, 281 batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache,
281 distanceAdjustTable, filte redColor, 282 distanceAdjustTable, useSR GBDistanceTable,
282 info.hasUseLCDText(), useB GR); 283 filteredColor, info.hasUse LCDText(), useBGR);
283 } else { 284 } else {
284 batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); 285 batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache);
285 } 286 }
286 GrAtlasTextBatch::Geometry& geometry = batch->geometry(); 287 GrAtlasTextBatch::Geometry& geometry = batch->geometry();
287 geometry.fViewMatrix = viewMatrix; 288 geometry.fViewMatrix = viewMatrix;
288 geometry.fBlob = SkRef(this); 289 geometry.fBlob = SkRef(this);
289 geometry.fRun = run; 290 geometry.fRun = run;
290 geometry.fSubRun = subRun; 291 geometry.fSubRun = subRun;
291 geometry.fColor = subRunColor; 292 geometry.fColor = subRunColor;
292 geometry.fX = x; 293 geometry.fX = x;
(...skipping 10 matching lines...) Expand all
303 const SkPaint& skPaint, const SkSurfaceProps& pro ps, 304 const SkPaint& skPaint, const SkSurfaceProps& pro ps,
304 const GrDistanceFieldAdjustTable* distanceAdjustT able, 305 const GrDistanceFieldAdjustTable* distanceAdjustT able,
305 GrBatchFontCache* cache) { 306 GrBatchFontCache* cache) {
306 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { 307 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) {
307 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; 308 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
308 int glyphCount = info.glyphCount(); 309 int glyphCount = info.glyphCount();
309 if (0 == glyphCount) { 310 if (0 == glyphCount) {
310 continue; 311 continue;
311 } 312 }
312 313
314 bool useSRGBDistanceTable = GrPixelConfigIsSRGB(dc->accessRenderTarget() ->config()) &&
315 !pipelineBuilder->getDisableOutputConversion ToSRGB();
316
313 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, 317 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run,
314 subRun, viewMatrix, x, y, color, 318 subRun, viewMatrix, x, y, color,
315 skPaint, props, 319 skPaint, props,
316 distanceAdjustTable, c ache)); 320 distanceAdjustTable, u seSRGBDistanceTable,
321 cache));
317 dc->drawBatch(pipelineBuilder, batch); 322 dc->drawBatch(pipelineBuilder, batch);
318 } 323 }
319 } 324 }
320 325
321 static void calculate_translation(bool applyVM, 326 static void calculate_translation(bool applyVM,
322 const SkMatrix& newViewMatrix, SkScalar newX, SkScalar newY, 327 const SkMatrix& newViewMatrix, SkScalar newX, SkScalar newY,
323 const SkMatrix& currentViewMatrix, SkScalar cu rrentX, 328 const SkMatrix& currentViewMatrix, SkScalar cu rrentX,
324 SkScalar currentY, SkScalar* transX, SkScalar* transY) { 329 SkScalar currentY, SkScalar* transX, SkScalar* transY) {
325 if (applyVM) { 330 if (applyVM) {
326 *transX = newViewMatrix.getTranslateX() + 331 *transX = newViewMatrix.getTranslateX() +
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 461
457 GrDrawBatch* GrAtlasTextBlob::test_createBatch( 462 GrDrawBatch* GrAtlasTextBlob::test_createBatch(
458 int glyphCount, int run, int subRu n, 463 int glyphCount, int run, int subRu n,
459 const SkMatrix& viewMatrix, SkScal ar x, SkScalar y, 464 const SkMatrix& viewMatrix, SkScal ar x, SkScalar y,
460 GrColor color, 465 GrColor color,
461 const SkPaint& skPaint, const SkSu rfaceProps& props, 466 const SkPaint& skPaint, const SkSu rfaceProps& props,
462 const GrDistanceFieldAdjustTable* distanceAdjustTable, 467 const GrDistanceFieldAdjustTable* distanceAdjustTable,
463 GrBatchFontCache* cache) { 468 GrBatchFontCache* cache) {
464 const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun ]; 469 const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun ];
465 return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, co lor, skPaint, 470 return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, co lor, skPaint,
466 props, distanceAdjustTable, cache); 471 props, distanceAdjustTable, false, cache);
467 } 472 }
468 473
469 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo b& r) { 474 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo b& r) {
470 SkASSERT_RELEASE(l.fSize == r.fSize); 475 SkASSERT_RELEASE(l.fSize == r.fSize);
471 SkASSERT_RELEASE(l.fPool == r.fPool); 476 SkASSERT_RELEASE(l.fPool == r.fPool);
472 477
473 SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma); 478 SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma);
474 SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle); 479 SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle);
475 SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality); 480 SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality);
476 481
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 559
555 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa trix, 560 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa trix,
556 SkScalar x, SkScalar y , SkScalar* transX, 561 SkScalar x, SkScalar y , SkScalar* transX,
557 SkScalar* transY) { 562 SkScalar* transY) {
558 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, 563 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y,
559 fCurrentViewMatrix, fX, fY, transX, transY); 564 fCurrentViewMatrix, fX, fY, transX, transY);
560 fCurrentViewMatrix = viewMatrix; 565 fCurrentViewMatrix = viewMatrix;
561 fX = x; 566 fX = x;
562 fY = y; 567 fY = y;
563 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698