Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
ganesh
mock
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
8
#include "
src/gpu/ganesh/mock/GrMockCaps.h
"
9
10
#include "
include/private/base/SkDebug.h
"
11
#include "
src/base/SkMathPriv.h
"
12
#include "
src/gpu/ganesh/GrProgramDesc.h
"
13
#include "
src/gpu/ganesh/TestFormatColorTypeCombination.h
"
14
15
int
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
29
GrProgramDesc
GrMockCaps::makeDesc
(
GrRenderTarget
*
/* rt */
,
30
const
GrProgramInfo
& programInfo,
31
ProgramDescOverrideFlags
overrideFlags)
const
{
32
SkASSERT
(overrideFlags ==
ProgramDescOverrideFlags::kNone
);
33
GrProgramDesc
desc
;
34
GrProgramDesc::Build
(&
desc
, programInfo, *
this
);
35
return
desc
;
36
}
37
38
uint64_t
GrMockCaps::computeFormatKey
(
const
GrBackendFormat
&
format
)
const
{
39
#ifdef SK_DEBUG
40
SkTextureCompressionType
compression =
format
.asMockCompressionType();
41
SkASSERT
(compression ==
SkTextureCompressionType::kNone
);
42
#endif
43
auto
ct =
format
.asMockColorType();
44
return
(uint64_t)ct;
45
}
46
47
#if defined(GR_TEST_UTILS)
48
std::vector<GrTest::TestFormatColorTypeCombination> GrMockCaps::getTestingCombinations()
const
{
49
// TODO: need to add compressed formats to this list
50
std::vector<GrTest::TestFormatColorTypeCombination> combos = {
51
{
GrColorType::kAlpha_8
,
GrBackendFormat::MakeMock
(
GrColorType::kAlpha_8
,
52
SkTextureCompressionType::kNone
)},
53
{
GrColorType::kBGR_565
,
GrBackendFormat::MakeMock
(
GrColorType::kBGR_565
,
54
SkTextureCompressionType::kNone
)},
55
{
GrColorType::kRGB_565
,
GrBackendFormat::MakeMock
(
GrColorType::kRGB_565
,
56
SkTextureCompressionType::kNone
)},
57
{
GrColorType::kABGR_4444
,
GrBackendFormat::MakeMock
(
GrColorType::kABGR_4444
,
58
SkTextureCompressionType::kNone
)},
59
{
GrColorType::kRGBA_8888
,
GrBackendFormat::MakeMock
(
GrColorType::kRGBA_8888
,
60
SkTextureCompressionType::kNone
)},
61
{
GrColorType::kRGBA_8888_SRGB
,
GrBackendFormat::MakeMock
(
GrColorType::kRGBA_8888_SRGB
,
62
SkTextureCompressionType::kNone
)},
63
{
GrColorType::kRGB_888x
,
GrBackendFormat::MakeMock
(
GrColorType::kRGB_888x
,
64
SkTextureCompressionType::kNone
)},
65
{
GrColorType::kRG_88
,
GrBackendFormat::MakeMock
(
GrColorType::kRG_88
,
66
SkTextureCompressionType::kNone
)},
67
{
GrColorType::kBGRA_8888
,
GrBackendFormat::MakeMock
(
GrColorType::kBGRA_8888
,
68
SkTextureCompressionType::kNone
)},
69
{
GrColorType::kRGBA_1010102
,
GrBackendFormat::MakeMock
(
GrColorType::kRGBA_1010102
,
70
SkTextureCompressionType::kNone
)},
71
{
GrColorType::kBGRA_1010102
,
GrBackendFormat::MakeMock
(
GrColorType::kBGRA_1010102
,
72
SkTextureCompressionType::kNone
)},
73
{
GrColorType::kGray_8
,
GrBackendFormat::MakeMock
(
GrColorType::kGray_8
,
74
SkTextureCompressionType::kNone
)},
75
{
GrColorType::kAlpha_F16
,
GrBackendFormat::MakeMock
(
GrColorType::kAlpha_F16
,
76
SkTextureCompressionType::kNone
)},
77
{
GrColorType::kRGBA_F16
,
GrBackendFormat::MakeMock
(
GrColorType::kRGBA_F16
,
78
SkTextureCompressionType::kNone
)},
79
{
GrColorType::kRGBA_F16_Clamped
,
GrBackendFormat::MakeMock
(
GrColorType::kRGBA_F16_Clamped
,
80
SkTextureCompressionType::kNone
)},
81
{
GrColorType::kAlpha_16
,
GrBackendFormat::MakeMock
(
GrColorType::kAlpha_16
,
82
SkTextureCompressionType::kNone
)},
83
{
GrColorType::kRG_1616
,
GrBackendFormat::MakeMock
(
GrColorType::kRG_1616
,
84
SkTextureCompressionType::kNone
)},
85
{
GrColorType::kRGBA_16161616
,
GrBackendFormat::MakeMock
(
GrColorType::kRGBA_16161616
,
86
SkTextureCompressionType::kNone
)},
87
{
GrColorType::kRG_F16
,
GrBackendFormat::MakeMock
(
GrColorType::kRG_F16
,
88
SkTextureCompressionType::kNone
)},
89
// For these two compressed image formats the color type will effectively be RGB_888x
90
{
GrColorType::kRGB_888x
,
GrBackendFormat::MakeMock
(
GrColorType::kUnknown
,
91
SkTextureCompressionType::kETC2_RGB8_UNORM
)},
92
{
GrColorType::kRGB_888x
,
GrBackendFormat::MakeMock
(
GrColorType::kUnknown
,
93
SkTextureCompressionType::kBC1_RGB8_UNORM
)},
94
{
GrColorType::kRGBA_8888
,
GrBackendFormat::MakeMock
(
GrColorType::kUnknown
,
95
SkTextureCompressionType::kBC1_RGBA8_UNORM
)},
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
GrMockCaps.h
GrProgramDesc.h
GrColorType
GrColorType
Definition:
GrTypesPriv.h:540
GrColorType::kRGBA_8888
@ kRGBA_8888
GrColorType::kUnknown
@ kUnknown
GrColorType::kAlpha_8
@ kAlpha_8
GrColorType::kBGR_565
@ kBGR_565
GrColorType::kBGRA_1010102
@ kBGRA_1010102
GrColorType::kAlpha_16
@ kAlpha_16
GrColorType::kRGBA_F16_Clamped
@ kRGBA_F16_Clamped
GrColorType::kABGR_4444
@ kABGR_4444
GrColorType::kRGBA_8888_SRGB
@ kRGBA_8888_SRGB
GrColorType::kRGB_565
@ kRGB_565
GrColorType::kRG_F16
@ kRG_F16
GrColorType::kRGBA_1010102
@ kRGBA_1010102
GrColorType::kRGB_888x
@ kRGB_888x
GrColorType::kAlpha_F16
@ kAlpha_F16
GrColorType::kRGBA_16161616
@ kRGBA_16161616
GrColorType::kRGBA_F16
@ kRGBA_F16
GrColorType::kBGRA_8888
@ kBGRA_8888
GrColorType::kGray_8
@ kGray_8
GrColorType::kRG_88
@ kRG_88
GrColorType::kRG_1616
@ kRG_1616
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkDebug.h
SkMathPriv.h
GrNextPow2
static uint32_t GrNextPow2(uint32_t n)
Definition:
SkMathPriv.h:302
SkTextureCompressionType
SkTextureCompressionType
Definition:
SkTextureCompressionType.h:20
SkTextureCompressionType::kBC1_RGBA8_UNORM
@ kBC1_RGBA8_UNORM
SkTextureCompressionType::kNone
@ kNone
SkTextureCompressionType::kETC2_RGB8_UNORM
@ kETC2_RGB8_UNORM
SkTextureCompressionType::kBC1_RGB8_UNORM
@ kBC1_RGB8_UNORM
TestFormatColorTypeCombination.h
GrBackendFormat
Definition:
GrBackendSurface.h:44
GrBackendFormat::MakeMock
static GrBackendFormat MakeMock(GrColorType colorType, SkTextureCompressionType compression, bool isStencilFormat=false)
Definition:
GrBackendSurface.cpp:189
GrCaps::ProgramDescOverrideFlags
ProgramDescOverrideFlags
Definition:
GrCaps.h:511
GrCaps::ProgramDescOverrideFlags::kNone
@ kNone
GrMockCaps::computeFormatKey
uint64_t computeFormatKey(const GrBackendFormat &) const override
Definition:
GrMockCaps.cpp:38
GrMockCaps::makeDesc
GrProgramDesc makeDesc(GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
Definition:
GrMockCaps.cpp:29
GrMockCaps::getRenderTargetSampleCount
int getRenderTargetSampleCount(int requestCount, GrColorType) const
Definition:
GrMockCaps.cpp:15
GrProgramDesc
Definition:
GrProgramDesc.h:26
GrProgramDesc::Build
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
Definition:
GrProgramDesc.cpp:176
GrProgramInfo
Definition:
GrProgramInfo.h:17
GrRenderTarget
Definition:
GrRenderTarget.h:26
format
uint32_t uint32_t * format
Definition:
fl_texture_registrar_test.cc:41
max
static float max(float r, float g, float b)
Definition:
hsl.cpp:49
import_conformance_tests.desc
desc
Definition:
import_conformance_tests.py:63
GrMockOptions::ConfigOptions::fRenderability
Renderability fRenderability
Definition:
GrMockTypes.h:138
GrMockOptions::fConfigOptions
ConfigOptions fConfigOptions[kGrColorTypeCnt]
Definition:
GrMockTypes.h:151
GrTest::TestFormatColorTypeCombination
Definition:
TestFormatColorTypeCombination.h:14
Generated on Sun Jun 23 2024 21:56:22 for Flutter Engine by
1.9.4