aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrGpuResource.cpp11
-rw-r--r--src/gpu/GrTexturePriv.h10
-rw-r--r--src/gpu/gl/GrGLExternalTextureData.cpp30
-rw-r--r--src/gpu/gl/GrGLGpu.cpp7
-rw-r--r--src/gpu/gl/GrGLTexture.cpp23
-rw-r--r--src/gpu/gl/GrGLTexture.h1
-rw-r--r--src/gpu/vk/GrVkGpu.cpp1
-rw-r--r--src/gpu/vk/GrVkTexture.cpp16
-rw-r--r--src/gpu/vk/GrVkTexture.h1
-rw-r--r--src/gpu/vk/GrVkTextureRenderTarget.cpp1
-rw-r--r--src/image/SkImage.cpp16
-rw-r--r--src/image/SkImage_Gpu.cpp62
12 files changed, 5 insertions, 174 deletions
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index c7df6632b3..872bbbbb93 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -43,17 +43,6 @@ void GrGpuResource::registerWithCacheWrapped() {
get_resource_cache(fGpu)->resourceAccess().insertResource(this);
}
-void GrGpuResource::detachFromCache() {
- if (this->wasDestroyed()) {
- return;
- }
- if (fUniqueKey.isValid()) {
- this->removeUniqueKey();
- }
- this->removeScratchKey();
- this->makeUnbudgeted();
-}
-
GrGpuResource::~GrGpuResource() {
// The cache should have released or destroyed this resource.
SkASSERT(this->wasDestroyed());
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index cc0a05edfd..042061129d 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -8,7 +8,6 @@
#ifndef GrTexturePriv_DEFINED
#define GrTexturePriv_DEFINED
-#include "GrExternalTextureData.h"
#include "GrTexture.h"
/** Class that adds methods to GrTexture that are only intended for use internal to Skia.
@@ -68,15 +67,6 @@ public:
}
SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
- /**
- * Return the native bookkeeping data for this texture, and detach the backend object from
- * this GrTexture. It's lifetime will no longer be managed by Ganesh, and this GrTexture will
- * no longer refer to it. Leaves this GrTexture in an orphan state.
- */
- std::unique_ptr<GrExternalTextureData> detachBackendTexture() {
- return fTexture->detachBackendTexture();
- }
-
static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
private:
diff --git a/src/gpu/gl/GrGLExternalTextureData.cpp b/src/gpu/gl/GrGLExternalTextureData.cpp
deleted file mode 100644
index 1087830947..0000000000
--- a/src/gpu/gl/GrGLExternalTextureData.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrContext.h"
-#include "GrContextPriv.h"
-#include "GrGpu.h"
-#include "GrResourceProvider.h"
-#include "GrSemaphore.h"
-#include "gl/GrGLTypes.h"
-
-GrGLExternalTextureData::GrGLExternalTextureData(const GrGLTextureInfo& info,
- sk_sp<GrSemaphore> semaphore,
- GrContext* context)
- : fInfo(info)
- , fSemaphore(std::move(semaphore)) {
- SkASSERT(fSemaphore->unique());
- context->resourceProvider()->releaseOwnershipOfSemaphore(fSemaphore);
-}
-
-void GrGLExternalTextureData::attachToContext(GrContext* context) {
- context->resourceProvider()->takeOwnershipOfSemaphore(fSemaphore);
- // Ideally we don't want to get the Gpu off of the context here. However, eventually this
- // semaphore will live on a GrTexture object and the wait will be called from there. At that
- // point we can use the GrGpu already stored directly on the GrTexture.
- context->getGpu()->waitSemaphore(fSemaphore);
-}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 9b507a42a6..c3e0a0c75c 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -529,7 +529,6 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
// next line relies on GrBackendTextureFlags matching GrTexture's
bool renderTarget = SkToBool(flags & kRenderTarget_GrBackendTextureFlag);
- SkASSERT(!renderTarget || kAdoptAndCache_GrWrapOwnership != ownership); // Not supported
GrGLTexture::IDDesc idDesc;
idDesc.fInfo = *info;
@@ -586,11 +585,7 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
return GrGLTextureRenderTarget::MakeWrapped(this, surfDesc, idDesc, rtIDDesc);
}
- if (kAdoptAndCache_GrWrapOwnership == ownership) {
- return sk_sp<GrTexture>(new GrGLTexture(this, SkBudgeted::kYes, surfDesc, idDesc));
- } else {
- return GrGLTexture::MakeWrapped(this, surfDesc, idDesc);
- }
+ return GrGLTexture::MakeWrapped(this, surfDesc, idDesc);
}
sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index d722f38fd3..ccbd1a6dae 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -5,13 +5,11 @@
* found in the LICENSE file.
*/
-#include "GrContext.h"
#include "GrGLTexture.h"
#include "GrGLGpu.h"
#include "GrResourceProvider.h"
#include "GrSemaphore.h"
#include "GrShaderCaps.h"
-#include "SkMakeUnique.h"
#include "SkTraceMemoryDump.h"
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
@@ -117,27 +115,6 @@ GrBackendObject GrGLTexture::getTextureHandle() const {
return reinterpret_cast<GrBackendObject>(&fInfo);
}
-std::unique_ptr<GrExternalTextureData> GrGLTexture::detachBackendTexture() {
- SkASSERT(!this->hasPendingIO());
-
- // Set up a semaphore to be signaled once the data is ready, and flush GL
- sk_sp<GrSemaphore> semaphore = this->getContext()->resourceProvider()->makeSemaphore();
- this->getGpu()->insertSemaphore(semaphore, true);
-
- // Make a copy of our GL-specific information
- auto data = skstd::make_unique<GrGLExternalTextureData>(fInfo, std::move(semaphore),
- this->getContext());
-
- // Ensure the cache can't reach this texture anymore
- this->detachFromCache();
-
- // Detach from the GL object, so we don't use it (or try to delete it when we're freed)
- fInfo.fTarget = 0;
- fInfo.fID = 0;
-
- return std::move(data);
-}
-
void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
const SkString& dumpName) const {
SkString texture_id;
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 7ba8058fc8..74358914ec 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -81,7 +81,6 @@ protected:
void onRelease() override;
void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
const SkString& dumpName) const override;
- std::unique_ptr<GrExternalTextureData> detachBackendTexture() override;
private:
void invokeReleaseProc() {
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 9dd3688470..107e46ae40 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -851,7 +851,6 @@ sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
surfDesc.fConfig = backendTex.config();
surfDesc.fSampleCnt = SkTMin(sampleCnt, this->caps()->maxSampleCount());
bool renderTarget = SkToBool(flags & kRenderTarget_GrBackendTextureFlag);
- SkASSERT(!renderTarget || kAdoptAndCache_GrWrapOwnership != ownership); // Not supported
// In GL, Chrome assumes all textures are BottomLeft
// In VK, we don't have this restriction
surfDesc.fOrigin = resolve_origin(origin);
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index defbe139c5..4857db6f13 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -105,13 +105,9 @@ sk_sp<GrVkTexture> GrVkTexture::MakeWrappedTexture(GrVkGpu* gpu,
return nullptr;
}
- if (kAdoptAndCache_GrWrapOwnership == ownership) {
- return sk_sp<GrVkTexture>(new GrVkTexture(gpu, SkBudgeted::kYes, desc, *info, imageView));
- } else {
- GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership
- ? GrVkImage::kBorrowed_Wrapped : GrVkImage::kAdopted_Wrapped;
- return sk_sp<GrVkTexture>(new GrVkTexture(gpu, kWrapped, desc, *info, imageView, wrapped));
- }
+ GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership
+ ? GrVkImage::kBorrowed_Wrapped : GrVkImage::kAdopted_Wrapped;
+ return sk_sp<GrVkTexture>(new GrVkTexture(gpu, kWrapped, desc, *info, imageView, wrapped));
}
GrVkTexture::~GrVkTexture() {
@@ -156,12 +152,6 @@ GrBackendObject GrVkTexture::getTextureHandle() const {
return (GrBackendObject)&fInfo;
}
-std::unique_ptr<GrExternalTextureData> GrVkTexture::detachBackendTexture() {
- // Not supported on Vulkan yet
- // TODO: Add thread-safe memory pools, and implement this.
- return nullptr;
-}
-
GrVkGpu* GrVkTexture::getVkGpu() const {
SkASSERT(!this->wasDestroyed());
return static_cast<GrVkGpu*>(this->getGpu());
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index a866748ef2..febd7ad294 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -49,7 +49,6 @@ protected:
void onAbandon() override;
void onRelease() override;
- std::unique_ptr<GrExternalTextureData> detachBackendTexture() override;
private:
enum Wrapped { kWrapped };
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index 1d7d75683f..cfa63be8af 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -143,7 +143,6 @@ GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(GrVkGpu* gpu,
SkASSERT(info);
// Wrapped textures require both image and allocation (because they can be mapped)
SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc.fMemory);
- SkASSERT(kAdoptAndCache_GrWrapOwnership != ownership); // Not supported
GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership ? GrVkImage::kBorrowed_Wrapped
: GrVkImage::kAdopted_Wrapped;
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index efa16c97a5..3e525b399c 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -9,7 +9,6 @@
#include "SkBitmapCache.h"
#include "SkCanvas.h"
#include "SkColorSpace_Base.h"
-#include "SkCrossContextImageData.h"
#include "SkData.h"
#include "SkImageEncoder.h"
#include "SkImageFilter.h"
@@ -381,21 +380,6 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext*, SkColorSpace* dstColorSpace
return nullptr;
}
-std::unique_ptr<SkCrossContextImageData> SkCrossContextImageData::MakeFromEncoded(
- GrContext*, sk_sp<SkData> encoded, SkColorSpace* dstColorSpace) {
- sk_sp<SkImage> image = SkImage::MakeFromEncoded(std::move(encoded));
- if (!image) {
- return nullptr;
- }
- // TODO: Force decode to raster here?
- return std::unique_ptr<SkCrossContextImageData>(new SkCCIDImage(std::move(image)));
-}
-
-sk_sp<SkImage> SkImage::MakeFromCrossContextImageData(
- GrContext*, std::unique_ptr<SkCrossContextImageData> ccid) {
- return ccid->makeImage(nullptr);
-}
-
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
return sk_ref_sp(const_cast<SkImage*>(this));
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 9bb98fbf10..474054378f 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -27,7 +27,6 @@
#include "effects/GrNonlinearColorSpaceXformEffect.h"
#include "effects/GrYUVEffect.h"
#include "SkCanvas.h"
-#include "SkCrossContextImageData.h"
#include "SkBitmapCache.h"
#include "SkGr.h"
#include "SkImage_Gpu.h"
@@ -268,8 +267,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
tex->setRelease(releaseProc, releaseCtx);
}
- const SkBudgeted budgeted = (kAdoptAndCache_GrWrapOwnership == ownership)
- ? SkBudgeted::kYes : SkBudgeted::kNo;
+ const SkBudgeted budgeted = SkBudgeted::kNo;
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex)));
return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID,
at, std::move(proxy), std::move(colorSpace), budgeted);
@@ -502,64 +500,6 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromEncoded(GrContext* context, sk_sp<Sk
return SkImage::MakeFromGenerator(std::move(gen));
}
-std::unique_ptr<SkCrossContextImageData> SkCrossContextImageData::MakeFromEncoded(
- GrContext* context, sk_sp<SkData> encoded, SkColorSpace* dstColorSpace) {
- sk_sp<SkImage> codecImage = SkImage::MakeFromEncoded(std::move(encoded));
- if (!codecImage) {
- return nullptr;
- }
-
- // Some backends or drivers don't support (safely) moving resources between contexts
- if (!context->caps()->crossContextTextureSupport()) {
- return std::unique_ptr<SkCrossContextImageData>(
- new SkCCIDImage(std::move(codecImage)));
- }
-
- sk_sp<SkImage> textureImage = codecImage->makeTextureImage(context, dstColorSpace);
- if (!textureImage) {
- // TODO: Force decode to raster here? Do mip-mapping, like getDeferredTextureImageData?
- return std::unique_ptr<SkCrossContextImageData>(
- new SkCCIDImage(std::move(codecImage)));
- }
-
- // Crack open the gpu image, extract the backend data, stick it in the SkCCID
- GrTexture* texture = as_IB(textureImage)->peekTexture();
- SkASSERT(texture);
-
- context->contextPriv().prepareSurfaceForExternalIO(as_IB(textureImage)->peekProxy());
- auto textureData = texture->texturePriv().detachBackendTexture();
- SkASSERT(textureData);
-
- GrBackend backend = context->contextPriv().getBackend();
- GrBackendTexture backendTex = make_backend_texture_from_handle(backend,
- texture->width(),
- texture->height(),
- texture->config(),
- textureData->getBackendObject());
-
- SkImageInfo info = as_IB(textureImage)->onImageInfo();
- return std::unique_ptr<SkCrossContextImageData>(new SkCCIDBackendTexture(
- backendTex, texture->origin(), std::move(textureData),
- info.alphaType(), info.refColorSpace()));
-}
-
-sk_sp<SkImage> SkCCIDBackendTexture::makeImage(GrContext* context) {
- if (fTextureData) {
- fTextureData->attachToContext(context);
- }
-
- // This texture was created by Ganesh on another thread (see MakeFromEncoded, above).
- // Thus, we can import it back into our cache and treat it as our own (again).
- GrWrapOwnership ownership = kAdoptAndCache_GrWrapOwnership;
- return new_wrapped_texture_common(context, fBackendTex, fOrigin, fAlphaType,
- std::move(fColorSpace), ownership, nullptr, nullptr);
-}
-
-sk_sp<SkImage> SkImage::MakeFromCrossContextImageData(
- GrContext* context, std::unique_ptr<SkCrossContextImageData> ccid) {
- return ccid->makeImage(context);
-}
-
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
if (!this->isTextureBacked()) {
return sk_ref_sp(const_cast<SkImage*>(this));