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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 SK_COMPILE_ASSERT(SkShader::kLinear_BitmapType == 6, shader_type_mismatch); | 358 SK_COMPILE_ASSERT(SkShader::kLinear_BitmapType == 6, shader_type_mismatch); |
359 SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch); | 359 SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch); |
360 | 360 |
361 /////////////////////////////////////////////////////////////////////////////// | 361 /////////////////////////////////////////////////////////////////////////////// |
362 | 362 |
363 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 363 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
364 CHECK_SHOULD_DRAW(draw); | 364 CHECK_SHOULD_DRAW(draw); |
365 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); | 365 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); |
366 | 366 |
367 GrPaint grPaint; | 367 GrPaint grPaint; |
368 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 368 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 369 return; |
| 370 } |
369 | 371 |
370 fContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix); | 372 fContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix); |
371 } | 373 } |
372 | 374 |
373 // must be in SkCanvas::PointMode order | 375 // must be in SkCanvas::PointMode order |
374 static const GrPrimitiveType gPointMode2PrimtiveType[] = { | 376 static const GrPrimitiveType gPointMode2PrimtiveType[] = { |
375 kPoints_GrPrimitiveType, | 377 kPoints_GrPrimitiveType, |
376 kLines_GrPrimitiveType, | 378 kLines_GrPrimitiveType, |
377 kLineStrip_GrPrimitiveType | 379 kLineStrip_GrPrimitiveType |
378 }; | 380 }; |
379 | 381 |
380 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 382 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
381 size_t count, const SkPoint pts[], const SkPaint& p
aint) { | 383 size_t count, const SkPoint pts[], const SkPaint& p
aint) { |
382 CHECK_FOR_ANNOTATION(paint); | 384 CHECK_FOR_ANNOTATION(paint); |
383 CHECK_SHOULD_DRAW(draw); | 385 CHECK_SHOULD_DRAW(draw); |
384 | 386 |
385 SkScalar width = paint.getStrokeWidth(); | 387 SkScalar width = paint.getStrokeWidth(); |
386 if (width < 0) { | 388 if (width < 0) { |
387 return; | 389 return; |
388 } | 390 } |
389 | 391 |
390 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { | 392 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { |
391 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); | 393 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); |
392 GrPaint grPaint; | 394 GrPaint grPaint; |
393 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatr
ix, true, &grPaint); | 395 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatri
x, true, |
| 396 &grPaint)) { |
| 397 return; |
| 398 } |
394 SkPath path; | 399 SkPath path; |
395 path.setIsVolatile(true); | 400 path.setIsVolatile(true); |
396 path.moveTo(pts[0]); | 401 path.moveTo(pts[0]); |
397 path.lineTo(pts[1]); | 402 path.lineTo(pts[1]); |
398 fContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, path, s
trokeInfo); | 403 fContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, path, s
trokeInfo); |
399 return; | 404 return; |
400 } | 405 } |
401 | 406 |
402 // we only handle hairlines and paints without path effects or mask filters, | 407 // we only handle hairlines and paints without path effects or mask filters, |
403 // else we let the SkDraw call our drawPath() | 408 // else we let the SkDraw call our drawPath() |
404 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter()) { | 409 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter()) { |
405 draw.drawPoints(mode, count, pts, paint, true); | 410 draw.drawPoints(mode, count, pts, paint, true); |
406 return; | 411 return; |
407 } | 412 } |
408 | 413 |
409 GrPaint grPaint; | 414 GrPaint grPaint; |
410 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 415 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 416 return; |
| 417 } |
411 | 418 |
412 fContext->drawVertices(fRenderTarget, | 419 fContext->drawVertices(fRenderTarget, |
413 fClip, | 420 fClip, |
414 grPaint, | 421 grPaint, |
415 *draw.fMatrix, | 422 *draw.fMatrix, |
416 gPointMode2PrimtiveType[mode], | 423 gPointMode2PrimtiveType[mode], |
417 SkToS32(count), | 424 SkToS32(count), |
418 (SkPoint*)pts, | 425 (SkPoint*)pts, |
419 NULL, | 426 NULL, |
420 NULL, | 427 NULL, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 479 |
473 if (usePath) { | 480 if (usePath) { |
474 SkPath path; | 481 SkPath path; |
475 path.setIsVolatile(true); | 482 path.setIsVolatile(true); |
476 path.addRect(rect); | 483 path.addRect(rect); |
477 this->drawPath(draw, path, paint, NULL, true); | 484 this->drawPath(draw, path, paint, NULL, true); |
478 return; | 485 return; |
479 } | 486 } |
480 | 487 |
481 GrPaint grPaint; | 488 GrPaint grPaint; |
482 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 489 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 490 return; |
| 491 } |
483 | 492 |
484 fContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &stro
keInfo); | 493 fContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &stro
keInfo); |
485 } | 494 } |
486 | 495 |
487 /////////////////////////////////////////////////////////////////////////////// | 496 /////////////////////////////////////////////////////////////////////////////// |
488 | 497 |
489 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 498 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
490 const SkPaint& paint) { | 499 const SkPaint& paint) { |
491 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); | 500 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); |
492 CHECK_FOR_ANNOTATION(paint); | 501 CHECK_FOR_ANNOTATION(paint); |
493 CHECK_SHOULD_DRAW(draw); | 502 CHECK_SHOULD_DRAW(draw); |
494 | 503 |
495 GrPaint grPaint; | 504 GrPaint grPaint; |
496 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 505 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 506 return; |
| 507 } |
497 | 508 |
498 GrStrokeInfo strokeInfo(paint); | 509 GrStrokeInfo strokeInfo(paint); |
499 if (paint.getMaskFilter()) { | 510 if (paint.getMaskFilter()) { |
500 // try to hit the fast path for drawing filtered round rects | 511 // try to hit the fast path for drawing filtered round rects |
501 | 512 |
502 SkRRect devRRect; | 513 SkRRect devRRect; |
503 if (rect.transform(*draw.fMatrix, &devRRect)) { | 514 if (rect.transform(*draw.fMatrix, &devRRect)) { |
504 if (devRRect.allCornersCircular()) { | 515 if (devRRect.allCornersCircular()) { |
505 SkRect maskRect; | 516 SkRect maskRect; |
506 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), | 517 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 565 |
555 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 566 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
556 const SkRRect& inner, const SkPaint& paint) { | 567 const SkRRect& inner, const SkPaint& paint) { |
557 SkStrokeRec stroke(paint); | 568 SkStrokeRec stroke(paint); |
558 if (stroke.isFillStyle()) { | 569 if (stroke.isFillStyle()) { |
559 | 570 |
560 CHECK_FOR_ANNOTATION(paint); | 571 CHECK_FOR_ANNOTATION(paint); |
561 CHECK_SHOULD_DRAW(draw); | 572 CHECK_SHOULD_DRAW(draw); |
562 | 573 |
563 GrPaint grPaint; | 574 GrPaint grPaint; |
564 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatr
ix, true, &grPaint); | 575 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatri
x, true, |
| 576 &grPaint)) { |
| 577 return; |
| 578 } |
565 | 579 |
566 if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) { | 580 if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) { |
567 fContext->drawDRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, o
uter, inner); | 581 fContext->drawDRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, o
uter, inner); |
568 return; | 582 return; |
569 } | 583 } |
570 } | 584 } |
571 | 585 |
572 SkPath path; | 586 SkPath path; |
573 path.setIsVolatile(true); | 587 path.setIsVolatile(true); |
574 path.addRRect(outer); | 588 path.addRRect(outer); |
(...skipping 27 matching lines...) Expand all Loading... |
602 | 616 |
603 if (usePath) { | 617 if (usePath) { |
604 SkPath path; | 618 SkPath path; |
605 path.setIsVolatile(true); | 619 path.setIsVolatile(true); |
606 path.addOval(oval); | 620 path.addOval(oval); |
607 this->drawPath(draw, path, paint, NULL, true); | 621 this->drawPath(draw, path, paint, NULL, true); |
608 return; | 622 return; |
609 } | 623 } |
610 | 624 |
611 GrPaint grPaint; | 625 GrPaint grPaint; |
612 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 626 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 627 return; |
| 628 } |
613 | 629 |
614 fContext->drawOval(fRenderTarget, fClip, grPaint, *draw.fMatrix, oval, strok
eInfo); | 630 fContext->drawOval(fRenderTarget, fClip, grPaint, *draw.fMatrix, oval, strok
eInfo); |
615 } | 631 } |
616 | 632 |
617 #include "SkMaskFilter.h" | 633 #include "SkMaskFilter.h" |
618 | 634 |
619 /////////////////////////////////////////////////////////////////////////////// | 635 /////////////////////////////////////////////////////////////////////////////// |
620 | 636 |
621 // helpers for applying mask filters | 637 // helpers for applying mask filters |
622 namespace { | 638 namespace { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 // should I push prePathMatrix on our MV stack temporarily, instead | 813 // should I push prePathMatrix on our MV stack temporarily, instead |
798 // of applying it here? See SkDraw.cpp | 814 // of applying it here? See SkDraw.cpp |
799 pathPtr->transform(*prePathMatrix, result); | 815 pathPtr->transform(*prePathMatrix, result); |
800 pathPtr = result; | 816 pathPtr = result; |
801 } | 817 } |
802 } | 818 } |
803 // at this point we're done with prePathMatrix | 819 // at this point we're done with prePathMatrix |
804 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 820 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
805 | 821 |
806 GrPaint grPaint; | 822 GrPaint grPaint; |
807 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, viewMatrix, tru
e, &grPaint); | 823 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, viewMatrix, true
, &grPaint)) { |
| 824 return; |
| 825 } |
808 | 826 |
809 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 827 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
810 SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr(); | 828 SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr(); |
811 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, stroke
Ptr, | 829 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, stroke
Ptr, |
812 cullRect)) { | 830 cullRect)) { |
813 pathPtr = effectPath.get(); | 831 pathPtr = effectPath.get(); |
814 pathIsMutable = true; | 832 pathIsMutable = true; |
815 strokeInfo.removeDash(); | 833 strokeInfo.removeDash(); |
816 } | 834 } |
817 | 835 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params)); | 1489 fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params)); |
1472 } | 1490 } |
1473 | 1491 |
1474 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring | 1492 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring |
1475 // the rest from the SkPaint. | 1493 // the rest from the SkPaint. |
1476 GrPaint grPaint; | 1494 GrPaint grPaint; |
1477 grPaint.addColorProcessor(fp); | 1495 grPaint.addColorProcessor(fp); |
1478 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); | 1496 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); |
1479 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : | 1497 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : |
1480 SkColor2GrColor(paint.getColor()); | 1498 SkColor2GrColor(paint.getColor()); |
1481 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, f
alse, &grPaint); | 1499 if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintCol
or, false, |
| 1500 &grPaint)) { |
| 1501 return; |
| 1502 } |
1482 | 1503 |
1483 fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dst
Rect, | 1504 fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dst
Rect, |
1484 paintRect); | 1505 paintRect); |
1485 } | 1506 } |
1486 | 1507 |
1487 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, | 1508 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
1488 int width, int height, | 1509 int width, int height, |
1489 const SkImageFilter* filter, | 1510 const SkImageFilter* filter, |
1490 const SkImageFilter::Context& ctx, | 1511 const SkImageFilter::Context& ctx, |
1491 SkBitmap* result, SkIPoint* offset) { | 1512 SkBitmap* result, SkIPoint* offset) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 left += offset.x(); | 1565 left += offset.x(); |
1545 top += offset.y(); | 1566 top += offset.y(); |
1546 } else { | 1567 } else { |
1547 return; | 1568 return; |
1548 } | 1569 } |
1549 } | 1570 } |
1550 | 1571 |
1551 GrPaint grPaint; | 1572 GrPaint grPaint; |
1552 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); | 1573 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); |
1553 | 1574 |
1554 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, | 1575 if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, |
1555 SkColor2GrColorJustAlpha(paint.getColor()), false, &
grPaint); | 1576 SkColor2GrColorJustAlpha(paint.getColor()), fal
se, &grPaint)) { |
| 1577 return; |
| 1578 } |
1556 | 1579 |
1557 fContext->drawNonAARectToRect(fRenderTarget, | 1580 fContext->drawNonAARectToRect(fRenderTarget, |
1558 fClip, | 1581 fClip, |
1559 grPaint, | 1582 grPaint, |
1560 SkMatrix::I(), | 1583 SkMatrix::I(), |
1561 SkRect::MakeXYWH(SkIntToScalar(left), | 1584 SkRect::MakeXYWH(SkIntToScalar(left), |
1562 SkIntToScalar(top), | 1585 SkIntToScalar(top), |
1563 SkIntToScalar(w), | 1586 SkIntToScalar(w), |
1564 SkIntToScalar(h)), | 1587 SkIntToScalar(h)), |
1565 SkRect::MakeXYWH(0, | 1588 SkRect::MakeXYWH(0, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 x += offset.fX; | 1681 x += offset.fX; |
1659 y += offset.fY; | 1682 y += offset.fY; |
1660 } else { | 1683 } else { |
1661 return; | 1684 return; |
1662 } | 1685 } |
1663 } | 1686 } |
1664 | 1687 |
1665 GrPaint grPaint; | 1688 GrPaint grPaint; |
1666 grPaint.addColorTextureProcessor(devTex, SkMatrix::I()); | 1689 grPaint.addColorTextureProcessor(devTex, SkMatrix::I()); |
1667 | 1690 |
1668 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, | 1691 if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, |
1669 SkColor2GrColorJustAlpha(paint.getColor()), false, &
grPaint); | 1692 SkColor2GrColorJustAlpha(paint.getColor()), fal
se, &grPaint)) { |
| 1693 return; |
| 1694 } |
1670 | 1695 |
1671 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), | 1696 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), |
1672 SkIntToScalar(y), | 1697 SkIntToScalar(y), |
1673 SkIntToScalar(w), | 1698 SkIntToScalar(w), |
1674 SkIntToScalar(h)); | 1699 SkIntToScalar(h)); |
1675 | 1700 |
1676 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate | 1701 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate |
1677 // scratch texture). | 1702 // scratch texture). |
1678 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), | 1703 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), |
1679 SK_Scalar1 * h / devTex->height()); | 1704 SK_Scalar1 * h / devTex->height()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 // If both textures and vertex-colors are NULL, strokes hairlines with the p
aint's color. | 1759 // If both textures and vertex-colors are NULL, strokes hairlines with the p
aint's color. |
1735 if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) { | 1760 if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) { |
1736 | 1761 |
1737 texs = NULL; | 1762 texs = NULL; |
1738 | 1763 |
1739 SkPaint copy(paint); | 1764 SkPaint copy(paint); |
1740 copy.setStyle(SkPaint::kStroke_Style); | 1765 copy.setStyle(SkPaint::kStroke_Style); |
1741 copy.setStrokeWidth(0); | 1766 copy.setStrokeWidth(0); |
1742 | 1767 |
1743 // we ignore the shader if texs is null. | 1768 // we ignore the shader if texs is null. |
1744 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, copy, | 1769 if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, copy, |
1745 SkColor2GrColor(copy.getColor()), NULL == colors
, &grPaint); | 1770 SkColor2GrColor(copy.getColor()), NULL == c
olors, &grPaint)) { |
| 1771 return; |
| 1772 } |
1746 | 1773 |
1747 primType = kLines_GrPrimitiveType; | 1774 primType = kLines_GrPrimitiveType; |
1748 int triangleCount = 0; | 1775 int triangleCount = 0; |
1749 int n = (NULL == indices) ? vertexCount : indexCount; | 1776 int n = (NULL == indices) ? vertexCount : indexCount; |
1750 switch (vmode) { | 1777 switch (vmode) { |
1751 case SkCanvas::kTriangles_VertexMode: | 1778 case SkCanvas::kTriangles_VertexMode: |
1752 triangleCount = n / 3; | 1779 triangleCount = n / 3; |
1753 break; | 1780 break; |
1754 case SkCanvas::kTriangleStrip_VertexMode: | 1781 case SkCanvas::kTriangleStrip_VertexMode: |
1755 case SkCanvas::kTriangleFan_VertexMode: | 1782 case SkCanvas::kTriangleFan_VertexMode: |
(...skipping 18 matching lines...) Expand all Loading... |
1774 auxIndices[i + 3] = state.f2; | 1801 auxIndices[i + 3] = state.f2; |
1775 auxIndices[i + 4] = state.f2; | 1802 auxIndices[i + 4] = state.f2; |
1776 auxIndices[i + 5] = state.f0; | 1803 auxIndices[i + 5] = state.f0; |
1777 i += 6; | 1804 i += 6; |
1778 } | 1805 } |
1779 } else { | 1806 } else { |
1780 outIndices = indices; | 1807 outIndices = indices; |
1781 primType = gVertexMode2PrimitiveType[vmode]; | 1808 primType = gVertexMode2PrimitiveType[vmode]; |
1782 | 1809 |
1783 if (NULL == texs || NULL == paint.getShader()) { | 1810 if (NULL == texs || NULL == paint.getShader()) { |
1784 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, | 1811 if (!SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, |
1785 SkColor2GrColor(paint.getColor()), | 1812 SkColor2GrColor(paint.getColor()), |
1786 NULL == colors, &grPaint); | 1813 NULL == colors, &grPaint)) { |
| 1814 return; |
| 1815 } |
1787 } else { | 1816 } else { |
1788 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.f
Matrix, | 1817 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fM
atrix, |
1789 NULL == colors, &grPaint); | 1818 NULL == colors, &grPaint)) { |
| 1819 return; |
| 1820 } |
1790 } | 1821 } |
1791 } | 1822 } |
1792 | 1823 |
1793 #if 0 | 1824 #if 0 |
1794 if (xmode && texs && colors) { | 1825 if (xmode && texs && colors) { |
1795 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { | 1826 if (!SkXfermode::IsMode(xmode, SkXfermode::kModulate_Mode)) { |
1796 SkDebugf("Unsupported vertex-color/texture xfer mode.\n"); | 1827 SkDebugf("Unsupported vertex-color/texture xfer mode.\n"); |
1797 return; | 1828 return; |
1798 } | 1829 } |
1799 } | 1830 } |
(...skipping 28 matching lines...) Expand all Loading... |
1828 | 1859 |
1829 /////////////////////////////////////////////////////////////////////////////// | 1860 /////////////////////////////////////////////////////////////////////////////// |
1830 | 1861 |
1831 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 1862 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
1832 size_t byteLength, SkScalar x, SkScalar y, | 1863 size_t byteLength, SkScalar x, SkScalar y, |
1833 const SkPaint& paint) { | 1864 const SkPaint& paint) { |
1834 CHECK_SHOULD_DRAW(draw); | 1865 CHECK_SHOULD_DRAW(draw); |
1835 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); | 1866 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); |
1836 | 1867 |
1837 GrPaint grPaint; | 1868 GrPaint grPaint; |
1838 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 1869 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 1870 return; |
| 1871 } |
1839 | 1872 |
1840 SkDEBUGCODE(this->validate();) | 1873 SkDEBUGCODE(this->validate();) |
1841 | 1874 |
1842 fTextContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix, | 1875 fTextContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMatrix, |
1843 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); | 1876 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); |
1844 } | 1877 } |
1845 | 1878 |
1846 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1879 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
1847 const SkScalar pos[], int scalarsPerPos, | 1880 const SkScalar pos[], int scalarsPerPos, |
1848 const SkPoint& offset, const SkPaint& paint) { | 1881 const SkPoint& offset, const SkPaint& paint) { |
1849 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); | 1882 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); |
1850 CHECK_SHOULD_DRAW(draw); | 1883 CHECK_SHOULD_DRAW(draw); |
1851 | 1884 |
1852 GrPaint grPaint; | 1885 GrPaint grPaint; |
1853 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 1886 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t
rue, &grPaint)) { |
| 1887 return; |
| 1888 } |
1854 | 1889 |
1855 SkDEBUGCODE(this->validate();) | 1890 SkDEBUGCODE(this->validate();) |
1856 | 1891 |
1857 fTextContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.fMatri
x, | 1892 fTextContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.fMatri
x, |
1858 (const char *)text, byteLength, pos, scalarsPerPos
, offset, | 1893 (const char *)text, byteLength, pos, scalarsPerPos
, offset, |
1859 draw.fClip->getBounds()); | 1894 draw.fClip->getBounds()); |
1860 } | 1895 } |
1861 | 1896 |
1862 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
lar x, SkScalar y, | 1897 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
lar x, SkScalar y, |
1863 const SkPaint& paint, SkDrawFilter* drawFilter) { | 1898 const SkPaint& paint, SkDrawFilter* drawFilter) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 #endif | 2033 #endif |
1999 } | 2034 } |
2000 | 2035 |
2001 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2036 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
2002 // We always return a transient cache, so it is freed after each | 2037 // We always return a transient cache, so it is freed after each |
2003 // filter traversal. | 2038 // filter traversal. |
2004 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2039 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
2005 } | 2040 } |
2006 | 2041 |
2007 #endif | 2042 #endif |
OLD | NEW |