Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
gpu
ganesh
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
8
#include "
src/gpu/ganesh/GrBackendUtils.h
"
9
10
#include "
include/core/SkTextureCompressionType.h
"
11
#include "
include/gpu/GrBackendSurface.h
"
12
#include "
include/gpu/GrTypes.h
"
13
#include "
include/private/base/SkAssert.h
"
// IWYU pragma: keep
14
#include "
include/private/gpu/ganesh/GrTypesPriv.h
"
15
#include "
src/gpu/DataUtils.h
"
16
#include "
src/gpu/ganesh/GrBackendSurfacePriv.h
"
17
18
#ifdef SK_DIRECT3D
19
#include "
src/gpu/ganesh/d3d/GrD3DUtil.h
"
20
#endif
21
22
SkTextureCompressionType
GrBackendFormatToCompressionType
(
const
GrBackendFormat
&
format
) {
23
switch
(
format
.backend()) {
24
case
GrBackendApi::kOpenGL
:
25
case
GrBackendApi::kVulkan
:
26
case
GrBackendApi::kMetal
:
27
return
GrBackendSurfacePriv::GetBackendData
(
format
)->
compressionType
();
28
case
GrBackendApi::kDirect3D
: {
29
#ifdef SK_DIRECT3D
30
DXGI_FORMAT dxgiFormat;
31
SkAssertResult
(
format
.asDxgiFormat(&dxgiFormat));
32
switch
(dxgiFormat) {
33
case
DXGI_FORMAT_BC1_UNORM:
34
return
SkTextureCompressionType::kBC1_RGBA8_UNORM
;
35
default
:
36
return
SkTextureCompressionType::kNone
;
37
}
38
#else
39
break
;
40
#endif
41
}
42
case
GrBackendApi::kMock
: {
43
return
format
.asMockCompressionType();
44
}
45
case
GrBackendApi::kUnsupported
: {
46
break
;
47
}
48
}
49
return
SkTextureCompressionType::kNone
;
50
}
51
52
size_t
GrBackendFormatBytesPerBlock
(
const
GrBackendFormat
&
format
) {
53
switch
(
format
.backend()) {
54
case
GrBackendApi::kOpenGL
:
55
case
GrBackendApi::kVulkan
:
56
case
GrBackendApi::kMetal
:
57
return
GrBackendSurfacePriv::GetBackendData
(
format
)->
bytesPerBlock
();
58
case
GrBackendApi::kDirect3D
: {
59
#ifdef SK_DIRECT3D
60
DXGI_FORMAT dxgiFormat;
61
SkAssertResult
(
format
.asDxgiFormat(&dxgiFormat));
62
return
GrDxgiFormatBytesPerBlock
(dxgiFormat);
63
#else
64
break
;
65
#endif
66
}
67
case
GrBackendApi::kMock
: {
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
}
77
case
GrBackendApi::kUnsupported
: {
78
break
;
79
}
80
}
81
return
0;
82
}
83
84
size_t
GrBackendFormatBytesPerPixel
(
const
GrBackendFormat
&
format
) {
85
if
(
GrBackendFormatToCompressionType
(
format
) !=
SkTextureCompressionType::kNone
) {
86
return
0;
87
}
88
return
GrBackendFormatBytesPerBlock
(
format
);
89
}
90
91
int
GrBackendFormatStencilBits
(
const
GrBackendFormat
&
format
) {
92
switch
(
format
.backend()) {
93
case
GrBackendApi::kOpenGL
:
94
case
GrBackendApi::kVulkan
:
95
case
GrBackendApi::kMetal
:
96
return
GrBackendSurfacePriv::GetBackendData
(
format
)->
stencilBits
();
97
case
GrBackendApi::kDirect3D
: {
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
}
113
case
GrBackendApi::kUnsupported
: {
114
break
;
115
}
116
}
117
return
0;
118
}
DataUtils.h
GrBackendSurfacePriv.h
GrBackendSurface.h
GrBackendFormatBytesPerPixel
size_t GrBackendFormatBytesPerPixel(const GrBackendFormat &format)
Definition
GrBackendUtils.cpp:84
GrBackendFormatToCompressionType
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
Definition
GrBackendUtils.cpp:22
GrBackendFormatStencilBits
int GrBackendFormatStencilBits(const GrBackendFormat &format)
Definition
GrBackendUtils.cpp:91
GrBackendFormatBytesPerBlock
size_t GrBackendFormatBytesPerBlock(const GrBackendFormat &format)
Definition
GrBackendUtils.cpp:52
GrBackendUtils.h
GrD3DUtil.h
GrDxgiFormatBytesPerBlock
static constexpr size_t GrDxgiFormatBytesPerBlock(DXGI_FORMAT format)
Definition
GrD3DUtil.h:101
GrDxgiFormatStencilBits
static constexpr int GrDxgiFormatStencilBits(DXGI_FORMAT format)
Definition
GrD3DUtil.h:125
GrTypesPriv.h
GrColorTypeBytesPerPixel
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
Definition
GrTypesPriv.h:895
GrTypes.h
GrBackendApi::kOpenGL
@ kOpenGL
GrBackendApi::kMetal
@ kMetal
GrBackendApi::kDirect3D
@ kDirect3D
GrBackendApi::kUnsupported
@ kUnsupported
GrBackendApi::kVulkan
@ kVulkan
GrBackendApi::kMock
@ kMock
SkAssert.h
SkAssertResult
#define SkAssertResult(cond)
Definition
SkAssert.h:123
SkTextureCompressionType.h
SkTextureCompressionType
SkTextureCompressionType
Definition
SkTextureCompressionType.h:20
SkTextureCompressionType::kBC1_RGBA8_UNORM
@ kBC1_RGBA8_UNORM
SkTextureCompressionType::kNone
@ kNone
GrBackendFormatData::compressionType
virtual SkTextureCompressionType compressionType() const =0
GrBackendFormatData::bytesPerBlock
virtual size_t bytesPerBlock() const =0
GrBackendFormatData::stencilBits
virtual int stencilBits() const =0
GrBackendFormat
Definition
GrBackendSurface.h:44
GrBackendSurfacePriv::GetBackendData
static const GrBackendFormatData * GetBackendData(const GrBackendFormat &format)
Definition
GrBackendSurfacePriv.h:114
format
uint32_t uint32_t * format
Definition
fl_texture_registrar_test.cc:41
skgpu::CompressedRowBytes
size_t CompressedRowBytes(SkTextureCompressionType type, int width)
Definition
DataUtils.cpp:179
Generated on Fri Apr 26 2024 06:17:02 for Flutter Engine by
1.9.8