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

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

Issue 1744103002: move annotations to canvas virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/core/SkRemote_protocol.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 do { \ 61 do { \
62 if (gShouldDrawProc && !gShouldDrawProc()) return; \ 62 if (gShouldDrawProc && !gShouldDrawProc()) return; \
63 this->prepareDraw(draw); \ 63 this->prepareDraw(draw); \
64 } while (0) 64 } while (0)
65 #else 65 #else
66 #define CHECK_SHOULD_DRAW(draw) this->prepareDraw(draw) 66 #define CHECK_SHOULD_DRAW(draw) this->prepareDraw(draw)
67 #endif 67 #endif
68 68
69 /////////////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////////////
70 70
71 #define CHECK_FOR_ANNOTATION(paint) \
72 do { if (paint.getAnnotation()) { return; } } while (0)
73
74 ///////////////////////////////////////////////////////////////////////////////
75
76 // Helper for turning a bitmap into a texture. If the bitmap is GrTexture backed this 71 // Helper for turning a bitmap into a texture. If the bitmap is GrTexture backed this
77 // just accesses the backing GrTexture. Otherwise, it creates a cached texture 72 // just accesses the backing GrTexture. Otherwise, it creates a cached texture
78 // representation and releases it in the destructor. 73 // representation and releases it in the destructor.
79 class AutoBitmapTexture : public SkNoncopyable { 74 class AutoBitmapTexture : public SkNoncopyable {
80 public: 75 public:
81 AutoBitmapTexture() {} 76 AutoBitmapTexture() {}
82 77
83 AutoBitmapTexture(GrContext* context, 78 AutoBitmapTexture(GrContext* context,
84 const SkBitmap& bitmap, 79 const SkBitmap& bitmap,
85 const GrTextureParams& params, 80 const GrTextureParams& params,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return ((int) pts[0].fY) != pts[0].fY; 389 return ((int) pts[0].fY) != pts[0].fY;
395 } 390 }
396 } 391 }
397 return true; 392 return true;
398 } 393 }
399 394
400 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, 395 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
401 size_t count, const SkPoint pts[], const SkPaint& p aint) { 396 size_t count, const SkPoint pts[], const SkPaint& p aint) {
402 ASSERT_SINGLE_OWNER 397 ASSERT_SINGLE_OWNER
403 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPoints", fContext); 398 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPoints", fContext);
404 CHECK_FOR_ANNOTATION(paint);
405 CHECK_SHOULD_DRAW(draw); 399 CHECK_SHOULD_DRAW(draw);
406 400
407 SkScalar width = paint.getStrokeWidth(); 401 SkScalar width = paint.getStrokeWidth();
408 if (width < 0) { 402 if (width < 0) {
409 return; 403 return;
410 } 404 }
411 405
412 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) { 406 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) {
413 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); 407 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
414 GrPaint grPaint; 408 GrPaint grPaint;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 nullptr, 440 nullptr,
447 nullptr, 441 nullptr,
448 0); 442 0);
449 } 443 }
450 444
451 /////////////////////////////////////////////////////////////////////////////// 445 ///////////////////////////////////////////////////////////////////////////////
452 446
453 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint & paint) { 447 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint & paint) {
454 ASSERT_SINGLE_OWNER 448 ASSERT_SINGLE_OWNER
455 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRect", fContext); 449 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRect", fContext);
456 CHECK_FOR_ANNOTATION(paint);
457 CHECK_SHOULD_DRAW(draw); 450 CHECK_SHOULD_DRAW(draw);
458 451
459 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; 452 bool doStroke = paint.getStyle() != SkPaint::kFill_Style;
460 SkScalar width = paint.getStrokeWidth(); 453 SkScalar width = paint.getStrokeWidth();
461 454
462 /* 455 /*
463 We have special code for hairline strokes, miter-strokes, bevel-stroke 456 We have special code for hairline strokes, miter-strokes, bevel-stroke
464 and fills. Anything else we just call our path code. 457 and fills. Anything else we just call our path code.
465 */ 458 */
466 bool usePath = doStroke && width > 0 && 459 bool usePath = doStroke && width > 0 &&
(...skipping 26 matching lines...) Expand all
493 486
494 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); 487 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
495 } 488 }
496 489
497 /////////////////////////////////////////////////////////////////////////////// 490 ///////////////////////////////////////////////////////////////////////////////
498 491
499 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, 492 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
500 const SkPaint& paint) { 493 const SkPaint& paint) {
501 ASSERT_SINGLE_OWNER 494 ASSERT_SINGLE_OWNER
502 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); 495 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext);
503 CHECK_FOR_ANNOTATION(paint);
504 CHECK_SHOULD_DRAW(draw); 496 CHECK_SHOULD_DRAW(draw);
505 497
506 GrPaint grPaint; 498 GrPaint grPaint;
507 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 499 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
508 return; 500 return;
509 } 501 }
510 502
511 GrStrokeInfo strokeInfo(paint); 503 GrStrokeInfo strokeInfo(paint);
512 if (paint.getMaskFilter()) { 504 if (paint.getMaskFilter()) {
513 // try to hit the fast path for drawing filtered round rects 505 // try to hit the fast path for drawing filtered round rects
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 SkASSERT(!strokeInfo.isDashed()); 550 SkASSERT(!strokeInfo.isDashed());
559 551
560 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); 552 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo);
561 } 553 }
562 554
563 555
564 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, 556 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
565 const SkRRect& inner, const SkPaint& paint) { 557 const SkRRect& inner, const SkPaint& paint) {
566 ASSERT_SINGLE_OWNER 558 ASSERT_SINGLE_OWNER
567 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext); 559 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext);
568 CHECK_FOR_ANNOTATION(paint);
569 CHECK_SHOULD_DRAW(draw); 560 CHECK_SHOULD_DRAW(draw);
570 561
571 if (outer.isEmpty()) { 562 if (outer.isEmpty()) {
572 return; 563 return;
573 } 564 }
574 565
575 if (inner.isEmpty()) { 566 if (inner.isEmpty()) {
576 return this->drawRRect(draw, outer, paint); 567 return this->drawRRect(draw, outer, paint);
577 } 568 }
578 569
(...skipping 20 matching lines...) Expand all
599 *draw.fMatrix, nullptr, 590 *draw.fMatrix, nullptr,
600 draw.fClip->getBounds(), true); 591 draw.fClip->getBounds(), true);
601 } 592 }
602 593
603 594
604 ///////////////////////////////////////////////////////////////////////////// 595 /////////////////////////////////////////////////////////////////////////////
605 596
606 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint & paint) { 597 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint & paint) {
607 ASSERT_SINGLE_OWNER 598 ASSERT_SINGLE_OWNER
608 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext); 599 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext);
609 CHECK_FOR_ANNOTATION(paint);
610 CHECK_SHOULD_DRAW(draw); 600 CHECK_SHOULD_DRAW(draw);
611 601
612 // Presumably the path effect warps this to something other than an oval 602 // Presumably the path effect warps this to something other than an oval
613 if (paint.getPathEffect()) { 603 if (paint.getPathEffect()) {
614 SkPath path; 604 SkPath path;
615 path.setIsVolatile(true); 605 path.setIsVolatile(true);
616 path.addOval(oval); 606 path.addOval(oval);
617 this->drawPath(draw, path, paint, nullptr, true); 607 this->drawPath(draw, path, paint, nullptr, true);
618 return; 608 return;
619 } 609 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 this->drawOval(draw, rect, paint); 644 this->drawOval(draw, rect, paint);
655 return; 645 return;
656 } 646 }
657 SkRRect rrect; 647 SkRRect rrect;
658 if (origSrcPath.isRRect(&rrect)) { 648 if (origSrcPath.isRRect(&rrect)) {
659 this->drawRRect(draw, rrect, paint); 649 this->drawRRect(draw, rrect, paint);
660 return; 650 return;
661 } 651 }
662 } 652 }
663 653
664 CHECK_FOR_ANNOTATION(paint);
665 CHECK_SHOULD_DRAW(draw); 654 CHECK_SHOULD_DRAW(draw);
666 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPath", fContext); 655 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPath", fContext);
667 656
668 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, 657 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext,
669 fClip, origSrcPath, paint, 658 fClip, origSrcPath, paint,
670 *draw.fMatrix, prePathMatrix, 659 *draw.fMatrix, prePathMatrix,
671 draw.fClip->getBounds(), pathIsMutable); 660 draw.fClip->getBounds(), pathIsMutable);
672 } 661 }
673 662
674 static const int kBmpSmallTileSize = 1 << 10; 663 static const int kBmpSmallTileSize = 1 << 10;
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 this->drawTextureProducer(&maker, src, &dst, constraint, *draw.fMatrix, fClip, paint); 1454 this->drawTextureProducer(&maker, src, &dst, constraint, *draw.fMatrix, fClip, paint);
1466 } else if (as_IB(image)->getROPixels(&bm)) { 1455 } else if (as_IB(image)->getROPixels(&bm)) {
1467 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); 1456 this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
1468 } 1457 }
1469 } 1458 }
1470 1459
1471 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc er, 1460 void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc er,
1472 const SkIRect& center, const SkRect& dst, con st SkPaint& paint) { 1461 const SkIRect& center, const SkRect& dst, con st SkPaint& paint) {
1473 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerNine", fContext); 1462 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerNine", fContext);
1474 1463
1475 CHECK_FOR_ANNOTATION(paint);
1476 CHECK_SHOULD_DRAW(draw); 1464 CHECK_SHOULD_DRAW(draw);
1477 1465
1478 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() || 1466 bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() ||
1479 fRenderTarget->isUnifiedMultisampled(); 1467 fRenderTarget->isUnifiedMultisampled();
1480 bool doBicubic; 1468 bool doBicubic;
1481 GrTextureParams::FilterMode textureFilterMode = 1469 GrTextureParams::FilterMode textureFilterMode =
1482 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(), 1470 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(),
1483 &doBicubic); 1471 &doBicubic);
1484 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) { 1472 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) {
1485 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ; 1473 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 } 1878 }
1891 1879
1892 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1880 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1893 ASSERT_SINGLE_OWNER 1881 ASSERT_SINGLE_OWNER
1894 // We always return a transient cache, so it is freed after each 1882 // We always return a transient cache, so it is freed after each
1895 // filter traversal. 1883 // filter traversal.
1896 return SkGpuDevice::NewImageFilterCache(); 1884 return SkGpuDevice::NewImageFilterCache();
1897 } 1885 }
1898 1886
1899 #endif 1887 #endif
OLDNEW
« no previous file with comments | « src/core/SkRemote_protocol.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698