086679bc11
This reverts commit e53de48393
.
Reason for revert: Key size distribution has changed back.
Original change's description:
> increase Builder's prealloc size after colorspace change
>
> BUG=skia:
>
> Change-Id: I003dcbde7d987404ae823df6621e13664cf440a1
> Reviewed-on: https://skia-review.googlesource.com/9523
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reed@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: skia:
Change-Id: I506a1ec791e6d99df1836cbf3262747fbfa224a7
Reviewed-on: https://skia-review.googlesource.com/153008
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
146 lines
6.0 KiB
C++
146 lines
6.0 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 GrDeferredProxyUploader;
|
|
class GrProxyProvider;
|
|
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;
|
|
|
|
// If we are instantiated and have a target, return the mip state of that target. Otherwise
|
|
// returns the proxy's mip state from creation time. This is useful for lazy proxies which may
|
|
// claim to not need mips at creation time, but the instantiation happens to give us a mipped
|
|
// target. In that case we should use that for our benefit to avoid possible copies/mip
|
|
// generation later.
|
|
GrMipMapped mipMapped() const;
|
|
|
|
// Returns the GrMipMapped value of the proxy from creation time regardless of whether it has
|
|
// been instantiated or not.
|
|
GrMipMapped proxyMipMapped() const { return fMipMapped; }
|
|
|
|
GrTextureType textureType() const { return fTextureType; }
|
|
/** If true then the texture does not support MIP maps and only supports clamp wrap mode. */
|
|
bool hasRestrictedSampling() const { return GrTextureTypeHasRestrictedSampling(fTextureType); }
|
|
/**
|
|
* 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:
|
|
// DDL TODO: rm the GrSurfaceProxy friending
|
|
friend class GrSurfaceProxy; // for ctors
|
|
friend class GrProxyProvider; // for ctors
|
|
friend class GrTextureProxyPriv;
|
|
|
|
// Deferred version - when constructed with data the origin is always kTopLeft.
|
|
GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped, GrTextureType, SkBackingFit,
|
|
SkBudgeted, const void* srcData, size_t srcRowBytes, GrInternalSurfaceFlags);
|
|
|
|
// Deferred version - no data.
|
|
GrTextureProxy(const GrSurfaceDesc& srcDesc, GrSurfaceOrigin, GrMipMapped, GrTextureType,
|
|
SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
|
|
|
|
// Lazy-callback version
|
|
// There are two main use cases for lazily-instantiated proxies:
|
|
// basic knowledge - width, height, config, origin are known
|
|
// minimal knowledge - only config is known.
|
|
//
|
|
// The basic knowledge version is used for DDL where we know the type of proxy we are going to
|
|
// use, but we don't have access to the GPU yet to instantiate it.
|
|
//
|
|
// The minimal knowledge version is used for CCPR where we are generating an atlas but we do not
|
|
// know the final size until flush time.
|
|
GrTextureProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrSurfaceDesc& desc,
|
|
GrSurfaceOrigin, GrMipMapped, GrTextureType, SkBackingFit, SkBudgeted,
|
|
GrInternalSurfaceFlags);
|
|
|
|
// Wrapped version
|
|
GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
|
|
|
|
~GrTextureProxy() override;
|
|
|
|
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
|
|
|
|
private:
|
|
// WARNING: Be careful when adding or removing fields here. ASAN is likely to trigger warnings
|
|
// when instantiating GrTextureRenderTargetProxy. The std::function in GrSurfaceProxy makes
|
|
// each class in the diamond require 16 byte alignment. Clang appears to layout the fields for
|
|
// each class to achieve the necessary alignment. However, ASAN checks the alignment of 'this'
|
|
// in the constructors, and always looks for the full 16 byte alignment, even if the fields in
|
|
// that particular class don't require it. Changing the size of this object can move the start
|
|
// address of other types, leading to this problem.
|
|
|
|
GrMipMapped fMipMapped;
|
|
GrTextureType fTextureType;
|
|
|
|
GrUniqueKey fUniqueKey;
|
|
GrProxyProvider* fProxyProvider; // only set when fUniqueKey is valid
|
|
|
|
// Only used for proxies whose contents are being prepared on a worker thread. This object
|
|
// stores the texture data, allowing the proxy to remain uninstantiated until flush. At that
|
|
// point, the proxy is instantiated, and this data is used to perform an ASAP upload.
|
|
std::unique_ptr<GrDeferredProxyUploader> fDeferredUploader;
|
|
|
|
size_t onUninstantiatedGpuMemorySize() const override;
|
|
|
|
// Methods made available via GrTextureProxy::CacheAccess
|
|
void setUniqueKey(GrProxyProvider*, const GrUniqueKey&);
|
|
void clearUniqueKey();
|
|
|
|
SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)
|
|
|
|
// 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
|