aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceProvider.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-11 12:54:57 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-11 19:38:18 +0000
commit1119dc366e15ef737d05d3a087410ea40c508101 (patch)
tree0b1363476a28c6df8baf79a46dbee8a74eac48af /src/gpu/GrResourceProvider.cpp
parentfafe135349bd34961a12bfd8185733709cd0e45e (diff)
Remove discard from GrRenderTarget & force it to always go through a RenderTargetContext
This is a bit sloppy in that it ignores some instances where discards were being issued before. The creation of the temp RTContext in the RenderTarget's discard method was causing an extra split in the opLists. This is split out of: https://skia-review.googlesource.com/c/10284/ (Omnibus: Remove GrSurface-derived classes from ops) Change-Id: Ic366d303280635763b0fae238c4df37c04fb8503 Reviewed-on: https://skia-review.googlesource.com/11125 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrResourceProvider.cpp')
-rw-r--r--src/gpu/GrResourceProvider.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index dafa27bcf2..d2ec204d6c 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -58,12 +58,17 @@ sk_sp<GrTextureProxy> GrResourceProvider::createMipMappedTexture(
SkDestinationSurfaceColorMode mipColorMode) {
ASSERT_SINGLE_OWNER
- if (this->isAbandoned()) {
- return nullptr;
+ if (!mipLevelCount) {
+ if (texels) {
+ return nullptr;
+ }
+ return GrSurfaceProxy::MakeDeferred(this, desc, budgeted, nullptr, 0);
}
- if (mipLevelCount && !texels) {
+
+ if (this->isAbandoned()) {
return nullptr;
}
+
for (int i = 0; i < mipLevelCount; ++i) {
if (!texels[i].fPixels) {
return nullptr;
@@ -82,8 +87,8 @@ sk_sp<GrTextureProxy> GrResourceProvider::createMipMappedTexture(
sk_sp<GrTexture> tex(this->refScratchTexture(desc, flags));
if (tex) {
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(tex);
- if (!mipLevelCount ||
- fGpu->getContext()->contextPriv().writeSurfacePixels(
+
+ if (fGpu->getContext()->contextPriv().writeSurfacePixels(
proxy.get(), nullptr, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
nullptr, texels[0].fPixels, texels[0].fRowBytes)) {
if (SkBudgeted::kNo == budgeted) {
@@ -143,12 +148,13 @@ GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, ui
if (this->isAbandoned()) {
return nullptr;
}
+
// Currently we don't recycle compressed textures as scratch.
if (GrPixelConfigIsCompressed(desc.fConfig)) {
return nullptr;
- } else {
- return this->refScratchTexture(desc, flags);
}
+
+ return this->refScratchTexture(desc, flags);
}
GrTexture* GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
@@ -182,10 +188,6 @@ GrTexture* GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
scratchFlags);
if (resource) {
GrSurface* surface = static_cast<GrSurface*>(resource);
- GrRenderTarget* rt = surface->asRenderTarget();
- if (rt && fGpu->caps()->discardRenderTargetSupport()) {
- rt->discard();
- }
return surface->asTexture();
}
}