aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mock/GrMockCaps.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-07-06 10:51:32 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-06 15:25:35 +0000
commit993e7e25217df05d63c3354c817e8bd18ea3738b (patch)
treecd1e0979409546c96d5ebfa55e1f62f77c4dc352 /src/gpu/mock/GrMockCaps.h
parent0c26a9dbd0b6546731df63c01411cb2aaa5ba236 (diff)
Make mock GrContext unit testable.
Bug: skia: Change-Id: I959122f1f2c390832ab1033bcdbdd2ca6cfc0419 Reviewed-on: https://skia-review.googlesource.com/20699 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/mock/GrMockCaps.h')
-rw-r--r--src/gpu/mock/GrMockCaps.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
new file mode 100644
index 0000000000..7190ad7d61
--- /dev/null
+++ b/src/gpu/mock/GrMockCaps.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrMockCaps_DEFINED
+#define GrMockCaps_DEFINED
+
+#include "GrCaps.h"
+#include "mock/GrMockOptions.h"
+
+class GrMockCaps : public GrCaps {
+public:
+ GrMockCaps(const GrContextOptions& contextOptions, const GrMockOptions& options)
+ : INHERITED(contextOptions), fOptions(options) {
+ fBufferMapThreshold = SK_MaxS32;
+ fMaxTextureSize = options.fMaxTextureSize;
+ fMaxRenderTargetSize = SkTMin(options.fMaxRenderTargetSize, fMaxTextureSize);
+ fMaxVertexAttributes = options.fMaxVertexAttributes;
+ fShaderCaps.reset(new GrShaderCaps(contextOptions));
+ }
+ bool isConfigTexturable(GrPixelConfig config) const override {
+ return fOptions.fConfigOptions[config].fTexturable;
+ }
+ bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
+ return fOptions.fConfigOptions[config].fRenderable[withMSAA];
+ }
+ bool canConfigBeImageStorage(GrPixelConfig) const override { return false; }
+ bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
+ bool* rectsMustMatch, bool* disallowSubrect) const override {
+ return false;
+ }
+
+private:
+ GrMockOptions fOptions;
+ typedef GrCaps INHERITED;
+};
+
+#endif