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 "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 info.width(), info.height()); | 1835 info.width(), info.height()); |
1836 return NULL; | 1836 return NULL; |
1837 } | 1837 } |
1838 } | 1838 } |
1839 | 1839 |
1840 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { | 1840 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { |
1841 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples(
)); | 1841 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples(
)); |
1842 } | 1842 } |
1843 | 1843 |
1844 void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { | 1844 void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { |
| 1845 fContext->getLayerCache()->processDeletedPictures(); |
| 1846 |
1845 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); | 1847 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); |
1846 | 1848 |
1847 const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(ke
y); | 1849 const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(ke
y); |
1848 if (NULL != existing) { | 1850 if (NULL != existing) { |
1849 return; | 1851 return; |
1850 } | 1852 } |
1851 | 1853 |
1852 SkAutoTUnref<GPUAccelData> data(SkNEW_ARGS(GPUAccelData, (key))); | 1854 SkAutoTUnref<GPUAccelData> data(SkNEW_ARGS(GPUAccelData, (key))); |
1853 | 1855 |
1854 picture->EXPERIMENTAL_addAccelData(data); | 1856 picture->EXPERIMENTAL_addAccelData(data); |
1855 | 1857 |
1856 GatherGPUInfo(picture, data); | 1858 GatherGPUInfo(picture, data); |
| 1859 |
| 1860 fContext->getLayerCache()->trackPicture(picture); |
1857 } | 1861 } |
1858 | 1862 |
1859 static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* re
sult) { | 1863 static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* re
sult) { |
1860 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 1864 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
1861 result->setInfo(info); | 1865 result->setInfo(info); |
1862 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 1866 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
1863 } | 1867 } |
1864 | 1868 |
1865 void SkGpuDevice::EXPERIMENTAL_purge(const SkPicture* picture) { | |
1866 fContext->getLayerCache()->purge(picture); | |
1867 } | |
1868 | |
1869 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
cture) { | 1869 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
cture) { |
| 1870 fContext->getLayerCache()->processDeletedPictures(); |
1870 | 1871 |
1871 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); | 1872 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); |
1872 | 1873 |
1873 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); | 1874 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); |
1874 if (NULL == data) { | 1875 if (NULL == data) { |
1875 return false; | 1876 return false; |
1876 } | 1877 } |
1877 | 1878 |
1878 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); | 1879 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); |
1879 | 1880 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 playback.draw(canvas, NULL); | 2051 playback.draw(canvas, NULL); |
2051 | 2052 |
2052 // unlock the layers | 2053 // unlock the layers |
2053 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 2054 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
2054 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); | 2055 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); |
2055 fContext->getLayerCache()->unlock(layer); | 2056 fContext->getLayerCache()->unlock(layer); |
2056 } | 2057 } |
2057 | 2058 |
2058 return true; | 2059 return true; |
2059 } | 2060 } |
OLD | NEW |