skia2/include/private/GrTextureProxy.h
Brian Osman 837c6c7c0c Revert "Make threaded proxy generation MDB-friendly, and defer instantiation"
This reverts commit 742f3d02a1.

Reason for revert: Aaah!

Original change's description:
> Make threaded proxy generation MDB-friendly, and defer instantiation
> 
> Replaces GrPrepareCallback with GrDeferredProxyUploader, stored directly
> on GrTextureProxy. Op lists now store a list of referenced proxies that
> are being generated by worker threads. At flush time, iterate over those
> proxies, and invoke their uploader.
> 
> Lifetime of the uploader object is now tied to the proxy, but the ASAP
> upload function will free the proxy's uploader, if it's called.
> 
> Bug: skia:
> Change-Id: Ieb2c6a805d19990012839a8e103c3ca5b8d3dfc6
> Reviewed-on: https://skia-review.googlesource.com/49904
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=egdaniel@google.com,robertphillips@google.com,brianosman@google.com

Change-Id: I8f76a67044dc4159f903097d8b1ef19ffb48c730
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/52760
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-09-28 15:14:40 +00:00

106 lines
3.2 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrTextureProxy_DEFINED
#define GrTextureProxy_DEFINED
#include "GrSamplerState.h"
#include "GrSurfaceProxy.h"
class GrCaps;
class GrResourceCache;
class GrResourceProvider;
class GrTextureOpList;
class GrTextureProxyPriv;
// This class delays the acquisition of textures until they are actually required
class GrTextureProxy : virtual public GrSurfaceProxy {
public:
GrTextureProxy* asTextureProxy() override { return this; }
const GrTextureProxy* asTextureProxy() const override { return this; }
// Actually instantiate the backing texture, if necessary
bool instantiate(GrResourceProvider*) override;
GrSamplerState::Filter highestFilterMode() const;
GrSLType imageStorageType() const {
if (GrPixelConfigIsSint(this->config())) {
return kIImageStorage2D_GrSLType;
} else {
return kImageStorage2D_GrSLType;
}
}
bool isMipMapped() const { return fIsMipMapped; }
/**
* Return the texture proxy's unique key. It will be invalid if the proxy doesn't have one.
*/
const GrUniqueKey& getUniqueKey() const {
#ifdef SK_DEBUG
if (fTarget && fUniqueKey.isValid()) {
SkASSERT(fTarget->getUniqueKey().isValid());
// It is possible for a non-keyed proxy to have a uniquely keyed resource assigned to
// it. This just means that a future user of the resource will be filling it with unique
// data. However, if the proxy has a unique key its attached resource should also
// have that key.
SkASSERT(fUniqueKey == fTarget->getUniqueKey());
}
#endif
return fUniqueKey;
}
/**
* Internal-only helper class used for manipulations of the resource by the cache.
*/
class CacheAccess;
inline CacheAccess cacheAccess();
inline const CacheAccess cacheAccess() const;
// Provides access to special purpose functions.
GrTextureProxyPriv texPriv();
const GrTextureProxyPriv texPriv() const;
protected:
friend class GrSurfaceProxy; // for ctors
// Deferred version
GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
const void* srcData, size_t srcRowBytes, uint32_t flags);
// Wrapped version
GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
~GrTextureProxy() override;
SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; }
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
private:
bool fIsMipMapped;
SkDestinationSurfaceColorMode fMipColorMode;
GrUniqueKey fUniqueKey;
GrResourceCache* fCache; // only set when fUniqueKey is valid
size_t onUninstantiatedGpuMemorySize() const override;
// Methods made available via GrTextureProxy::CacheAccess
void setUniqueKey(GrResourceCache*, const GrUniqueKey&);
void clearUniqueKey();
// For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
// For deferred proxies that pointer will be filled in when we need to instantiate
// the deferred resource
typedef GrSurfaceProxy INHERITED;
};
#endif