Flutter Engine
The Flutter Engine
GrMockCaps.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google LLC
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
9
11#include "src/base/SkMathPriv.h"
14
15int GrMockCaps::getRenderTargetSampleCount(int requestCount, GrColorType ct) const {
16 requestCount = std::max(requestCount, 1);
17
18 switch (fOptions.fConfigOptions[(int)ct].fRenderability) {
19 case GrMockOptions::ConfigOptions::Renderability::kNo:
20 return 0;
21 case GrMockOptions::ConfigOptions::Renderability::kNonMSAA:
22 return requestCount > 1 ? 0 : 1;
23 case GrMockOptions::ConfigOptions::Renderability::kMSAA:
24 return requestCount > kMaxSampleCnt ? 0 : GrNextPow2(requestCount);
25 }
26 return 0;
27}
28
30 const GrProgramInfo& programInfo,
31 ProgramDescOverrideFlags overrideFlags) const {
34 GrProgramDesc::Build(&desc, programInfo, *this);
35 return desc;
36}
37
39#ifdef SK_DEBUG
40 SkTextureCompressionType compression = format.asMockCompressionType();
42#endif
43 auto ct = format.asMockColorType();
44 return (uint64_t)ct;
45}
46
47#if defined(GR_TEST_UTILS)
48std::vector<GrTest::TestFormatColorTypeCombination> GrMockCaps::getTestingCombinations() const {
49 // TODO: need to add compressed formats to this list
50 std::vector<GrTest::TestFormatColorTypeCombination> combos = {
89 // For these two compressed image formats the color type will effectively be RGB_888x
96 };
97
98#ifdef SK_DEBUG
99 for (const GrTest::TestFormatColorTypeCombination& combo : combos) {
100 SkASSERT(this->onAreColorTypeAndFormatCompatible(combo.fColorType, combo.fFormat));
101 }
102#endif
103
104 return combos;
105}
106
107#endif
GrColorType
Definition: GrTypesPriv.h:540
#define SkASSERT(cond)
Definition: SkAssert.h:116
static uint32_t GrNextPow2(uint32_t n)
Definition: SkMathPriv.h:302
SkTextureCompressionType
static GrBackendFormat MakeMock(GrColorType colorType, SkTextureCompressionType compression, bool isStencilFormat=false)
ProgramDescOverrideFlags
Definition: GrCaps.h:511
uint64_t computeFormatKey(const GrBackendFormat &) const override
Definition: GrMockCaps.cpp:38
GrProgramDesc makeDesc(GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
Definition: GrMockCaps.cpp:29
int getRenderTargetSampleCount(int requestCount, GrColorType) const
Definition: GrMockCaps.cpp:15
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
uint32_t uint32_t * format
static float max(float r, float g, float b)
Definition: hsl.cpp:49
ConfigOptions fConfigOptions[kGrColorTypeCnt]
Definition: GrMockTypes.h:151