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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 #include "SkGrTexturePixelRef.h" | 23 #include "SkGrTexturePixelRef.h" |
24 | 24 |
25 #include "SkDeviceImageFilterProxy.h" | 25 #include "SkDeviceImageFilterProxy.h" |
26 #include "SkDrawProcs.h" | 26 #include "SkDrawProcs.h" |
27 #include "SkGlyphCache.h" | 27 #include "SkGlyphCache.h" |
28 #include "SkImageFilter.h" | 28 #include "SkImageFilter.h" |
29 #include "SkMaskFilter.h" | 29 #include "SkMaskFilter.h" |
30 #include "SkPathEffect.h" | 30 #include "SkPathEffect.h" |
31 #include "SkPicture.h" | 31 #include "SkPicture.h" |
32 #include "SkPicturePlayback.h" | 32 #include "SkPictureData.h" |
33 #include "SkRRect.h" | 33 #include "SkRRect.h" |
34 #include "SkStroke.h" | 34 #include "SkStroke.h" |
35 #include "SkSurface.h" | 35 #include "SkSurface.h" |
36 #include "SkTLazy.h" | 36 #include "SkTLazy.h" |
37 #include "SkUtils.h" | 37 #include "SkUtils.h" |
38 #include "SkVertState.h" | 38 #include "SkVertState.h" |
39 #include "SkErrorInternals.h" | 39 #include "SkErrorInternals.h" |
40 | 40 |
41 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 | 41 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 |
42 | 42 |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 result->setInfo(info); | 1823 result->setInfo(info); |
1824 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 1824 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
1825 } | 1825 } |
1826 | 1826 |
1827 void SkGpuDevice::EXPERIMENTAL_purge(const SkPicture* picture) { | 1827 void SkGpuDevice::EXPERIMENTAL_purge(const SkPicture* picture) { |
1828 fContext->getLayerCache()->purge(picture); | 1828 fContext->getLayerCache()->purge(picture); |
1829 } | 1829 } |
1830 | 1830 |
1831 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
cture) { | 1831 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
cture) { |
1832 | 1832 |
1833 if (NULL == picture->fPlayback.get()) { | 1833 if (NULL == picture->fData.get()) { |
1834 return false; | 1834 return false; |
1835 } | 1835 } |
1836 | 1836 |
1837 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); | 1837 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); |
1838 | 1838 |
1839 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); | 1839 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); |
1840 if (NULL == data) { | 1840 if (NULL == data) { |
1841 return false; | 1841 return false; |
1842 } | 1842 } |
1843 | 1843 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 kSaveLayerMaxSize < info.fSize.fWidth || | 1921 kSaveLayerMaxSize < info.fSize.fWidth || |
1922 kSaveLayerMaxSize < info.fSize.fHeight || | 1922 kSaveLayerMaxSize < info.fSize.fHeight || |
1923 info.fIsNested) { | 1923 info.fIsNested) { |
1924 continue; | 1924 continue; |
1925 } | 1925 } |
1926 | 1926 |
1927 pullForward[j] = true; | 1927 pullForward[j] = true; |
1928 } | 1928 } |
1929 } | 1929 } |
1930 | 1930 |
1931 SkPicturePlayback::PlaybackReplacements replacements; | 1931 SkPictureData::PlaybackReplacements replacements; |
1932 | 1932 |
1933 // Generate the layer and/or ensure it is locked | 1933 // Generate the layer and/or ensure it is locked |
1934 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 1934 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
1935 if (pullForward[i]) { | 1935 if (pullForward[i]) { |
1936 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(
picture, i); | 1936 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(
picture, i); |
1937 | 1937 |
1938 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); | 1938 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); |
1939 | 1939 |
1940 SkPicturePlayback::PlaybackReplacements::ReplacementInfo* layerInfo
= | 1940 SkPictureData::PlaybackReplacements::ReplacementInfo* layerInfo = |
1941 replacem
ents.push(); | 1941 replacem
ents.push(); |
1942 layerInfo->fStart = info.fSaveLayerOpID; | 1942 layerInfo->fStart = info.fSaveLayerOpID; |
1943 layerInfo->fStop = info.fRestoreOpID; | 1943 layerInfo->fStop = info.fRestoreOpID; |
1944 layerInfo->fPos = info.fOffset; | 1944 layerInfo->fPos = info.fOffset; |
1945 | 1945 |
1946 GrTextureDesc desc; | 1946 GrTextureDesc desc; |
1947 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 1947 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
1948 desc.fWidth = info.fSize.fWidth; | 1948 desc.fWidth = info.fSize.fWidth; |
1949 desc.fHeight = info.fSize.fHeight; | 1949 desc.fHeight = info.fSize.fHeight; |
1950 desc.fConfig = kSkia8888_GrPixelConfig; | 1950 desc.fConfig = kSkia8888_GrPixelConfig; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2002 | 2002 |
2003 if (!layer->rect().isEmpty()) { | 2003 if (!layer->rect().isEmpty()) { |
2004 // info.fCTM maps the layer's top/left to the origin. | 2004 // info.fCTM maps the layer's top/left to the origin. |
2005 // Since this layer is atlased the top/left corner needs | 2005 // Since this layer is atlased the top/left corner needs |
2006 // to be offset to some arbitrary location in the backing | 2006 // to be offset to some arbitrary location in the backing |
2007 // texture. | 2007 // texture. |
2008 canvas->translate(SkIntToScalar(layer->rect().fLeft), | 2008 canvas->translate(SkIntToScalar(layer->rect().fLeft), |
2009 SkIntToScalar(layer->rect().fTop)); | 2009 SkIntToScalar(layer->rect().fTop)); |
2010 } | 2010 } |
2011 | 2011 |
2012 picture->fPlayback->setDrawLimits(info.fSaveLayerOpID, info.fRes
toreOpID); | 2012 picture->fData->setDrawLimits(info.fSaveLayerOpID, info.fRestore
OpID); |
2013 picture->fPlayback->draw(*canvas, NULL); | 2013 picture->fData->draw(*canvas, NULL); |
2014 picture->fPlayback->setDrawLimits(0, 0); | 2014 picture->fData->setDrawLimits(0, 0); |
2015 | 2015 |
2016 canvas->flush(); | 2016 canvas->flush(); |
2017 } | 2017 } |
2018 } | 2018 } |
2019 } | 2019 } |
2020 | 2020 |
2021 // Playback using new layers | 2021 // Playback using new layers |
2022 picture->fPlayback->setReplacements(&replacements); | 2022 picture->fData->setReplacements(&replacements); |
2023 picture->fPlayback->draw(*canvas, NULL); | 2023 picture->fData->draw(*canvas, NULL); |
2024 picture->fPlayback->setReplacements(NULL); | 2024 picture->fData->setReplacements(NULL); |
2025 | 2025 |
2026 // unlock the layers | 2026 // unlock the layers |
2027 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { | 2027 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { |
2028 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); | 2028 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); |
2029 fContext->getLayerCache()->unlock(layer); | 2029 fContext->getLayerCache()->unlock(layer); |
2030 } | 2030 } |
2031 | 2031 |
2032 return true; | 2032 return true; |
2033 } | 2033 } |
OLD | NEW |