• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
12 #include "mock/GrMockTypes.h"
13 
14 class GrMockCaps : public GrCaps {
15 public:
GrMockCaps(const GrContextOptions & contextOptions,const GrMockOptions & options)16     GrMockCaps(const GrContextOptions& contextOptions, const GrMockOptions& options)
17             : INHERITED(contextOptions), fOptions(options) {
18         fInstanceAttribSupport = options.fInstanceAttribSupport;
19         fMapBufferFlags = options.fMapBufferFlags;
20         fBufferMapThreshold = SK_MaxS32; // Overridable in GrContextOptions.
21         fMaxTextureSize = options.fMaxTextureSize;
22         fMaxRenderTargetSize = SkTMin(options.fMaxRenderTargetSize, fMaxTextureSize);
23         fMaxVertexAttributes = options.fMaxVertexAttributes;
24 
25         fShaderCaps.reset(new GrShaderCaps(contextOptions));
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;
31         fShaderCaps->fMaxFragmentSamplers = options.fMaxFragmentSamplers;
32         fShaderCaps->fShaderDerivativeSupport = options.fShaderDerivativeSupport;
33 
34         this->applyOptionsOverrides(contextOptions);
35     }
getSampleCount(int requestCount,GrPixelConfig)36     int getSampleCount(int requestCount, GrPixelConfig /*config*/) const override {
37         return (requestCount > 0 && requestCount <= 16) ? GrNextPow2(requestCount) : 0;
38     }
isConfigTexturable(GrPixelConfig config)39     bool isConfigTexturable(GrPixelConfig config) const override {
40         return fOptions.fConfigOptions[config].fTexturable;
41     }
isConfigRenderable(GrPixelConfig config,bool withMSAA)42     bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
43         return fOptions.fConfigOptions[config].fRenderable[withMSAA];
44     }
isConfigCopyable(GrPixelConfig config)45     bool isConfigCopyable(GrPixelConfig config) const override {
46         return false;
47     }
48 
initDescForDstCopy(const GrRenderTargetProxy * src,GrSurfaceDesc * desc,bool * rectsMustMatch,bool * disallowSubrect)49     bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
50                             bool* rectsMustMatch, bool* disallowSubrect) const override {
51         return false;
52     }
53 
validateBackendTexture(const GrBackendTexture & tex,SkColorType,GrPixelConfig *)54     bool validateBackendTexture(const GrBackendTexture& tex, SkColorType,
55                                 GrPixelConfig*) const override {
56         return SkToBool(tex.getMockTextureInfo());
57     }
58 
validateBackendRenderTarget(const GrBackendRenderTarget & rt,SkColorType,GrPixelConfig *)59     bool validateBackendRenderTarget(const GrBackendRenderTarget& rt, SkColorType,
60                                      GrPixelConfig*) const override {
61         return false;
62     }
63 
64 private:
65     GrMockOptions fOptions;
66     typedef GrCaps INHERITED;
67 };
68 
69 #endif
70