GrDawnRenderTarget.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2019 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 GrDawnRenderTarget_DEFINED
  8. #define GrDawnRenderTarget_DEFINED
  9. #include "include/gpu/dawn/GrDawnTypes.h"
  10. #include "include/gpu/GrRenderTarget.h"
  11. class GrDawnGpu;
  12. class GrDawnRenderTarget: public GrRenderTarget {
  13. public:
  14. static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*, const GrSurfaceDesc&, int sampleCnt,
  15. const GrDawnImageInfo&);
  16. ~GrDawnRenderTarget() override;
  17. // override of GrRenderTarget
  18. ResolveType getResolveType() const override {
  19. if (this->numSamples() > 1) {
  20. return kCanResolve_ResolveType;
  21. }
  22. return kAutoResolves_ResolveType;
  23. }
  24. bool canAttemptStencilAttachment() const override {
  25. return true;
  26. }
  27. GrBackendRenderTarget getBackendRenderTarget() const override;
  28. GrBackendFormat backendFormat() const override;
  29. protected:
  30. GrDawnRenderTarget(GrDawnGpu* gpu,
  31. const GrSurfaceDesc& desc,
  32. int sampleCnt,
  33. const GrDawnImageInfo& info,
  34. GrBackendObjectOwnership);
  35. GrDawnGpu* getDawnGpu() const;
  36. void onAbandon() override;
  37. void onRelease() override;
  38. void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {}
  39. // This accounts for the texture's memory and any MSAA renderbuffer's memory.
  40. size_t onGpuMemorySize() const override {
  41. // The plus 1 is to account for the resolve texture or if not using msaa the RT itself
  42. int numSamples = this->numSamples() + 1;
  43. return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
  44. numSamples, GrMipMapped::kNo);
  45. }
  46. static GrDawnRenderTarget* Create(GrDawnGpu*, const GrSurfaceDesc&, int sampleCnt,
  47. const GrDawnImageInfo&, GrBackendObjectOwnership);
  48. bool completeStencilAttachment() override;
  49. GrDawnImageInfo fInfo;
  50. typedef GrRenderTarget INHERITED;
  51. };
  52. #endif