GrTextureContext.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2016 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 GrTextureContext_DEFINED
  8. #define GrTextureContext_DEFINED
  9. #include "src/gpu/GrSurfaceContext.h"
  10. #include "src/gpu/GrTextureProxy.h"
  11. class GrContext;
  12. class GrDrawingManager;
  13. class GrSurface;
  14. class GrTextureOpList;
  15. class GrTextureProxy;
  16. struct SkIPoint;
  17. struct SkIRect;
  18. /**
  19. * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
  20. * GrTextures and not GrRenderTargets.
  21. */
  22. class SK_API GrTextureContext : public GrSurfaceContext {
  23. public:
  24. ~GrTextureContext() override;
  25. GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
  26. const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
  27. sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }
  28. GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
  29. const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
  30. sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
  31. GrRenderTargetProxy* asRenderTargetProxy() override;
  32. sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
  33. protected:
  34. GrTextureContext(GrRecordingContext*,
  35. sk_sp<GrTextureProxy>,
  36. GrColorType,
  37. SkAlphaType,
  38. sk_sp<SkColorSpace>);
  39. SkDEBUGCODE(void validate() const override;)
  40. private:
  41. friend class GrDrawingManager; // for ctor
  42. GrOpList* getOpList() override;
  43. sk_sp<GrTextureProxy> fTextureProxy;
  44. // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
  45. // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
  46. sk_sp<GrTextureOpList> fOpList;
  47. typedef GrSurfaceContext INHERITED;
  48. };
  49. #endif