* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrSurfaceProxyPriv_DEFINED
#define GrSurfaceProxyPriv_DEFINED
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/GrResourceProvider.h"
This class is purely a privileged window into GrSurfaceProxy. It should never have additional
data members or virtual methods. */
class GrSurfaceProxyPriv {
public:
int32_t getProxyRefCnt() const { return fProxy->getProxyRefCnt(); }
void computeScratchKey(GrScratchKey* key) const { return fProxy->computeScratchKey(key); }
sk_sp<GrSurface> createSurface(GrResourceProvider* resourceProvider) const {
return fProxy->createSurface(resourceProvider);
}
void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); }
bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }
void exactify(bool allocatedCaseOnly);
void setLazySize(int width, int height) { fProxy->setLazySize(width, height); }
bool doLazyInstantiation(GrResourceProvider*);
GrSurfaceProxy::LazyInstantiationType lazyInstantiationType() const {
return fProxy->fLazyInstantiationType;
}
bool isSafeToDeinstantiate() const {
return SkToBool(fProxy->fTarget) && SkToBool(fProxy->fLazyInstantiateCallback) &&
GrSurfaceProxy::LazyInstantiationType::kDeinstantiate == lazyInstantiationType();
}
static bool SK_WARN_UNUSED_RESULT AttachStencilIfNeeded(GrResourceProvider*, GrSurface*,
int minStencilSampleCount);
bool ignoredByResourceAllocator() const { return fProxy->ignoredByResourceAllocator(); }
void setIgnoredByResourceAllocator() { fProxy->setIgnoredByResourceAllocator(); }
private:
explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {}
GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&);
const GrSurfaceProxyPriv* operator&() const;
GrSurfaceProxyPriv* operator&();
GrSurfaceProxy* fProxy;
friend class GrSurfaceProxy;
};
inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); }
inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const {
return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));
}
#endif