Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 GrMockCaps_DEFINED |
| 9 | #define GrMockCaps_DEFINED |
| 10 | |
| 11 | #include "GrCaps.h" |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 12 | #include "mock/GrMockTypes.h" |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 13 | |
| 14 | class GrMockCaps : public GrCaps { |
| 15 | public: |
| 16 | GrMockCaps(const GrContextOptions& contextOptions, const GrMockOptions& options) |
| 17 | : INHERITED(contextOptions), fOptions(options) { |
Chris Dalton | fddb6c0 | 2017-11-04 15:22:22 -0600 | [diff] [blame] | 18 | fInstanceAttribSupport = options.fInstanceAttribSupport; |
| 19 | fMapBufferFlags = options.fMapBufferFlags; |
| 20 | fBufferMapThreshold = SK_MaxS32; // Overridable in GrContextOptions. |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 21 | fMaxTextureSize = options.fMaxTextureSize; |
| 22 | fMaxRenderTargetSize = SkTMin(options.fMaxRenderTargetSize, fMaxTextureSize); |
| 23 | fMaxVertexAttributes = options.fMaxVertexAttributes; |
Chris Dalton | fddb6c0 | 2017-11-04 15:22:22 -0600 | [diff] [blame] | 24 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 25 | fShaderCaps.reset(new GrShaderCaps(contextOptions)); |
Chris Dalton | fddb6c0 | 2017-11-04 15:22:22 -0600 | [diff] [blame] | 26 | fShaderCaps->fGeometryShaderSupport = options.fGeometryShaderSupport; |
| 27 | fShaderCaps->fTexelBufferSupport = options.fTexelBufferSupport; |
| 28 | fShaderCaps->fIntegerSupport = options.fIntegerSupport; |
| 29 | fShaderCaps->fFlatInterpolationSupport = options.fFlatInterpolationSupport; |
| 30 | fShaderCaps->fMaxVertexSamplers = options.fMaxVertexSamplers; |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 31 | fShaderCaps->fMaxFragmentSamplers = options.fMaxFragmentSamplers; |
Brian Salomon | 821ef18 | 2017-11-07 16:41:11 -0500 | [diff] [blame] | 32 | fShaderCaps->fShaderDerivativeSupport = options.fShaderDerivativeSupport; |
Chris Dalton | fddb6c0 | 2017-11-04 15:22:22 -0600 | [diff] [blame] | 33 | |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 34 | this->applyOptionsOverrides(contextOptions); |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 35 | } |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 36 | int getSampleCount(int /*requestCount*/, GrPixelConfig /*config*/) const override { |
| 37 | return 0; |
| 38 | } |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 39 | bool isConfigTexturable(GrPixelConfig config) const override { |
| 40 | return fOptions.fConfigOptions[config].fTexturable; |
| 41 | } |
| 42 | bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { |
| 43 | return fOptions.fConfigOptions[config].fRenderable[withMSAA]; |
| 44 | } |
Greg Daniel | bb76ace | 2017-09-29 15:58:22 -0400 | [diff] [blame] | 45 | bool isConfigCopyable(GrPixelConfig config) const override { |
| 46 | return false; |
| 47 | } |
| 48 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 49 | bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, |
| 50 | bool* rectsMustMatch, bool* disallowSubrect) const override { |
| 51 | return false; |
| 52 | } |
| 53 | |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame^] | 54 | bool validateBackendTexture(const GrBackendTexture& tex, SkColorType, |
| 55 | GrPixelConfig*) const override { |
| 56 | return SkToBool(tex.getMockTextureInfo()); |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 57 | } |
| 58 | |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame^] | 59 | bool validateBackendRenderTarget(const GrBackendRenderTarget& rt, SkColorType, |
| 60 | GrPixelConfig*) const override { |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | private: |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 65 | GrMockOptions fOptions; |
| 66 | typedef GrCaps INHERITED; |
| 67 | }; |
| 68 | |
| 69 | #endif |