| OLD | NEW |
| 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 "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| 11 #include "GrContext.h" | 11 #include "GrContext.h" |
| 12 #include "SkDraw.h" | 12 #include "SkDraw.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrGpuResourcePriv.h" | 14 #include "GrGpuResourcePriv.h" |
| 15 #include "GrImageIDTextureAdjuster.h" | 15 #include "GrImageIDTextureAdjuster.h" |
| 16 #include "GrLayerHoister.h" | |
| 17 #include "GrRecordReplaceDraw.h" | |
| 18 #include "GrStyle.h" | 16 #include "GrStyle.h" |
| 19 #include "GrTracing.h" | 17 #include "GrTracing.h" |
| 20 #include "SkCanvasPriv.h" | 18 #include "SkCanvasPriv.h" |
| 21 #include "SkErrorInternals.h" | 19 #include "SkErrorInternals.h" |
| 22 #include "SkGlyphCache.h" | 20 #include "SkGlyphCache.h" |
| 23 #include "SkGrTexturePixelRef.h" | 21 #include "SkGrTexturePixelRef.h" |
| 24 #include "SkGr.h" | 22 #include "SkGr.h" |
| 25 #include "SkGrPriv.h" | 23 #include "SkGrPriv.h" |
| 26 #include "SkImage_Base.h" | 24 #include "SkImage_Base.h" |
| 27 #include "SkImageCacherator.h" | 25 #include "SkImageCacherator.h" |
| 28 #include "SkImageFilter.h" | 26 #include "SkImageFilter.h" |
| 29 #include "SkImageFilterCache.h" | 27 #include "SkImageFilterCache.h" |
| 30 #include "SkLayerInfo.h" | |
| 31 #include "SkMaskFilter.h" | 28 #include "SkMaskFilter.h" |
| 32 #include "SkNinePatchIter.h" | 29 #include "SkNinePatchIter.h" |
| 33 #include "SkPathEffect.h" | 30 #include "SkPathEffect.h" |
| 34 #include "SkPicture.h" | 31 #include "SkPicture.h" |
| 35 #include "SkPictureData.h" | 32 #include "SkPictureData.h" |
| 36 #include "SkRasterClip.h" | 33 #include "SkRasterClip.h" |
| 37 #include "SkRRect.h" | 34 #include "SkRRect.h" |
| 38 #include "SkRecord.h" | 35 #include "SkRecord.h" |
| 39 #include "SkStroke.h" | 36 #include "SkStroke.h" |
| 40 #include "SkSurface.h" | 37 #include "SkSurface.h" |
| (...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 } | 1827 } |
| 1831 | 1828 |
| 1832 sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfa
ceProps& props) { | 1829 sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfa
ceProps& props) { |
| 1833 ASSERT_SINGLE_OWNER | 1830 ASSERT_SINGLE_OWNER |
| 1834 // TODO: Change the signature of newSurface to take a budgeted parameter. | 1831 // TODO: Change the signature of newSurface to take a budgeted parameter. |
| 1835 static const SkBudgeted kBudgeted = SkBudgeted::kNo; | 1832 static const SkBudgeted kBudgeted = SkBudgeted::kNo; |
| 1836 return SkSurface::MakeRenderTarget(fContext, kBudgeted, info, fDrawContext->
desc().fSampleCnt, | 1833 return SkSurface::MakeRenderTarget(fContext, kBudgeted, info, fDrawContext->
desc().fSampleCnt, |
| 1837 &props); | 1834 &props); |
| 1838 } | 1835 } |
| 1839 | 1836 |
| 1840 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
* mainPicture, | |
| 1841 const SkMatrix* matrix, const SkPaint
* paint) { | |
| 1842 ASSERT_SINGLE_OWNER | |
| 1843 #ifndef SK_IGNORE_GPU_LAYER_HOISTING | |
| 1844 // todo: should handle this natively | |
| 1845 if (paint || | |
| 1846 (kRGBA_8888_SkColorType != mainCanvas->imageInfo().colorType() && | |
| 1847 kBGRA_8888_SkColorType != mainCanvas->imageInfo().colorType())) { | |
| 1848 return false; | |
| 1849 } | |
| 1850 | |
| 1851 const SkBigPicture::AccelData* data = nullptr; | |
| 1852 if (const SkBigPicture* bp = mainPicture->asSkBigPicture()) { | |
| 1853 data = bp->accelData(); | |
| 1854 } | |
| 1855 if (!data) { | |
| 1856 return false; | |
| 1857 } | |
| 1858 | |
| 1859 const SkLayerInfo *gpuData = static_cast<const SkLayerInfo*>(data); | |
| 1860 if (0 == gpuData->numBlocks()) { | |
| 1861 return false; | |
| 1862 } | |
| 1863 | |
| 1864 SkTDArray<GrHoistedLayer> atlasedNeedRendering, atlasedRecycled; | |
| 1865 | |
| 1866 SkIRect iBounds; | |
| 1867 if (!mainCanvas->getClipDeviceBounds(&iBounds)) { | |
| 1868 return false; | |
| 1869 } | |
| 1870 | |
| 1871 SkRect clipBounds = SkRect::Make(iBounds); | |
| 1872 | |
| 1873 SkMatrix initialMatrix = mainCanvas->getTotalMatrix(); | |
| 1874 | |
| 1875 GrLayerHoister::Begin(fContext); | |
| 1876 | |
| 1877 GrLayerHoister::FindLayersToAtlas(fContext, mainPicture, | |
| 1878 initialMatrix, | |
| 1879 clipBounds, | |
| 1880 &atlasedNeedRendering, &atlasedRecycled, | |
| 1881 fDrawContext->numColorSamples()); | |
| 1882 | |
| 1883 GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering); | |
| 1884 | |
| 1885 SkTDArray<GrHoistedLayer> needRendering, recycled; | |
| 1886 | |
| 1887 SkAutoCanvasMatrixPaint acmp(mainCanvas, matrix, paint, mainPicture->cullRec
t()); | |
| 1888 | |
| 1889 GrLayerHoister::FindLayersToHoist(fContext, mainPicture, | |
| 1890 initialMatrix, | |
| 1891 clipBounds, | |
| 1892 &needRendering, &recycled, | |
| 1893 fDrawContext->numColorSamples()); | |
| 1894 | |
| 1895 GrLayerHoister::DrawLayers(fContext, needRendering); | |
| 1896 | |
| 1897 // Render the entire picture using new layers | |
| 1898 GrRecordReplaceDraw(mainPicture, mainCanvas, fContext->getLayerCache(), | |
| 1899 initialMatrix, nullptr); | |
| 1900 | |
| 1901 GrLayerHoister::UnlockLayers(fContext, needRendering); | |
| 1902 GrLayerHoister::UnlockLayers(fContext, recycled); | |
| 1903 GrLayerHoister::UnlockLayers(fContext, atlasedNeedRendering); | |
| 1904 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled); | |
| 1905 GrLayerHoister::End(fContext); | |
| 1906 | |
| 1907 return true; | |
| 1908 #else | |
| 1909 return false; | |
| 1910 #endif | |
| 1911 } | |
| 1912 | |
| 1913 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1837 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
| 1914 ASSERT_SINGLE_OWNER | 1838 ASSERT_SINGLE_OWNER |
| 1915 // We always return a transient cache, so it is freed after each | 1839 // We always return a transient cache, so it is freed after each |
| 1916 // filter traversal. | 1840 // filter traversal. |
| 1917 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1841 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
| 1918 } | 1842 } |
| 1919 | 1843 |
| 1920 #endif | 1844 #endif |
| OLD | NEW |