Flutter Engine
The Flutter Engine
GrBackendUtils.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 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
12#include "include/gpu/GrTypes.h"
13#include "include/private/base/SkAssert.h" // IWYU pragma: keep
15#include "src/gpu/DataUtils.h"
17
18#ifdef SK_DIRECT3D
20#endif
21
23 switch (format.backend()) {
29#ifdef SK_DIRECT3D
30 DXGI_FORMAT dxgiFormat;
31 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
32 switch (dxgiFormat) {
33 case DXGI_FORMAT_BC1_UNORM:
35 default:
37 }
38#else
39 break;
40#endif
41 }
43 return format.asMockCompressionType();
44 }
46 break;
47 }
48 }
50}
51
53 switch (format.backend()) {
59#ifdef SK_DIRECT3D
60 DXGI_FORMAT dxgiFormat;
61 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
62 return GrDxgiFormatBytesPerBlock(dxgiFormat);
63#else
64 break;
65#endif
66 }
68 SkTextureCompressionType compression = format.asMockCompressionType();
69 if (compression != SkTextureCompressionType::kNone) {
70 return skgpu::CompressedRowBytes(compression, 1);
71 } else if (format.isMockStencilFormat()) {
72 static constexpr int kMockStencilSize = 4;
73 return kMockStencilSize;
74 }
75 return GrColorTypeBytesPerPixel(format.asMockColorType());
76 }
78 break;
79 }
80 }
81 return 0;
82}
83
86 return 0;
87 }
89}
90
92 switch (format.backend()) {
98#ifdef SK_DIRECT3D
99 DXGI_FORMAT dxgiFormat;
100 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
101 return GrDxgiFormatStencilBits(dxgiFormat);
102#else
103 break;
104#endif
105 }
106 case GrBackendApi::kMock: {
107 if (format.isMockStencilFormat()) {
108 static constexpr int kMockStencilBits = 8;
109 return kMockStencilBits;
110 }
111 break;
112 }
114 break;
115 }
116 }
117 return 0;
118}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
size_t GrBackendFormatBytesPerPixel(const GrBackendFormat &format)
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
int GrBackendFormatStencilBits(const GrBackendFormat &format)
size_t GrBackendFormatBytesPerBlock(const GrBackendFormat &format)
static constexpr size_t GrDxgiFormatBytesPerBlock(DXGI_FORMAT format)
Definition: GrD3DUtil.h:103
static constexpr int GrDxgiFormatStencilBits(DXGI_FORMAT format)
Definition: GrD3DUtil.h:127
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
Definition: GrTypesPriv.h:896
SkTextureCompressionType
virtual SkTextureCompressionType compressionType() const =0
virtual size_t bytesPerBlock() const =0
virtual int stencilBits() const =0
static const GrBackendFormatData * GetBackendData(const GrBackendFormat &format)
uint32_t uint32_t * format
size_t CompressedRowBytes(SkTextureCompressionType type, int width)
Definition: DataUtils.cpp:179