GrSurfaceProxyPriv.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2017 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrSurfaceProxyPriv_DEFINED
  8. #define GrSurfaceProxyPriv_DEFINED
  9. #include "src/gpu/GrSurfaceProxy.h"
  10. #include "src/gpu/GrResourceProvider.h"
  11. /** Class that adds methods to GrSurfaceProxy that are only intended for use internal to Skia.
  12. This class is purely a privileged window into GrSurfaceProxy. It should never have additional
  13. data members or virtual methods. */
  14. class GrSurfaceProxyPriv {
  15. public:
  16. int32_t getProxyRefCnt() const { return fProxy->getProxyRefCnt(); }
  17. void computeScratchKey(GrScratchKey* key) const { return fProxy->computeScratchKey(key); }
  18. // Create a GrSurface-derived class that meets the requirements (i.e, desc, renderability)
  19. // of the GrSurfaceProxy.
  20. sk_sp<GrSurface> createSurface(GrResourceProvider* resourceProvider) const {
  21. return fProxy->createSurface(resourceProvider);
  22. }
  23. // Assign this proxy the provided GrSurface as its backing surface
  24. void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); }
  25. // Don't abuse this call!!!!!!!
  26. bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }
  27. // Don't. Just don't.
  28. void exactify();
  29. void setLazySize(int width, int height) { fProxy->setLazySize(width, height); }
  30. bool doLazyInstantiation(GrResourceProvider*);
  31. GrSurfaceProxy::LazyInstantiationType lazyInstantiationType() const {
  32. return fProxy->fLazyInstantiationType;
  33. }
  34. bool isSafeToDeinstantiate() const {
  35. return SkToBool(fProxy->fTarget) && SkToBool(fProxy->fLazyInstantiateCallback) &&
  36. GrSurfaceProxy::LazyInstantiationType::kDeinstantiate == lazyInstantiationType();
  37. }
  38. static bool SK_WARN_UNUSED_RESULT AttachStencilIfNeeded(GrResourceProvider*, GrSurface*,
  39. int minStencilSampleCount);
  40. bool ignoredByResourceAllocator() const { return fProxy->ignoredByResourceAllocator(); }
  41. void setIgnoredByResourceAllocator() { fProxy->setIgnoredByResourceAllocator(); }
  42. private:
  43. explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
  44. GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl
  45. GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl
  46. // No taking addresses of this type.
  47. const GrSurfaceProxyPriv* operator&() const;
  48. GrSurfaceProxyPriv* operator&();
  49. GrSurfaceProxy* fProxy;
  50. friend class GrSurfaceProxy; // to construct/copy this type.
  51. };
  52. inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); }
  53. inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const {
  54. return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));
  55. }
  56. #endif