aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceProvider.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-01-08 13:40:32 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-08 19:05:31 +0000
commit1afd4cdb0800e2e395b465da24eb71e0e834dafa (patch)
treed3353e7e4487a86d00002ab882f34ec24347000b /src/gpu/GrResourceProvider.cpp
parent5ec5d677b02c41a3c58609461cd8b62c2feaeddc (diff)
Add GrProxyProvider
This pulls all the proxy tracking & creation functionality out of the GrResourceCache and GrResourceProvider and consolidates it in the GrProxyProvider. Change-Id: I7256f7c544319a70c1bd93dd5a9ccbe5fa0a544f Reviewed-on: https://skia-review.googlesource.com/91501 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrResourceProvider.cpp')
-rw-r--r--src/gpu/GrResourceProvider.cpp49
1 files changed, 7 insertions, 42 deletions
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 7fef3508eb..0112b5c15c 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -20,7 +20,6 @@
#include "GrResourceKey.h"
#include "GrSemaphore.h"
#include "GrStencilAttachment.h"
-#include "GrSurfaceProxyPriv.h"
#include "GrTexturePriv.h"
#include "../private/GrSingleOwner.h"
#include "SkGr.h"
@@ -46,10 +45,6 @@ GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSin
fQuadIndexBufferKey = gQuadIndexBufferKey;
}
-bool GrResourceProvider::IsFunctionallyExact(GrSurfaceProxy* proxy) {
- return proxy->priv().isExact() || (SkIsPow2(proxy->width()) && SkIsPow2(proxy->height()));
-}
-
bool validate_desc(const GrSurfaceDesc& desc, const GrCaps& caps, int levelCount = 0) {
if (desc.fWidth <= 0 || desc.fHeight <= 0) {
return false;
@@ -115,9 +110,9 @@ static bool make_info(int w, int h, GrPixelConfig config, SkImageInfo* ii) {
return true;
}
-sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc& desc,
- SkBudgeted budgeted,
- const GrMipLevel& mipLevel) {
+sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
+ SkBudgeted budgeted,
+ const GrMipLevel& mipLevel) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
@@ -138,20 +133,20 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc
if (make_info(desc.fWidth, desc.fHeight, desc.fConfig, &srcInfo)) {
sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, 0);
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+ sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(tex, desc.fOrigin);
if (proxy) {
sk_sp<GrSurfaceContext> sContext =
context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), nullptr);
if (sContext) {
if (sContext->writePixels(srcInfo, mipLevel.fPixels, mipLevel.fRowBytes, 0, 0)) {
- return sContext->asTextureProxyRef();
+ SkASSERT(sContext->asTextureProxy()->priv().peekTexture() == tex.get());
+ return tex;
}
}
}
}
- sk_sp<GrTexture> tex(fGpu->createTexture(desc, budgeted, &mipLevel, 1));
- return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+ return fGpu->createTexture(desc, budgeted, &mipLevel, 1);
}
sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
@@ -276,42 +271,12 @@ void GrResourceProvider::assignUniqueKeyToResource(const GrUniqueKey& key,
resource->resourcePriv().setUniqueKey(key);
}
-void GrResourceProvider::removeUniqueKeyFromProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
- ASSERT_SINGLE_OWNER
- if (this->isAbandoned() || !proxy) {
- return;
- }
- fCache->processInvalidProxyUniqueKey(key, proxy, true);
-}
-
sk_sp<GrGpuResource> GrResourceProvider::findResourceByUniqueKey(const GrUniqueKey& key) {
ASSERT_SINGLE_OWNER
return this->isAbandoned() ? nullptr
: sk_sp<GrGpuResource>(fCache->findAndRefUniqueResource(key));
}
-void GrResourceProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
- ASSERT_SINGLE_OWNER
- SkASSERT(key.isValid());
- if (this->isAbandoned() || !proxy) {
- return;
- }
-
- fCache->assignUniqueKeyToProxy(key, proxy);
-}
-
-sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey& key,
- GrSurfaceOrigin origin) {
- ASSERT_SINGLE_OWNER
- return this->isAbandoned() ? nullptr : fCache->findProxyByUniqueKey(key, origin);
-}
-
-sk_sp<GrTextureProxy> GrResourceProvider::findOrCreateProxyByUniqueKey(const GrUniqueKey& key,
- GrSurfaceOrigin origin) {
- ASSERT_SINGLE_OWNER
- return this->isAbandoned() ? nullptr : fCache->findOrCreateProxyByUniqueKey(key, origin);
-}
-
sk_sp<const GrBuffer> GrResourceProvider::findOrMakeStaticBuffer(GrBufferType intendedType,
size_t size,
const void* data,