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 #ifndef GrUtil_DEFINED
8 #define GrUtil_DEFINED
9
10 #include "include/core/SkScalar.h"
11 #include "include/core/SkTypes.h"
12 #include "include/private/gpu/ganesh/GrTypesPriv.h"
13 #include "src/core/SkSLTypeShared.h"
14
15 class GrStyle;
16 class SkMatrix;
17
18 enum GrIntelGpuFamily {
19 kUnknown_IntelGpuFamily,
20
21 // 6th gen
22 kSandyBridge_IntelGpuFamily,
23
24 // 7th gen
25 kIvyBridge_IntelGpuFamily,
26 kValleyView_IntelGpuFamily, // aka BayTrail
27 kHaswell_IntelGpuFamily,
28
29 // 8th gen
30 kCherryView_IntelGpuFamily, // aka Braswell
31 kBroadwell_IntelGpuFamily,
32
33 // 9th gen
34 kApolloLake_IntelGpuFamily,
35 kSkyLake_IntelGpuFamily,
36 kGeminiLake_IntelGpuFamily,
37 kKabyLake_IntelGpuFamily,
38 kCoffeeLake_IntelGpuFamily,
39
40 // 11th gen
41 kIceLake_IntelGpuFamily,
42 };
43
44 GrIntelGpuFamily GrGetIntelGpuFamily(uint32_t deviceID);
45
46 // Helper for determining if we can treat a thin stroke as a hairline w/ coverage.
47 // If we can, we draw lots faster (raster device does this same test).
48 bool GrIsStrokeHairlineOrEquivalent(const GrStyle&, const SkMatrix&, SkScalar* outCoverage);
49
SkSLCombinedSamplerTypeForTextureType(GrTextureType type)50 static inline SkSLType SkSLCombinedSamplerTypeForTextureType(GrTextureType type) {
51 switch (type) {
52 case GrTextureType::k2D:
53 return SkSLType::kTexture2DSampler;
54 case GrTextureType::kRectangle:
55 return SkSLType::kTexture2DRectSampler;
56 case GrTextureType::kExternal:
57 return SkSLType::kTextureExternalSampler;
58 default:
59 SK_ABORT("Unexpected texture type");
60 }
61 }
62
63 #endif
64