blob: 68cc9397c214d67356c49131e68a6dcaa1d989c9 [file] [log] [blame]
Greg Daniel94403452017-04-18 15:52:36 -04001/*
2 * Copyright 2017 Google Inc.
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 GrBackendSurface_DEFINED
9#define GrBackendSurface_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/gpu/GrTypes.h"
12#include "include/gpu/gl/GrGLTypes.h"
13#include "include/gpu/mock/GrMockTypes.h"
14#include "include/gpu/vk/GrVkTypes.h"
Brian Salomone2826ab2019-06-04 15:58:31 -040015#include "include/private/GrGLTypesPriv.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050016#include "include/private/GrVkTypesPriv.h"
Greg Daniel52e16d92018-04-10 09:34:07 -040017
18class GrVkImageLayout;
Brian Salomone2826ab2019-06-04 15:58:31 -040019class GrGLTextureParameters;
Greg Daniel94403452017-04-18 15:52:36 -040020
Timothy Liang4e85e802018-06-28 16:37:18 -040021#ifdef SK_METAL
Mike Kleinc0bd9f92019-04-23 12:05:21 -050022#include "include/gpu/mtl/GrMtlTypes.h"
Timothy Liang4e85e802018-06-28 16:37:18 -040023#endif
24
Robert Phillips8caf85f2018-04-05 09:30:38 -040025#if !SK_SUPPORT_GPU
26
27// SkSurface and SkImage rely on a minimal version of these always being available
28class SK_API GrBackendTexture {
29public:
30 GrBackendTexture() {}
31
32 bool isValid() const { return false; }
33};
34
35class SK_API GrBackendRenderTarget {
36public:
37 GrBackendRenderTarget() {}
38
39 bool isValid() const { return false; }
40};
41#else
42
Robert Phillipsfc711a22018-02-13 17:03:00 -050043class SK_API GrBackendFormat {
44public:
45 // Creates an invalid backend format.
Robert Phillipsb2adbef2019-07-02 16:33:05 -040046 GrBackendFormat() {}
47
48 GrBackendFormat(const GrBackendFormat& src);
Robert Phillipsfc711a22018-02-13 17:03:00 -050049
50 static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target) {
51 return GrBackendFormat(format, target);
52 }
53
Greg Daniela8d92112018-03-09 12:05:04 -050054 static GrBackendFormat MakeVk(VkFormat format) {
Greg Daniel7e000222018-12-03 10:08:21 -050055 return GrBackendFormat(format, GrVkYcbcrConversionInfo());
Robert Phillipsfc711a22018-02-13 17:03:00 -050056 }
Robert Phillipsfc711a22018-02-13 17:03:00 -050057
Greg Daniel7e000222018-12-03 10:08:21 -050058 // This is used for external textures and the VkFormat is assumed to be VK_FORMAT_UNDEFINED.
59 // This call is only supported on Android since the GrVkYcbcrConvesionInfo contains an android
60 // external format.
61 static GrBackendFormat MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo);
62
Timothy Liang4e85e802018-06-28 16:37:18 -040063#ifdef SK_METAL
64 static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
65 return GrBackendFormat(format);
66 }
67#endif
68
Robert Phillipsfc711a22018-02-13 17:03:00 -050069 static GrBackendFormat MakeMock(GrPixelConfig config) {
70 return GrBackendFormat(config);
71 }
72
Greg Daniel45723ac2018-11-30 10:12:43 -050073 bool operator==(const GrBackendFormat& that) const;
74 bool operator!=(const GrBackendFormat& that) const { return !(*this == that); }
75
Greg Daniel4065d452018-11-16 15:43:41 -050076 GrBackendApi backend() const { return fBackend; }
77 GrTextureType textureType() const { return fTextureType; }
Robert Phillipsfc711a22018-02-13 17:03:00 -050078
79 // If the backend API is GL, these return a pointer to the format and target. Otherwise
80 // it returns nullptr.
81 const GrGLenum* getGLFormat() const;
82 const GrGLenum* getGLTarget() const;
83
Robert Phillipsfc711a22018-02-13 17:03:00 -050084 // If the backend API is Vulkan, this returns a pointer to a VkFormat. Otherwise
85 // it returns nullptr
86 const VkFormat* getVkFormat() const;
Robert Phillipsfc711a22018-02-13 17:03:00 -050087
Greg Daniel7e000222018-12-03 10:08:21 -050088 const GrVkYcbcrConversionInfo* getVkYcbcrConversionInfo() const;
89
Timothy Liang4e85e802018-06-28 16:37:18 -040090#ifdef SK_METAL
91 // If the backend API is Metal, this returns a pointer to a GrMTLPixelFormat. Otherwise
92 // it returns nullptr
93 const GrMTLPixelFormat* getMtlFormat() const;
94#endif
95
Robert Phillipsfc711a22018-02-13 17:03:00 -050096 // If the backend API is Mock, this returns a pointer to a GrPixelConfig. Otherwise
97 // it returns nullptr.
98 const GrPixelConfig* getMockFormat() const;
99
Greg Daniel387ec9a2019-03-07 16:44:54 -0500100 // If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
101 // GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
102 // remove the conversion and set the format to be VK_FORMAT_R8G8B8A8_UNORM.
Greg Daniel4065d452018-11-16 15:43:41 -0500103 GrBackendFormat makeTexture2D() const;
104
Robert Phillipsfc711a22018-02-13 17:03:00 -0500105 // Returns true if the backend format has been initialized.
106 bool isValid() const { return fValid; }
107
108private:
109 GrBackendFormat(GrGLenum format, GrGLenum target);
110
Greg Daniel7e000222018-12-03 10:08:21 -0500111 GrBackendFormat(const VkFormat vkFormat, const GrVkYcbcrConversionInfo&);
Robert Phillipsfc711a22018-02-13 17:03:00 -0500112
Timothy Liang4e85e802018-06-28 16:37:18 -0400113#ifdef SK_METAL
114 GrBackendFormat(const GrMTLPixelFormat mtlFormat);
115#endif
116
Robert Phillipsfc711a22018-02-13 17:03:00 -0500117 GrBackendFormat(const GrPixelConfig config);
118
Robert Phillipsb2adbef2019-07-02 16:33:05 -0400119 GrBackendApi fBackend = GrBackendApi::kMock;
120 bool fValid = false;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500121
122 union {
Greg Daniel4065d452018-11-16 15:43:41 -0500123 GrGLenum fGLFormat; // the sized, internal format of the GL resource
Greg Daniel7e000222018-12-03 10:08:21 -0500124 struct {
125 VkFormat fFormat;
126 GrVkYcbcrConversionInfo fYcbcrConversionInfo;
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400127 } fVk;
Timothy Liang4e85e802018-06-28 16:37:18 -0400128#ifdef SK_METAL
129 GrMTLPixelFormat fMtlFormat;
130#endif
131 GrPixelConfig fMockFormat;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500132 };
Robert Phillipsb2adbef2019-07-02 16:33:05 -0400133 GrTextureType fTextureType = GrTextureType::kNone;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500134};
135
Brian Salomonec045b42017-07-07 10:34:40 -0400136class SK_API GrBackendTexture {
Greg Daniel94403452017-04-18 15:52:36 -0400137public:
Brian Salomon8fe24272017-07-07 12:56:11 -0400138 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400139 GrBackendTexture() : fIsValid(false) {}
Brian Salomon8fe24272017-07-07 12:56:11 -0400140
Greg Daniele7d8da42017-12-04 11:23:19 -0500141 // The GrGLTextureInfo must have a valid fFormat.
142 GrBackendTexture(int width,
143 int height,
144 GrMipMapped,
145 const GrGLTextureInfo& glInfo);
146
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000147 GrBackendTexture(int width,
148 int height,
149 const GrVkImageInfo& vkInfo);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000150
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400151 GrBackendTexture(int width,
152 int height,
153 GrProtected isProtected,
154 const GrVkImageInfo& vkInfo);
155
Timothy Liang4e85e802018-06-28 16:37:18 -0400156#ifdef SK_METAL
157 GrBackendTexture(int width,
158 int height,
159 GrMipMapped,
160 const GrMtlTextureInfo& mtlInfo);
161#endif
162
Brian Salomon8fe24272017-07-07 12:56:11 -0400163 GrBackendTexture(int width,
164 int height,
Greg Daniel177e6952017-10-12 12:27:11 -0400165 GrMipMapped,
166 const GrMockTextureInfo& mockInfo);
167
Greg Daniel52e16d92018-04-10 09:34:07 -0400168 GrBackendTexture(const GrBackendTexture& that);
169
170 ~GrBackendTexture();
171
172 GrBackendTexture& operator=(const GrBackendTexture& that);
173
Greg Daniel94403452017-04-18 15:52:36 -0400174 int width() const { return fWidth; }
175 int height() const { return fHeight; }
Greg Daniel177e6952017-10-12 12:27:11 -0400176 bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400177 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400178
Greg Daniel52e16d92018-04-10 09:34:07 -0400179 // If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
180 // pointer and returns true. Otherwise returns false if the backend API is not GL.
181 bool getGLTextureInfo(GrGLTextureInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400182
Brian Salomone2826ab2019-06-04 15:58:31 -0400183 // Call this to indicate that the texture parameters have been modified in the GL context
184 // externally to GrContext.
185 void glTextureParametersModified();
186
Greg Daniel323fbcf2018-04-10 13:46:30 -0400187 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
Greg Daniel52e16d92018-04-10 09:34:07 -0400188 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
189 // state. Otherwise returns false if the backend API is not Vulkan.
190 bool getVkImageInfo(GrVkImageInfo*) const;
191
Greg Daniel323fbcf2018-04-10 13:46:30 -0400192 // Anytime the client changes the VkImageLayout of the VkImage captured by this
193 // GrBackendTexture, they must call this function to notify Skia of the changed layout.
Greg Daniel52e16d92018-04-10 09:34:07 -0400194 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000195
Timothy Liang4e85e802018-06-28 16:37:18 -0400196#ifdef SK_METAL
197 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
198 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
199 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
200#endif
201
Brian Salomonf391d0f2018-12-14 09:18:50 -0500202 // Get the GrBackendFormat for this texture (or an invalid format if this is not valid).
203 GrBackendFormat getBackendFormat() const;
204
Greg Daniel52e16d92018-04-10 09:34:07 -0400205 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
206 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
207 bool getMockTextureInfo(GrMockTextureInfo*) const;
Brian Salomon8fe24272017-07-07 12:56:11 -0400208
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400209 // Returns true if we are working with protected content.
210 bool isProtected() const { return fIsProtected == GrProtected::kYes; }
211
Eric Karl914a36b2017-10-12 12:44:50 -0700212 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400213 bool isValid() const { return fIsValid; }
Brian Salomon8fe24272017-07-07 12:56:11 -0400214
Brian Salomonaad83152019-05-24 10:16:35 -0400215 // Returns true if both textures are valid and refer to the same API texture.
216 bool isSameTexture(const GrBackendTexture&);
217
Robert Phillipsc5509952018-04-04 15:54:55 -0400218#if GR_TEST_UTILS
Greg Daniel108bb232018-07-03 16:18:29 -0400219 // We can remove the pixelConfig getter and setter once we remove the GrPixelConfig from the
220 // GrBackendTexture and plumb the GrPixelconfig manually throughout our code (or remove all use
221 // of GrPixelConfig in general).
222 GrPixelConfig pixelConfig() const { return fConfig; }
223 void setPixelConfig(GrPixelConfig config) { fConfig = config; }
224
Robert Phillipsc5509952018-04-04 15:54:55 -0400225 static bool TestingOnly_Equals(const GrBackendTexture& , const GrBackendTexture&);
226#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500227
Eric Karl914a36b2017-10-12 12:44:50 -0700228private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500229 // Friending for access to the GrPixelConfig
Greg Danielfaa095e2017-12-19 13:15:02 -0500230 friend class SkImage;
Brian Salomon6a426c12018-03-15 12:16:02 -0400231 friend class SkImage_Gpu;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400232 friend class SkImage_GpuBase;
Jim Van Verthf49262d2018-10-02 12:07:20 -0400233 friend class SkImage_GpuYUVA;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400234 friend class SkPromiseImageHelper;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500235 friend class SkSurface;
Brian Salomonaad83152019-05-24 10:16:35 -0400236 friend class SkSurface_Gpu;
Greg Daniel108bb232018-07-03 16:18:29 -0400237 friend class GrAHardwareBufferImageGenerator;
Greg Daniele728f672018-01-17 10:52:04 -0500238 friend class GrBackendTextureImageGenerator;
Greg Danielf2336e42018-01-23 16:38:14 -0500239 friend class GrProxyProvider;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500240 friend class GrGpu;
241 friend class GrGLGpu;
242 friend class GrVkGpu;
Timothy Liang4e85e802018-06-28 16:37:18 -0400243 friend class GrMtlGpu;
Greg Daniel057627f2018-03-14 15:51:58 -0400244 friend class PromiseImageHelper;
Robert Phillipsc5509952018-04-04 15:54:55 -0400245
Greg Daniel5254ccc2017-11-13 11:05:52 -0500246 GrPixelConfig config() const { return fConfig; }
247
Brian Salomone2826ab2019-06-04 15:58:31 -0400248#ifdef SK_GL
249 friend class GrGLTexture;
250 GrBackendTexture(int width,
251 int height,
252 GrMipMapped,
253 const GrGLTextureInfo,
254 sk_sp<GrGLTextureParameters>);
255 sk_sp<GrGLTextureParameters> getGLTextureParams() const;
256#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400257
Greg Danielb4d89562018-10-03 18:44:49 +0000258#ifdef SK_VULKAN
Brian Salomone2826ab2019-06-04 15:58:31 -0400259 friend class GrVkTexture;
260 GrBackendTexture(int width,
261 int height,
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400262 GrProtected isProtected,
Brian Salomone2826ab2019-06-04 15:58:31 -0400263 const GrVkImageInfo& vkInfo,
264 sk_sp<GrVkImageLayout> layout);
265 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
Greg Daniel52e16d92018-04-10 09:34:07 -0400266#endif
267
268 // Free and release and resources being held by the GrBackendTexture.
269 void cleanup();
270
Greg Daniel9ca30652018-04-06 09:27:20 -0400271 bool fIsValid;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400272 GrProtected fIsProtected = GrProtected::kNo;
Greg Daniel94403452017-04-18 15:52:36 -0400273 int fWidth; //<! width in pixels
274 int fHeight; //<! height in pixels
275 GrPixelConfig fConfig;
Greg Daniel177e6952017-10-12 12:27:11 -0400276 GrMipMapped fMipMapped;
Greg Danielbdf12ad2018-10-12 09:31:11 -0400277 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400278
279 union {
Brian Salomone2826ab2019-06-04 15:58:31 -0400280#ifdef SK_GL
281 GrGLBackendTextureInfo fGLInfo;
282#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400283 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon8fe24272017-07-07 12:56:11 -0400284 GrMockTextureInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400285 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400286#ifdef SK_METAL
287 GrMtlTextureInfo fMtlInfo;
288#endif
Greg Daniel94403452017-04-18 15:52:36 -0400289};
290
Brian Salomonec045b42017-07-07 10:34:40 -0400291class SK_API GrBackendRenderTarget {
Greg Daniel94403452017-04-18 15:52:36 -0400292public:
Robert Phillips57e08282017-11-16 14:59:48 -0500293 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400294 GrBackendRenderTarget() : fIsValid(false) {}
Robert Phillips57e08282017-11-16 14:59:48 -0500295
Greg Danielfaa095e2017-12-19 13:15:02 -0500296 // The GrGLTextureInfo must have a valid fFormat.
297 GrBackendRenderTarget(int width,
298 int height,
299 int sampleCnt,
300 int stencilBits,
301 const GrGLFramebufferInfo& glInfo);
302
Brian Salomonafdc6b12018-03-09 12:02:32 -0500303 /** Deprecated, use version that does not take stencil bits. */
Greg Daniel94403452017-04-18 15:52:36 -0400304 GrBackendRenderTarget(int width,
305 int height,
306 int sampleCnt,
307 int stencilBits,
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000308 const GrVkImageInfo& vkInfo);
Brian Salomonafdc6b12018-03-09 12:02:32 -0500309 GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400310 GrBackendRenderTarget(int width,
311 int height,
312 int sampleCnt,
313 GrProtected isProtected,
314 const GrVkImageInfo& vkInfo);
Greg Daniel94403452017-04-18 15:52:36 -0400315
Timothy Liang4e85e802018-06-28 16:37:18 -0400316#ifdef SK_METAL
317 GrBackendRenderTarget(int width,
318 int height,
319 int sampleCnt,
320 const GrMtlTextureInfo& mtlInfo);
321#endif
322
Brian Salomon0c51eea2018-03-09 17:02:09 -0500323 GrBackendRenderTarget(int width,
324 int height,
325 int sampleCnt,
326 int stencilBits,
327 const GrMockRenderTargetInfo& mockInfo);
328
Greg Daniel323fbcf2018-04-10 13:46:30 -0400329 ~GrBackendRenderTarget();
330
331 GrBackendRenderTarget(const GrBackendRenderTarget& that);
332 GrBackendRenderTarget& operator=(const GrBackendRenderTarget&);
333
Greg Daniel94403452017-04-18 15:52:36 -0400334 int width() const { return fWidth; }
335 int height() const { return fHeight; }
336 int sampleCnt() const { return fSampleCnt; }
337 int stencilBits() const { return fStencilBits; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400338 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400339
Greg Daniel323fbcf2018-04-10 13:46:30 -0400340 // If the backend API is GL, copies a snapshot of the GrGLFramebufferInfo struct into the passed
341 // in pointer and returns true. Otherwise returns false if the backend API is not GL.
342 bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400343
Greg Daniel323fbcf2018-04-10 13:46:30 -0400344 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
345 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
346 // state. Otherwise returns false if the backend API is not Vulkan.
347 bool getVkImageInfo(GrVkImageInfo*) const;
348
349 // Anytime the client changes the VkImageLayout of the VkImage captured by this
350 // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout.
351 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000352
Timothy Liang4e85e802018-06-28 16:37:18 -0400353#ifdef SK_METAL
354 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
355 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
356 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
357#endif
358
Robert Phillipsf209e882019-06-25 15:59:50 -0400359 // Get the GrBackendFormat for this render target (or an invalid format if this is not valid).
360 GrBackendFormat getBackendFormat() const;
361
Greg Daniel323fbcf2018-04-10 13:46:30 -0400362 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
363 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
364 bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500365
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400366 // Returns true if we are working with protected content.
367 bool isProtected() const { return fIsProtected == GrProtected::kYes; }
368
Robert Phillips57e08282017-11-16 14:59:48 -0500369 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400370 bool isValid() const { return fIsValid; }
Robert Phillips57e08282017-11-16 14:59:48 -0500371
Robert Phillips8caf85f2018-04-05 09:30:38 -0400372
373#if GR_TEST_UTILS
Greg Daniel108bb232018-07-03 16:18:29 -0400374 // We can remove the pixelConfig getter and setter once we remove the pixel config from the
375 // GrBackendRenderTarget and plumb the pixel config manually throughout our code (or remove all
376 // use of GrPixelConfig in general).
377 GrPixelConfig pixelConfig() const { return fConfig; }
378 void setPixelConfig(GrPixelConfig config) { fConfig = config; }
379
Robert Phillips8caf85f2018-04-05 09:30:38 -0400380 static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&);
381#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500382
Greg Daniel94403452017-04-18 15:52:36 -0400383private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500384 // Friending for access to the GrPixelConfig
385 friend class SkSurface;
Greg Danielfaa095e2017-12-19 13:15:02 -0500386 friend class SkSurface_Gpu;
387 friend class SkImage_Gpu;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500388 friend class GrGpu;
389 friend class GrGLGpu;
Greg Daniel2a303902018-02-20 10:25:54 -0500390 friend class GrProxyProvider;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500391 friend class GrVkGpu;
Timothy Liang4e85e802018-06-28 16:37:18 -0400392 friend class GrMtlGpu;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500393 GrPixelConfig config() const { return fConfig; }
394
Greg Daniel323fbcf2018-04-10 13:46:30 -0400395 // Requires friending of GrVkGpu (done above already)
396 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
397
398 friend class GrVkRenderTarget;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400399 GrBackendRenderTarget(int width, int height, int sampleCnt, GrProtected isProtected,
400 const GrVkImageInfo& vkInfo, sk_sp<GrVkImageLayout> layout);
Greg Daniel323fbcf2018-04-10 13:46:30 -0400401
402 // Free and release and resources being held by the GrBackendTexture.
403 void cleanup();
404
Greg Daniel9ca30652018-04-06 09:27:20 -0400405 bool fIsValid;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400406 GrProtected fIsProtected = GrProtected::kNo;
Greg Daniel94403452017-04-18 15:52:36 -0400407 int fWidth; //<! width in pixels
408 int fHeight; //<! height in pixels
409
410 int fSampleCnt;
411 int fStencilBits;
412 GrPixelConfig fConfig;
Jim Van Verth7730d7c2019-05-28 03:03:45 +0000413
Greg Danielbdf12ad2018-10-12 09:31:11 -0400414 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400415
416 union {
Robert Phillipsf209e882019-06-25 15:59:50 -0400417#ifdef SK_GL
Robert Phillipsfad9e3f2017-06-13 22:16:08 +0000418 GrGLFramebufferInfo fGLInfo;
Robert Phillipsf209e882019-06-25 15:59:50 -0400419#endif
Greg Daniel323fbcf2018-04-10 13:46:30 -0400420 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500421 GrMockRenderTargetInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400422 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400423#ifdef SK_METAL
424 GrMtlTextureInfo fMtlInfo;
425#endif
Greg Daniel94403452017-04-18 15:52:36 -0400426};
427
428#endif
429
Robert Phillips8caf85f2018-04-05 09:30:38 -0400430#endif
431