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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1845283003: Gamma-correctness pushed into Skia, top-down. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase 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 2011 Google Inc. 2 * Copyright 2011 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 390
391 /////////////////////////////////////////////////////////////////////////////// 391 ///////////////////////////////////////////////////////////////////////////////
392 392
393 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { 393 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
394 ASSERT_SINGLE_OWNER 394 ASSERT_SINGLE_OWNER
395 CHECK_SHOULD_DRAW(draw); 395 CHECK_SHOULD_DRAW(draw);
396 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); 396 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext);
397 397
398 GrPaint grPaint; 398 GrPaint grPaint;
399 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 399 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
400 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
400 return; 401 return;
401 } 402 }
402 403
403 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); 404 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix);
404 } 405 }
405 406
406 // must be in SkCanvas::PointMode order 407 // must be in SkCanvas::PointMode order
407 static const GrPrimitiveType gPointMode2PrimtiveType[] = { 408 static const GrPrimitiveType gPointMode2PrimtiveType[] = {
408 kPoints_GrPrimitiveType, 409 kPoints_GrPrimitiveType,
409 kLines_GrPrimitiveType, 410 kLines_GrPrimitiveType,
(...skipping 29 matching lines...) Expand all
439 CHECK_SHOULD_DRAW(draw); 440 CHECK_SHOULD_DRAW(draw);
440 441
441 SkScalar width = paint.getStrokeWidth(); 442 SkScalar width = paint.getStrokeWidth();
442 if (width < 0) { 443 if (width < 0) {
443 return; 444 return;
444 } 445 }
445 446
446 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) { 447 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) {
447 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); 448 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
448 GrPaint grPaint; 449 GrPaint grPaint;
449 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 450 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
451 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
450 return; 452 return;
451 } 453 }
452 SkPath path; 454 SkPath path;
453 path.setIsVolatile(true); 455 path.setIsVolatile(true);
454 path.moveTo(pts[0]); 456 path.moveTo(pts[0]);
455 path.lineTo(pts[1]); 457 path.lineTo(pts[1]);
456 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, strokeInfo); 458 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, strokeInfo);
457 return; 459 return;
458 } 460 }
459 461
460 // we only handle non-antialiased hairlines and paints without path effects or mask filters, 462 // we only handle non-antialiased hairlines and paints without path effects or mask filters,
461 // else we let the SkDraw call our drawPath() 463 // else we let the SkDraw call our drawPath()
462 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || 464 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() ||
463 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { 465 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) {
464 draw.drawPoints(mode, count, pts, paint, true); 466 draw.drawPoints(mode, count, pts, paint, true);
465 return; 467 return;
466 } 468 }
467 469
468 GrPaint grPaint; 470 GrPaint grPaint;
469 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 471 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
472 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
470 return; 473 return;
471 } 474 }
472 475
473 fDrawContext->drawVertices(fClip, 476 fDrawContext->drawVertices(fClip,
474 grPaint, 477 grPaint,
475 *draw.fMatrix, 478 *draw.fMatrix,
476 gPointMode2PrimtiveType[mode], 479 gPointMode2PrimtiveType[mode],
477 SkToS32(count), 480 SkToS32(count),
478 (SkPoint*)pts, 481 (SkPoint*)pts,
479 nullptr, 482 nullptr,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 path.setIsVolatile(true); 514 path.setIsVolatile(true);
512 path.addRect(rect); 515 path.addRect(rect);
513 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, 516 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext,
514 fClip, path, paint, 517 fClip, path, paint,
515 *draw.fMatrix, nullptr, 518 *draw.fMatrix, nullptr,
516 draw.fClip->getBounds(), true); 519 draw.fClip->getBounds(), true);
517 return; 520 return;
518 } 521 }
519 522
520 GrPaint grPaint; 523 GrPaint grPaint;
521 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 524 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
525 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
522 return; 526 return;
523 } 527 }
524 528
525 GrStrokeInfo strokeInfo(paint); 529 GrStrokeInfo strokeInfo(paint);
526 530
527 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); 531 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
528 } 532 }
529 533
530 /////////////////////////////////////////////////////////////////////////////// 534 ///////////////////////////////////////////////////////////////////////////////
531 535
532 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, 536 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
533 const SkPaint& paint) { 537 const SkPaint& paint) {
534 ASSERT_SINGLE_OWNER 538 ASSERT_SINGLE_OWNER
535 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); 539 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext);
536 CHECK_SHOULD_DRAW(draw); 540 CHECK_SHOULD_DRAW(draw);
537 541
538 GrPaint grPaint; 542 GrPaint grPaint;
539 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 543 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
544 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
540 return; 545 return;
541 } 546 }
542 547
543 GrStrokeInfo strokeInfo(paint); 548 GrStrokeInfo strokeInfo(paint);
544 if (paint.getMaskFilter()) { 549 if (paint.getMaskFilter()) {
545 // try to hit the fast path for drawing filtered round rects 550 // try to hit the fast path for drawing filtered round rects
546 551
547 SkRRect devRRect; 552 SkRRect devRRect;
548 if (rect.transform(*draw.fMatrix, &devRRect)) { 553 if (rect.transform(*draw.fMatrix, &devRRect)) {
549 if (devRRect.allCornersCircular()) { 554 if (devRRect.allCornersCircular()) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 609 }
605 610
606 if (inner.isEmpty()) { 611 if (inner.isEmpty()) {
607 return this->drawRRect(draw, outer, paint); 612 return this->drawRRect(draw, outer, paint);
608 } 613 }
609 614
610 SkStrokeRec stroke(paint); 615 SkStrokeRec stroke(paint);
611 616
612 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect() ) { 617 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect() ) {
613 GrPaint grPaint; 618 GrPaint grPaint;
614 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 619 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
620 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
615 return; 621 return;
616 } 622 }
617 623
618 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); 624 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
619 return; 625 return;
620 } 626 }
621 627
622 SkPath path; 628 SkPath path;
623 path.setIsVolatile(true); 629 path.setIsVolatile(true);
624 path.addRRect(outer); 630 path.addRRect(outer);
(...skipping 23 matching lines...) Expand all
648 return; 654 return;
649 } 655 }
650 656
651 if (paint.getMaskFilter()) { 657 if (paint.getMaskFilter()) {
652 // The RRect path can handle special case blurring 658 // The RRect path can handle special case blurring
653 SkRRect rr = SkRRect::MakeOval(oval); 659 SkRRect rr = SkRRect::MakeOval(oval);
654 return this->drawRRect(draw, rr, paint); 660 return this->drawRRect(draw, rr, paint);
655 } 661 }
656 662
657 GrPaint grPaint; 663 GrPaint grPaint;
658 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 664 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
665 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
659 return; 666 return;
660 } 667 }
661 668
662 GrStrokeInfo strokeInfo(paint); 669 GrStrokeInfo strokeInfo(paint);
663 SkASSERT(!strokeInfo.isDashed()); 670 SkASSERT(!strokeInfo.isDashed());
664 671
665 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo); 672 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo);
666 } 673 }
667 674
668 #include "SkMaskFilter.h" 675 #include "SkMaskFilter.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 } else if (bicubic) { 1139 } else if (bicubic) {
1133 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); 1140 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
1134 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() }; 1141 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() };
1135 fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes)); 1142 fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes));
1136 } else { 1143 } else {
1137 fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params)); 1144 fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params));
1138 } 1145 }
1139 1146
1140 GrPaint grPaint; 1147 GrPaint grPaint;
1141 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, fp, 1148 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, fp,
1142 kAlpha_8_SkColorType == bitmap.colorType(), &grPaint)) { 1149 kAlpha_8_SkColorType == bitmap.colorType(),
1150 this->surfaceProps().allowSRGBInputs(), &gr Paint)) {
1143 return; 1151 return;
1144 } 1152 }
1145 1153
1146 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { 1154 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) {
1147 // We don't have local coords in this case and have previously set the t ransform 1155 // We don't have local coords in this case and have previously set the t ransform
1148 // matrices directly on the texture processor. 1156 // matrices directly on the texture processor.
1149 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); 1157 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect);
1150 } else { 1158 } else {
1151 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR ect); 1159 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR ect);
1152 } 1160 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1234 }
1227 1235
1228 GrPaint grPaint; 1236 GrPaint grPaint;
1229 SkAutoTUnref<const GrFragmentProcessor> fp( 1237 SkAutoTUnref<const GrFragmentProcessor> fp(
1230 GrSimpleTextureEffect::Create(texture, SkMatrix::I())); 1238 GrSimpleTextureEffect::Create(texture, SkMatrix::I()));
1231 if (alphaOnly) { 1239 if (alphaOnly) {
1232 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); 1240 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
1233 } else { 1241 } else {
1234 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 1242 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
1235 } 1243 }
1236 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { 1244 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
1245 this->surfaceProps().allowSRGBInputs(), & grPaint)) {
1237 return; 1246 return;
1238 } 1247 }
1239 1248
1240 fDrawContext->fillRectToRect(fClip, 1249 fDrawContext->fillRectToRect(fClip,
1241 grPaint, 1250 grPaint,
1242 SkMatrix::I(), 1251 SkMatrix::I(),
1243 SkRect::MakeXYWH(SkIntToScalar(left), 1252 SkRect::MakeXYWH(SkIntToScalar(left),
1244 SkIntToScalar(top), 1253 SkIntToScalar(top),
1245 SkIntToScalar(w), 1254 SkIntToScalar(w),
1246 SkIntToScalar(h)), 1255 SkIntToScalar(h)),
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 GrPaint grPaint; 1395 GrPaint grPaint;
1387 SkAutoTUnref<const GrFragmentProcessor> fp( 1396 SkAutoTUnref<const GrFragmentProcessor> fp(
1388 GrSimpleTextureEffect::Create(devTex, SkMatrix::I())); 1397 GrSimpleTextureEffect::Create(devTex, SkMatrix::I()));
1389 if (GrPixelConfigIsAlphaOnly(devTex->config())) { 1398 if (GrPixelConfigIsAlphaOnly(devTex->config())) {
1390 // Can this happen? 1399 // Can this happen?
1391 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); 1400 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
1392 } else { 1401 } else {
1393 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 1402 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
1394 } 1403 }
1395 1404
1396 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { 1405 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
1406 this->surfaceProps().allowSRGBInputs(), & grPaint)) {
1397 return; 1407 return;
1398 } 1408 }
1399 1409
1400 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), 1410 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x),
1401 SkIntToScalar(y), 1411 SkIntToScalar(y),
1402 SkIntToScalar(w), 1412 SkIntToScalar(w),
1403 SkIntToScalar(h)); 1413 SkIntToScalar(h));
1404 1414
1405 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate 1415 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate
1406 // scratch texture). 1416 // scratch texture).
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 } 1535 }
1526 1536
1527 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode; 1537 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode;
1528 SkAutoTUnref<const GrFragmentProcessor> fp( 1538 SkAutoTUnref<const GrFragmentProcessor> fp(
1529 producer->createFragmentProcessor(SkMatrix::I(), 1539 producer->createFragmentProcessor(SkMatrix::I(),
1530 SkRect::MakeIWH(producer->width(), pro ducer->height()), 1540 SkRect::MakeIWH(producer->width(), pro ducer->height()),
1531 GrTextureProducer::kNo_FilterConstrain t, true, 1541 GrTextureProducer::kNo_FilterConstrain t, true,
1532 &kMode)); 1542 &kMode));
1533 GrPaint grPaint; 1543 GrPaint grPaint;
1534 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp, 1544 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp,
1535 producer->isAlphaOnly(), &grPaint)) { 1545 producer->isAlphaOnly(),
1546 this->surfaceProps().allowSRGBInputs(), &gr Paint)) {
1536 return; 1547 return;
1537 } 1548 }
1538 1549
1539 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() , 1550 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width() ,
1540 producer->height(), center, dst); 1551 producer->height(), center, dst);
1541 } 1552 }
1542 1553
1543 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, 1554 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image,
1544 const SkIRect& center, const SkRect& dst, const SkPaint& paint) { 1555 const SkIRect& center, const SkRect& dst, const SkPaint& paint) {
1545 ASSERT_SINGLE_OWNER 1556 ASSERT_SINGLE_OWNER
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors) { 1603 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors) {
1593 1604
1594 texs = nullptr; 1605 texs = nullptr;
1595 1606
1596 SkPaint copy(paint); 1607 SkPaint copy(paint);
1597 copy.setStyle(SkPaint::kStroke_Style); 1608 copy.setStyle(SkPaint::kStroke_Style);
1598 copy.setStrokeWidth(0); 1609 copy.setStrokeWidth(0);
1599 1610
1600 GrPaint grPaint; 1611 GrPaint grPaint;
1601 // we ignore the shader if texs is null. 1612 // we ignore the shader if texs is null.
1602 if (!SkPaintToGrPaintNoShader(this->context(), copy, &grPaint)) { 1613 if (!SkPaintToGrPaintNoShader(this->context(), copy,
1614 this->surfaceProps().allowSRGBInputs(), &g rPaint)) {
1603 return; 1615 return;
1604 } 1616 }
1605 1617
1606 int triangleCount = 0; 1618 int triangleCount = 0;
1607 int n = (nullptr == indices) ? vertexCount : indexCount; 1619 int n = (nullptr == indices) ? vertexCount : indexCount;
1608 switch (vmode) { 1620 switch (vmode) {
1609 case SkCanvas::kTriangles_VertexMode: 1621 case SkCanvas::kTriangles_VertexMode:
1610 triangleCount = n / 3; 1622 triangleCount = n / 3;
1611 break; 1623 break;
1612 case SkCanvas::kTriangleStrip_VertexMode: 1624 case SkCanvas::kTriangleStrip_VertexMode:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 // xmode is defined to mean modulate. 1676 // xmode is defined to mean modulate.
1665 SkXfermode::Mode colorMode; 1677 SkXfermode::Mode colorMode;
1666 if (xmode) { 1678 if (xmode) {
1667 if (!xmode->asMode(&colorMode)) { 1679 if (!xmode->asMode(&colorMode)) {
1668 return; 1680 return;
1669 } 1681 }
1670 } else { 1682 } else {
1671 colorMode = SkXfermode::kModulate_Mode; 1683 colorMode = SkXfermode::kModulate_Mode;
1672 } 1684 }
1673 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat rix, colorMode, 1685 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat rix, colorMode,
1674 false, &grPaint)) { 1686 false, this->surfaceProps().allowS RGBInputs(),
1687 &grPaint)) {
1675 return; 1688 return;
1676 } 1689 }
1677 } else { 1690 } else {
1678 // We have a shader, but no colors to blend it against. 1691 // We have a shader, but no colors to blend it against.
1679 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPain t)) { 1692 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
1693 this->surfaceProps().allowSRGBInputs(), &grPai nt)) {
1680 return; 1694 return;
1681 } 1695 }
1682 } 1696 }
1683 } else { 1697 } else {
1684 if (colors) { 1698 if (colors) {
1685 // We have colors, but either have no shader or no texture coords (w hich implies that 1699 // We have colors, but either have no shader or no texture coords (w hich implies that
1686 // we should ignore the shader). 1700 // we should ignore the shader).
1687 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grP aint)) { 1701 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint,
1702 this->surfaceProps().allowSR GBInputs(),
1703 &grPaint)) {
1688 return; 1704 return;
1689 } 1705 }
1690 } else { 1706 } else {
1691 // No colors and no shaders. Just draw with the paint color. 1707 // No colors and no shaders. Just draw with the paint color.
1692 if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) { 1708 if (!SkPaintToGrPaintNoShader(this->context(), paint,
1709 this->surfaceProps().allowSRGBInputs() , &grPaint)) {
1693 return; 1710 return;
1694 } 1711 }
1695 } 1712 }
1696 } 1713 }
1697 1714
1698 fDrawContext->drawVertices(fClip, 1715 fDrawContext->drawVertices(fClip,
1699 grPaint, 1716 grPaint,
1700 *draw.fMatrix, 1717 *draw.fMatrix,
1701 primType, 1718 primType,
1702 vertexCount, 1719 vertexCount,
(...skipping 17 matching lines...) Expand all
1720 1737
1721 CHECK_SHOULD_DRAW(draw); 1738 CHECK_SHOULD_DRAW(draw);
1722 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); 1739 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext);
1723 1740
1724 SkPaint p(paint); 1741 SkPaint p(paint);
1725 p.setShader(atlas->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_Ti leMode)); 1742 p.setShader(atlas->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_Ti leMode));
1726 1743
1727 GrPaint grPaint; 1744 GrPaint grPaint;
1728 if (colors) { 1745 if (colors) {
1729 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod e, true, 1746 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod e, true,
1730 &grPaint)) { 1747 this->surfaceProps().allowSRGBInputs() , &grPaint)) {
1731 return; 1748 return;
1732 } 1749 }
1733 } else { 1750 } else {
1734 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint)) { 1751 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix,
1752 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
1735 return; 1753 return;
1736 } 1754 }
1737 } 1755 }
1738 1756
1739 SkDEBUGCODE(this->validate();) 1757 SkDEBUGCODE(this->validate();)
1740 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect , colors); 1758 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect , colors);
1741 } 1759 }
1742 1760
1743 /////////////////////////////////////////////////////////////////////////////// 1761 ///////////////////////////////////////////////////////////////////////////////
1744 1762
1745 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, 1763 void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
1746 size_t byteLength, SkScalar x, SkScalar y, 1764 size_t byteLength, SkScalar x, SkScalar y,
1747 const SkPaint& paint) { 1765 const SkPaint& paint) {
1748 ASSERT_SINGLE_OWNER 1766 ASSERT_SINGLE_OWNER
1749 CHECK_SHOULD_DRAW(draw); 1767 CHECK_SHOULD_DRAW(draw);
1750 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); 1768 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext);
1751 1769
1752 GrPaint grPaint; 1770 GrPaint grPaint;
1753 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 1771 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
1772 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
1754 return; 1773 return;
1755 } 1774 }
1756 1775
1757 SkDEBUGCODE(this->validate();) 1776 SkDEBUGCODE(this->validate();)
1758 1777
1759 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, 1778 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix,
1760 (const char *)text, byteLength, x, y, draw.fClip->get Bounds()); 1779 (const char *)text, byteLength, x, y, draw.fClip->get Bounds());
1761 } 1780 }
1762 1781
1763 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL ength, 1782 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL ength,
1764 const SkScalar pos[], int scalarsPerPos, 1783 const SkScalar pos[], int scalarsPerPos,
1765 const SkPoint& offset, const SkPaint& paint) { 1784 const SkPoint& offset, const SkPaint& paint) {
1766 ASSERT_SINGLE_OWNER 1785 ASSERT_SINGLE_OWNER
1767 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); 1786 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext);
1768 CHECK_SHOULD_DRAW(draw); 1787 CHECK_SHOULD_DRAW(draw);
1769 1788
1770 GrPaint grPaint; 1789 GrPaint grPaint;
1771 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 1790 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
1791 this->surfaceProps().allowSRGBInputs(), &grPaint)) {
1772 return; 1792 return;
1773 } 1793 }
1774 1794
1775 SkDEBUGCODE(this->validate();) 1795 SkDEBUGCODE(this->validate();)
1776 1796
1777 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, 1797 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix,
1778 (const char *)text, byteLength, pos, scalarsPerPos , offset, 1798 (const char *)text, byteLength, pos, scalarsPerPos , offset,
1779 draw.fClip->getBounds()); 1799 draw.fClip->getBounds());
1780 } 1800 }
1781 1801
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 } 1942 }
1923 1943
1924 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1944 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1925 ASSERT_SINGLE_OWNER 1945 ASSERT_SINGLE_OWNER
1926 // We always return a transient cache, so it is freed after each 1946 // We always return a transient cache, so it is freed after each
1927 // filter traversal. 1947 // filter traversal.
1928 return SkGpuDevice::NewImageFilterCache(); 1948 return SkGpuDevice::NewImageFilterCache();
1929 } 1949 }
1930 1950
1931 #endif 1951 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698