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 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 return; | 1854 return; |
1855 } | 1855 } |
1856 | 1856 |
1857 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); | 1857 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); |
1858 | 1858 |
1859 const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(ke
y); | 1859 const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(ke
y); |
1860 if (NULL != existing) { | 1860 if (NULL != existing) { |
1861 return; | 1861 return; |
1862 } | 1862 } |
1863 | 1863 |
1864 SkAutoTUnref<GrAccelData> data(SkNEW_ARGS(GrAccelData, (key))); | 1864 GPUOptimize(picture); |
1865 | |
1866 picture->EXPERIMENTAL_addAccelData(data); | |
1867 | |
1868 GatherGPUInfo(picture, data); | |
1869 | 1865 |
1870 fContext->getLayerCache()->trackPicture(picture); | 1866 fContext->getLayerCache()->trackPicture(picture); |
1871 } | 1867 } |
1872 | 1868 |
1873 static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* re
sult) { | 1869 static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* re
sult) { |
1874 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 1870 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
1875 result->setInfo(info); | 1871 result->setInfo(info); |
1876 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 1872 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
1877 } | 1873 } |
1878 | 1874 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 atlased.setReserve(gpuData->numSaveLayers()); | 1997 atlased.setReserve(gpuData->numSaveLayers()); |
2002 | 1998 |
2003 // Generate the layer and/or ensure it is locked | 1999 // Generate the layer and/or ensure it is locked |
2004 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 2000 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
2005 if (pullForward[i]) { | 2001 if (pullForward[i]) { |
2006 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); | 2002 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); |
2007 | 2003 |
2008 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(
picture->uniqueID(), | 2004 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(
picture->uniqueID(), |
2009
info.fSaveLayerOpID, | 2005
info.fSaveLayerOpID, |
2010
info.fRestoreOpID, | 2006
info.fRestoreOpID, |
2011
info.fCTM); | 2007
info.fOriginXform); |
2012 | 2008 |
2013 SkPictureReplacementPlayback::PlaybackReplacements::ReplacementInfo*
layerInfo = | 2009 SkPictureReplacementPlayback::PlaybackReplacements::ReplacementInfo*
layerInfo = |
2014 replacem
ents.push(); | 2010 replacem
ents.push(); |
2015 layerInfo->fStart = info.fSaveLayerOpID; | 2011 layerInfo->fStart = info.fSaveLayerOpID; |
2016 layerInfo->fStop = info.fRestoreOpID; | 2012 layerInfo->fStop = info.fRestoreOpID; |
2017 layerInfo->fPos = info.fOffset; | 2013 layerInfo->fPos = info.fOffset; |
2018 | 2014 |
2019 GrTextureDesc desc; | 2015 GrTextureDesc desc; |
2020 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 2016 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
2021 desc.fWidth = info.fSize.fWidth; | 2017 desc.fWidth = info.fSize.fWidth; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 const GrAccelData *gpuData = static_cast<const GrAccelData*>(data); | 2155 const GrAccelData *gpuData = static_cast<const GrAccelData*>(data); |
2160 SkASSERT(0 != gpuData->numSaveLayers()); | 2156 SkASSERT(0 != gpuData->numSaveLayers()); |
2161 | 2157 |
2162 // unlock the layers | 2158 // unlock the layers |
2163 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 2159 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
2164 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); | 2160 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); |
2165 | 2161 |
2166 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture->uni
queID(), | 2162 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture->uni
queID(), |
2167 info.fSaveLa
yerOpID, | 2163 info.fSaveLa
yerOpID, |
2168 info.fRestor
eOpID, | 2164 info.fRestor
eOpID, |
2169 info.fCTM); | 2165 info.fOrigin
Xform); |
2170 fContext->getLayerCache()->unlock(layer); | 2166 fContext->getLayerCache()->unlock(layer); |
2171 } | 2167 } |
2172 | 2168 |
2173 #if DISABLE_CACHING | 2169 #if DISABLE_CACHING |
2174 // This code completely clears out the atlas. It is required when | 2170 // This code completely clears out the atlas. It is required when |
2175 // caching is disabled so the atlas doesn't fill up and force more | 2171 // caching is disabled so the atlas doesn't fill up and force more |
2176 // free floating layers | 2172 // free floating layers |
2177 fContext->getLayerCache()->purge(picture->uniqueID()); | 2173 fContext->getLayerCache()->purge(picture->uniqueID()); |
2178 | 2174 |
2179 fContext->getLayerCache()->purgeAll(); | 2175 fContext->getLayerCache()->purgeAll(); |
2180 #endif | 2176 #endif |
2181 } | 2177 } |
2182 | 2178 |
2183 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2179 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
2184 // We always return a transient cache, so it is freed after each | 2180 // We always return a transient cache, so it is freed after each |
2185 // filter traversal. | 2181 // filter traversal. |
2186 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2182 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
2187 } | 2183 } |
OLD | NEW |