| 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 | 790 |
| 791 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 791 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
| 792 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 792 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 793 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 793 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 794 } | 794 } |
| 795 | 795 |
| 796 void GrContext::drawRect(const GrPaint& paint, | 796 void GrContext::drawRect(const GrPaint& paint, |
| 797 const SkRect& rect, | 797 const SkRect& rect, |
| 798 SkScalar width, | 798 const SkStrokeRec* stroke, |
| 799 const SkMatrix* matrix) { | 799 const SkMatrix* matrix) { |
| 800 SK_TRACE_EVENT0("GrContext::drawRect"); | 800 SK_TRACE_EVENT0("GrContext::drawRect"); |
| 801 | 801 |
| 802 AutoRestoreEffects are; | 802 AutoRestoreEffects are; |
| 803 AutoCheckFlush acf(this); | 803 AutoCheckFlush acf(this); |
| 804 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 804 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 805 | 805 |
| 806 SkScalar width = stroke == NULL ? -1 : stroke->getWidth(); |
| 806 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); | 807 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); |
| 807 if (NULL != matrix) { | 808 if (NULL != matrix) { |
| 808 combinedMatrix.preConcat(*matrix); | 809 combinedMatrix.preConcat(*matrix); |
| 809 } | 810 } |
| 810 | 811 |
| 811 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking | 812 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking |
| 812 // cases where the RT is fully inside a stroke. | 813 // cases where the RT is fully inside a stroke. |
| 813 if (width < 0) { | 814 if (width < 0) { |
| 814 SkRect rtRect; | 815 SkRect rtRect; |
| 815 target->getDrawState().getRenderTarget()->getBoundsRect(&rtRect); | 816 target->getDrawState().getRenderTarget()->getBoundsRect(&rtRect); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 bool needAA = paint.isAntiAlias() && | 849 bool needAA = paint.isAntiAlias() && |
| 849 !target->getDrawState().getRenderTarget()->isMultisampled(); | 850 !target->getDrawState().getRenderTarget()->isMultisampled(); |
| 850 bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix,
&devBoundRect, | 851 bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix,
&devBoundRect, |
| 851 &useVertexCoverage); | 852 &useVertexCoverage); |
| 852 if (doAA) { | 853 if (doAA) { |
| 853 GrDrawState::AutoViewMatrixRestore avmr; | 854 GrDrawState::AutoViewMatrixRestore avmr; |
| 854 if (!avmr.setIdentity(target->drawState())) { | 855 if (!avmr.setIdentity(target->drawState())) { |
| 855 return; | 856 return; |
| 856 } | 857 } |
| 857 if (width >= 0) { | 858 if (width >= 0) { |
| 858 fAARectRenderer->strokeAARect(this->getGpu(), target, | 859 fAARectRenderer->strokeAARect(this->getGpu(), target, rect, |
| 859 rect, combinedMatrix, devBoundRect, | 860 combinedMatrix, devBoundRect, |
| 860 width, useVertexCoverage); | 861 stroke, useVertexCoverage); |
| 861 } else { | 862 } else { |
| 862 // filled AA rect | 863 // filled AA rect |
| 863 fAARectRenderer->fillAARect(this->getGpu(), target, | 864 fAARectRenderer->fillAARect(this->getGpu(), target, |
| 864 rect, combinedMatrix, devBoundRect, | 865 rect, combinedMatrix, devBoundRect, |
| 865 useVertexCoverage); | 866 useVertexCoverage); |
| 866 } | 867 } |
| 867 return; | 868 return; |
| 868 } | 869 } |
| 869 | 870 |
| 870 if (width >= 0) { | 871 if (width >= 0) { |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 } | 1829 } |
| 1829 return path; | 1830 return path; |
| 1830 } | 1831 } |
| 1831 | 1832 |
| 1832 /////////////////////////////////////////////////////////////////////////////// | 1833 /////////////////////////////////////////////////////////////////////////////// |
| 1833 #if GR_CACHE_STATS | 1834 #if GR_CACHE_STATS |
| 1834 void GrContext::printCacheStats() const { | 1835 void GrContext::printCacheStats() const { |
| 1835 fTextureCache->printStats(); | 1836 fTextureCache->printStats(); |
| 1836 } | 1837 } |
| 1837 #endif | 1838 #endif |
| OLD | NEW |