OLD | NEW |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 /** | 70 /** |
71 * Since we are providing the storage for the shader (to avoid the perf cost | 71 * Since we are providing the storage for the shader (to avoid the perf cost |
72 * of calling new) we insist that in our destructor we can account for all | 72 * of calling new) we insist that in our destructor we can account for all |
73 * owners of the shader. | 73 * owners of the shader. |
74 */ | 74 */ |
75 class SkAutoBitmapShaderInstall : SkNoncopyable { | 75 class SkAutoBitmapShaderInstall : SkNoncopyable { |
76 public: | 76 public: |
77 SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint& paint, | 77 SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint& paint, |
78 const SkMatrix* localMatrix = NULL) | 78 const SkMatrix* localMatrix = NULL) |
79 : fPaint(paint) /* makes a copy of the paint */ { | 79 : fPaint(paint) /* makes a copy of the paint */ { |
80 fPaint.setShader(CreateBitmapShader(src, SkShader::kClamp_TileMode, | 80 fPaint.setShader(SkCreateBitmapShader(src, SkShader::kClamp_TileMode, |
81 SkShader::kClamp_TileMode, | 81 SkShader::kClamp_TileMode, |
82 localMatrix, &fAllocator)); | 82 localMatrix, &fAllocator)); |
83 // we deliberately left the shader with an owner-count of 2 | 83 // we deliberately left the shader with an owner-count of 2 |
84 SkASSERT(2 == fPaint.getShader()->getRefCnt()); | 84 SkASSERT(2 == fPaint.getShader()->getRefCnt()); |
85 } | 85 } |
86 | 86 |
87 ~SkAutoBitmapShaderInstall() { | 87 ~SkAutoBitmapShaderInstall() { |
88 // since fAllocator will destroy shader, we insist that owners == 2 | 88 // since fAllocator will destroy shader, we insist that owners == 2 |
89 SkASSERT(2 == fPaint.getShader()->getRefCnt()); | 89 SkASSERT(2 == fPaint.getShader()->getRefCnt()); |
90 | 90 |
91 fPaint.setShader(NULL); // unref the shader by 1 | 91 fPaint.setShader(NULL); // unref the shader by 1 |
92 | 92 |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 path.setIsVolatile((count-1) == i); |
605 if (fDevice) { | 605 if (fDevice) { |
606 fDevice->drawPath(*this, path, newPaint, &preMatrix, | 606 fDevice->drawPath(*this, path, newPaint, &preMatrix, |
607 (count-1) == i); | 607 (count-1) == i); |
608 } else { | 608 } else { |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 SkScalar xpos; | 1948 SkScalar xpos; |
1949 SkMatrix scaledMatrix; | 1949 SkMatrix scaledMatrix; |
1950 SkScalar scale = iter.getPathScale(); | 1950 SkScalar scale = iter.getPathScale(); |
1951 | 1951 |
1952 scaledMatrix.setScale(scale, scale); | 1952 scaledMatrix.setScale(scale, scale); |
1953 | 1953 |
1954 while (iter.next(&iterPath, &xpos)) { | 1954 while (iter.next(&iterPath, &xpos)) { |
1955 if (iterPath) { | 1955 if (iterPath) { |
1956 SkPath tmp; | 1956 SkPath tmp; |
1957 SkMatrix m(scaledMatrix); | 1957 SkMatrix m(scaledMatrix); |
1958 | 1958 |
1959 tmp.setIsVolatile(true); | 1959 tmp.setIsVolatile(true); |
1960 m.postTranslate(xpos + hOffset, 0); | 1960 m.postTranslate(xpos + hOffset, 0); |
1961 if (matrix) { | 1961 if (matrix) { |
1962 m.postConcat(*matrix); | 1962 m.postConcat(*matrix); |
1963 } | 1963 } |
1964 morphpath(&tmp, *iterPath, meas, m); | 1964 morphpath(&tmp, *iterPath, meas, m); |
1965 if (fDevice) { | 1965 if (fDevice) { |
1966 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); | 1966 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); |
1967 } else { | 1967 } else { |
1968 this->drawPath(tmp, iter.getPaint(), NULL, true); | 1968 this->drawPath(tmp, iter.getPaint(), NULL, true); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 mask->fImage = SkMask::AllocImage(size); | 2370 mask->fImage = SkMask::AllocImage(size); |
2371 memset(mask->fImage, 0, mask->computeImageSize()); | 2371 memset(mask->fImage, 0, mask->computeImageSize()); |
2372 } | 2372 } |
2373 | 2373 |
2374 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2374 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2375 draw_into_mask(*mask, devPath, style); | 2375 draw_into_mask(*mask, devPath, style); |
2376 } | 2376 } |
2377 | 2377 |
2378 return true; | 2378 return true; |
2379 } | 2379 } |
OLD | NEW |