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) { |
| 18 | fBufferMapThreshold = SK_MaxS32; |
| 19 | fMaxTextureSize = options.fMaxTextureSize; |
| 20 | fMaxRenderTargetSize = SkTMin(options.fMaxRenderTargetSize, fMaxTextureSize); |
| 21 | fMaxVertexAttributes = options.fMaxVertexAttributes; |
| 22 | fShaderCaps.reset(new GrShaderCaps(contextOptions)); |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 23 | this->applyOptionsOverrides(contextOptions); |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 24 | } |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 25 | int getSampleCount(int /*requestCount*/, GrPixelConfig /*config*/) const override { |
| 26 | return 0; |
| 27 | } |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 28 | bool isConfigTexturable(GrPixelConfig config) const override { |
| 29 | return fOptions.fConfigOptions[config].fTexturable; |
| 30 | } |
| 31 | bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { |
| 32 | return fOptions.fConfigOptions[config].fRenderable[withMSAA]; |
| 33 | } |
Greg Daniel | bb76ace | 2017-09-29 15:58:22 -0400 | [diff] [blame] | 34 | bool isConfigCopyable(GrPixelConfig config) const override { |
| 35 | return false; |
| 36 | } |
| 37 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 38 | bool canConfigBeImageStorage(GrPixelConfig) const override { return false; } |
| 39 | bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, |
| 40 | bool* rectsMustMatch, bool* disallowSubrect) const override { |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | private: |
| 45 | GrMockOptions fOptions; |
| 46 | typedef GrCaps INHERITED; |
| 47 | }; |
| 48 | |
| 49 | #endif |