| Index: src/image/SkSurface_Gpu.cpp
|
| diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
|
| index ae05ea8c04609369fcef5279b53fe4c4c630319f..50d6606145a644d9a69be50613555854cc4d6da6 100644
|
| --- a/src/image/SkSurface_Gpu.cpp
|
| +++ b/src/image/SkSurface_Gpu.cpp
|
| @@ -14,7 +14,7 @@ class SkSurface_Gpu : public SkSurface_Base {
|
| public:
|
| SK_DECLARE_INST_COUNT(SkSurface_Gpu)
|
|
|
| - SkSurface_Gpu(GrRenderTarget*);
|
| + SkSurface_Gpu(GrRenderTarget*, bool cached);
|
| virtual ~SkSurface_Gpu();
|
|
|
| virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
| @@ -32,9 +32,9 @@ private:
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget)
|
| +SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached)
|
| : INHERITED(renderTarget->width(), renderTarget->height()) {
|
| - fDevice = SkNEW_ARGS(SkGpuDevice, (renderTarget->getContext(), renderTarget));
|
| + fDevice = SkGpuDevice::Create(renderTarget, cached ? SkGpuDevice::kCached_Flag : 0);
|
|
|
| if (kRGB_565_GrPixelConfig != renderTarget->config()) {
|
| fDevice->clear(0x0);
|
| @@ -95,7 +95,7 @@ SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target) {
|
| if (NULL == target) {
|
| return NULL;
|
| }
|
| - return SkNEW_ARGS(SkSurface_Gpu, (target));
|
| + return SkNEW_ARGS(SkSurface_Gpu, (target, false));
|
| }
|
|
|
| SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount) {
|
| @@ -117,5 +117,28 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
|
| return NULL;
|
| }
|
|
|
| - return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget()));
|
| + return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false));
|
| +}
|
| +
|
| +SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount) {
|
| + if (NULL == ctx) {
|
| + return NULL;
|
| + }
|
| +
|
| + SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
|
| +
|
| + GrTextureDesc desc;
|
| + desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFlagBit;
|
| + desc.fWidth = info.fWidth;
|
| + desc.fHeight = info.fHeight;
|
| + desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
|
| + desc.fSampleCnt = sampleCount;
|
| +
|
| + SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::kExact_ScratchTexMatch));
|
| +
|
| + if (NULL == tex) {
|
| + return NULL;
|
| + }
|
| +
|
| + return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true));
|
| }
|
|
|