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

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

Issue 748853002: Add support for hoisting layers in pictures drawn with a matrix (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 6 years 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
« no previous file with comments | « src/gpu/GrRecordReplaceDraw.cpp ('k') | no next file » | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
11 #include "effects/GrDashingEffect.h" 11 #include "effects/GrDashingEffect.h"
12 #include "effects/GrTextureDomain.h" 12 #include "effects/GrTextureDomain.h"
13 #include "effects/GrSimpleTextureEffect.h" 13 #include "effects/GrSimpleTextureEffect.h"
14 14
15 #include "GrContext.h" 15 #include "GrContext.h"
16 #include "GrBitmapTextContext.h" 16 #include "GrBitmapTextContext.h"
17 #include "GrDistanceFieldTextContext.h" 17 #include "GrDistanceFieldTextContext.h"
18 #include "GrLayerHoister.h" 18 #include "GrLayerHoister.h"
19 #include "GrRecordReplaceDraw.h" 19 #include "GrRecordReplaceDraw.h"
20 #include "GrStrokeInfo.h" 20 #include "GrStrokeInfo.h"
21 #include "GrTracing.h" 21 #include "GrTracing.h"
22 #include "GrGpu.h" 22 #include "GrGpu.h"
23 23
24 #include "SkGrTexturePixelRef.h" 24 #include "SkGrTexturePixelRef.h"
25 25
26 #include "SkCanvasPriv.h"
26 #include "SkDeviceImageFilterProxy.h" 27 #include "SkDeviceImageFilterProxy.h"
27 #include "SkDrawProcs.h" 28 #include "SkDrawProcs.h"
28 #include "SkGlyphCache.h" 29 #include "SkGlyphCache.h"
29 #include "SkImageFilter.h" 30 #include "SkImageFilter.h"
30 #include "SkLayerInfo.h" 31 #include "SkLayerInfo.h"
31 #include "SkMaskFilter.h" 32 #include "SkMaskFilter.h"
32 #include "SkPathEffect.h" 33 #include "SkPathEffect.h"
33 #include "SkPicture.h" 34 #include "SkPicture.h"
34 #include "SkPictureData.h" 35 #include "SkPictureData.h"
35 #include "SkRecord.h" 36 #include "SkRecord.h"
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 return NULL; 1782 return NULL;
1782 } 1783 }
1783 } 1784 }
1784 1785
1785 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { 1786 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1786 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( ), &props); 1787 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( ), &props);
1787 } 1788 }
1788 1789
1789 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture, 1790 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture,
1790 const SkMatrix* matrix, const SkPaint * paint) { 1791 const SkMatrix* matrix, const SkPaint * paint) {
1791 // todo: should handle these natively 1792 // todo: should handle this natively
1792 if (matrix || paint) { 1793 if (paint) {
1793 return false; 1794 return false;
1794 } 1795 }
1795 1796
1796 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); 1797 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey();
1797 1798
1798 const SkPicture::AccelData* data = mainPicture->EXPERIMENTAL_getAccelData(ke y); 1799 const SkPicture::AccelData* data = mainPicture->EXPERIMENTAL_getAccelData(ke y);
1799 if (!data) { 1800 if (!data) {
1800 return false; 1801 return false;
1801 } 1802 }
1802 1803
1803 SkRect clipBounds; 1804 SkRect clipBounds;
1804 if (!mainCanvas->getClipBounds(&clipBounds)) { 1805 if (!mainCanvas->getClipBounds(&clipBounds)) {
1805 return true; 1806 return true;
1806 } 1807 }
1807 1808
1809 SkAutoCanvasMatrixPaint acmp(mainCanvas, matrix, paint, mainPicture->cullRec t());
1810
1811 const SkMatrix initialMatrix = mainCanvas->getTotalMatrix();
1812
1808 SkTDArray<GrHoistedLayer> atlasedNeedRendering, atlasedRecycled; 1813 SkTDArray<GrHoistedLayer> atlasedNeedRendering, atlasedRecycled;
1809 1814
1810 GrLayerHoister::FindLayersToAtlas(fContext, mainPicture, 1815 GrLayerHoister::FindLayersToAtlas(fContext, mainPicture,
1816 initialMatrix,
1811 clipBounds, 1817 clipBounds,
1812 &atlasedNeedRendering, &atlasedRecycled, 1818 &atlasedNeedRendering, &atlasedRecycled,
1813 fRenderTarget->numSamples()); 1819 fRenderTarget->numSamples());
1814 1820
1815 GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering); 1821 GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering);
1816 1822
1817 SkTDArray<GrHoistedLayer> needRendering, recycled; 1823 SkTDArray<GrHoistedLayer> needRendering, recycled;
1818 1824
1819 GrLayerHoister::FindLayersToHoist(fContext, mainPicture, 1825 GrLayerHoister::FindLayersToHoist(fContext, mainPicture,
1826 initialMatrix,
1820 clipBounds, 1827 clipBounds,
1821 &needRendering, &recycled, 1828 &needRendering, &recycled,
1822 fRenderTarget->numSamples()); 1829 fRenderTarget->numSamples());
1823 1830
1824 GrLayerHoister::DrawLayers(fContext, needRendering); 1831 GrLayerHoister::DrawLayers(fContext, needRendering);
1825 1832
1826 GrReplacements replacements; 1833 GrReplacements replacements;
1827 1834
1828 GrLayerHoister::ConvertLayersToReplacements(needRendering, &replacements); 1835 GrLayerHoister::ConvertLayersToReplacements(needRendering, &replacements);
1829 GrLayerHoister::ConvertLayersToReplacements(recycled, &replacements); 1836 GrLayerHoister::ConvertLayersToReplacements(recycled, &replacements);
1830 1837
1831 // Render the entire picture using new layers 1838 // Render the entire picture using new layers
1832 const SkMatrix initialMatrix = mainCanvas->getTotalMatrix();
1833
1834 GrRecordReplaceDraw(mainPicture, mainCanvas, &replacements, initialMatrix, N ULL); 1839 GrRecordReplaceDraw(mainPicture, mainCanvas, &replacements, initialMatrix, N ULL);
1835 1840
1836 GrLayerHoister::UnlockLayers(fContext, needRendering); 1841 GrLayerHoister::UnlockLayers(fContext, needRendering);
1837 GrLayerHoister::UnlockLayers(fContext, recycled); 1842 GrLayerHoister::UnlockLayers(fContext, recycled);
1838 GrLayerHoister::UnlockLayers(fContext, atlasedNeedRendering); 1843 GrLayerHoister::UnlockLayers(fContext, atlasedNeedRendering);
1839 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled); 1844 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled);
1840 1845
1841 return true; 1846 return true;
1842 } 1847 }
1843 1848
1844 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1849 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1845 // We always return a transient cache, so it is freed after each 1850 // We always return a transient cache, so it is freed after each
1846 // filter traversal. 1851 // filter traversal.
1847 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1852 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1848 } 1853 }
1849 1854
1850 #endif 1855 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrRecordReplaceDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698