aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r--src/gpu/GrContext.cpp63
1 files changed, 60 insertions, 3 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2a3852ce03..7d6a90a44d 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -484,7 +484,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src,
// TODO: Need to decide the semantics of this function for color spaces. Do we support
// conversion to a passed-in color space? For now, specifying nullptr means that this
// path will do no conversion, so it will match the behavior of the non-draw path.
- sk_sp<GrRenderTargetContext> tempRTC = fContext->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> tempRTC = fContext->makeRenderTargetContext(
tempDrawInfo.fTempSurfaceFit,
tempDrawInfo.fTempSurfaceDesc.fWidth,
tempDrawInfo.fTempSurfaceDesc.fHeight,
@@ -771,6 +771,23 @@ static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
}
}
+sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContextWithFallback(
+ SkBackingFit fit,
+ int width, int height,
+ GrPixelConfig config,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps* surfaceProps,
+ SkBudgeted budgeted) {
+ if (!this->caps()->isConfigRenderable(config, sampleCnt > 0)) {
+ config = GrPixelConfigFallback(config);
+ }
+
+ return this->makeRenderTargetContext(fit, width, height, config, std::move(colorSpace),
+ sampleCnt, origin, surfaceProps, budgeted);
+}
+
sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit,
int width, int height,
@@ -788,6 +805,48 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallb
sampleCnt, origin, surfaceProps, budgeted);
}
+sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContext(SkBackingFit fit,
+ int width, int height,
+ GrPixelConfig config,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps* surfaceProps,
+ SkBudgeted budgeted) {
+ if (!this->caps()->isConfigRenderable(config, sampleCnt > 0)) {
+ return nullptr;
+ }
+
+ 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 (SkBackingFit::kExact == fit) {
+ tex = this->resourceProvider()->createTexture(desc, budgeted);
+ } else {
+ tex.reset(this->resourceProvider()->createApproxTexture(desc, 0));
+ }
+ if (!tex) {
+ return nullptr;
+ }
+
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ this->contextPriv().makeWrappedRenderTargetContext(sk_ref_sp(tex->asRenderTarget()),
+ std::move(colorSpace), surfaceProps));
+ if (!renderTargetContext) {
+ return nullptr;
+ }
+
+ renderTargetContext->discard();
+
+ return renderTargetContext;
+}
+
sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
SkBackingFit fit,
int width, int height,
@@ -797,8 +856,6 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
GrSurfaceOrigin origin,
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted) {
- SkASSERT(kDefault_GrSurfaceOrigin != origin);
-
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fOrigin = origin;