Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 5ebb2e95fbf62c478db804e0e1254827a37e5689..a186bd87bc101f1cf9107ccc1903172adf354622 100644 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -615,6 +615,37 @@ sk_sp<GrDrawContext> GrContext::drawContext(sk_sp<GrRenderTarget> rt, |
return fDrawingManager->drawContext(std::move(rt), surfaceProps); |
} |
+sk_sp<GrDrawContext> GrContext::newDrawContext(BackingFit fit, |
+ int width, int height, |
+ GrPixelConfig config, |
+ int sampleCnt, |
+ GrSurfaceOrigin origin) { |
+ GrSurfaceDesc desc; |
+ desc.fFlags = kRenderTarget_GrSurfaceFlag; |
+ desc.fOrigin = origin; |
+ desc.fWidth = width; |
+ desc.fHeight = height; |
+ desc.fConfig = config; |
+ desc.fSampleCnt = sampleCnt; |
+ |
+ sk_sp<GrTexture> tex; |
+ if (kTight_BackingFit == fit) { |
+ tex.reset(this->textureProvider()->createTexture(desc, SkBudgeted::kYes)); |
+ } else { |
+ tex.reset(this->textureProvider()->createApproxTexture(desc)); |
+ } |
+ if (!tex) { |
+ return nullptr; |
+ } |
+ |
+ sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(tex->asRenderTarget()))); |
+ if (!drawContext) { |
+ return nullptr; |
+ } |
+ |
+ return drawContext; |
+} |
+ |
bool GrContext::abandoned() const { |
ASSERT_SINGLE_OWNER |
return fDrawingManager->abandoned(); |