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 22 bool isFormatRenderable(const GrBackendFormat& format, 23 int sampleCount = 1) const override; 24 bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat& format, 25 int sampleCount = 1) const override; 26 27 isFormatCopyable(const GrBackendFormat & format)28 bool isFormatCopyable(const GrBackendFormat& format) const override { return true; } 29 30 bool isFormatTexturable(const GrBackendFormat& format) const override; 31 supportedWritePixelsColorType(GrColorType surfaceColorType,const GrBackendFormat & surfaceFormat,GrColorType srcColorType)32 SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, 33 const GrBackendFormat& surfaceFormat, 34 GrColorType srcColorType) const override { 35 return {surfaceColorType, GrColorTypeBytesPerPixel(surfaceColorType)}; 36 } 37 38 SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override; 39 40 int getRenderTargetSampleCount(int requestedCount, 41 const GrBackendFormat&) const override; 42 43 int maxRenderTargetSampleCount(const GrBackendFormat& format) const override; 44 45 GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override; 46 47 GrSwizzle getWriteSwizzle(const GrBackendFormat&, GrColorType) const override; 48 49 uint64_t computeFormatKey(const GrBackendFormat&) const override; 50 51 GrProgramDesc makeDesc(GrRenderTarget*, 52 const GrProgramInfo&, 53 ProgramDescOverrideFlags) const override; 54 55 #if GR_TEST_UTILS 56 std::vector<TestFormatColorTypeCombination> getTestingCombinations() const override; 57 #endif 58 59 private: 60 bool onSurfaceSupportsWritePixels(const GrSurface* surface) const override; onCanCopySurface(const GrSurfaceProxy * dst,const GrSurfaceProxy * src,const SkIRect & srcRect,const SkIPoint & dstPoint)61 bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src, 62 const SkIRect& srcRect, const SkIPoint& dstPoint) const override { 63 return true; 64 } 65 GrBackendFormat onGetDefaultBackendFormat(GrColorType) const override; 66 67 bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override; 68 onSupportedReadPixelsColorType(GrColorType srcColorType,const GrBackendFormat & backendFormat,GrColorType dstColorType)69 SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType, 70 const GrBackendFormat& backendFormat, 71 GrColorType dstColorType) const override { 72 return { srcColorType, GrColorTypeBytesPerPixel(srcColorType) }; 73 } 74 75 GrSwizzle onGetReadSwizzle(const GrBackendFormat&, GrColorType) const override; 76 77 using INHERITED = GrCaps; 78 }; 79 80 #endif 81