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 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 1756 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
1757 desc.fWidth = info.width(); | 1757 desc.fWidth = info.width(); |
1758 desc.fHeight = info.height(); | 1758 desc.fHeight = info.height(); |
1759 desc.fSampleCnt = fRenderTarget->numSamples(); | 1759 desc.fSampleCnt = fRenderTarget->numSamples(); |
1760 | 1760 |
1761 SkAutoTUnref<GrTexture> texture; | 1761 SkAutoTUnref<GrTexture> texture; |
1762 // Skia's convention is to only clear a device if it is non-opaque. | 1762 // Skia's convention is to only clear a device if it is non-opaque. |
1763 unsigned flags = info.isOpaque() ? 0 : kNeedClear_Flag; | 1763 unsigned flags = info.isOpaque() ? 0 : kNeedClear_Flag; |
1764 | 1764 |
1765 #if CACHE_COMPATIBLE_DEVICE_TEXTURES | 1765 #if CACHE_COMPATIBLE_DEVICE_TEXTURES |
1766 // layers are never draw in repeat modes, so we can request an approx | 1766 // layers are never draw in repeat modes or with mip maps, so we can request
an approx |
1767 // match and ignore any padding. | 1767 // match and ignore any padding. Image filters (at present) don't tile their
inputs or use mip |
1768 const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == usage) ? | 1768 // maps, either. |
1769 GrContext::kApprox_ScratchTexMat
ch : | 1769 const GrContext::ScratchTexMatch match = |
1770 GrContext::kExact_ScratchTexMatc
h; | 1770 (kSaveLayer_Usage == usage || kImageFilter_Usage == usage) ? |
| 1771 GrContext::kApprox_ScratchTexMatch : |
| 1772 GrContext::kExact_ScratchTexMatch; |
1771 texture.reset(fContext->refScratchTexture(desc, match)); | 1773 texture.reset(fContext->refScratchTexture(desc, match)); |
1772 #else | 1774 #else |
1773 texture.reset(fContext->createUncachedTexture(desc, NULL, 0)); | 1775 texture.reset(fContext->createUncachedTexture(desc, NULL, 0)); |
1774 #endif | 1776 #endif |
1775 if (texture.get()) { | 1777 if (texture.get()) { |
1776 return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLega
cyFontHost_InitType), flags); | 1778 return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLega
cyFontHost_InitType), flags); |
1777 } else { | 1779 } else { |
1778 GrPrintf("---- failed to create compatible device texture [%d %d]\n", | 1780 GrPrintf("---- failed to create compatible device texture [%d %d]\n", |
1779 info.width(), info.height()); | 1781 info.width(), info.height()); |
1780 return NULL; | 1782 return NULL; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 GrLayerHoister::UnlockLayers(fContext, atlased, nonAtlased, recycled); | 1837 GrLayerHoister::UnlockLayers(fContext, atlased, nonAtlased, recycled); |
1836 | 1838 |
1837 return true; | 1839 return true; |
1838 } | 1840 } |
1839 | 1841 |
1840 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1842 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1841 // We always return a transient cache, so it is freed after each | 1843 // We always return a transient cache, so it is freed after each |
1842 // filter traversal. | 1844 // filter traversal. |
1843 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1845 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1844 } | 1846 } |
OLD | NEW |