OLD | NEW |
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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 /////////////////////////////////////////////////////////////////////////////// | 359 /////////////////////////////////////////////////////////////////////////////// |
360 | 360 |
361 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 361 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
362 ASSERT_SINGLE_OWNER | 362 ASSERT_SINGLE_OWNER |
363 CHECK_SHOULD_DRAW(draw); | 363 CHECK_SHOULD_DRAW(draw); |
364 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); | 364 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); |
365 | 365 |
366 GrPaint grPaint; | 366 GrPaint grPaint; |
367 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 367 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
368 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 368 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 369 &grPaint)) { |
369 return; | 370 return; |
370 } | 371 } |
371 | 372 |
372 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); | 373 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); |
373 } | 374 } |
374 | 375 |
375 // must be in SkCanvas::PointMode order | 376 // must be in SkCanvas::PointMode order |
376 static const GrPrimitiveType gPointMode2PrimtiveType[] = { | 377 static const GrPrimitiveType gPointMode2PrimtiveType[] = { |
377 kPoints_GrPrimitiveType, | 378 kPoints_GrPrimitiveType, |
378 kLines_GrPrimitiveType, | 379 kLines_GrPrimitiveType, |
(...skipping 30 matching lines...) Expand all Loading... |
409 | 410 |
410 SkScalar width = paint.getStrokeWidth(); | 411 SkScalar width = paint.getStrokeWidth(); |
411 if (width < 0) { | 412 if (width < 0) { |
412 return; | 413 return; |
413 } | 414 } |
414 | 415 |
415 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { | 416 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { |
416 GrStyle style(paint, SkPaint::kStroke_Style); | 417 GrStyle style(paint, SkPaint::kStroke_Style); |
417 GrPaint grPaint; | 418 GrPaint grPaint; |
418 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 419 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
419 this->surfaceProps().isGammaCorrect(), &grPaint))
{ | 420 this->surfaceProps().isGammaCorrect(), fDrawContex
t->getColorSpace(), |
| 421 &grPaint)) { |
420 return; | 422 return; |
421 } | 423 } |
422 SkPath path; | 424 SkPath path; |
423 path.setIsVolatile(true); | 425 path.setIsVolatile(true); |
424 path.moveTo(pts[0]); | 426 path.moveTo(pts[0]); |
425 path.lineTo(pts[1]); | 427 path.lineTo(pts[1]); |
426 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style); | 428 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style); |
427 return; | 429 return; |
428 } | 430 } |
429 | 431 |
430 // we only handle non-antialiased hairlines and paints without path effects
or mask filters, | 432 // we only handle non-antialiased hairlines and paints without path effects
or mask filters, |
431 // else we let the SkDraw call our drawPath() | 433 // else we let the SkDraw call our drawPath() |
432 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || | 434 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || |
433 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { | 435 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { |
434 draw.drawPoints(mode, count, pts, paint, true); | 436 draw.drawPoints(mode, count, pts, paint, true); |
435 return; | 437 return; |
436 } | 438 } |
437 | 439 |
438 GrPaint grPaint; | 440 GrPaint grPaint; |
439 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 441 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
440 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 442 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 443 &grPaint)) { |
441 return; | 444 return; |
442 } | 445 } |
443 | 446 |
444 fDrawContext->drawVertices(fClip, | 447 fDrawContext->drawVertices(fClip, |
445 grPaint, | 448 grPaint, |
446 *draw.fMatrix, | 449 *draw.fMatrix, |
447 gPointMode2PrimtiveType[mode], | 450 gPointMode2PrimtiveType[mode], |
448 SkToS32(count), | 451 SkToS32(count), |
449 (SkPoint*)pts, | 452 (SkPoint*)pts, |
450 nullptr, | 453 nullptr, |
(...skipping 17 matching lines...) Expand all Loading... |
468 path.addRect(rect); | 471 path.addRect(rect); |
469 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(), | 472 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(), |
470 fClip, path, paint, | 473 fClip, path, paint, |
471 *draw.fMatrix, nullptr, | 474 *draw.fMatrix, nullptr, |
472 draw.fRC->getBounds(), true); | 475 draw.fRC->getBounds(), true); |
473 return; | 476 return; |
474 } | 477 } |
475 | 478 |
476 GrPaint grPaint; | 479 GrPaint grPaint; |
477 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 480 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
478 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 481 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 482 &grPaint)) { |
479 return; | 483 return; |
480 } | 484 } |
481 | 485 |
482 GrStyle style(paint); | 486 GrStyle style(paint); |
483 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &style); | 487 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &style); |
484 } | 488 } |
485 | 489 |
486 /////////////////////////////////////////////////////////////////////////////// | 490 /////////////////////////////////////////////////////////////////////////////// |
487 | 491 |
488 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 492 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
489 const SkPaint& paint) { | 493 const SkPaint& paint) { |
490 ASSERT_SINGLE_OWNER | 494 ASSERT_SINGLE_OWNER |
491 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); | 495 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); |
492 CHECK_SHOULD_DRAW(draw); | 496 CHECK_SHOULD_DRAW(draw); |
493 | 497 |
494 GrPaint grPaint; | 498 GrPaint grPaint; |
495 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 499 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
496 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 500 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 501 &grPaint)) { |
497 return; | 502 return; |
498 } | 503 } |
499 | 504 |
500 GrStyle style(paint); | 505 GrStyle style(paint); |
501 if (paint.getMaskFilter()) { | 506 if (paint.getMaskFilter()) { |
502 // try to hit the fast path for drawing filtered round rects | 507 // try to hit the fast path for drawing filtered round rects |
503 | 508 |
504 SkRRect devRRect; | 509 SkRRect devRRect; |
505 if (rect.transform(*draw.fMatrix, &devRRect)) { | 510 if (rect.transform(*draw.fMatrix, &devRRect)) { |
506 if (devRRect.allCornersCircular()) { | 511 if (devRRect.allCornersCircular()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 567 |
563 if (inner.isEmpty()) { | 568 if (inner.isEmpty()) { |
564 return this->drawRRect(draw, outer, paint); | 569 return this->drawRRect(draw, outer, paint); |
565 } | 570 } |
566 | 571 |
567 SkStrokeRec stroke(paint); | 572 SkStrokeRec stroke(paint); |
568 | 573 |
569 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { | 574 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { |
570 GrPaint grPaint; | 575 GrPaint grPaint; |
571 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 576 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
572 this->surfaceProps().isGammaCorrect(), &grPaint))
{ | 577 this->surfaceProps().isGammaCorrect(), fDrawContex
t->getColorSpace(), |
| 578 &grPaint)) { |
573 return; | 579 return; |
574 } | 580 } |
575 | 581 |
576 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); | 582 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); |
577 return; | 583 return; |
578 } | 584 } |
579 | 585 |
580 SkPath path; | 586 SkPath path; |
581 path.setIsVolatile(true); | 587 path.setIsVolatile(true); |
582 path.addRRect(outer); | 588 path.addRRect(outer); |
(...skipping 24 matching lines...) Expand all Loading... |
607 } | 613 } |
608 | 614 |
609 if (paint.getMaskFilter()) { | 615 if (paint.getMaskFilter()) { |
610 // The RRect path can handle special case blurring | 616 // The RRect path can handle special case blurring |
611 SkRRect rr = SkRRect::MakeOval(oval); | 617 SkRRect rr = SkRRect::MakeOval(oval); |
612 return this->drawRRect(draw, rr, paint); | 618 return this->drawRRect(draw, rr, paint); |
613 } | 619 } |
614 | 620 |
615 GrPaint grPaint; | 621 GrPaint grPaint; |
616 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 622 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
617 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 623 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 624 &grPaint)) { |
618 return; | 625 return; |
619 } | 626 } |
620 | 627 |
621 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, GrStyle(paint)); | 628 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, GrStyle(paint)); |
622 } | 629 } |
623 | 630 |
624 #include "SkMaskFilter.h" | 631 #include "SkMaskFilter.h" |
625 | 632 |
626 /////////////////////////////////////////////////////////////////////////////// | 633 /////////////////////////////////////////////////////////////////////////////// |
627 void SkGpuDevice::drawStrokedLine(const SkPoint points[2], | 634 void SkGpuDevice::drawStrokedLine(const SkPoint points[2], |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 mid.fX+halfWidth, mid.fY + 0.5f*length + xtra
Length); | 671 mid.fX+halfWidth, mid.fY + 0.5f*length + xtra
Length); |
665 SkMatrix m; | 672 SkMatrix m; |
666 m.setSinCos(v.fX, -v.fY, mid.fX, mid.fY); | 673 m.setSinCos(v.fX, -v.fY, mid.fX, mid.fY); |
667 | 674 |
668 SkMatrix local = m; | 675 SkMatrix local = m; |
669 | 676 |
670 m.postConcat(*draw.fMatrix); | 677 m.postConcat(*draw.fMatrix); |
671 | 678 |
672 GrPaint grPaint; | 679 GrPaint grPaint; |
673 if (!SkPaintToGrPaint(this->context(), newPaint, m, | 680 if (!SkPaintToGrPaint(this->context(), newPaint, m, |
674 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 681 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 682 &grPaint)) { |
675 return; | 683 return; |
676 } | 684 } |
677 | 685 |
678 fDrawContext->fillRectWithLocalMatrix(fClip, grPaint, m, rect, local); | 686 fDrawContext->fillRectWithLocalMatrix(fClip, grPaint, m, rect, local); |
679 } | 687 } |
680 | 688 |
681 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 689 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
682 const SkPaint& paint, const SkMatrix* prePathMatrix, | 690 const SkPaint& paint, const SkMatrix* prePathMatrix, |
683 bool pathIsMutable) { | 691 bool pathIsMutable) { |
684 ASSERT_SINGLE_OWNER | 692 ASSERT_SINGLE_OWNER |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); | 1169 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); |
1162 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; | 1170 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; |
1163 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texMatri
x, tileModes); | 1171 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texMatri
x, tileModes); |
1164 } else { | 1172 } else { |
1165 fp = GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform), te
xMatrix, params); | 1173 fp = GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform), te
xMatrix, params); |
1166 } | 1174 } |
1167 | 1175 |
1168 GrPaint grPaint; | 1176 GrPaint grPaint; |
1169 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo
ve(fp), | 1177 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo
ve(fp), |
1170 kAlpha_8_SkColorType == bitmap.colorType(), | 1178 kAlpha_8_SkColorType == bitmap.colorType(), |
1171 this->surfaceProps().isGammaCorrect(), &grP
aint)) { | 1179 this->surfaceProps().isGammaCorrect(), |
| 1180 fDrawContext->getColorSpace(), &grPaint)) { |
1172 return; | 1181 return; |
1173 } | 1182 } |
1174 | 1183 |
1175 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { | 1184 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { |
1176 // We don't have local coords in this case and have previously set the t
ransform | 1185 // We don't have local coords in this case and have previously set the t
ransform |
1177 // matrices directly on the texture processor. | 1186 // matrices directly on the texture processor. |
1178 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); | 1187 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); |
1179 } else { | 1188 } else { |
1180 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); | 1189 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); |
1181 } | 1190 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 | 1261 |
1253 GrPaint grPaint; | 1262 GrPaint grPaint; |
1254 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul
lptr, | 1263 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul
lptr, |
1255 SkMatrix::I())); | 1264 SkMatrix::I())); |
1256 if (GrPixelConfigIsAlphaOnly(texture->config())) { | 1265 if (GrPixelConfigIsAlphaOnly(texture->config())) { |
1257 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); | 1266 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); |
1258 } else { | 1267 } else { |
1259 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); | 1268 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); |
1260 } | 1269 } |
1261 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move
(fp), | 1270 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move
(fp), |
1262 this->surfaceProps().isGammaCorrect(), &g
rPaint)) { | 1271 this->surfaceProps().isGammaCorrect(), |
| 1272 fDrawContext->getColorSpace(), &grPaint))
{ |
1263 return; | 1273 return; |
1264 } | 1274 } |
1265 | 1275 |
1266 const SkIRect& subset = result->subset(); | 1276 const SkIRect& subset = result->subset(); |
1267 | 1277 |
1268 fDrawContext->fillRectToRect(fClip, | 1278 fDrawContext->fillRectToRect(fClip, |
1269 grPaint, | 1279 grPaint, |
1270 SkMatrix::I(), | 1280 SkMatrix::I(), |
1271 SkRect::Make(SkIRect::MakeXYWH(left + offset.fX
, top + offset.fY, | 1281 SkRect::Make(SkIRect::MakeXYWH(left + offset.fX
, top + offset.fY, |
1272 subset.width(),
subset.height())), | 1282 subset.width(),
subset.height())), |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 bool gammaCorrect = this->surfaceProps().isGammaCorrect(); | 1550 bool gammaCorrect = this->surfaceProps().isGammaCorrect(); |
1541 SkSourceGammaTreatment gammaTreatment = gammaCorrect | 1551 SkSourceGammaTreatment gammaTreatment = gammaCorrect |
1542 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; | 1552 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; |
1543 sk_sp<GrFragmentProcessor> fp( | 1553 sk_sp<GrFragmentProcessor> fp( |
1544 producer->createFragmentProcessor(SkMatrix::I(), | 1554 producer->createFragmentProcessor(SkMatrix::I(), |
1545 SkRect::MakeIWH(producer->width(), pro
ducer->height()), | 1555 SkRect::MakeIWH(producer->width(), pro
ducer->height()), |
1546 GrTextureProducer::kNo_FilterConstrain
t, true, | 1556 GrTextureProducer::kNo_FilterConstrain
t, true, |
1547 &kMode, fDrawContext->getColorSpace(),
gammaTreatment)); | 1557 &kMode, fDrawContext->getColorSpace(),
gammaTreatment)); |
1548 GrPaint grPaint; | 1558 GrPaint grPaint; |
1549 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std:
:move(fp), | 1559 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std:
:move(fp), |
1550 producer->isAlphaOnly(), gammaCorrect, &grP
aint)) { | 1560 producer->isAlphaOnly(), gammaCorrect, |
| 1561 fDrawContext->getColorSpace(), &grPaint)) { |
1551 return; | 1562 return; |
1552 } | 1563 } |
1553 | 1564 |
1554 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width()
, | 1565 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width()
, |
1555 producer->height(), center, dst); | 1566 producer->height(), center, dst); |
1556 } | 1567 } |
1557 | 1568 |
1558 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, | 1569 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, |
1559 const SkIRect& center, const SkRect& dst, const
SkPaint& paint) { | 1570 const SkIRect& center, const SkRect& dst, const
SkPaint& paint) { |
1560 ASSERT_SINGLE_OWNER | 1571 ASSERT_SINGLE_OWNER |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 | 1619 |
1609 texs = nullptr; | 1620 texs = nullptr; |
1610 | 1621 |
1611 SkPaint copy(paint); | 1622 SkPaint copy(paint); |
1612 copy.setStyle(SkPaint::kStroke_Style); | 1623 copy.setStyle(SkPaint::kStroke_Style); |
1613 copy.setStrokeWidth(0); | 1624 copy.setStrokeWidth(0); |
1614 | 1625 |
1615 GrPaint grPaint; | 1626 GrPaint grPaint; |
1616 // we ignore the shader if texs is null. | 1627 // we ignore the shader if texs is null. |
1617 if (!SkPaintToGrPaintNoShader(this->context(), copy, | 1628 if (!SkPaintToGrPaintNoShader(this->context(), copy, |
1618 this->surfaceProps().isGammaCorrect(), &gr
Paint)) { | 1629 this->surfaceProps().isGammaCorrect(), |
| 1630 fDrawContext->getColorSpace(), &grPaint))
{ |
1619 return; | 1631 return; |
1620 } | 1632 } |
1621 | 1633 |
1622 int triangleCount = 0; | 1634 int triangleCount = 0; |
1623 int n = (nullptr == indices) ? vertexCount : indexCount; | 1635 int n = (nullptr == indices) ? vertexCount : indexCount; |
1624 switch (vmode) { | 1636 switch (vmode) { |
1625 case SkCanvas::kTriangles_VertexMode: | 1637 case SkCanvas::kTriangles_VertexMode: |
1626 triangleCount = n / 3; | 1638 triangleCount = n / 3; |
1627 break; | 1639 break; |
1628 case SkCanvas::kTriangleStrip_VertexMode: | 1640 case SkCanvas::kTriangleStrip_VertexMode: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 SkXfermode::Mode colorMode; | 1693 SkXfermode::Mode colorMode; |
1682 if (xmode) { | 1694 if (xmode) { |
1683 if (!xmode->asMode(&colorMode)) { | 1695 if (!xmode->asMode(&colorMode)) { |
1684 return; | 1696 return; |
1685 } | 1697 } |
1686 } else { | 1698 } else { |
1687 colorMode = SkXfermode::kModulate_Mode; | 1699 colorMode = SkXfermode::kModulate_Mode; |
1688 } | 1700 } |
1689 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat
rix, colorMode, | 1701 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat
rix, colorMode, |
1690 false, this->surfaceProps().isGamm
aCorrect(), | 1702 false, this->surfaceProps().isGamm
aCorrect(), |
1691 &grPaint)) { | 1703 fDrawContext->getColorSpace(), &gr
Paint)) { |
1692 return; | 1704 return; |
1693 } | 1705 } |
1694 } else { | 1706 } else { |
1695 // We have a shader, but no colors to blend it against. | 1707 // We have a shader, but no colors to blend it against. |
1696 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 1708 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
1697 this->surfaceProps().isGammaCorrect(), &grPain
t)) { | 1709 this->surfaceProps().isGammaCorrect(), |
| 1710 fDrawContext->getColorSpace(), &grPaint)) { |
1698 return; | 1711 return; |
1699 } | 1712 } |
1700 } | 1713 } |
1701 } else { | 1714 } else { |
1702 if (colors) { | 1715 if (colors) { |
1703 // We have colors, but either have no shader or no texture coords (w
hich implies that | 1716 // We have colors, but either have no shader or no texture coords (w
hich implies that |
1704 // we should ignore the shader). | 1717 // we should ignore the shader). |
1705 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, | 1718 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, |
1706 this->surfaceProps().isGamma
Correct(), | 1719 this->surfaceProps().isGamma
Correct(), |
1707 &grPaint)) { | 1720 fDrawContext->getColorSpace(
), &grPaint)) { |
1708 return; | 1721 return; |
1709 } | 1722 } |
1710 } else { | 1723 } else { |
1711 // No colors and no shaders. Just draw with the paint color. | 1724 // No colors and no shaders. Just draw with the paint color. |
1712 if (!SkPaintToGrPaintNoShader(this->context(), paint, | 1725 if (!SkPaintToGrPaintNoShader(this->context(), paint, |
1713 this->surfaceProps().isGammaCorrect(),
&grPaint)) { | 1726 this->surfaceProps().isGammaCorrect(), |
| 1727 fDrawContext->getColorSpace(), &grPain
t)) { |
1714 return; | 1728 return; |
1715 } | 1729 } |
1716 } | 1730 } |
1717 } | 1731 } |
1718 | 1732 |
1719 fDrawContext->drawVertices(fClip, | 1733 fDrawContext->drawVertices(fClip, |
1720 grPaint, | 1734 grPaint, |
1721 *draw.fMatrix, | 1735 *draw.fMatrix, |
1722 primType, | 1736 primType, |
1723 vertexCount, | 1737 vertexCount, |
(...skipping 17 matching lines...) Expand all Loading... |
1741 | 1755 |
1742 CHECK_SHOULD_DRAW(draw); | 1756 CHECK_SHOULD_DRAW(draw); |
1743 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); | 1757 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
1744 | 1758 |
1745 SkPaint p(paint); | 1759 SkPaint p(paint); |
1746 p.setShader(atlas->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_Ti
leMode)); | 1760 p.setShader(atlas->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_Ti
leMode)); |
1747 | 1761 |
1748 GrPaint grPaint; | 1762 GrPaint grPaint; |
1749 if (colors) { | 1763 if (colors) { |
1750 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod
e, true, | 1764 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod
e, true, |
1751 this->surfaceProps().isGammaCorrect(),
&grPaint)) { | 1765 this->surfaceProps().isGammaCorrect(), |
| 1766 fDrawContext->getColorSpace(), &grPain
t)) { |
1752 return; | 1767 return; |
1753 } | 1768 } |
1754 } else { | 1769 } else { |
1755 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, | 1770 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, |
1756 this->surfaceProps().isGammaCorrect(), &grPaint))
{ | 1771 this->surfaceProps().isGammaCorrect(), |
| 1772 fDrawContext->getColorSpace(), &grPaint)) { |
1757 return; | 1773 return; |
1758 } | 1774 } |
1759 } | 1775 } |
1760 | 1776 |
1761 SkDEBUGCODE(this->validate();) | 1777 SkDEBUGCODE(this->validate();) |
1762 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); | 1778 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); |
1763 } | 1779 } |
1764 | 1780 |
1765 /////////////////////////////////////////////////////////////////////////////// | 1781 /////////////////////////////////////////////////////////////////////////////// |
1766 | 1782 |
1767 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 1783 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
1768 size_t byteLength, SkScalar x, SkScalar y, | 1784 size_t byteLength, SkScalar x, SkScalar y, |
1769 const SkPaint& paint) { | 1785 const SkPaint& paint) { |
1770 ASSERT_SINGLE_OWNER | 1786 ASSERT_SINGLE_OWNER |
1771 CHECK_SHOULD_DRAW(draw); | 1787 CHECK_SHOULD_DRAW(draw); |
1772 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); | 1788 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
1773 | 1789 |
1774 GrPaint grPaint; | 1790 GrPaint grPaint; |
1775 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 1791 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
1776 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 1792 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 1793 &grPaint)) { |
1777 return; | 1794 return; |
1778 } | 1795 } |
1779 | 1796 |
1780 SkDEBUGCODE(this->validate();) | 1797 SkDEBUGCODE(this->validate();) |
1781 | 1798 |
1782 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, | 1799 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, |
1783 (const char *)text, byteLength, x, y, draw.fRC->getBo
unds()); | 1800 (const char *)text, byteLength, x, y, draw.fRC->getBo
unds()); |
1784 } | 1801 } |
1785 | 1802 |
1786 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1803 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
1787 const SkScalar pos[], int scalarsPerPos, | 1804 const SkScalar pos[], int scalarsPerPos, |
1788 const SkPoint& offset, const SkPaint& paint) { | 1805 const SkPoint& offset, const SkPaint& paint) { |
1789 ASSERT_SINGLE_OWNER | 1806 ASSERT_SINGLE_OWNER |
1790 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); | 1807 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); |
1791 CHECK_SHOULD_DRAW(draw); | 1808 CHECK_SHOULD_DRAW(draw); |
1792 | 1809 |
1793 GrPaint grPaint; | 1810 GrPaint grPaint; |
1794 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 1811 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, |
1795 this->surfaceProps().isGammaCorrect(), &grPaint)) { | 1812 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), |
| 1813 &grPaint)) { |
1796 return; | 1814 return; |
1797 } | 1815 } |
1798 | 1816 |
1799 SkDEBUGCODE(this->validate();) | 1817 SkDEBUGCODE(this->validate();) |
1800 | 1818 |
1801 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, | 1819 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, |
1802 (const char *)text, byteLength, pos, scalarsPerPos
, offset, | 1820 (const char *)text, byteLength, pos, scalarsPerPos
, offset, |
1803 draw.fRC->getBounds()); | 1821 draw.fRC->getBounds()); |
1804 } | 1822 } |
1805 | 1823 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 } | 1888 } |
1871 | 1889 |
1872 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1890 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1873 ASSERT_SINGLE_OWNER | 1891 ASSERT_SINGLE_OWNER |
1874 // We always return a transient cache, so it is freed after each | 1892 // We always return a transient cache, so it is freed after each |
1875 // filter traversal. | 1893 // filter traversal. |
1876 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1894 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1877 } | 1895 } |
1878 | 1896 |
1879 #endif | 1897 #endif |
OLD | NEW |