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/mock/GrMockCaps.h" |
9 | |
10 | #include "src/gpu/GrProgramDesc.h" |
11 | |
12 | GrProgramDesc GrMockCaps::makeDesc(GrRenderTarget* rt, const GrProgramInfo& programInfo) const { |
13 | GrProgramDesc desc; |
14 | SkDEBUGCODE(bool result =) GrProgramDesc::Build(&desc, rt, programInfo, *this); |
15 | SkASSERT(result == desc.isValid()); |
16 | return desc; |
17 | } |
18 | |
19 | uint64_t GrMockCaps::computeFormatKey(const GrBackendFormat& format) const { |
20 | #ifdef SK_DEBUG |
21 | SkImage::CompressionType compression = format.asMockCompressionType(); |
22 | SkASSERT(compression == SkImage::CompressionType::kNone); |
23 | #endif |
24 | auto ct = format.asMockColorType(); |
25 | return (uint64_t)ct; |
26 | } |
27 | |
28 | #if GR_TEST_UTILS |
29 | std::vector<GrCaps::TestFormatColorTypeCombination> GrMockCaps::getTestingCombinations() const { |
30 | // TODO: need to add compressed formats to this list |
31 | std::vector<GrCaps::TestFormatColorTypeCombination> combos = { |
32 | { GrColorType::kAlpha_8, GrBackendFormat::MakeMock(GrColorType::kAlpha_8, |
33 | SkImage::CompressionType::kNone)}, |
34 | { GrColorType::kBGR_565, GrBackendFormat::MakeMock(GrColorType::kBGR_565, |
35 | SkImage::CompressionType::kNone)}, |
36 | { GrColorType::kABGR_4444, GrBackendFormat::MakeMock(GrColorType::kABGR_4444, |
37 | SkImage::CompressionType::kNone)}, |
38 | { GrColorType::kRGBA_8888, GrBackendFormat::MakeMock(GrColorType::kRGBA_8888, |
39 | SkImage::CompressionType::kNone)}, |
40 | { GrColorType::kRGBA_8888_SRGB, GrBackendFormat::MakeMock(GrColorType::kRGBA_8888_SRGB, |
41 | SkImage::CompressionType::kNone)}, |
42 | { GrColorType::kRGB_888x, GrBackendFormat::MakeMock(GrColorType::kRGB_888x, |
43 | SkImage::CompressionType::kNone)}, |
44 | { GrColorType::kRG_88, GrBackendFormat::MakeMock(GrColorType::kRG_88, |
45 | SkImage::CompressionType::kNone)}, |
46 | { GrColorType::kBGRA_8888, GrBackendFormat::MakeMock(GrColorType::kBGRA_8888, |
47 | SkImage::CompressionType::kNone)}, |
48 | { GrColorType::kRGBA_1010102, GrBackendFormat::MakeMock(GrColorType::kRGBA_1010102, |
49 | SkImage::CompressionType::kNone)}, |
50 | { GrColorType::kBGRA_1010102, GrBackendFormat::MakeMock(GrColorType::kBGRA_1010102, |
51 | SkImage::CompressionType::kNone)}, |
52 | { GrColorType::kGray_8, GrBackendFormat::MakeMock(GrColorType::kGray_8, |
53 | SkImage::CompressionType::kNone)}, |
54 | { GrColorType::kAlpha_F16, GrBackendFormat::MakeMock(GrColorType::kAlpha_F16, |
55 | SkImage::CompressionType::kNone)}, |
56 | { GrColorType::kRGBA_F16, GrBackendFormat::MakeMock(GrColorType::kRGBA_F16, |
57 | SkImage::CompressionType::kNone)}, |
58 | { GrColorType::kRGBA_F16_Clamped,GrBackendFormat::MakeMock(GrColorType::kRGBA_F16_Clamped, |
59 | SkImage::CompressionType::kNone)}, |
60 | { GrColorType::kAlpha_16, GrBackendFormat::MakeMock(GrColorType::kAlpha_16, |
61 | SkImage::CompressionType::kNone)}, |
62 | { GrColorType::kRG_1616, GrBackendFormat::MakeMock(GrColorType::kRG_1616, |
63 | SkImage::CompressionType::kNone)}, |
64 | { GrColorType::kRGBA_16161616, GrBackendFormat::MakeMock(GrColorType::kRGBA_16161616, |
65 | SkImage::CompressionType::kNone)}, |
66 | { GrColorType::kRG_F16, GrBackendFormat::MakeMock(GrColorType::kRG_F16, |
67 | SkImage::CompressionType::kNone)}, |
68 | // For these two compressed image formats the color type will effectively be RGB_888x |
69 | { GrColorType::kRGB_888x, GrBackendFormat::MakeMock(GrColorType::kUnknown, |
70 | SkImage::CompressionType::kETC2_RGB8_UNORM)}, |
71 | { GrColorType::kRGB_888x, GrBackendFormat::MakeMock(GrColorType::kUnknown, |
72 | SkImage::CompressionType::kBC1_RGB8_UNORM)}, |
73 | { GrColorType::kRGBA_8888, GrBackendFormat::MakeMock(GrColorType::kUnknown, |
74 | SkImage::CompressionType::kBC1_RGBA8_UNORM)}, |
75 | }; |
76 | |
77 | #ifdef SK_DEBUG |
78 | for (const GrCaps::TestFormatColorTypeCombination& combo : combos) { |
79 | SkASSERT(this->onAreColorTypeAndFormatCompatible(combo.fColorType, combo.fFormat)); |
80 | } |
81 | #endif |
82 | |
83 | return combos; |
84 | } |
85 | |
86 | #endif |
87 | |