aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
authorGreg Daniel <egdaniel@google.com>2018-11-16 15:43:41 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-11-19 18:51:07 +0000
commit4065d45d2de171a36de60a0d7b094166bfa1a782 (patch)
tree635a095ce5d1b059032fd1261ca6d744d5bb75b0 /src/image
parent6d9a51a75c52e5857e8c665f2ca8463bdb687cee (diff)
downloadskqp-4065d45d2de171a36de60a0d7b094166bfa1a782.tar.gz
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies.""
This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkImage_Gpu.cpp22
-rw-r--r--src/image/SkImage_GpuBase.cpp15
-rw-r--r--src/image/SkImage_GpuYUVA.cpp11
-rw-r--r--src/image/SkImage_Lazy.cpp7
-rw-r--r--src/image/SkSurface_Gpu.cpp5
5 files changed, 39 insertions, 21 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index b8aa1a5f3f..600ba39b5a 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -155,10 +155,13 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* ctx,
const int width = imageSize.width();
const int height = imageSize.height();
+ const GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
+ format, SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
if (!renderTargetContext) {
return nullptr;
@@ -312,13 +315,6 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, SkColorSpace* dstCo
///////////////////////////////////////////////////////////////////////////////////////////////////
-static GrTextureType TextureTypeFromBackendFormat(const GrBackendFormat& backendFormat) {
- if (const GrGLenum* target = backendFormat.getGLTarget()) {
- return GrGLTexture::TextureTypeFromTarget(*target);
- }
- return GrTextureType::k2D;
-}
-
sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
const GrBackendFormat& backendFormat,
int width,
@@ -363,9 +359,8 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
return nullptr;
}
- GrTextureType textureType = TextureTypeFromBackendFormat(backendFormat);
-
- if (mipMapped == GrMipMapped::kYes && GrTextureTypeHasRestrictedSampling(textureType)) {
+ if (mipMapped == GrMipMapped::kYes &&
+ GrTextureTypeHasRestrictedSampling(backendFormat.textureType())) {
// It is invalid to have a GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE and have mips as
// well.
return nullptr;
@@ -387,7 +382,7 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
return promiseHelper.getTexture(resourceProvider, config);
},
- desc, origin, mipMapped, textureType, GrInternalSurfaceFlags::kNone,
+ backendFormat, desc, origin, mipMapped, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo,
GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
@@ -537,7 +532,8 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseYUVATexture(GrContext* context,
return sk_ref_sp<GrTexture>(tmp->getTexture());
#endif
},
- desc, imageOrigin, GrMipMapped::kNo, GrTextureType::k2D,
+ yuvaFormats[yuvaIndices[SkYUVAIndex::kY_Index].fIndex],
+ desc, imageOrigin, GrMipMapped::kNo,
GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo,
GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 8360361314..4dfc483671 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -100,8 +100,13 @@ sk_sp<SkImage> SkImage_GpuBase::onMakeSubset(const SkIRect& subset) const {
desc.fHeight = subset.height();
desc.fConfig = proxy->config();
+ GrBackendFormat format = proxy->backendFormat().makeTexture2D();
+ if (!format.isValid()) {
+ return nullptr;
+ }
+
sk_sp<GrSurfaceContext> sContext(fContext->contextPriv().makeDeferredSurfaceContext(
- desc, proxy->origin(), GrMipMapped::kNo, SkBackingFit::kExact, fBudgeted));
+ format, desc, proxy->origin(), GrMipMapped::kNo, SkBackingFit::kExact, fBudgeted));
if (!sContext) {
return nullptr;
}
@@ -253,9 +258,15 @@ sk_sp<SkImage> SkImage_GpuBase::onMakeColorSpace(sk_sp<SkColorSpace> target) con
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef();
+ GrBackendFormat format = proxy->backendFormat().makeTexture2D();
+ if (!format.isValid()) {
+ return nullptr;
+ }
+
sk_sp<GrRenderTargetContext> renderTargetContext(
fContext->contextPriv().makeDeferredRenderTargetContextWithFallback(
- SkBackingFit::kExact, this->width(), this->height(), proxy->config(), nullptr));
+ format, SkBackingFit::kExact, this->width(), this->height(),
+ proxy->config(), nullptr));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index ab13835a2d..a1d06964d5 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -78,11 +78,14 @@ bool SkImage_GpuYUVA::setupMipmapsForPlanes() const {
sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef() const {
if (!fRGBProxy) {
+ const GrBackendFormat format =
+ fContext->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
fContext->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, this->width(), this->height(), kRGBA_8888_GrPixelConfig,
- fColorSpace, 1, GrMipMapped::kNo, fOrigin));
+ format, SkBackingFit::kExact, this->width(), this->height(),
+ kRGBA_8888_GrPixelConfig, fColorSpace, 1, GrMipMapped::kNo, fOrigin));
if (!renderTargetContext) {
return nullptr;
}
@@ -242,8 +245,8 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(GrContext* context,
desc.fConfig = params.fConfig;
desc.fSampleCnt = 1;
proxies[texIdx] = proxyProvider->createLazyProxy(
- std::move(lazyInstCallback), desc, imageOrigin, GrMipMapped::kNo,
- GrTextureType::k2D, GrInternalSurfaceFlags::kNone,
+ std::move(lazyInstCallback), yuvaFormats[texIdx], desc, imageOrigin,
+ GrMipMapped::kNo, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo,
GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
if (!proxies[texIdx]) {
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index bd219c6701..fef4bf418d 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -418,6 +418,11 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
// the texture we fall through here and have the CPU generate the mip maps for us.
if (!proxy && !willBeMipped && !ctx->contextPriv().disableGpuYUVConversion()) {
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo);
+
+ SkColorType colorType = fInfo.colorType();
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(colorType);
+
ScopedGenerator generator(fSharedGenerator);
Generator_GrYUVProvider provider(generator);
@@ -429,7 +434,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
// TODO: Update to create the mipped surface in the YUV generator and draw the base
// layer directly into the mipped surface.
- proxy = provider.refAsTextureProxy(ctx, desc, generatorColorSpace, thisColorSpace);
+ proxy = provider.refAsTextureProxy(ctx, format, desc, generatorColorSpace, thisColorSpace);
if (proxy) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount);
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 9c04ac2e8e..af0b564515 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -300,8 +300,11 @@ sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* context,
desc.fConfig = c.config();
desc.fSampleCnt = c.stencilCount();
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(c.colorType());
+
sk_sp<GrSurfaceContext> sc(
- context->contextPriv().makeDeferredSurfaceContext(desc, c.origin(),
+ context->contextPriv().makeDeferredSurfaceContext(format, desc, c.origin(),
GrMipMapped(c.isMipMapped()),
SkBackingFit::kExact, budgeted,
c.refColorSpace(),