| 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 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 SkPictureReplacementPlayback::PlaybackReplacements replacements; | 1982 SkPictureReplacementPlayback::PlaybackReplacements replacements; |
| 1983 | 1983 |
| 1984 SkTDArray<GrCachedLayer*> atlased, nonAtlased; | 1984 SkTDArray<GrCachedLayer*> atlased, nonAtlased; |
| 1985 atlased.setReserve(gpuData->numSaveLayers()); | 1985 atlased.setReserve(gpuData->numSaveLayers()); |
| 1986 | 1986 |
| 1987 // Generate the layer and/or ensure it is locked | 1987 // Generate the layer and/or ensure it is locked |
| 1988 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 1988 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
| 1989 if (pullForward[i]) { | 1989 if (pullForward[i]) { |
| 1990 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); | 1990 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); |
| 1991 | 1991 |
| 1992 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(
picture, | 1992 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(
picture->uniqueID(), |
| 1993
info.fSaveLayerOpID, | 1993
info.fSaveLayerOpID, |
| 1994
info.fRestoreOpID, | 1994
info.fRestoreOpID, |
| 1995
info.fCTM); | 1995
info.fCTM); |
| 1996 | 1996 |
| 1997 SkPictureReplacementPlayback::PlaybackReplacements::ReplacementInfo*
layerInfo = | 1997 SkPictureReplacementPlayback::PlaybackReplacements::ReplacementInfo*
layerInfo = |
| 1998 replacem
ents.push(); | 1998 replacem
ents.push(); |
| 1999 layerInfo->fStart = info.fSaveLayerOpID; | 1999 layerInfo->fStart = info.fSaveLayerOpID; |
| 2000 layerInfo->fStop = info.fRestoreOpID; | 2000 layerInfo->fStop = info.fRestoreOpID; |
| 2001 layerInfo->fPos = info.fOffset; | 2001 layerInfo->fPos = info.fOffset; |
| 2002 | 2002 |
| 2003 GrTextureDesc desc; | 2003 GrTextureDesc desc; |
| 2004 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 2004 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 2005 desc.fWidth = info.fSize.fWidth; | 2005 desc.fWidth = info.fSize.fWidth; |
| 2006 desc.fHeight = info.fSize.fHeight; | 2006 desc.fHeight = info.fSize.fHeight; |
| 2007 desc.fConfig = kSkia8888_GrPixelConfig; | 2007 desc.fConfig = kSkia8888_GrPixelConfig; |
| 2008 // TODO: need to deal with sample count | 2008 // TODO: need to deal with sample count |
| 2009 | 2009 |
| 2010 bool needsRendering = !fContext->getLayerCache()->lock(layer, desc); | 2010 bool needsRendering = fContext->getLayerCache()->lock(layer, desc, |
| 2011 info.fHasNestedLayers || inf
o.fIsNested); |
| 2011 if (NULL == layer->texture()) { | 2012 if (NULL == layer->texture()) { |
| 2012 continue; | 2013 continue; |
| 2013 } | 2014 } |
| 2014 | 2015 |
| 2015 layerInfo->fBM = SkNEW(SkBitmap); // fBM is allocated so Replacemen
tInfo can be POD | 2016 layerInfo->fBM = SkNEW(SkBitmap); // fBM is allocated so Replacemen
tInfo can be POD |
| 2016 wrap_texture(layer->texture(), | 2017 wrap_texture(layer->texture(), |
| 2017 !layer->isAtlased() ? desc.fWidth : layer->texture()->w
idth(), | 2018 !layer->isAtlased() ? desc.fWidth : layer->texture()->w
idth(), |
| 2018 !layer->isAtlased() ? desc.fHeight : layer->texture()->
height(), | 2019 !layer->isAtlased() ? desc.fHeight : layer->texture()->
height(), |
| 2019 layerInfo->fBM); | 2020 layerInfo->fBM); |
| 2020 | 2021 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 | 2120 |
| 2120 // Render the entire picture using new layers | 2121 // Render the entire picture using new layers |
| 2121 SkPictureReplacementPlayback playback(picture, &replacements, ops.get()); | 2122 SkPictureReplacementPlayback playback(picture, &replacements, ops.get()); |
| 2122 | 2123 |
| 2123 playback.draw(mainCanvas, NULL); | 2124 playback.draw(mainCanvas, NULL); |
| 2124 | 2125 |
| 2125 // unlock the layers | 2126 // unlock the layers |
| 2126 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 2127 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
| 2127 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); | 2128 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); |
| 2128 | 2129 |
| 2129 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, | 2130 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture->uni
queID(), |
| 2130 info.fSaveLa
yerOpID, | 2131 info.fSaveLa
yerOpID, |
| 2131 info.fRestor
eOpID, | 2132 info.fRestor
eOpID, |
| 2132 info.fCTM); | 2133 info.fCTM); |
| 2133 fContext->getLayerCache()->unlock(layer); | 2134 fContext->getLayerCache()->unlock(layer); |
| 2134 } | 2135 } |
| 2135 | 2136 |
| 2137 #if DISABLE_CACHING |
| 2138 // This code completely clears out the atlas. It is required when |
| 2139 // caching is disabled so the atlas doesn't fill up and force more |
| 2140 // free floating layers |
| 2141 fContext->getLayerCache()->purge(picture->uniqueID()); |
| 2142 |
| 2143 fContext->getLayerCache()->purgeAll(); |
| 2144 #endif |
| 2145 |
| 2136 return true; | 2146 return true; |
| 2137 } | 2147 } |
| 2138 | 2148 |
| 2139 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2149 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 2140 // We always return a transient cache, so it is freed after each | 2150 // We always return a transient cache, so it is freed after each |
| 2141 // filter traversal. | 2151 // filter traversal. |
| 2142 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2152 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 2143 } | 2153 } |
| OLD | NEW |