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 8 #ifndef GrDawnCaps_DEFINED 9 #define GrDawnCaps_DEFINED 10 11 #include "include/gpu/GrBackendSurface.h" 12 #include "include/gpu/GrContextOptions.h" 13 #include "src/gpu/GrCaps.h" 14 #include "src/gpu/dawn/GrDawnUtil.h" 15 16 class GrDawnCaps : public GrCaps { 17 public: 18 GrDawnCaps(const GrContextOptions& contextOptions); 19 20 bool isFormatSRGB(const GrBackendFormat&) const override; 21 bool isFormatCompressed(const GrBackendFormat&) const override; 22 23 bool isFormatTexturableAndUploadable(GrColorType, const GrBackendFormat& format) const override; 24 bool isFormatRenderable(const GrBackendFormat& format, 25 int sampleCount = 1) const override; 26 bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat& format, 27 int sampleCount = 1) const override; 28 29 isFormatCopyable(const GrBackendFormat & format)30 bool isFormatCopyable(const GrBackendFormat& format) const override { return true; } 31 32 bool isFormatTexturable(const GrBackendFormat& format) const override; 33 supportedWritePixelsColorType(GrColorType surfaceColorType,const GrBackendFormat & surfaceFormat,GrColorType srcColorType)34 SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, 35 const GrBackendFormat& surfaceFormat, 36 GrColorType srcColorType) const override { 37 return {surfaceColorType, GrColorTypeBytesPerPixel(surfaceColorType)}; 38 } 39 surfaceSupportsReadPixels(const GrSurface *)40 SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override { 41 return SurfaceReadPixelsSupport::kSupported; 42 } 43 44 int getRenderTargetSampleCount(int requestedCount, 45 const GrBackendFormat&) const override; 46 47 int maxRenderTargetSampleCount(const GrBackendFormat& format) const override; 48 49 GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override; 50 51 bool canClearTextureOnCreation() const override; 52 53 GrSwizzle getTextureSwizzle(const GrBackendFormat&, GrColorType) const override; 54 55 GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const override; 56 57 GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&, 58 bool isAlphaChannel) const override; 59 60 #if GR_TEST_UTILS 61 std::vector<TestFormatColorTypeCombination> getTestingCombinations() const override; 62 #endif 63 64 private: onSurfaceSupportsWritePixels(const GrSurface * surface)65 bool onSurfaceSupportsWritePixels(const GrSurface* surface) const override { 66 return true; 67 } onCanCopySurface(const GrSurfaceProxy * dst,const GrSurfaceProxy * src,const SkIRect & srcRect,const SkIPoint & dstPoint)68 bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src, 69 const SkIRect& srcRect, const SkIPoint& dstPoint) const override { 70 return true; 71 } 72 GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override; 73 74 GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override; 75 76 bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override; 77 onSupportedReadPixelsColorType(GrColorType srcColorType,const GrBackendFormat & backendFormat,GrColorType dstColorType)78 SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType, 79 const GrBackendFormat& backendFormat, 80 GrColorType dstColorType) const override { 81 return { GrColorType::kUnknown, 0 }; 82 } 83 84 typedef GrCaps INHERITED; 85 }; 86 87 #endif 88