aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-21 12:28:48 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-21 12:29:00 +0000
commit2af746c1e74af30d0fb02d5c35a178e61d152965 (patch)
tree3a8bda0962ad77d0d9ccb1d89c15f70578a7fe78 /src
parent02242e82e4bf94a8f6862dadb5bf347ea5e31eb5 (diff)
Revert "Rm makeRenderTargetContext in favor of deferred version (take 2)"
This reverts commit 02242e82e4bf94a8f6862dadb5bf347ea5e31eb5. Reason for revert: Maybe breaking Chrome DEPS roll Original change's description: > Rm makeRenderTargetContext in favor of deferred version (take 2) > > This is a reland of: https://skia-review.googlesource.com/c/13001/ (Rm makeRenderTargetContext in favor of deferred version) > > Change-Id: Ife77b012d09c46895884a168fc5045bd92a4b919 > Reviewed-on: https://skia-review.googlesource.com/13196 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I2607116ed743f5d313da4a7b7f056776ed907702 Reviewed-on: https://skia-review.googlesource.com/14024 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkSpecialSurface.cpp2
-rw-r--r--src/gpu/GrClipStackClip.cpp2
-rw-r--r--src/gpu/GrContext.cpp63
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp7
-rw-r--r--src/gpu/GrTextureProducer.cpp2
-rw-r--r--src/gpu/GrTextureToYUVPlanes.cpp10
-rw-r--r--src/gpu/GrYUVProvider.cpp2
-rw-r--r--src/gpu/SkGpuDevice.cpp14
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp6
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp2
-rw-r--r--src/image/SkImage_Gpu.cpp4
11 files changed, 83 insertions, 31 deletions
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 33ef97e5bd..40afb57cec 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -164,7 +164,7 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
return nullptr;
}
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext(
SkBackingFit::kApprox, width, height, config, std::move(colorSpace)));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 18df1d6711..b0109819d7 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -392,7 +392,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context,
return proxy;
}
- sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
+ sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContextWithFallback(
SkBackingFit::kApprox,
reducedClip.width(),
reducedClip.height(),
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;
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 04472c58a0..4d309f407e 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -227,11 +227,8 @@ void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext,
// remove all the previously recorded ops and change the load op to clear with supplied
// color.
// TODO: this needs to be updated to use GrSurfaceProxy::UniqueID
- // MDB TODO: re-enable once opLists are divided. This assertion fails when a rendering is
- // aborted but the same RT is reused for the next draw. The clears really shouldn't be
- // fused in that case.
- //SkASSERT((fLastFullClearResourceID == renderTarget->uniqueID()) ==
- // (fLastFullClearProxyID == renderTargetContext->asRenderTargetProxy()->uniqueID()));
+ SkASSERT((fLastFullClearResourceID == renderTarget->uniqueID()) ==
+ (fLastFullClearProxyID == renderTargetContext->asRenderTargetProxy()->uniqueID()));
if (fLastFullClearResourceID == renderTarget->uniqueID()) {
// As currently implemented, fLastFullClearOp should be the last op because we would
// have cleared it when another op was recorded.
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 75796b1aa4..d226c3feb6 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -27,7 +27,7 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
- sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
+ sk_sp<GrRenderTargetContext> copyRTC = context->makeRenderTargetContextWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), config, nullptr);
if (!copyRTC) {
return nullptr;
diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp
index c6f9794192..0a0edee4df 100644
--- a/src/gpu/GrTextureToYUVPlanes.cpp
+++ b/src/gpu/GrTextureToYUVPlanes.cpp
@@ -73,7 +73,7 @@ bool GrTextureToYUVPlanes(GrContext* context, sk_sp<GrTextureProxy> proxy,
// sizes however we optimize for two other cases - all planes are the same (1 draw to YUV),
// and U and V are the same but Y differs (2 draws, one for Y, one for UV).
if (sizes[0] == sizes[1] && sizes[1] == sizes[2]) {
- yuvRenderTargetContext = context->makeDeferredRenderTargetContextWithFallback(
+ yuvRenderTargetContext = context->makeRenderTargetContextWithFallback(
SkBackingFit::kApprox,
sizes[0].fWidth,
sizes[0].fHeight,
@@ -83,7 +83,7 @@ bool GrTextureToYUVPlanes(GrContext* context, sk_sp<GrTextureProxy> proxy,
return false;
}
} else {
- yRenderTargetContext = context->makeDeferredRenderTargetContextWithFallback(
+ yRenderTargetContext = context->makeRenderTargetContextWithFallback(
SkBackingFit::kApprox,
sizes[0].fWidth,
sizes[0].fHeight,
@@ -94,7 +94,7 @@ bool GrTextureToYUVPlanes(GrContext* context, sk_sp<GrTextureProxy> proxy,
}
if (sizes[1] == sizes[2]) {
// TODO: Add support for GL_RG when available.
- uvRenderTargetContext = context->makeDeferredRenderTargetContextWithFallback(
+ uvRenderTargetContext = context->makeRenderTargetContextWithFallback(
SkBackingFit::kApprox,
sizes[1].fWidth,
sizes[1].fHeight,
@@ -104,13 +104,13 @@ bool GrTextureToYUVPlanes(GrContext* context, sk_sp<GrTextureProxy> proxy,
return false;
}
} else {
- uRenderTargetContext = context->makeDeferredRenderTargetContextWithFallback(
+ uRenderTargetContext = context->makeRenderTargetContextWithFallback(
SkBackingFit::kApprox,
sizes[1].fWidth,
sizes[1].fHeight,
kAlpha_8_GrPixelConfig,
nullptr);
- vRenderTargetContext = context->makeDeferredRenderTargetContextWithFallback(
+ vRenderTargetContext = context->makeRenderTargetContextWithFallback(
SkBackingFit::kApprox,
sizes[2].fWidth,
sizes[2].fHeight,
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 6b51303488..cfd27d0d39 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -121,7 +121,7 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx,
}
// We never want to perform color-space conversion during the decode
- sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeRenderTargetContext(
SkBackingFit::kExact,
desc.fWidth, desc.fHeight,
desc.fConfig, nullptr,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 6ddae65a9c..7046f1cefe 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -168,8 +168,7 @@ sk_sp<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
GrPixelConfig config = SkImageInfo2GrPixelConfig(origInfo, *context->caps());
// This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case
// they need to be exact.
- return context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact,
+ return context->makeRenderTargetContext(SkBackingFit::kExact,
origInfo.width(), origInfo.height(),
config, origInfo.refColorSpace(), sampleCount,
origin, surfaceProps, budgeted);
@@ -1330,6 +1329,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() {
const SkImageInfo ii = this->imageInfo();
const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height());
+ SkASSERT(proxy->priv().isExact());
return SkSpecialImage::MakeDeferredFromGpu(fContext.get(),
srcRect,
kNeedNewImageUniqueID_SpecialImage,
@@ -1760,13 +1760,13 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApprox
: SkBackingFit::kExact;
- sk_sp<GrRenderTargetContext> rtc(fContext->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(fContext->makeRenderTargetContext(
fit,
cinfo.fInfo.width(), cinfo.fInfo.height(),
- fRenderTargetContext->config(),
- fRenderTargetContext->refColorSpace(),
- fRenderTargetContext->desc().fSampleCnt,
- kBottomLeft_GrSurfaceOrigin,
+ fRenderTargetContext->config(),
+ fRenderTargetContext->refColorSpace(),
+ fRenderTargetContext->desc().fSampleCnt,
+ kDefault_GrSurfaceOrigin,
&props));
if (!rtc) {
return nullptr;
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 41c7e6f56c..2e0886f698 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -121,12 +121,10 @@ bool GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
const SkImageInfo ii = SkImageInfo::Make(kSize, kSize,
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<GrRenderTargetContext> readRTC(context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact,
+ sk_sp<GrRenderTargetContext> readRTC(context->makeRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
kConfig, nullptr));
- sk_sp<GrRenderTargetContext> tempRTC(context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact,
+ sk_sp<GrRenderTargetContext> tempRTC(context->makeRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
kConfig, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index d99f2828fc..4e377c9595 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -352,7 +352,7 @@ DRAW_OP_TEST_DEFINE(TextBlobOp) {
}
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext(
SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr));
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 96a81f5d01..dd1b0c166e 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -385,7 +385,7 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
const int height = yuvSizes[0].fHeight;
// Needs to be a render target in order to draw to it for the yuv->rgb conversion.
- sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeRenderTargetContext(
SkBackingFit::kExact,
width, height,
kRGBA_8888_GrPixelConfig,
@@ -922,7 +922,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> colorSpace) con
return sk_ref_sp(const_cast<SkImage_Gpu*>(this));
}
- sk_sp<GrRenderTargetContext> renderTargetContext(fContext->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(fContext->makeRenderTargetContext(
SkBackingFit::kExact, this->width(), this->height(), kRGBA_8888_GrPixelConfig, nullptr));
if (!renderTargetContext) {
return nullptr;