| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 verts[3].set(rect.fRight + rad, rect.fTop - rad); | 674 verts[3].set(rect.fRight + rad, rect.fTop - rad); |
| 675 verts[4].set(rect.fRight - rad, rect.fBottom - rad); | 675 verts[4].set(rect.fRight - rad, rect.fBottom - rad); |
| 676 verts[5].set(rect.fRight + rad, rect.fBottom + rad); | 676 verts[5].set(rect.fRight + rad, rect.fBottom + rad); |
| 677 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); | 677 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); |
| 678 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); | 678 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); |
| 679 verts[8] = verts[0]; | 679 verts[8] = verts[0]; |
| 680 verts[9] = verts[1]; | 680 verts[9] = verts[1]; |
| 681 } | 681 } |
| 682 | 682 |
| 683 static bool apply_aa_to_rect(GrDrawTarget* target, | 683 static bool apply_aa_to_rect(GrDrawTarget* target, |
| 684 const GrRect& rect, |
| 684 SkScalar strokeWidth, | 685 SkScalar strokeWidth, |
| 685 const SkMatrix* matrix, | 686 const SkMatrix* matrix, |
| 686 SkMatrix* combinedMatrix, | 687 SkMatrix* combinedMatrix, |
| 687 bool* useVertexCoverage) { | 688 bool* useVertexCoverage) { |
| 688 // we use a simple coverage ramp to do aa on axis-aligned rects | 689 // we use a simple coverage ramp to do aa on axis-aligned rects |
| 689 // we check if the rect will be axis-aligned, and the rect won't land on | 690 // we check if the rect will be axis-aligned, and the rect won't land on |
| 690 // integer coords. | 691 // integer coords. |
| 691 | 692 |
| 692 // we are keeping around the "tweak the alpha" trick because | 693 // we are keeping around the "tweak the alpha" trick because |
| 693 // it is our only hope for the fixed-pipe implementation. | 694 // it is our only hope for the fixed-pipe implementation. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 #endif | 747 #endif |
| 747 GrAssert(combinedMatrix->preservesAxisAlignment()); | 748 GrAssert(combinedMatrix->preservesAxisAlignment()); |
| 748 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 749 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 749 } else { | 750 } else { |
| 750 GrAssert(combinedMatrix->preservesRightAngles()); | 751 GrAssert(combinedMatrix->preservesRightAngles()); |
| 751 } | 752 } |
| 752 #endif | 753 #endif |
| 753 #endif | 754 #endif |
| 754 } | 755 } |
| 755 | 756 |
| 757 if (0 == rect.width() || 0 == rect.height()) { |
| 758 return false; |
| 759 } |
| 760 |
| 756 return true; | 761 return true; |
| 757 } | 762 } |
| 758 | 763 |
| 759 void GrContext::drawRect(const GrPaint& paint, | 764 void GrContext::drawRect(const GrPaint& paint, |
| 760 const GrRect& rect, | 765 const GrRect& rect, |
| 761 SkScalar width, | 766 SkScalar width, |
| 762 const SkMatrix* matrix) { | 767 const SkMatrix* matrix) { |
| 763 SK_TRACE_EVENT0("GrContext::drawRect"); | 768 SK_TRACE_EVENT0("GrContext::drawRect"); |
| 764 | 769 |
| 765 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); | 770 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); |
| 766 GrDrawState::AutoStageDisable atr(fDrawState); | 771 GrDrawState::AutoStageDisable atr(fDrawState); |
| 767 | 772 |
| 768 SkMatrix combinedMatrix; | 773 SkMatrix combinedMatrix; |
| 769 bool useVertexCoverage; | 774 bool useVertexCoverage; |
| 770 bool needAA = paint.isAntiAlias() && | 775 bool needAA = paint.isAntiAlias() && |
| 771 !this->getRenderTarget()->isMultisampled(); | 776 !this->getRenderTarget()->isMultisampled(); |
| 772 bool doAA = needAA && apply_aa_to_rect(target, width, matrix, | 777 bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix, |
| 773 &combinedMatrix, | 778 &combinedMatrix, |
| 774 &useVertexCoverage); | 779 &useVertexCoverage); |
| 775 if (doAA) { | 780 if (doAA) { |
| 776 GrDrawState::AutoDeviceCoordDraw adcd(target->drawState()); | 781 GrDrawState::AutoDeviceCoordDraw adcd(target->drawState()); |
| 777 if (!adcd.succeeded()) { | 782 if (!adcd.succeeded()) { |
| 778 return; | 783 return; |
| 779 } | 784 } |
| 780 if (width >= 0) { | 785 if (width >= 0) { |
| 781 GrVec strokeSize; | 786 GrVec strokeSize; |
| 782 if (width > 0) { | 787 if (width > 0) { |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 return srcTexture; | 1791 return srcTexture; |
| 1787 } | 1792 } |
| 1788 } | 1793 } |
| 1789 | 1794 |
| 1790 /////////////////////////////////////////////////////////////////////////////// | 1795 /////////////////////////////////////////////////////////////////////////////// |
| 1791 #if GR_CACHE_STATS | 1796 #if GR_CACHE_STATS |
| 1792 void GrContext::printCacheStats() const { | 1797 void GrContext::printCacheStats() const { |
| 1793 fTextureCache->printStats(); | 1798 fTextureCache->printStats(); |
| 1794 } | 1799 } |
| 1795 #endif | 1800 #endif |
| OLD | NEW |