Add support for SkImageGenerator creating external textures
Copy the SkImageGenerator texture if tiling is needed and
original texture target is GR_GL_TEXTURE_EXTERNAL.
Bug: skia:
Change-Id: I98f5acc3883e2060b1a35f80633b02b08a706107
Reviewed-on: https://skia-review.googlesource.com/18268
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Stan Iliev <stani@google.com>
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index 4fb0c0d..69e3a6e 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -26,10 +26,21 @@
*texColorSpace = this->getColorSpace(dstColorSpace);
}
- if (!fContext->getGpu()->isACopyNeededForTextureParams(this->width(), this->height(), params,
- ©Params, scaleAdjust)) {
- return this->refOriginalTextureProxy(willBeMipped, dstColorSpace);
+ sk_sp<GrTextureProxy> original(this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
+ AllowedTexGenType::kCheap));
+ if (original) {
+ if (!fContext->getGpu()->isACopyNeededForTextureParams(original.get(), params, ©Params,
+ scaleAdjust)) {
+ return original;
+ }
+ } else {
+ if (!fContext->getGpu()->isACopyNeededForTextureParams(this->width(), this->height(),
+ params, ©Params, scaleAdjust)) {
+ return this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
+ AllowedTexGenType::kAny);
+ }
}
+
GrUniqueKey copyKey;
this->makeCopyKey(copyParams, ©Key, dstColorSpace);
if (copyKey.isValid()) {
@@ -39,8 +50,13 @@
}
}
- sk_sp<GrTextureProxy> result(this->generateTextureProxyForParams(copyParams, willBeMipped,
- dstColorSpace));
+ sk_sp<GrTextureProxy> result;
+ if (original) {
+ result = CopyOnGpu(fContext, std::move(original), nullptr, copyParams);
+ } else {
+ result = this->generateTextureProxyForParams(copyParams, willBeMipped, dstColorSpace);
+ }
+
if (!result) {
return nullptr;
}
@@ -106,7 +122,8 @@
sk_sp<GrTextureProxy> GrTextureMaker::generateTextureProxyForParams(const CopyParams& copyParams,
bool willBeMipped,
SkColorSpace* dstColorSpace) {
- sk_sp<GrTextureProxy> original(this->refOriginalTextureProxy(willBeMipped, dstColorSpace));
+ sk_sp<GrTextureProxy> original(this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
+ AllowedTexGenType::kAny));
if (!original) {
return nullptr;
}