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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 return false; | 1855 return false; |
1856 } | 1856 } |
1857 | 1857 |
1858 void SkGpuDevice::flush() { | 1858 void SkGpuDevice::flush() { |
1859 DO_DEFERRED_CLEAR(); | 1859 DO_DEFERRED_CLEAR(); |
1860 fRenderTarget->prepareForExternalRead(); | 1860 fRenderTarget->prepareForExternalRead(); |
1861 } | 1861 } |
1862 | 1862 |
1863 /////////////////////////////////////////////////////////////////////////////// | 1863 /////////////////////////////////////////////////////////////////////////////// |
1864 | 1864 |
1865 SkBaseDevice* SkGpuDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) { | 1865 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
*) { |
1866 GrSurfaceDesc desc; | 1866 GrSurfaceDesc desc; |
1867 desc.fConfig = fRenderTarget->config(); | 1867 desc.fConfig = fRenderTarget->config(); |
1868 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 1868 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
1869 desc.fWidth = cinfo.fInfo.width(); | 1869 desc.fWidth = cinfo.fInfo.width(); |
1870 desc.fHeight = cinfo.fInfo.height(); | 1870 desc.fHeight = cinfo.fInfo.height(); |
1871 desc.fSampleCnt = fRenderTarget->numSamples(); | 1871 desc.fSampleCnt = fRenderTarget->numSamples(); |
1872 | 1872 |
1873 SkAutoTUnref<GrTexture> texture; | 1873 SkAutoTUnref<GrTexture> texture; |
1874 // Skia's convention is to only clear a device if it is non-opaque. | 1874 // Skia's convention is to only clear a device if it is non-opaque. |
1875 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; | 1875 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; |
1876 | 1876 |
1877 // layers are never draw in repeat modes, so we can request an approx | 1877 // layers are never draw in repeat modes, so we can request an approx |
1878 // match and ignore any padding. | 1878 // match and ignore any padding. |
1879 const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == cinfo.fUsage)
? | 1879 const GrContext::ScratchTexMatch match = (kNever_TileUsage == cinfo.fTileUsa
ge) ? |
1880 GrContext::kApprox_ScratchTexMat
ch : | 1880 GrContext::kApprox_ScratchTexMat
ch : |
1881 GrContext::kExact_ScratchTexMatc
h; | 1881 GrContext::kExact_ScratchTexMatc
h; |
1882 texture.reset(fContext->refScratchTexture(desc, match)); | 1882 texture.reset(fContext->refScratchTexture(desc, match)); |
1883 | 1883 |
1884 if (texture) { | 1884 if (texture) { |
1885 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); | 1885 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); |
1886 return SkGpuDevice::Create(texture->asRenderTarget(), &props, flags); | 1886 return SkGpuDevice::Create(texture->asRenderTarget(), &props, flags); |
1887 } else { | 1887 } else { |
1888 SkErrorInternals::SetError( kInternalError_SkError, | 1888 SkErrorInternals::SetError( kInternalError_SkError, |
1889 "---- failed to create compatible device tex
ture [%d %d]\n", | 1889 "---- failed to create compatible device tex
ture [%d %d]\n", |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 #endif | 1965 #endif |
1966 } | 1966 } |
1967 | 1967 |
1968 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1968 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1969 // We always return a transient cache, so it is freed after each | 1969 // We always return a transient cache, so it is freed after each |
1970 // filter traversal. | 1970 // filter traversal. |
1971 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1971 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1972 } | 1972 } |
1973 | 1973 |
1974 #endif | 1974 #endif |
OLD | NEW |