From 993e7e25217df05d63c3354c817e8bd18ea3738b Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Thu, 6 Jul 2017 10:51:32 -0400 Subject: Make mock GrContext unit testable. Bug: skia: Change-Id: I959122f1f2c390832ab1033bcdbdd2ca6cfc0419 Reviewed-on: https://skia-review.googlesource.com/20699 Reviewed-by: Greg Daniel Commit-Queue: Brian Salomon --- src/gpu/mock/GrMockCaps.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/gpu/mock/GrMockCaps.h (limited to 'src/gpu/mock/GrMockCaps.h') 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 -- cgit v1.2.3