GrDawnRenderTarget.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "GrDawnRenderTarget.h"
  8. #include "include/gpu/GrBackendSurface.h"
  9. #include "src/gpu/dawn/GrDawnGpu.h"
  10. #include "src/gpu/dawn/GrDawnUtil.h"
  11. GrDawnRenderTarget::GrDawnRenderTarget(GrDawnGpu* gpu,
  12. const GrSurfaceDesc& desc,
  13. int sampleCnt,
  14. const GrDawnImageInfo& info,
  15. GrBackendObjectOwnership ownership)
  16. : GrSurface(gpu, desc, GrProtected::kNo)
  17. , GrRenderTarget(gpu, desc, sampleCnt, GrProtected::kNo)
  18. , fInfo(info) {
  19. this->registerWithCacheWrapped(GrWrapCacheable::kNo);
  20. }
  21. GrDawnRenderTarget*
  22. GrDawnRenderTarget::Create(GrDawnGpu* gpu,
  23. const GrSurfaceDesc& desc,
  24. int sampleCnt,
  25. const GrDawnImageInfo& info,
  26. GrBackendObjectOwnership ownership) {
  27. SkASSERT(1 == info.fLevelCount);
  28. return new GrDawnRenderTarget(gpu, desc, sampleCnt, info, ownership);
  29. }
  30. sk_sp<GrDawnRenderTarget>
  31. GrDawnRenderTarget::MakeWrapped(GrDawnGpu* gpu,
  32. const GrSurfaceDesc& desc,
  33. int sampleCnt,
  34. const GrDawnImageInfo& info) {
  35. return sk_sp<GrDawnRenderTarget>(
  36. GrDawnRenderTarget::Create(gpu, desc, sampleCnt, info,
  37. GrBackendObjectOwnership::kBorrowed));
  38. }
  39. bool GrDawnRenderTarget::completeStencilAttachment() {
  40. return true;
  41. }
  42. GrDawnRenderTarget::~GrDawnRenderTarget() {
  43. }
  44. void GrDawnRenderTarget::onRelease() {
  45. INHERITED::onRelease();
  46. }
  47. void GrDawnRenderTarget::onAbandon() {
  48. INHERITED::onAbandon();
  49. }
  50. GrBackendRenderTarget GrDawnRenderTarget::getBackendRenderTarget() const {
  51. return GrBackendRenderTarget(this->width(), this->height(), this->numSamples(),
  52. this->numSamples(), fInfo);
  53. }
  54. GrBackendFormat GrDawnRenderTarget::backendFormat() const {
  55. return GrBackendFormat::MakeDawn(fInfo.fFormat);
  56. }