blob: a4f5004f758698acc6db8db7e10ae3bb2210a2ff [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.
46 GrBackendFormat() : fValid(false) {}
47
48 static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target) {
49 return GrBackendFormat(format, target);
50 }
51
Greg Daniela8d92112018-03-09 12:05:04 -050052 static GrBackendFormat MakeVk(VkFormat format) {
Greg Daniel7e000222018-12-03 10:08:21 -050053 return GrBackendFormat(format, GrVkYcbcrConversionInfo());
Robert Phillipsfc711a22018-02-13 17:03:00 -050054 }
Robert Phillipsfc711a22018-02-13 17:03:00 -050055
Greg Daniel7e000222018-12-03 10:08:21 -050056 // This is used for external textures and the VkFormat is assumed to be VK_FORMAT_UNDEFINED.
57 // This call is only supported on Android since the GrVkYcbcrConvesionInfo contains an android
58 // external format.
59 static GrBackendFormat MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo);
60
Timothy Liang4e85e802018-06-28 16:37:18 -040061#ifdef SK_METAL
62 static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
63 return GrBackendFormat(format);
64 }
65#endif
66
Robert Phillipsfc711a22018-02-13 17:03:00 -050067 static GrBackendFormat MakeMock(GrPixelConfig config) {
68 return GrBackendFormat(config);
69 }
70
Greg Daniel45723ac2018-11-30 10:12:43 -050071 bool operator==(const GrBackendFormat& that) const;
72 bool operator!=(const GrBackendFormat& that) const { return !(*this == that); }
73
Greg Daniel4065d452018-11-16 15:43:41 -050074 GrBackendApi backend() const { return fBackend; }
75 GrTextureType textureType() const { return fTextureType; }
Robert Phillipsfc711a22018-02-13 17:03:00 -050076
77 // If the backend API is GL, these return a pointer to the format and target. Otherwise
78 // it returns nullptr.
79 const GrGLenum* getGLFormat() const;
80 const GrGLenum* getGLTarget() const;
81
Robert Phillipsfc711a22018-02-13 17:03:00 -050082 // If the backend API is Vulkan, this returns a pointer to a VkFormat. Otherwise
83 // it returns nullptr
84 const VkFormat* getVkFormat() const;
Robert Phillipsfc711a22018-02-13 17:03:00 -050085
Greg Daniel7e000222018-12-03 10:08:21 -050086 const GrVkYcbcrConversionInfo* getVkYcbcrConversionInfo() const;
87
Timothy Liang4e85e802018-06-28 16:37:18 -040088#ifdef SK_METAL
89 // If the backend API is Metal, this returns a pointer to a GrMTLPixelFormat. Otherwise
90 // it returns nullptr
91 const GrMTLPixelFormat* getMtlFormat() const;
92#endif
93
Robert Phillipsfc711a22018-02-13 17:03:00 -050094 // If the backend API is Mock, this returns a pointer to a GrPixelConfig. Otherwise
95 // it returns nullptr.
96 const GrPixelConfig* getMockFormat() const;
97
Greg Daniel387ec9a2019-03-07 16:44:54 -050098 // If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
99 // GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
100 // remove the conversion and set the format to be VK_FORMAT_R8G8B8A8_UNORM.
Greg Daniel4065d452018-11-16 15:43:41 -0500101 GrBackendFormat makeTexture2D() const;
102
Robert Phillipsfc711a22018-02-13 17:03:00 -0500103 // Returns true if the backend format has been initialized.
104 bool isValid() const { return fValid; }
105
106private:
107 GrBackendFormat(GrGLenum format, GrGLenum target);
108
Greg Daniel7e000222018-12-03 10:08:21 -0500109 GrBackendFormat(const VkFormat vkFormat, const GrVkYcbcrConversionInfo&);
Robert Phillipsfc711a22018-02-13 17:03:00 -0500110
Timothy Liang4e85e802018-06-28 16:37:18 -0400111#ifdef SK_METAL
112 GrBackendFormat(const GrMTLPixelFormat mtlFormat);
113#endif
114
Robert Phillipsfc711a22018-02-13 17:03:00 -0500115 GrBackendFormat(const GrPixelConfig config);
116
Greg Danielbdf12ad2018-10-12 09:31:11 -0400117 GrBackendApi fBackend;
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400118 bool fValid;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500119
120 union {
Greg Daniel4065d452018-11-16 15:43:41 -0500121 GrGLenum fGLFormat; // the sized, internal format of the GL resource
Greg Daniel7e000222018-12-03 10:08:21 -0500122 struct {
123 VkFormat fFormat;
124 GrVkYcbcrConversionInfo fYcbcrConversionInfo;
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400125 } fVk;
Timothy Liang4e85e802018-06-28 16:37:18 -0400126#ifdef SK_METAL
127 GrMTLPixelFormat fMtlFormat;
128#endif
129 GrPixelConfig fMockFormat;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500130 };
Greg Daniel4065d452018-11-16 15:43:41 -0500131 GrTextureType fTextureType;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500132};
133
Brian Salomonec045b42017-07-07 10:34:40 -0400134class SK_API GrBackendTexture {
Greg Daniel94403452017-04-18 15:52:36 -0400135public:
Brian Salomon8fe24272017-07-07 12:56:11 -0400136 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400137 GrBackendTexture() : fIsValid(false) {}
Brian Salomon8fe24272017-07-07 12:56:11 -0400138
Greg Daniele7d8da42017-12-04 11:23:19 -0500139 // The GrGLTextureInfo must have a valid fFormat.
140 GrBackendTexture(int width,
141 int height,
142 GrMipMapped,
143 const GrGLTextureInfo& glInfo);
144
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000145 GrBackendTexture(int width,
146 int height,
147 const GrVkImageInfo& vkInfo);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000148
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400149 GrBackendTexture(int width,
150 int height,
151 GrProtected isProtected,
152 const GrVkImageInfo& vkInfo);
153
Timothy Liang4e85e802018-06-28 16:37:18 -0400154#ifdef SK_METAL
155 GrBackendTexture(int width,
156 int height,
157 GrMipMapped,
158 const GrMtlTextureInfo& mtlInfo);
159#endif
160
Brian Salomon8fe24272017-07-07 12:56:11 -0400161 GrBackendTexture(int width,
162 int height,
Greg Daniel177e6952017-10-12 12:27:11 -0400163 GrMipMapped,
164 const GrMockTextureInfo& mockInfo);
165
Greg Daniel52e16d92018-04-10 09:34:07 -0400166 GrBackendTexture(const GrBackendTexture& that);
167
168 ~GrBackendTexture();
169
170 GrBackendTexture& operator=(const GrBackendTexture& that);
171
Greg Daniel94403452017-04-18 15:52:36 -0400172 int width() const { return fWidth; }
173 int height() const { return fHeight; }
Greg Daniel177e6952017-10-12 12:27:11 -0400174 bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400175 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400176
Greg Daniel52e16d92018-04-10 09:34:07 -0400177 // If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
178 // pointer and returns true. Otherwise returns false if the backend API is not GL.
179 bool getGLTextureInfo(GrGLTextureInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400180
Brian Salomone2826ab2019-06-04 15:58:31 -0400181 // Call this to indicate that the texture parameters have been modified in the GL context
182 // externally to GrContext.
183 void glTextureParametersModified();
184
Greg Daniel323fbcf2018-04-10 13:46:30 -0400185 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
Greg Daniel52e16d92018-04-10 09:34:07 -0400186 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
187 // state. Otherwise returns false if the backend API is not Vulkan.
188 bool getVkImageInfo(GrVkImageInfo*) const;
189
Greg Daniel323fbcf2018-04-10 13:46:30 -0400190 // Anytime the client changes the VkImageLayout of the VkImage captured by this
191 // GrBackendTexture, they must call this function to notify Skia of the changed layout.
Greg Daniel52e16d92018-04-10 09:34:07 -0400192 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000193
Timothy Liang4e85e802018-06-28 16:37:18 -0400194#ifdef SK_METAL
195 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
196 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
197 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
198#endif
199
Brian Salomonf391d0f2018-12-14 09:18:50 -0500200 // Get the GrBackendFormat for this texture (or an invalid format if this is not valid).
201 GrBackendFormat getBackendFormat() const;
202
Greg Daniel52e16d92018-04-10 09:34:07 -0400203 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
204 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
205 bool getMockTextureInfo(GrMockTextureInfo*) const;
Brian Salomon8fe24272017-07-07 12:56:11 -0400206
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400207 // Returns true if we are working with protected content.
208 bool isProtected() const { return fIsProtected == GrProtected::kYes; }
209
Eric Karl914a36b2017-10-12 12:44:50 -0700210 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400211 bool isValid() const { return fIsValid; }
Brian Salomon8fe24272017-07-07 12:56:11 -0400212
Brian Salomonaad83152019-05-24 10:16:35 -0400213 // Returns true if both textures are valid and refer to the same API texture.
214 bool isSameTexture(const GrBackendTexture&);
215
Robert Phillipsc5509952018-04-04 15:54:55 -0400216#if GR_TEST_UTILS
Greg Daniel108bb232018-07-03 16:18:29 -0400217 // We can remove the pixelConfig getter and setter once we remove the GrPixelConfig from the
218 // GrBackendTexture and plumb the GrPixelconfig manually throughout our code (or remove all use
219 // of GrPixelConfig in general).
220 GrPixelConfig pixelConfig() const { return fConfig; }
221 void setPixelConfig(GrPixelConfig config) { fConfig = config; }
222
Robert Phillipsc5509952018-04-04 15:54:55 -0400223 static bool TestingOnly_Equals(const GrBackendTexture& , const GrBackendTexture&);
224#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500225
Eric Karl914a36b2017-10-12 12:44:50 -0700226private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500227 // Friending for access to the GrPixelConfig
Greg Danielfaa095e2017-12-19 13:15:02 -0500228 friend class SkImage;
Brian Salomon6a426c12018-03-15 12:16:02 -0400229 friend class SkImage_Gpu;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400230 friend class SkImage_GpuBase;
Jim Van Verthf49262d2018-10-02 12:07:20 -0400231 friend class SkImage_GpuYUVA;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400232 friend class SkPromiseImageHelper;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500233 friend class SkSurface;
Brian Salomonaad83152019-05-24 10:16:35 -0400234 friend class SkSurface_Gpu;
Greg Daniel108bb232018-07-03 16:18:29 -0400235 friend class GrAHardwareBufferImageGenerator;
Greg Daniele728f672018-01-17 10:52:04 -0500236 friend class GrBackendTextureImageGenerator;
Greg Danielf2336e42018-01-23 16:38:14 -0500237 friend class GrProxyProvider;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500238 friend class GrGpu;
239 friend class GrGLGpu;
240 friend class GrVkGpu;
Timothy Liang4e85e802018-06-28 16:37:18 -0400241 friend class GrMtlGpu;
Greg Daniel057627f2018-03-14 15:51:58 -0400242 friend class PromiseImageHelper;
Robert Phillipsc5509952018-04-04 15:54:55 -0400243
Greg Daniel5254ccc2017-11-13 11:05:52 -0500244 GrPixelConfig config() const { return fConfig; }
245
Brian Salomone2826ab2019-06-04 15:58:31 -0400246#ifdef SK_GL
247 friend class GrGLTexture;
248 GrBackendTexture(int width,
249 int height,
250 GrMipMapped,
251 const GrGLTextureInfo,
252 sk_sp<GrGLTextureParameters>);
253 sk_sp<GrGLTextureParameters> getGLTextureParams() const;
254#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400255
Greg Danielb4d89562018-10-03 18:44:49 +0000256#ifdef SK_VULKAN
Brian Salomone2826ab2019-06-04 15:58:31 -0400257 friend class GrVkTexture;
258 GrBackendTexture(int width,
259 int height,
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400260 GrProtected isProtected,
Brian Salomone2826ab2019-06-04 15:58:31 -0400261 const GrVkImageInfo& vkInfo,
262 sk_sp<GrVkImageLayout> layout);
263 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
Greg Daniel52e16d92018-04-10 09:34:07 -0400264#endif
265
266 // Free and release and resources being held by the GrBackendTexture.
267 void cleanup();
268
Greg Daniel9ca30652018-04-06 09:27:20 -0400269 bool fIsValid;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400270 GrProtected fIsProtected = GrProtected::kNo;
Greg Daniel94403452017-04-18 15:52:36 -0400271 int fWidth; //<! width in pixels
272 int fHeight; //<! height in pixels
273 GrPixelConfig fConfig;
Greg Daniel177e6952017-10-12 12:27:11 -0400274 GrMipMapped fMipMapped;
Greg Danielbdf12ad2018-10-12 09:31:11 -0400275 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400276
277 union {
Brian Salomone2826ab2019-06-04 15:58:31 -0400278#ifdef SK_GL
279 GrGLBackendTextureInfo fGLInfo;
280#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400281 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon8fe24272017-07-07 12:56:11 -0400282 GrMockTextureInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400283 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400284#ifdef SK_METAL
285 GrMtlTextureInfo fMtlInfo;
286#endif
Greg Daniel94403452017-04-18 15:52:36 -0400287};
288
Brian Salomonec045b42017-07-07 10:34:40 -0400289class SK_API GrBackendRenderTarget {
Greg Daniel94403452017-04-18 15:52:36 -0400290public:
Robert Phillips57e08282017-11-16 14:59:48 -0500291 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400292 GrBackendRenderTarget() : fIsValid(false) {}
Robert Phillips57e08282017-11-16 14:59:48 -0500293
Greg Danielfaa095e2017-12-19 13:15:02 -0500294 // The GrGLTextureInfo must have a valid fFormat.
295 GrBackendRenderTarget(int width,
296 int height,
297 int sampleCnt,
298 int stencilBits,
299 const GrGLFramebufferInfo& glInfo);
300
Brian Salomonafdc6b12018-03-09 12:02:32 -0500301 /** Deprecated, use version that does not take stencil bits. */
Greg Daniel94403452017-04-18 15:52:36 -0400302 GrBackendRenderTarget(int width,
303 int height,
304 int sampleCnt,
305 int stencilBits,
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000306 const GrVkImageInfo& vkInfo);
Brian Salomonafdc6b12018-03-09 12:02:32 -0500307 GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400308 GrBackendRenderTarget(int width,
309 int height,
310 int sampleCnt,
311 GrProtected isProtected,
312 const GrVkImageInfo& vkInfo);
Greg Daniel94403452017-04-18 15:52:36 -0400313
Timothy Liang4e85e802018-06-28 16:37:18 -0400314#ifdef SK_METAL
315 GrBackendRenderTarget(int width,
316 int height,
317 int sampleCnt,
318 const GrMtlTextureInfo& mtlInfo);
319#endif
320
Brian Salomon0c51eea2018-03-09 17:02:09 -0500321 GrBackendRenderTarget(int width,
322 int height,
323 int sampleCnt,
324 int stencilBits,
325 const GrMockRenderTargetInfo& mockInfo);
326
Greg Daniel323fbcf2018-04-10 13:46:30 -0400327 ~GrBackendRenderTarget();
328
329 GrBackendRenderTarget(const GrBackendRenderTarget& that);
330 GrBackendRenderTarget& operator=(const GrBackendRenderTarget&);
331
Greg Daniel94403452017-04-18 15:52:36 -0400332 int width() const { return fWidth; }
333 int height() const { return fHeight; }
334 int sampleCnt() const { return fSampleCnt; }
335 int stencilBits() const { return fStencilBits; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400336 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400337
Greg Daniel323fbcf2018-04-10 13:46:30 -0400338 // If the backend API is GL, copies a snapshot of the GrGLFramebufferInfo struct into the passed
339 // in pointer and returns true. Otherwise returns false if the backend API is not GL.
340 bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400341
Greg Daniel323fbcf2018-04-10 13:46:30 -0400342 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
343 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
344 // state. Otherwise returns false if the backend API is not Vulkan.
345 bool getVkImageInfo(GrVkImageInfo*) const;
346
347 // Anytime the client changes the VkImageLayout of the VkImage captured by this
348 // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout.
349 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000350
Timothy Liang4e85e802018-06-28 16:37:18 -0400351#ifdef SK_METAL
352 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
353 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
354 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
355#endif
356
Robert Phillipsf209e882019-06-25 15:59:50 -0400357 // Get the GrBackendFormat for this render target (or an invalid format if this is not valid).
358 GrBackendFormat getBackendFormat() const;
359
Greg Daniel323fbcf2018-04-10 13:46:30 -0400360 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
361 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
362 bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500363
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400364 // Returns true if we are working with protected content.
365 bool isProtected() const { return fIsProtected == GrProtected::kYes; }
366
Robert Phillips57e08282017-11-16 14:59:48 -0500367 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400368 bool isValid() const { return fIsValid; }
Robert Phillips57e08282017-11-16 14:59:48 -0500369
Robert Phillips8caf85f2018-04-05 09:30:38 -0400370
371#if GR_TEST_UTILS
Greg Daniel108bb232018-07-03 16:18:29 -0400372 // We can remove the pixelConfig getter and setter once we remove the pixel config from the
373 // GrBackendRenderTarget and plumb the pixel config manually throughout our code (or remove all
374 // use of GrPixelConfig in general).
375 GrPixelConfig pixelConfig() const { return fConfig; }
376 void setPixelConfig(GrPixelConfig config) { fConfig = config; }
377
Robert Phillips8caf85f2018-04-05 09:30:38 -0400378 static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&);
379#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500380
Greg Daniel94403452017-04-18 15:52:36 -0400381private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500382 // Friending for access to the GrPixelConfig
383 friend class SkSurface;
Greg Danielfaa095e2017-12-19 13:15:02 -0500384 friend class SkSurface_Gpu;
385 friend class SkImage_Gpu;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500386 friend class GrGpu;
387 friend class GrGLGpu;
Greg Daniel2a303902018-02-20 10:25:54 -0500388 friend class GrProxyProvider;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500389 friend class GrVkGpu;
Timothy Liang4e85e802018-06-28 16:37:18 -0400390 friend class GrMtlGpu;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500391 GrPixelConfig config() const { return fConfig; }
392
Greg Daniel323fbcf2018-04-10 13:46:30 -0400393 // Requires friending of GrVkGpu (done above already)
394 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
395
396 friend class GrVkRenderTarget;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400397 GrBackendRenderTarget(int width, int height, int sampleCnt, GrProtected isProtected,
398 const GrVkImageInfo& vkInfo, sk_sp<GrVkImageLayout> layout);
Greg Daniel323fbcf2018-04-10 13:46:30 -0400399
400 // Free and release and resources being held by the GrBackendTexture.
401 void cleanup();
402
Greg Daniel9ca30652018-04-06 09:27:20 -0400403 bool fIsValid;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400404 GrProtected fIsProtected = GrProtected::kNo;
Greg Daniel94403452017-04-18 15:52:36 -0400405 int fWidth; //<! width in pixels
406 int fHeight; //<! height in pixels
407
408 int fSampleCnt;
409 int fStencilBits;
410 GrPixelConfig fConfig;
Jim Van Verth7730d7c2019-05-28 03:03:45 +0000411
Greg Danielbdf12ad2018-10-12 09:31:11 -0400412 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400413
414 union {
Robert Phillipsf209e882019-06-25 15:59:50 -0400415#ifdef SK_GL
Robert Phillipsfad9e3f2017-06-13 22:16:08 +0000416 GrGLFramebufferInfo fGLInfo;
Robert Phillipsf209e882019-06-25 15:59:50 -0400417#endif
Greg Daniel323fbcf2018-04-10 13:46:30 -0400418 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500419 GrMockRenderTargetInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400420 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400421#ifdef SK_METAL
422 GrMtlTextureInfo fMtlInfo;
423#endif
Greg Daniel94403452017-04-18 15:52:36 -0400424};
425
426#endif
427
Robert Phillips8caf85f2018-04-05 09:30:38 -0400428#endif
429