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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 DO_DEFERRED_CLEAR(); | 301 DO_DEFERRED_CLEAR(); |
302 } | 302 } |
303 | 303 |
304 GrRenderTarget* SkGpuDevice::accessRenderTarget() { | 304 GrRenderTarget* SkGpuDevice::accessRenderTarget() { |
305 DO_DEFERRED_CLEAR(); | 305 DO_DEFERRED_CLEAR(); |
306 return fRenderTarget; | 306 return fRenderTarget; |
307 } | 307 } |
308 | 308 |
309 void SkGpuDevice::clearAll() { | 309 void SkGpuDevice::clearAll() { |
310 GrColor color = 0; | 310 GrColor color = 0; |
311 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clearAll", fContext); | 311 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext); |
312 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); | 312 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); |
313 fDrawContext->clear(&rect, color, true); | 313 fDrawContext->clear(&rect, color, true); |
314 fNeedClear = false; | 314 fNeedClear = false; |
315 } | 315 } |
316 | 316 |
317 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { | 317 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { |
318 // Caller must have accessed the render target, because it knows the rt must
be replaced. | 318 // Caller must have accessed the render target, because it knows the rt must
be replaced. |
319 SkASSERT(!fNeedClear); | 319 SkASSERT(!fNeedClear); |
320 | 320 |
321 SkSurface::Budgeted budgeted = | 321 SkSurface::Budgeted budgeted = |
(...skipping 26 matching lines...) Expand all Loading... |
348 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); | 348 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); |
349 fLegacyBitmap.setPixelRef(pr)->unref(); | 349 fLegacyBitmap.setPixelRef(pr)->unref(); |
350 | 350 |
351 fDrawContext.reset(this->context()->drawContext(fRenderTarget, &this->surfac
eProps())); | 351 fDrawContext.reset(this->context()->drawContext(fRenderTarget, &this->surfac
eProps())); |
352 } | 352 } |
353 | 353 |
354 /////////////////////////////////////////////////////////////////////////////// | 354 /////////////////////////////////////////////////////////////////////////////// |
355 | 355 |
356 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 356 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
357 CHECK_SHOULD_DRAW(draw); | 357 CHECK_SHOULD_DRAW(draw); |
358 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); | 358 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); |
359 | 359 |
360 GrPaint grPaint; | 360 GrPaint grPaint; |
361 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 361 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
362 return; | 362 return; |
363 } | 363 } |
364 | 364 |
365 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); | 365 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); |
366 } | 366 } |
367 | 367 |
368 // must be in SkCanvas::PointMode order | 368 // must be in SkCanvas::PointMode order |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 (SkPoint*)pts, | 439 (SkPoint*)pts, |
440 nullptr, | 440 nullptr, |
441 nullptr, | 441 nullptr, |
442 nullptr, | 442 nullptr, |
443 0); | 443 0); |
444 } | 444 } |
445 | 445 |
446 /////////////////////////////////////////////////////////////////////////////// | 446 /////////////////////////////////////////////////////////////////////////////// |
447 | 447 |
448 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint
& paint) { | 448 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint
& paint) { |
449 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext); | 449 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRect", fContext); |
450 CHECK_FOR_ANNOTATION(paint); | 450 CHECK_FOR_ANNOTATION(paint); |
451 CHECK_SHOULD_DRAW(draw); | 451 CHECK_SHOULD_DRAW(draw); |
452 | 452 |
453 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; | 453 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; |
454 SkScalar width = paint.getStrokeWidth(); | 454 SkScalar width = paint.getStrokeWidth(); |
455 | 455 |
456 /* | 456 /* |
457 We have special code for hairline strokes, miter-strokes, bevel-stroke | 457 We have special code for hairline strokes, miter-strokes, bevel-stroke |
458 and fills. Anything else we just call our path code. | 458 and fills. Anything else we just call our path code. |
459 */ | 459 */ |
(...skipping 25 matching lines...) Expand all Loading... |
485 | 485 |
486 GrStrokeInfo strokeInfo(paint); | 486 GrStrokeInfo strokeInfo(paint); |
487 | 487 |
488 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); | 488 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); |
489 } | 489 } |
490 | 490 |
491 /////////////////////////////////////////////////////////////////////////////// | 491 /////////////////////////////////////////////////////////////////////////////// |
492 | 492 |
493 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 493 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
494 const SkPaint& paint) { | 494 const SkPaint& paint) { |
495 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); | 495 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); |
496 CHECK_FOR_ANNOTATION(paint); | 496 CHECK_FOR_ANNOTATION(paint); |
497 CHECK_SHOULD_DRAW(draw); | 497 CHECK_SHOULD_DRAW(draw); |
498 | 498 |
499 GrPaint grPaint; | 499 GrPaint grPaint; |
500 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 500 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
501 return; | 501 return; |
502 } | 502 } |
503 | 503 |
504 GrStrokeInfo strokeInfo(paint); | 504 GrStrokeInfo strokeInfo(paint); |
505 if (paint.getMaskFilter()) { | 505 if (paint.getMaskFilter()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 return; | 548 return; |
549 } | 549 } |
550 | 550 |
551 SkASSERT(!strokeInfo.isDashed()); | 551 SkASSERT(!strokeInfo.isDashed()); |
552 | 552 |
553 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); | 553 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); |
554 } | 554 } |
555 | 555 |
556 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 556 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
557 const SkRRect& inner, const SkPaint& paint) { | 557 const SkRRect& inner, const SkPaint& paint) { |
558 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDRRect", fContext); | 558 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext); |
559 CHECK_FOR_ANNOTATION(paint); | 559 CHECK_FOR_ANNOTATION(paint); |
560 CHECK_SHOULD_DRAW(draw); | 560 CHECK_SHOULD_DRAW(draw); |
561 | 561 |
562 SkStrokeRec stroke(paint); | 562 SkStrokeRec stroke(paint); |
563 | 563 |
564 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { | 564 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { |
565 GrPaint grPaint; | 565 GrPaint grPaint; |
566 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint))
{ | 566 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint))
{ |
567 return; | 567 return; |
568 } | 568 } |
(...skipping 11 matching lines...) Expand all Loading... |
580 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, | 580 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
581 fClip, path, paint, | 581 fClip, path, paint, |
582 *draw.fMatrix, nullptr, | 582 *draw.fMatrix, nullptr, |
583 draw.fClip->getBounds(), true); | 583 draw.fClip->getBounds(), true); |
584 } | 584 } |
585 | 585 |
586 | 586 |
587 ///////////////////////////////////////////////////////////////////////////// | 587 ///////////////////////////////////////////////////////////////////////////// |
588 | 588 |
589 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
& paint) { | 589 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
& paint) { |
590 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext); | 590 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext); |
591 CHECK_FOR_ANNOTATION(paint); | 591 CHECK_FOR_ANNOTATION(paint); |
592 CHECK_SHOULD_DRAW(draw); | 592 CHECK_SHOULD_DRAW(draw); |
593 | 593 |
594 // Presumably the path effect warps this to something other than an oval | 594 // Presumably the path effect warps this to something other than an oval |
595 if (paint.getPathEffect()) { | 595 if (paint.getPathEffect()) { |
596 SkPath path; | 596 SkPath path; |
597 path.setIsVolatile(true); | 597 path.setIsVolatile(true); |
598 path.addOval(oval); | 598 path.addOval(oval); |
599 this->drawPath(draw, path, paint, nullptr, true); | 599 this->drawPath(draw, path, paint, nullptr, true); |
600 return; | 600 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } | 644 } |
645 SkRRect rrect; | 645 SkRRect rrect; |
646 if (origSrcPath.isRRect(&rrect)) { | 646 if (origSrcPath.isRRect(&rrect)) { |
647 this->drawRRect(draw, rrect, paint); | 647 this->drawRRect(draw, rrect, paint); |
648 return; | 648 return; |
649 } | 649 } |
650 } | 650 } |
651 | 651 |
652 CHECK_FOR_ANNOTATION(paint); | 652 CHECK_FOR_ANNOTATION(paint); |
653 CHECK_SHOULD_DRAW(draw); | 653 CHECK_SHOULD_DRAW(draw); |
654 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); | 654 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPath", fContext); |
655 | 655 |
656 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, | 656 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
657 fClip, origSrcPath, paint, | 657 fClip, origSrcPath, paint, |
658 *draw.fMatrix, prePathMatrix, | 658 *draw.fMatrix, prePathMatrix, |
659 draw.fClip->getBounds(), pathIsMutable); | 659 draw.fClip->getBounds(), pathIsMutable); |
660 } | 660 } |
661 | 661 |
662 static const int kBmpSmallTileSize = 1 << 10; | 662 static const int kBmpSmallTileSize = 1 << 10; |
663 | 663 |
664 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { | 664 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 return; | 1280 return; |
1281 } | 1281 } |
1282 } | 1282 } |
1283 GrBitmapTextureMaker maker(fContext, bitmap); | 1283 GrBitmapTextureMaker maker(fContext, bitmap); |
1284 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip
, paint); | 1284 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip
, paint); |
1285 } | 1285 } |
1286 | 1286 |
1287 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, | 1287 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
1288 int x, int y, const SkPaint& paint) { | 1288 int x, int y, const SkPaint& paint) { |
1289 // clear of the source device must occur before CHECK_SHOULD_DRAW | 1289 // clear of the source device must occur before CHECK_SHOULD_DRAW |
1290 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext); | 1290 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); |
1291 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); | 1291 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); |
1292 | 1292 |
1293 // TODO: If the source device covers the whole of this device, we could | 1293 // TODO: If the source device covers the whole of this device, we could |
1294 // omit fNeedsClear -related flushing. | 1294 // omit fNeedsClear -related flushing. |
1295 // TODO: if source needs clear, we could maybe omit the draw fully. | 1295 // TODO: if source needs clear, we could maybe omit the draw fully. |
1296 | 1296 |
1297 // drawDevice is defined to be in device coords. | 1297 // drawDevice is defined to be in device coords. |
1298 CHECK_SHOULD_DRAW(draw); | 1298 CHECK_SHOULD_DRAW(draw); |
1299 | 1299 |
1300 GrRenderTarget* devRT = dev->accessRenderTarget(); | 1300 GrRenderTarget* devRT = dev->accessRenderTarget(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 CHECK_SHOULD_DRAW(draw); | 1445 CHECK_SHOULD_DRAW(draw); |
1446 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_Cachi
ngHint); | 1446 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_Cachi
ngHint); |
1447 this->drawTextureProducer(&maker, src, &dst, constraint, *draw.fMatrix,
fClip, paint); | 1447 this->drawTextureProducer(&maker, src, &dst, constraint, *draw.fMatrix,
fClip, paint); |
1448 } else if (as_IB(image)->getROPixels(&bm)) { | 1448 } else if (as_IB(image)->getROPixels(&bm)) { |
1449 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); | 1449 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); |
1450 } | 1450 } |
1451 } | 1451 } |
1452 | 1452 |
1453 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
er, | 1453 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
er, |
1454 const SkIRect& center, const SkRect& dst, con
st SkPaint& paint) { | 1454 const SkIRect& center, const SkRect& dst, con
st SkPaint& paint) { |
1455 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawProducerNine", fContext); | 1455 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerNine", fContext); |
1456 | 1456 |
1457 CHECK_FOR_ANNOTATION(paint); | 1457 CHECK_FOR_ANNOTATION(paint); |
1458 CHECK_SHOULD_DRAW(draw); | 1458 CHECK_SHOULD_DRAW(draw); |
1459 | 1459 |
1460 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() || | 1460 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() || |
1461 fRenderTarget->isUnifiedMultisampled(); | 1461 fRenderTarget->isUnifiedMultisampled(); |
1462 bool doBicubic; | 1462 bool doBicubic; |
1463 GrTextureParams::FilterMode textureFilterMode = | 1463 GrTextureParams::FilterMode textureFilterMode = |
1464 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix,
SkMatrix::I(), | 1464 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix,
SkMatrix::I(), |
1465 &doBicubic); | 1465 &doBicubic); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 kTriangleFan_GrPrimitiveType, | 1526 kTriangleFan_GrPrimitiveType, |
1527 }; | 1527 }; |
1528 | 1528 |
1529 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, | 1529 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, |
1530 int vertexCount, const SkPoint vertices[], | 1530 int vertexCount, const SkPoint vertices[], |
1531 const SkPoint texs[], const SkColor colors[], | 1531 const SkPoint texs[], const SkColor colors[], |
1532 SkXfermode* xmode, | 1532 SkXfermode* xmode, |
1533 const uint16_t indices[], int indexCount, | 1533 const uint16_t indices[], int indexCount, |
1534 const SkPaint& paint) { | 1534 const SkPaint& paint) { |
1535 CHECK_SHOULD_DRAW(draw); | 1535 CHECK_SHOULD_DRAW(draw); |
1536 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawVertices", fContext); | 1536 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVertices", fContext); |
1537 | 1537 |
1538 // If both textures and vertex-colors are nullptr, strokes hairlines with th
e paint's color. | 1538 // If both textures and vertex-colors are nullptr, strokes hairlines with th
e paint's color. |
1539 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors)
{ | 1539 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors)
{ |
1540 | 1540 |
1541 texs = nullptr; | 1541 texs = nullptr; |
1542 | 1542 |
1543 SkPaint copy(paint); | 1543 SkPaint copy(paint); |
1544 copy.setStyle(SkPaint::kStroke_Style); | 1544 copy.setStyle(SkPaint::kStroke_Style); |
1545 copy.setStrokeWidth(0); | 1545 copy.setStrokeWidth(0); |
1546 | 1546 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 | 1658 |
1659 void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
Xform xform[], | 1659 void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
Xform xform[], |
1660 const SkRect texRect[], const SkColor colors[], int
count, | 1660 const SkRect texRect[], const SkColor colors[], int
count, |
1661 SkXfermode::Mode mode, const SkPaint& paint) { | 1661 SkXfermode::Mode mode, const SkPaint& paint) { |
1662 if (paint.isAntiAlias()) { | 1662 if (paint.isAntiAlias()) { |
1663 this->INHERITED::drawAtlas(draw, atlas, xform, texRect, colors, count, m
ode, paint); | 1663 this->INHERITED::drawAtlas(draw, atlas, xform, texRect, colors, count, m
ode, paint); |
1664 return; | 1664 return; |
1665 } | 1665 } |
1666 | 1666 |
1667 CHECK_SHOULD_DRAW(draw); | 1667 CHECK_SHOULD_DRAW(draw); |
1668 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); | 1668 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
1669 | 1669 |
1670 SkPaint p(paint); | 1670 SkPaint p(paint); |
1671 p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_Til
eMode))->unref(); | 1671 p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_Til
eMode))->unref(); |
1672 | 1672 |
1673 GrPaint grPaint; | 1673 GrPaint grPaint; |
1674 if (colors) { | 1674 if (colors) { |
1675 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod
e, true, | 1675 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod
e, true, |
1676 &grPaint)) { | 1676 &grPaint)) { |
1677 return; | 1677 return; |
1678 } | 1678 } |
1679 } else { | 1679 } else { |
1680 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint)) { | 1680 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint)) { |
1681 return; | 1681 return; |
1682 } | 1682 } |
1683 } | 1683 } |
1684 | 1684 |
1685 SkDEBUGCODE(this->validate();) | 1685 SkDEBUGCODE(this->validate();) |
1686 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); | 1686 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); |
1687 } | 1687 } |
1688 | 1688 |
1689 /////////////////////////////////////////////////////////////////////////////// | 1689 /////////////////////////////////////////////////////////////////////////////// |
1690 | 1690 |
1691 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 1691 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
1692 size_t byteLength, SkScalar x, SkScalar y, | 1692 size_t byteLength, SkScalar x, SkScalar y, |
1693 const SkPaint& paint) { | 1693 const SkPaint& paint) { |
1694 CHECK_SHOULD_DRAW(draw); | 1694 CHECK_SHOULD_DRAW(draw); |
1695 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); | 1695 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
1696 | 1696 |
1697 GrPaint grPaint; | 1697 GrPaint grPaint; |
1698 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 1698 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
1699 return; | 1699 return; |
1700 } | 1700 } |
1701 | 1701 |
1702 SkDEBUGCODE(this->validate();) | 1702 SkDEBUGCODE(this->validate();) |
1703 | 1703 |
1704 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, | 1704 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, |
1705 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); | 1705 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); |
1706 } | 1706 } |
1707 | 1707 |
1708 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1708 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
1709 const SkScalar pos[], int scalarsPerPos, | 1709 const SkScalar pos[], int scalarsPerPos, |
1710 const SkPoint& offset, const SkPaint& paint) { | 1710 const SkPoint& offset, const SkPaint& paint) { |
1711 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); | 1711 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); |
1712 CHECK_SHOULD_DRAW(draw); | 1712 CHECK_SHOULD_DRAW(draw); |
1713 | 1713 |
1714 GrPaint grPaint; | 1714 GrPaint grPaint; |
1715 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 1715 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
1716 return; | 1716 return; |
1717 } | 1717 } |
1718 | 1718 |
1719 SkDEBUGCODE(this->validate();) | 1719 SkDEBUGCODE(this->validate();) |
1720 | 1720 |
1721 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, | 1721 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, |
1722 (const char *)text, byteLength, pos, scalarsPerPos
, offset, | 1722 (const char *)text, byteLength, pos, scalarsPerPos
, offset, |
1723 draw.fClip->getBounds()); | 1723 draw.fClip->getBounds()); |
1724 } | 1724 } |
1725 | 1725 |
1726 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
lar x, SkScalar y, | 1726 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
lar x, SkScalar y, |
1727 const SkPaint& paint, SkDrawFilter* drawFilter) { | 1727 const SkPaint& paint, SkDrawFilter* drawFilter) { |
1728 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawTextBlob", fContext); | 1728 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawTextBlob", fContext); |
1729 CHECK_SHOULD_DRAW(draw); | 1729 CHECK_SHOULD_DRAW(draw); |
1730 | 1730 |
1731 SkDEBUGCODE(this->validate();) | 1731 SkDEBUGCODE(this->validate();) |
1732 | 1732 |
1733 fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix, | 1733 fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix, |
1734 blob, x, y, drawFilter, draw.fClip->getBounds()); | 1734 blob, x, y, drawFilter, draw.fClip->getBounds()); |
1735 } | 1735 } |
1736 | 1736 |
1737 /////////////////////////////////////////////////////////////////////////////// | 1737 /////////////////////////////////////////////////////////////////////////////// |
1738 | 1738 |
1739 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { | 1739 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { |
1740 return GrTextContext::ShouldDisableLCD(paint); | 1740 return GrTextContext::ShouldDisableLCD(paint); |
1741 } | 1741 } |
1742 | 1742 |
1743 void SkGpuDevice::flush() { | 1743 void SkGpuDevice::flush() { |
1744 DO_DEFERRED_CLEAR(); | 1744 DO_DEFERRED_CLEAR(); |
1745 fRenderTarget->prepareForExternalIO(); | 1745 fRenderTarget->prepareForExternalIO(); |
| 1746 |
| 1747 // Clear batch debugging output |
| 1748 if (GR_BATCH_DEBUGGING_OUTPUT) { |
| 1749 SkDebugf("%s\n", fContext->getAuditTrail()->toJson().c_str()); |
| 1750 GR_AUDIT_TRAIL_RESET(fContext->getAuditTrail()); |
| 1751 } |
1746 } | 1752 } |
1747 | 1753 |
1748 /////////////////////////////////////////////////////////////////////////////// | 1754 /////////////////////////////////////////////////////////////////////////////// |
1749 | 1755 |
1750 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
*) { | 1756 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
*) { |
1751 GrSurfaceDesc desc; | 1757 GrSurfaceDesc desc; |
1752 desc.fConfig = fRenderTarget->config(); | 1758 desc.fConfig = fRenderTarget->config(); |
1753 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 1759 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
1754 desc.fWidth = cinfo.fInfo.width(); | 1760 desc.fWidth = cinfo.fInfo.width(); |
1755 desc.fHeight = cinfo.fInfo.height(); | 1761 desc.fHeight = cinfo.fInfo.height(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1866 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1861 } | 1867 } |
1862 | 1868 |
1863 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1869 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1864 // We always return a transient cache, so it is freed after each | 1870 // We always return a transient cache, so it is freed after each |
1865 // filter traversal. | 1871 // filter traversal. |
1866 return SkGpuDevice::NewImageFilterCache(); | 1872 return SkGpuDevice::NewImageFilterCache(); |
1867 } | 1873 } |
1868 | 1874 |
1869 #endif | 1875 #endif |
OLD | NEW |