GrDawnCaps.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 GrDawnCaps_DEFINED
  8. #define GrDawnCaps_DEFINED
  9. #include "src/gpu/GrCaps.h"
  10. #include "include/gpu/GrContextOptions.h"
  11. #include "src/gpu/dawn/GrDawnUtil.h"
  12. #include "include/gpu/GrBackendSurface.h"
  13. class GrDawnCaps : public GrCaps {
  14. public:
  15. GrDawnCaps(const GrContextOptions& contextOptions);
  16. bool isFormatSRGB(const GrBackendFormat& format) const override;
  17. bool isFormatTexturable(GrColorType, const GrBackendFormat& format) const override;
  18. bool isFormatCopyable(GrColorType, const GrBackendFormat& format) const override;
  19. bool isConfigTexturable(GrPixelConfig config) const override;
  20. bool isConfigCopyable(GrPixelConfig config) const override {
  21. return true;
  22. }
  23. bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
  24. const SkIRect& srcRect, const SkIPoint& dstPoint) const override {
  25. return true;
  26. }
  27. GrPixelConfig validateBackendRenderTarget(const GrBackendRenderTarget&, GrColorType) const
  28. override {
  29. return GrPixelConfig::kUnknown_GrPixelConfig;
  30. }
  31. GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override;
  32. GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat&) const override;
  33. SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override {
  34. return SurfaceReadPixelsSupport::kSupported;
  35. }
  36. bool onSurfaceSupportsWritePixels(const GrSurface* surface) const override {
  37. return true;
  38. }
  39. int getRenderTargetSampleCount(int requestedCount, GrColorType,
  40. const GrBackendFormat&) const override;
  41. int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override {
  42. return this->isConfigTexturable(config) ? 1 : 0;
  43. }
  44. int maxRenderTargetSampleCount(GrColorType ct,
  45. const GrBackendFormat& format) const override {
  46. return this->maxRenderTargetSampleCount(this->getConfigFromBackendFormat(format, ct));
  47. }
  48. int maxRenderTargetSampleCount(GrPixelConfig config) const override {
  49. return this->isConfigTexturable(config) ? 1 : 0;
  50. }
  51. GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const override;
  52. GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override;
  53. bool canClearTextureOnCreation() const override;
  54. GrSwizzle getTextureSwizzle(const GrBackendFormat&, GrColorType) const override;
  55. GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const override;
  56. size_t onTransferFromOffsetAlignment(GrColorType bufferColorType) const override;
  57. bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
  58. typedef GrCaps INHERITED;
  59. };
  60. #endif