8 #ifndef GrBackendSurface_DEFINED
9 #define GrBackendSurface_DEFINED
15 #include "include/private/base/SkAPI.h"
16 #include "include/private/base/SkAnySubclass.h"
17 #include "include/private/gpu/ganesh/GrTypesPriv.h"
19 #include "include/gpu/mock/GrMockTypes.h"
22 class GrBackendFormatData;
23 class GrBackendTextureData;
24 class GrBackendRenderTargetData;
27 class MutableTextureState;
28 class MutableTextureStateRef;
32 #include "include/gpu/mtl/GrMtlTypes.h"
36 #include "include/private/gpu/ganesh/GrD3DTypesMinimal.h"
37 class GrD3DResourceState;
40 #if defined(SK_DEBUG) || defined(GR_TEST_UTILS)
47 #include <string_view>
71 bool isStencilFormat =
false);
85 GrColorFormatDesc
desc()
const;
92 GrMTLPixelFormat asMtlFormat()
const;
100 bool asDxgiFormat(DXGI_FORMAT*)
const;
120 #if defined(SK_DEBUG) || defined(GR_TEST_UTILS)
127 inline constexpr
static size_t kMaxSubclassSize = 64;
128 using AnyFormatData = SkAnySubclass<GrBackendFormatData, kMaxSubclassSize>;
130 friend class GrBackendSurfacePriv;
131 friend class GrBackendFormatData;
135 template <
typename FormatData>
137 : fBackend(api), fValid(true), fTextureType(textureType) {
138 fFormatData.emplace<FormatData>(formatData);
152 bool validateMock()
const;
157 AnyFormatData fFormatData;
161 GrMTLPixelFormat fMtlFormat;
165 DXGI_FORMAT fDxgiFormat;
173 GrTextureType fTextureType = GrTextureType::kNone;
185 const GrMtlTextureInfo& mtlInfo,
186 std::string_view label = {});
192 const GrD3DTextureResourceInfo& d3dInfo,
193 std::string_view label = {});
199 const GrMockTextureInfo& mockInfo,
200 std::string_view label = {});
209 int width()
const {
return fWidth; }
211 std::string_view
getLabel()
const {
return fLabel; }
222 bool getMtlTextureInfo(GrMtlTextureInfo*)
const;
229 bool getD3DTextureResourceInfo(GrD3DTextureResourceInfo*)
const;
233 void setD3DResourceState(GrD3DResourceStateEnum);
259 #if defined(GR_TEST_UTILS)
266 inline constexpr
static size_t kMaxSubclassSize = 160;
267 using AnyTextureData = SkAnySubclass<GrBackendTextureData, kMaxSubclassSize>;
269 friend class GrBackendSurfacePriv;
270 friend class GrBackendTextureData;
274 template <
typename TextureData>
277 std::string_view label,
280 GrTextureType texture,
281 const TextureData& textureData)
288 , fTextureType(texture) {
289 fTextureData.emplace<TextureData>(textureData);
292 friend class GrVkGpu;
296 friend class GrD3DTexture;
297 friend class GrD3DGpu;
300 const GrD3DTextureResourceInfo& vkInfo,
302 std::string_view label = {});
312 const std::string fLabel;
315 GrTextureType fTextureType;
316 AnyTextureData fTextureData;
321 GrD3DBackendSurfaceInfo fD3DInfo;
325 GrMtlTextureInfo fMtlInfo;
337 const GrMtlTextureInfo& mtlInfo);
343 const GrD3DTextureResourceInfo& d3dInfo);
350 const GrMockRenderTargetInfo& mockInfo);
358 int width()
const {
return fWidth; }
368 bool getMtlTextureInfo(GrMtlTextureInfo*)
const;
374 bool getD3DTextureResourceInfo(GrD3DTextureResourceInfo*)
const;
378 void setD3DResourceState(GrD3DResourceStateEnum);
401 #if defined(GR_TEST_UTILS)
409 inline constexpr
static size_t kMaxSubclassSize = 160;
410 using AnyRenderTargetData = SkAnySubclass<GrBackendRenderTargetData, kMaxSubclassSize>;
412 friend class GrBackendSurfacePriv;
413 friend class GrBackendRenderTargetData;
417 template <
typename RenderTargetData>
423 bool framebufferOnly,
424 const RenderTargetData& rtData)
426 , fFramebufferOnly(framebufferOnly)
429 , fSampleCnt(sampleCnt)
430 , fStencilBits(stencilBits)
431 , fBackend(backend) {
432 fRTData.emplace<RenderTargetData>(rtData);
435 friend class GrVkGpu;
439 friend class GrD3DGpu;
440 friend class GrD3DRenderTarget;
443 const GrD3DTextureResourceInfo& d3dInfo,
452 bool fFramebufferOnly =
false;
460 AnyRenderTargetData fRTData;
465 GrD3DBackendSurfaceInfo fD3DInfo;
469 GrMtlTextureInfo fMtlInfo;
GrBackendApi
Possible 3D APIs that may be used by Ganesh.
Definition: GrTypes.h:96
@ kMock
Mock is a backend that does not draw anything.
SkTextureCompressionType
Definition: SkTextureCompressionType.h:20
Definition: GrBackendSurface.h:329
void setMutableState(const skgpu::MutableTextureState &)
bool isFramebufferOnly() const
Definition: GrBackendSurface.h:363
GrBackendRenderTarget(const GrBackendRenderTarget &that)
GrBackendRenderTarget(int width, int height, int sampleCnt, int stencilBits, const GrMockRenderTargetInfo &mockInfo)
bool getMockRenderTargetInfo(GrMockRenderTargetInfo *) const
int width() const
Definition: GrBackendSurface.h:358
int stencilBits() const
Definition: GrBackendSurface.h:361
GrMockRenderTargetInfo fMockInfo
Definition: GrBackendSurface.h:463
GrBackendFormat getBackendFormat() const
int sampleCnt() const
Definition: GrBackendSurface.h:360
GrBackendRenderTarget & operator=(const GrBackendRenderTarget &)
GrBackendApi backend() const
Definition: GrBackendSurface.h:362
int height() const
Definition: GrBackendSurface.h:359
bool isValid() const
Definition: GrBackendSurface.h:399
SkISize dimensions() const
Definition: GrBackendSurface.h:357
Definition: GrBackendSurface.h:176
SkISize dimensions() const
Definition: GrBackendSurface.h:208
GrBackendTexture(int width, int height, skgpu::Mipmapped, const GrMockTextureInfo &mockInfo, std::string_view label={})
GrBackendFormat getBackendFormat() const
bool isSameTexture(const GrBackendTexture &)
skgpu::Mipmapped mipmapped() const
Definition: GrBackendSurface.h:212
GrBackendTexture(const GrBackendTexture &that)
bool hasMipmaps() const
Definition: GrBackendSurface.h:213
std::string_view getLabel() const
Definition: GrBackendSurface.h:211
GrBackendTexture & operator=(const GrBackendTexture &that)
bool getMockTextureInfo(GrMockTextureInfo *) const
bool isValid() const
Definition: GrBackendSurface.h:254
GrTextureType textureType() const
Definition: GrBackendSurface.h:217
GrMockTextureInfo fMockInfo
Definition: GrBackendSurface.h:319
void setMutableState(const skgpu::MutableTextureState &)
bool hasMipMaps() const
deprecated alias of hasMipmaps().
Definition: GrBackendSurface.h:215
GrBackendApi backend() const
Definition: GrBackendSurface.h:216
int height() const
Definition: GrBackendSurface.h:210
int width() const
Definition: GrBackendSurface.h:209
Light weight class for managing strings.
Definition: SkString.h:118
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:220
Since Skia and clients can both modify gpu textures and their connected state, Skia needs a way for c...
Definition: MutableTextureState.h:37
This file includes numerous public types that are used by all of our gpu backends.
Definition: SkCanvas.h:73
Mipmapped
Is the texture mipmapped or not.
Definition: GpuTypes.h:53