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

Side by Side Diff: src/gpu/GrContext.cpp

Issue 18686007: Make GrPaint have a variable sized array of color and coverage stages rather than a fixed size. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rob's comments Created 7 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrDrawState.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 /* 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 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 desc.fHeight = SkScalarFloorToInt(srcRect.height()); 1757 desc.fHeight = SkScalarFloorToInt(srcRect.height());
1758 desc.fConfig = srcTexture->config(); 1758 desc.fConfig = srcTexture->config();
1759 1759
1760 GrAutoScratchTexture temp1, temp2; 1760 GrAutoScratchTexture temp1, temp2;
1761 GrTexture* dstTexture = temp1.set(this, desc); 1761 GrTexture* dstTexture = temp1.set(this, desc);
1762 GrTexture* tempTexture = canClobberSrc ? srcTexture : temp2.set(this, desc); 1762 GrTexture* tempTexture = canClobberSrc ? srcTexture : temp2.set(this, desc);
1763 if (NULL == dstTexture || NULL == tempTexture) { 1763 if (NULL == dstTexture || NULL == tempTexture) {
1764 return NULL; 1764 return NULL;
1765 } 1765 }
1766 1766
1767 GrPaint paint;
1768 paint.reset();
1769
1770 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { 1767 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
1768 GrPaint paint;
1771 SkMatrix matrix; 1769 SkMatrix matrix;
1772 matrix.setIDiv(srcTexture->width(), srcTexture->height()); 1770 matrix.setIDiv(srcTexture->width(), srcTexture->height());
1773 this->setRenderTarget(dstTexture->asRenderTarget()); 1771 this->setRenderTarget(dstTexture->asRenderTarget());
1774 SkRect dstRect(srcRect); 1772 SkRect dstRect(srcRect);
1775 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, 1773 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
1776 i < scaleFactorY ? 0.5f : 1.0f); 1774 i < scaleFactorY ? 0.5f : 1.0f);
1777 1775 GrTextureParams params(SkShader::kClamp_TileMode, true);
1778 paint.colorStage(0)->setEffect(GrSimpleTextureEffect::Create(srcTexture, 1776 paint.addColorTextureEffect(srcTexture, matrix, params);
1779 matrix,
1780 true))->unr ef();
1781 this->drawRectToRect(paint, dstRect, srcRect); 1777 this->drawRectToRect(paint, dstRect, srcRect);
1782 srcRect = dstRect; 1778 srcRect = dstRect;
1783 srcTexture = dstTexture; 1779 srcTexture = dstTexture;
1784 SkTSwap(dstTexture, tempTexture); 1780 SkTSwap(dstTexture, tempTexture);
1785 } 1781 }
1786 1782
1787 SkIRect srcIRect; 1783 SkIRect srcIRect;
1788 srcRect.roundOut(&srcIRect); 1784 srcRect.roundOut(&srcIRect);
1789 1785
1790 if (sigmaX > 0.0f) { 1786 if (sigmaX > 0.0f) {
1791 if (scaleFactorX > 1) { 1787 if (scaleFactorX > 1) {
1792 // Clear out a radius to the right of the srcRect to prevent the 1788 // Clear out a radius to the right of the srcRect to prevent the
1793 // X convolution from reading garbage. 1789 // X convolution from reading garbage.
1794 clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, 1790 clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1795 radiusX, srcIRect.height()); 1791 radiusX, srcIRect.height());
1796 this->clear(&clearRect, 0x0); 1792 this->clear(&clearRect, 0x0);
1797 } 1793 }
1798 1794 GrPaint paint;
1799 this->setRenderTarget(dstTexture->asRenderTarget()); 1795 this->setRenderTarget(dstTexture->asRenderTarget());
1800 AutoRestoreEffects are; 1796 AutoRestoreEffects are;
1801 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); 1797 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are);
1802 convolve_gaussian(target, srcTexture, srcRect, sigmaX, radiusX, 1798 convolve_gaussian(target, srcTexture, srcRect, sigmaX, radiusX,
1803 Gr1DKernelEffect::kX_Direction); 1799 Gr1DKernelEffect::kX_Direction);
1804 srcTexture = dstTexture; 1800 srcTexture = dstTexture;
1805 SkTSwap(dstTexture, tempTexture); 1801 SkTSwap(dstTexture, tempTexture);
1806 } 1802 }
1807 1803
1808 if (sigmaY > 0.0f) { 1804 if (sigmaY > 0.0f) {
1809 if (scaleFactorY > 1 || sigmaX > 0.0f) { 1805 if (scaleFactorY > 1 || sigmaX > 0.0f) {
1810 // Clear out a radius below the srcRect to prevent the Y 1806 // Clear out a radius below the srcRect to prevent the Y
1811 // convolution from reading garbage. 1807 // convolution from reading garbage.
1812 clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom, 1808 clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
1813 srcIRect.width(), radiusY); 1809 srcIRect.width(), radiusY);
1814 this->clear(&clearRect, 0x0); 1810 this->clear(&clearRect, 0x0);
1815 } 1811 }
1816 1812
1817 this->setRenderTarget(dstTexture->asRenderTarget()); 1813 this->setRenderTarget(dstTexture->asRenderTarget());
1814 GrPaint paint;
1818 AutoRestoreEffects are; 1815 AutoRestoreEffects are;
1819 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); 1816 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are);
1820 convolve_gaussian(target, srcTexture, srcRect, sigmaY, radiusY, 1817 convolve_gaussian(target, srcTexture, srcRect, sigmaY, radiusY,
1821 Gr1DKernelEffect::kY_Direction); 1818 Gr1DKernelEffect::kY_Direction);
1822 srcTexture = dstTexture; 1819 srcTexture = dstTexture;
1823 SkTSwap(dstTexture, tempTexture); 1820 SkTSwap(dstTexture, tempTexture);
1824 } 1821 }
1825 1822
1826 if (scaleFactorX > 1 || scaleFactorY > 1) { 1823 if (scaleFactorX > 1 || scaleFactorY > 1) {
1827 // Clear one pixel to the right and below, to accommodate bilinear 1824 // Clear one pixel to the right and below, to accommodate bilinear
1828 // upsampling. 1825 // upsampling.
1829 clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom, 1826 clearRect = SkIRect::MakeXYWH(srcIRect.fLeft, srcIRect.fBottom,
1830 srcIRect.width() + 1, 1); 1827 srcIRect.width() + 1, 1);
1831 this->clear(&clearRect, 0x0); 1828 this->clear(&clearRect, 0x0);
1832 clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, 1829 clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1833 1, srcIRect.height()); 1830 1, srcIRect.height());
1834 this->clear(&clearRect, 0x0); 1831 this->clear(&clearRect, 0x0);
1835 SkMatrix matrix; 1832 SkMatrix matrix;
1836 // FIXME: This should be mitchell, not bilinear.
1837 matrix.setIDiv(srcTexture->width(), srcTexture->height()); 1833 matrix.setIDiv(srcTexture->width(), srcTexture->height());
1838 this->setRenderTarget(dstTexture->asRenderTarget()); 1834 this->setRenderTarget(dstTexture->asRenderTarget());
1839 paint.colorStage(0)->setEffect(GrSimpleTextureEffect::Create(srcTexture, 1835
1840 matrix, 1836 GrPaint paint;
1841 true))->unr ef(); 1837 // FIXME: This should be mitchell, not bilinear.
1838 GrTextureParams params(SkShader::kClamp_TileMode, true);
1839 paint.addColorTextureEffect(srcTexture, matrix, params);
1840
1842 SkRect dstRect(srcRect); 1841 SkRect dstRect(srcRect);
1843 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); 1842 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
1844 this->drawRectToRect(paint, dstRect, srcRect); 1843 this->drawRectToRect(paint, dstRect, srcRect);
1845 srcRect = dstRect; 1844 srcRect = dstRect;
1846 srcTexture = dstTexture; 1845 srcTexture = dstTexture;
1847 SkTSwap(dstTexture, tempTexture); 1846 SkTSwap(dstTexture, tempTexture);
1848 } 1847 }
1849 if (srcTexture == temp1.texture()) { 1848 if (srcTexture == temp1.texture()) {
1850 return temp1.detach(); 1849 return temp1.detach();
1851 } else if (srcTexture == temp2.texture()) { 1850 } else if (srcTexture == temp2.texture()) {
1852 return temp2.detach(); 1851 return temp2.detach();
1853 } else { 1852 } else {
1854 srcTexture->ref(); 1853 srcTexture->ref();
1855 return srcTexture; 1854 return srcTexture;
1856 } 1855 }
1857 } 1856 }
1858 1857
1859 /////////////////////////////////////////////////////////////////////////////// 1858 ///////////////////////////////////////////////////////////////////////////////
1860 #if GR_CACHE_STATS 1859 #if GR_CACHE_STATS
1861 void GrContext::printCacheStats() const { 1860 void GrContext::printCacheStats() const {
1862 fTextureCache->printStats(); 1861 fTextureCache->printStats();
1863 } 1862 }
1864 #endif 1863 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698