blob: edec5563c4052858e355980ae74eba80a8260117 [file] [log] [blame]
Brian Salomoncfe910d2017-07-06 16:40:18 -04001/*
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 Salomon8fe24272017-07-07 12:56:11 -040012#include "mock/GrMockTypes.h"
Brian Salomoncfe910d2017-07-06 16:40:18 -040013
14class GrMockCaps : public GrCaps {
15public:
16 GrMockCaps(const GrContextOptions& contextOptions, const GrMockOptions& options)
17 : INHERITED(contextOptions), fOptions(options) {
Chris Daltonfddb6c02017-11-04 15:22:22 -060018 fInstanceAttribSupport = options.fInstanceAttribSupport;
19 fMapBufferFlags = options.fMapBufferFlags;
20 fBufferMapThreshold = SK_MaxS32; // Overridable in GrContextOptions.
Brian Salomoncfe910d2017-07-06 16:40:18 -040021 fMaxTextureSize = options.fMaxTextureSize;
22 fMaxRenderTargetSize = SkTMin(options.fMaxRenderTargetSize, fMaxTextureSize);
23 fMaxVertexAttributes = options.fMaxVertexAttributes;
Chris Daltonfddb6c02017-11-04 15:22:22 -060024
Brian Salomoncfe910d2017-07-06 16:40:18 -040025 fShaderCaps.reset(new GrShaderCaps(contextOptions));
Chris Daltonfddb6c02017-11-04 15:22:22 -060026 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 Phillips7ffbcf92017-12-04 12:52:46 -050031 fShaderCaps->fMaxFragmentSamplers = options.fMaxFragmentSamplers;
Brian Salomon821ef182017-11-07 16:41:11 -050032 fShaderCaps->fShaderDerivativeSupport = options.fShaderDerivativeSupport;
Chris Daltonfddb6c02017-11-04 15:22:22 -060033
Brian Salomon8fe24272017-07-07 12:56:11 -040034 this->applyOptionsOverrides(contextOptions);
Brian Salomoncfe910d2017-07-06 16:40:18 -040035 }
Greg Daniel81e7bf82017-07-19 14:47:42 -040036 int getSampleCount(int /*requestCount*/, GrPixelConfig /*config*/) const override {
37 return 0;
38 }
Brian Salomoncfe910d2017-07-06 16:40:18 -040039 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 Danielbb76ace2017-09-29 15:58:22 -040045 bool isConfigCopyable(GrPixelConfig config) const override {
46 return false;
47 }
48
Brian Salomoncfe910d2017-07-06 16:40:18 -040049 bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
50 bool* rectsMustMatch, bool* disallowSubrect) const override {
51 return false;
52 }
53
Greg Danielfaa095e2017-12-19 13:15:02 -050054 bool validateBackendTexture(const GrBackendTexture& tex, SkColorType,
55 GrPixelConfig*) const override {
56 return SkToBool(tex.getMockTextureInfo());
Greg Danielf5d87582017-12-18 14:48:15 -050057 }
58
Greg Danielfaa095e2017-12-19 13:15:02 -050059 bool validateBackendRenderTarget(const GrBackendRenderTarget& rt, SkColorType,
60 GrPixelConfig*) const override {
61 return false;
62 }
63
64private:
Brian Salomoncfe910d2017-07-06 16:40:18 -040065 GrMockOptions fOptions;
66 typedef GrCaps INHERITED;
67};
68
69#endif