| 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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 | 759 |
| 760 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 760 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
| 761 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 761 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 762 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 762 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 763 } | 763 } |
| 764 | 764 |
| 765 void GrContext::drawRect(const GrPaint& paint, | 765 void GrContext::drawRect(const GrPaint& paint, |
| 766 const SkRect& rect, | 766 const SkRect& rect, |
| 767 SkScalar width, | 767 const SkStrokeRec* stroke, |
| 768 const SkMatrix* matrix) { | 768 const SkMatrix* matrix) { |
| 769 SK_TRACE_EVENT0("GrContext::drawRect"); | 769 SK_TRACE_EVENT0("GrContext::drawRect"); |
| 770 | 770 |
| 771 AutoRestoreEffects are; | 771 AutoRestoreEffects are; |
| 772 AutoCheckFlush acf(this); | 772 AutoCheckFlush acf(this); |
| 773 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 773 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 774 | 774 |
| 775 SkScalar width = stroke == NULL ? -1 : stroke->getWidth(); |
| 775 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); | 776 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); |
| 776 if (NULL != matrix) { | 777 if (NULL != matrix) { |
| 777 combinedMatrix.preConcat(*matrix); | 778 combinedMatrix.preConcat(*matrix); |
| 778 } | 779 } |
| 779 | 780 |
| 780 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking | 781 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking |
| 781 // cases where the RT is fully inside a stroke. | 782 // cases where the RT is fully inside a stroke. |
| 782 if (width < 0) { | 783 if (width < 0) { |
| 783 SkRect rtRect; | 784 SkRect rtRect; |
| 784 target->getDrawState().getRenderTarget()->getBoundsRect(&rtRect); | 785 target->getDrawState().getRenderTarget()->getBoundsRect(&rtRect); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 bool needAA = paint.isAntiAlias() && | 818 bool needAA = paint.isAntiAlias() && |
| 818 !target->getDrawState().getRenderTarget()->isMultisampled(); | 819 !target->getDrawState().getRenderTarget()->isMultisampled(); |
| 819 bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix,
&devBoundRect, | 820 bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix,
&devBoundRect, |
| 820 &useVertexCoverage); | 821 &useVertexCoverage); |
| 821 if (doAA) { | 822 if (doAA) { |
| 822 GrDrawState::AutoViewMatrixRestore avmr; | 823 GrDrawState::AutoViewMatrixRestore avmr; |
| 823 if (!avmr.setIdentity(target->drawState())) { | 824 if (!avmr.setIdentity(target->drawState())) { |
| 824 return; | 825 return; |
| 825 } | 826 } |
| 826 if (width >= 0) { | 827 if (width >= 0) { |
| 827 fAARectRenderer->strokeAARect(this->getGpu(), target, | 828 fAARectRenderer->strokeAARect(this->getGpu(), target, rect, |
| 828 rect, combinedMatrix, devBoundRect, | 829 combinedMatrix, devBoundRect, |
| 829 width, useVertexCoverage); | 830 stroke, useVertexCoverage); |
| 830 } else { | 831 } else { |
| 831 // filled AA rect | 832 // filled AA rect |
| 832 fAARectRenderer->fillAARect(this->getGpu(), target, | 833 fAARectRenderer->fillAARect(this->getGpu(), target, |
| 833 rect, combinedMatrix, devBoundRect, | 834 rect, combinedMatrix, devBoundRect, |
| 834 useVertexCoverage); | 835 useVertexCoverage); |
| 835 } | 836 } |
| 836 return; | 837 return; |
| 837 } | 838 } |
| 838 | 839 |
| 839 if (width >= 0) { | 840 if (width >= 0) { |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 return NULL; | 1762 return NULL; |
| 1762 } | 1763 } |
| 1763 } | 1764 } |
| 1764 | 1765 |
| 1765 /////////////////////////////////////////////////////////////////////////////// | 1766 /////////////////////////////////////////////////////////////////////////////// |
| 1766 #if GR_CACHE_STATS | 1767 #if GR_CACHE_STATS |
| 1767 void GrContext::printCacheStats() const { | 1768 void GrContext::printCacheStats() const { |
| 1768 fTextureCache->printStats(); | 1769 fTextureCache->printStats(); |
| 1769 } | 1770 } |
| 1770 #endif | 1771 #endif |
| OLD | NEW |