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