Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GrBackendSurfacePriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 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#ifndef GrBackendSurfacePriv_DEFINED
9#define GrBackendSurfacePriv_DEFINED
10
13#include "include/gpu/MutableTextureState.h" // IWYU pragma: keep
17
18#include <cstddef>
19#include <cstdint>
20#include <string>
21#include <string_view>
22
23enum class GrBackendApi : unsigned int;
25
26namespace skgpu {
27enum class Mipmapped : bool;
28}
29
31public:
32 virtual ~GrBackendFormatData();
34 virtual size_t bytesPerBlock() const = 0;
35 virtual int stencilBits() const = 0;
36 virtual bool equal(const GrBackendFormatData* that) const = 0;
37#if defined(SK_DEBUG)
38 virtual GrBackendApi type() const = 0;
39#endif
40protected:
43
45
46private:
47 friend class GrBackendFormat;
48 virtual uint32_t channelMask() const = 0;
49 virtual GrColorFormatDesc desc() const = 0;
50 virtual std::string toString() const = 0;
51 virtual void copyTo(AnyFormatData&) const = 0;
52
53 // Vulkan-only API:
54 virtual void makeTexture2D() {}
55};
56
58public:
59 virtual ~GrBackendTextureData();
60#if defined(SK_DEBUG)
61 virtual GrBackendApi type() const = 0;
62#endif
63protected:
66
68
69private:
70 friend class GrBackendTexture;
71 virtual bool isProtected() const = 0;
72 virtual bool equal(const GrBackendTextureData* that) const = 0;
73 virtual bool isSameTexture(const GrBackendTextureData*) const = 0;
74 virtual GrBackendFormat getBackendFormat() const = 0;
75 virtual void copyTo(AnyTextureData&) const = 0;
76
77 // Vulkan-only API:
78 virtual sk_sp<skgpu::MutableTextureState> getMutableState() const { return nullptr; }
80};
81
83public:
85#if defined(SK_DEBUG)
86 virtual GrBackendApi type() const = 0;
87#endif
88protected:
91
93
94private:
96 virtual GrBackendFormat getBackendFormat() const = 0;
97 virtual bool isProtected() const = 0;
98 virtual bool equal(const GrBackendRenderTargetData* that) const = 0;
99 virtual void copyTo(AnyRenderTargetData&) const = 0;
100
101 // Vulkan-only API:
102 virtual sk_sp<skgpu::MutableTextureState> getMutableState() const { return nullptr; }
104};
105
107public:
108 template <typename FormatData>
110 GrBackendApi api,
111 const FormatData& data) {
112 return GrBackendFormat(textureType, api, data);
113 }
114
116 return format.fFormatData.get();
117 }
118
119 template <typename TextureData>
121 int height,
122 std::string_view label,
123 skgpu::Mipmapped mipped,
126 const TextureData& data) {
127 return GrBackendTexture(width, height, label, mipped, backend, texture, data);
128 }
129
131 return tex.fTextureData.get();
132 }
133
135 SkASSERT(tex);
136 return tex->fTextureData.get();
137 }
138
139 template <typename RenderTargetData>
141 int height,
142 int sampleCnt,
143 int stencilBits,
145 bool framebufferOnly,
146 const RenderTargetData& data) {
148 width, height, sampleCnt, stencilBits, backend, framebufferOnly, data);
149 }
150
152 return rt.fRTData.get();
153 }
154
156 return rt->fRTData.get();
157 }
158};
159
160#endif
const char * backend
GrTextureType
Definition: GrTypesPriv.h:268
GrBackendApi
Definition: GrTypes.h:95
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkTextureCompressionType
GLenum type
virtual void makeTexture2D()
GrBackendFormatData()=default
virtual SkTextureCompressionType compressionType() const =0
virtual GrColorFormatDesc desc() const =0
virtual void copyTo(AnyFormatData &) const =0
virtual std::string toString() const =0
GrBackendFormatData(const GrBackendFormatData &)=default
virtual bool equal(const GrBackendFormatData *that) const =0
virtual uint32_t channelMask() const =0
virtual size_t bytesPerBlock() const =0
virtual int stencilBits() const =0
virtual void setMutableState(const skgpu::MutableTextureState &)
GrBackendRenderTargetData()=default
GrBackendRenderTargetData(const GrBackendRenderTargetData &)=default
virtual void copyTo(AnyRenderTargetData &) const =0
virtual bool isProtected() const =0
virtual sk_sp< skgpu::MutableTextureState > getMutableState() const
virtual GrBackendFormat getBackendFormat() const =0
virtual bool equal(const GrBackendRenderTargetData *that) const =0
static GrBackendRenderTarget MakeGrBackendRenderTarget(int width, int height, int sampleCnt, int stencilBits, GrBackendApi backend, bool framebufferOnly, const RenderTargetData &data)
static GrBackendRenderTargetData * GetBackendData(GrBackendRenderTarget *rt)
static const GrBackendTextureData * GetBackendData(const GrBackendTexture &tex)
static GrBackendTextureData * GetBackendData(GrBackendTexture *tex)
static GrBackendTexture MakeGrBackendTexture(int width, int height, std::string_view label, skgpu::Mipmapped mipped, GrBackendApi backend, GrTextureType texture, const TextureData &data)
static GrBackendFormat MakeGrBackendFormat(GrTextureType textureType, GrBackendApi api, const FormatData &data)
static const GrBackendRenderTargetData * GetBackendData(const GrBackendRenderTarget &rt)
static const GrBackendFormatData * GetBackendData(const GrBackendFormat &format)
virtual bool equal(const GrBackendTextureData *that) const =0
GrBackendTextureData(const GrBackendTextureData &)=default
virtual bool isSameTexture(const GrBackendTextureData *) const =0
virtual bool isProtected() const =0
virtual sk_sp< skgpu::MutableTextureState > getMutableState() const
virtual void copyTo(AnyTextureData &) const =0
GrBackendTextureData()=default
virtual GrBackendFormat getBackendFormat() const =0
virtual void setMutableState(const skgpu::MutableTextureState &)
const Base * get() const
Definition: SkAnySubclass.h:55
uint32_t uint32_t * format
FlTexture * texture
Definition: GpuTools.h:21
Mipmapped
Definition: GpuTypes.h:53
int32_t height
int32_t width
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63