Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Unified Diff: src/gpu/GrContext.cpp

Issue 1914883002: Refactor drawContext/RenderTarget creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix variable name Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrBlurUtils.cpp ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/gpu/GrBlurUtils.cpp ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698