Change PromiseImage API to take GrContextThreadSafeProxy
This detaches PromiseImages from any specific context, just to
a certain family.
Next up is to remove the tileSpecificSKP code from the DDLTileHelper.
Currently we have this janky PromiseImageDummy GrImageContext that
we make for each promise image. It's not ideal but it'll tide us over.
Bug: skia:10286
Change-Id: I12ab0bb7df9360a08af594da80de9df14cc2a44f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372516
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 8ec7265..8e4bc2a 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -20,6 +20,7 @@
#include "src/core/SkMipmap.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/GrCaps.h"
+#include "src/gpu/GrContextThreadSafeProxyPriv.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageContextPriv.h"
#include "src/gpu/GrRenderTarget.h"
@@ -666,6 +667,41 @@
std::move(rt), UseAllocator::kNo, GrRenderTargetProxy::WrapsVkSecondaryCB::kYes));
}
+sk_sp<GrTextureProxy> GrProxyProvider::CreatePromiseProxy(GrContextThreadSafeProxy* threadSafeProxy,
+ LazyInstantiateCallback&& callback,
+ const GrBackendFormat& format,
+ SkISize dimensions,
+ GrMipmapped mipMapped) {
+ if (threadSafeProxy->priv().abandoned()) {
+ return nullptr;
+ }
+ SkASSERT((dimensions.fWidth <= 0 && dimensions.fHeight <= 0) ||
+ (dimensions.fWidth > 0 && dimensions.fHeight > 0));
+
+ if (dimensions.fWidth > threadSafeProxy->priv().caps()->maxTextureSize() ||
+ dimensions.fHeight > threadSafeProxy->priv().caps()->maxTextureSize()) {
+ return nullptr;
+ }
+ // Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its
+ // mipmaps are fully fleshed out.
+ GrMipmapStatus mipmapStatus = (GrMipmapped::kYes == mipMapped) ? GrMipmapStatus::kValid
+ : GrMipmapStatus::kNotAllocated;
+
+ // We pass kReadOnly here since we should treat content of the client's texture as immutable.
+ // The promise API provides no way for the client to indicate that the texture is protected.
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(callback),
+ format,
+ dimensions,
+ mipMapped,
+ mipmapStatus,
+ SkBackingFit::kExact,
+ SkBudgeted::kNo,
+ GrProtected::kNo,
+ GrInternalSurfaceFlags::kReadOnly,
+ GrSurfaceProxy::UseAllocator::kYes,
+ GrDDLProvider::kYes));
+}
+
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
SkISize dimensions,