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

Side by Side Diff: src/core/SkDraw.cpp

Issue 677463002: Set temporary paths volatile so we don't cache them. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Init fIsVolatile Created 6 years, 1 month 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 | « include/core/SkPath.h ('k') | src/core/SkPath.cpp » ('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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkDraw.h" 8 #include "SkDraw.h"
9 #include "SkBlitter.h" 9 #include "SkBlitter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // temporarily mark the paint as filling. 588 // temporarily mark the paint as filling.
589 SkPaint newPaint(paint); 589 SkPaint newPaint(paint);
590 newPaint.setStyle(SkPaint::kFill_Style); 590 newPaint.setStyle(SkPaint::kFill_Style);
591 591
592 SkScalar width = newPaint.getStrokeWidth(); 592 SkScalar width = newPaint.getStrokeWidth();
593 SkScalar radius = SkScalarHalf(width); 593 SkScalar radius = SkScalarHalf(width);
594 594
595 if (newPaint.getStrokeCap() == SkPaint::kRound_Cap) { 595 if (newPaint.getStrokeCap() == SkPaint::kRound_Cap) {
596 SkPath path; 596 SkPath path;
597 SkMatrix preMatrix; 597 SkMatrix preMatrix;
598 598
599 path.addCircle(0, 0, radius); 599 path.addCircle(0, 0, radius);
600 for (size_t i = 0; i < count; i++) { 600 for (size_t i = 0; i < count; i++) {
601 preMatrix.setTranslate(pts[i].fX, pts[i].fY); 601 preMatrix.setTranslate(pts[i].fX, pts[i].fY);
602 // pass true for the last point, since we can modify 602 // pass true for the last point, since we can modify
603 // then path then 603 // then path then
604 path.setIsVolatile((count-1) == i);
604 if (fDevice) { 605 if (fDevice) {
605 fDevice->drawPath(*this, path, newPaint, &preMatrix, 606 fDevice->drawPath(*this, path, newPaint, &preMatrix,
606 (count-1) == i); 607 (count-1) == i);
607 } else { 608 } else {
608 this->drawPath(path, newPaint, &preMatrix, 609 this->drawPath(path, newPaint, &preMatrix,
609 (count-1) == i); 610 (count-1) == i);
610 } 611 }
611 } 612 }
612 } else { 613 } else {
613 SkRect r; 614 SkRect r;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 713 }
713 } 714 }
714 #endif // DISABLE_DASHING_OPTIMIZATION 715 #endif // DISABLE_DASHING_OPTIMIZATION
715 // couldn't take fast path so fall through! 716 // couldn't take fast path so fall through!
716 case SkCanvas::kPolygon_PointMode: { 717 case SkCanvas::kPolygon_PointMode: {
717 count -= 1; 718 count -= 1;
718 SkPath path; 719 SkPath path;
719 SkPaint p(paint); 720 SkPaint p(paint);
720 p.setStyle(SkPaint::kStroke_Style); 721 p.setStyle(SkPaint::kStroke_Style);
721 size_t inc = (SkCanvas::kLines_PointMode == mode) ? 2 : 1; 722 size_t inc = (SkCanvas::kLines_PointMode == mode) ? 2 : 1;
723 path.setIsVolatile(true);
722 for (size_t i = 0; i < count; i += inc) { 724 for (size_t i = 0; i < count; i += inc) {
723 path.moveTo(pts[i]); 725 path.moveTo(pts[i]);
724 path.lineTo(pts[i+1]); 726 path.lineTo(pts[i+1]);
725 if (fDevice) { 727 if (fDevice) {
726 fDevice->drawPath(*this, path, p, NULL, true); 728 fDevice->drawPath(*this, path, p, NULL, true);
727 } else { 729 } else {
728 this->drawPath(path, p, NULL, true); 730 this->drawPath(path, p, NULL, true);
729 } 731 }
730 path.rewind(); 732 path.rewind();
731 } 733 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 // nothing to draw 1006 // nothing to draw
1005 if (fRC->isEmpty()) { 1007 if (fRC->isEmpty()) {
1006 return; 1008 return;
1007 } 1009 }
1008 1010
1009 SkPath* pathPtr = (SkPath*)&origSrcPath; 1011 SkPath* pathPtr = (SkPath*)&origSrcPath;
1010 bool doFill = true; 1012 bool doFill = true;
1011 SkPath tmpPath; 1013 SkPath tmpPath;
1012 SkMatrix tmpMatrix; 1014 SkMatrix tmpMatrix;
1013 const SkMatrix* matrix = fMatrix; 1015 const SkMatrix* matrix = fMatrix;
1016 tmpPath.setIsVolatile(true);
1014 1017
1015 if (prePathMatrix) { 1018 if (prePathMatrix) {
1016 if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_ Style || 1019 if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_ Style ||
1017 origPaint.getRasterizer()) { 1020 origPaint.getRasterizer()) {
1018 SkPath* result = pathPtr; 1021 SkPath* result = pathPtr;
1019 1022
1020 if (!pathIsMutable) { 1023 if (!pathIsMutable) {
1021 result = &tmpPath; 1024 result = &tmpPath;
1022 pathIsMutable = true; 1025 pathIsMutable = true;
1023 } 1026 }
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 SkScalar xpos; 1958 SkScalar xpos;
1956 SkMatrix scaledMatrix; 1959 SkMatrix scaledMatrix;
1957 SkScalar scale = iter.getPathScale(); 1960 SkScalar scale = iter.getPathScale();
1958 1961
1959 scaledMatrix.setScale(scale, scale); 1962 scaledMatrix.setScale(scale, scale);
1960 1963
1961 while (iter.next(&iterPath, &xpos)) { 1964 while (iter.next(&iterPath, &xpos)) {
1962 if (iterPath) { 1965 if (iterPath) {
1963 SkPath tmp; 1966 SkPath tmp;
1964 SkMatrix m(scaledMatrix); 1967 SkMatrix m(scaledMatrix);
1965 1968
1969 tmp.setIsVolatile(true);
1966 m.postTranslate(xpos + hOffset, 0); 1970 m.postTranslate(xpos + hOffset, 0);
1967 if (matrix) { 1971 if (matrix) {
1968 m.postConcat(*matrix); 1972 m.postConcat(*matrix);
1969 } 1973 }
1970 morphpath(&tmp, *iterPath, meas, m); 1974 morphpath(&tmp, *iterPath, meas, m);
1971 if (fDevice) { 1975 if (fDevice) {
1972 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); 1976 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true);
1973 } else { 1977 } else {
1974 this->drawPath(tmp, iter.getPaint(), NULL, true); 1978 this->drawPath(tmp, iter.getPaint(), NULL, true);
1975 } 1979 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 mask->fImage = SkMask::AllocImage(size); 2380 mask->fImage = SkMask::AllocImage(size);
2377 memset(mask->fImage, 0, mask->computeImageSize()); 2381 memset(mask->fImage, 0, mask->computeImageSize());
2378 } 2382 }
2379 2383
2380 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2384 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2381 draw_into_mask(*mask, devPath, style); 2385 draw_into_mask(*mask, devPath, style);
2382 } 2386 }
2383 2387
2384 return true; 2388 return true;
2385 } 2389 }
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698