blob: 4f6d2ab860e226aed57827d80de640670df6ead0 [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 Phillipsa5e78be2019-07-09 12:34:38 -040069 static GrBackendFormat MakeMock(GrColorType colorType, GrSRGBEncoded srgbEncoded) {
70 return GrBackendFormat(colorType, srgbEncoded);
Robert Phillipsfc711a22018-02-13 17:03:00 -050071 }
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
Robert Phillipsa5e78be2019-07-09 12:34:38 -040080 // they return nullptr.
Robert Phillipsfc711a22018-02-13 17:03:00 -050081 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 Phillipsa5e78be2019-07-09 12:34:38 -040096 // If the backend API is Mock, these return a pointer to the colorType and srgb encoding.
97 // Otherwise they return nullptr.
98 const GrColorType* getMockColorType() const;
99 const GrSRGBEncoded* getMockSRGBEncoded() const;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500100
Greg Daniel387ec9a2019-03-07 16:44:54 -0500101 // If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
102 // GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
103 // remove the conversion and set the format to be VK_FORMAT_R8G8B8A8_UNORM.
Greg Daniel4065d452018-11-16 15:43:41 -0500104 GrBackendFormat makeTexture2D() const;
105
Robert Phillipsfc711a22018-02-13 17:03:00 -0500106 // Returns true if the backend format has been initialized.
107 bool isValid() const { return fValid; }
108
109private:
110 GrBackendFormat(GrGLenum format, GrGLenum target);
111
Greg Daniel7e000222018-12-03 10:08:21 -0500112 GrBackendFormat(const VkFormat vkFormat, const GrVkYcbcrConversionInfo&);
Robert Phillipsfc711a22018-02-13 17:03:00 -0500113
Timothy Liang4e85e802018-06-28 16:37:18 -0400114#ifdef SK_METAL
115 GrBackendFormat(const GrMTLPixelFormat mtlFormat);
116#endif
117
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400118 GrBackendFormat(GrColorType colorType, GrSRGBEncoded srgbEncoded);
Robert Phillipsfc711a22018-02-13 17:03:00 -0500119
Robert Phillipsb2adbef2019-07-02 16:33:05 -0400120 GrBackendApi fBackend = GrBackendApi::kMock;
121 bool fValid = false;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500122
123 union {
Greg Daniel4065d452018-11-16 15:43:41 -0500124 GrGLenum fGLFormat; // the sized, internal format of the GL resource
Greg Daniel7e000222018-12-03 10:08:21 -0500125 struct {
126 VkFormat fFormat;
127 GrVkYcbcrConversionInfo fYcbcrConversionInfo;
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400128 } fVk;
Timothy Liang4e85e802018-06-28 16:37:18 -0400129#ifdef SK_METAL
130 GrMTLPixelFormat fMtlFormat;
131#endif
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400132 struct {
133 GrColorType fColorType;
134 GrSRGBEncoded fSRGBEncoded;
135 } fMock;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500136 };
Robert Phillipsb2adbef2019-07-02 16:33:05 -0400137 GrTextureType fTextureType = GrTextureType::kNone;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500138};
139
Brian Salomonec045b42017-07-07 10:34:40 -0400140class SK_API GrBackendTexture {
Greg Daniel94403452017-04-18 15:52:36 -0400141public:
Brian Salomon8fe24272017-07-07 12:56:11 -0400142 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400143 GrBackendTexture() : fIsValid(false) {}
Brian Salomon8fe24272017-07-07 12:56:11 -0400144
Greg Daniele7d8da42017-12-04 11:23:19 -0500145 // The GrGLTextureInfo must have a valid fFormat.
146 GrBackendTexture(int width,
147 int height,
148 GrMipMapped,
149 const GrGLTextureInfo& glInfo);
150
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000151 GrBackendTexture(int width,
152 int height,
153 const GrVkImageInfo& vkInfo);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000154
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400155 GrBackendTexture(int width,
156 int height,
157 GrProtected isProtected,
158 const GrVkImageInfo& vkInfo);
159
Timothy Liang4e85e802018-06-28 16:37:18 -0400160#ifdef SK_METAL
161 GrBackendTexture(int width,
162 int height,
163 GrMipMapped,
164 const GrMtlTextureInfo& mtlInfo);
165#endif
166
Brian Salomon8fe24272017-07-07 12:56:11 -0400167 GrBackendTexture(int width,
168 int height,
Greg Daniel177e6952017-10-12 12:27:11 -0400169 GrMipMapped,
170 const GrMockTextureInfo& mockInfo);
171
Greg Daniel52e16d92018-04-10 09:34:07 -0400172 GrBackendTexture(const GrBackendTexture& that);
173
174 ~GrBackendTexture();
175
176 GrBackendTexture& operator=(const GrBackendTexture& that);
177
Greg Daniel94403452017-04-18 15:52:36 -0400178 int width() const { return fWidth; }
179 int height() const { return fHeight; }
Greg Daniel177e6952017-10-12 12:27:11 -0400180 bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400181 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400182
Greg Daniel52e16d92018-04-10 09:34:07 -0400183 // If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
184 // pointer and returns true. Otherwise returns false if the backend API is not GL.
185 bool getGLTextureInfo(GrGLTextureInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400186
Brian Salomone2826ab2019-06-04 15:58:31 -0400187 // Call this to indicate that the texture parameters have been modified in the GL context
188 // externally to GrContext.
189 void glTextureParametersModified();
190
Greg Daniel323fbcf2018-04-10 13:46:30 -0400191 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
Greg Daniel52e16d92018-04-10 09:34:07 -0400192 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
193 // state. Otherwise returns false if the backend API is not Vulkan.
194 bool getVkImageInfo(GrVkImageInfo*) const;
195
Greg Daniel323fbcf2018-04-10 13:46:30 -0400196 // Anytime the client changes the VkImageLayout of the VkImage captured by this
197 // GrBackendTexture, they must call this function to notify Skia of the changed layout.
Greg Daniel52e16d92018-04-10 09:34:07 -0400198 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000199
Timothy Liang4e85e802018-06-28 16:37:18 -0400200#ifdef SK_METAL
201 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
202 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
203 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
204#endif
205
Brian Salomonf391d0f2018-12-14 09:18:50 -0500206 // Get the GrBackendFormat for this texture (or an invalid format if this is not valid).
207 GrBackendFormat getBackendFormat() const;
208
Greg Daniel52e16d92018-04-10 09:34:07 -0400209 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
210 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
211 bool getMockTextureInfo(GrMockTextureInfo*) const;
Brian Salomon8fe24272017-07-07 12:56:11 -0400212
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400213 // Returns true if we are working with protected content.
214 bool isProtected() const { return fIsProtected == GrProtected::kYes; }
215
Eric Karl914a36b2017-10-12 12:44:50 -0700216 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400217 bool isValid() const { return fIsValid; }
Brian Salomon8fe24272017-07-07 12:56:11 -0400218
Brian Salomonaad83152019-05-24 10:16:35 -0400219 // Returns true if both textures are valid and refer to the same API texture.
220 bool isSameTexture(const GrBackendTexture&);
221
Robert Phillipsc5509952018-04-04 15:54:55 -0400222#if GR_TEST_UTILS
Greg Daniel108bb232018-07-03 16:18:29 -0400223 // We can remove the pixelConfig getter and setter once we remove the GrPixelConfig from the
224 // GrBackendTexture and plumb the GrPixelconfig manually throughout our code (or remove all use
225 // of GrPixelConfig in general).
226 GrPixelConfig pixelConfig() const { return fConfig; }
227 void setPixelConfig(GrPixelConfig config) { fConfig = config; }
228
Robert Phillipsc5509952018-04-04 15:54:55 -0400229 static bool TestingOnly_Equals(const GrBackendTexture& , const GrBackendTexture&);
230#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500231
Eric Karl914a36b2017-10-12 12:44:50 -0700232private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500233 // Friending for access to the GrPixelConfig
Greg Danielfaa095e2017-12-19 13:15:02 -0500234 friend class SkImage;
Brian Salomon6a426c12018-03-15 12:16:02 -0400235 friend class SkImage_Gpu;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400236 friend class SkImage_GpuBase;
Jim Van Verthf49262d2018-10-02 12:07:20 -0400237 friend class SkImage_GpuYUVA;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400238 friend class SkPromiseImageHelper;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500239 friend class SkSurface;
Brian Salomonaad83152019-05-24 10:16:35 -0400240 friend class SkSurface_Gpu;
Greg Daniel108bb232018-07-03 16:18:29 -0400241 friend class GrAHardwareBufferImageGenerator;
Greg Daniele728f672018-01-17 10:52:04 -0500242 friend class GrBackendTextureImageGenerator;
Greg Danielf2336e42018-01-23 16:38:14 -0500243 friend class GrProxyProvider;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500244 friend class GrGpu;
245 friend class GrGLGpu;
246 friend class GrVkGpu;
Timothy Liang4e85e802018-06-28 16:37:18 -0400247 friend class GrMtlGpu;
Greg Daniel057627f2018-03-14 15:51:58 -0400248 friend class PromiseImageHelper;
Robert Phillipsc5509952018-04-04 15:54:55 -0400249
Greg Daniel5254ccc2017-11-13 11:05:52 -0500250 GrPixelConfig config() const { return fConfig; }
251
Brian Salomone2826ab2019-06-04 15:58:31 -0400252#ifdef SK_GL
253 friend class GrGLTexture;
254 GrBackendTexture(int width,
255 int height,
256 GrMipMapped,
257 const GrGLTextureInfo,
258 sk_sp<GrGLTextureParameters>);
259 sk_sp<GrGLTextureParameters> getGLTextureParams() const;
260#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400261
Greg Danielb4d89562018-10-03 18:44:49 +0000262#ifdef SK_VULKAN
Brian Salomone2826ab2019-06-04 15:58:31 -0400263 friend class GrVkTexture;
264 GrBackendTexture(int width,
265 int height,
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400266 GrProtected isProtected,
Brian Salomone2826ab2019-06-04 15:58:31 -0400267 const GrVkImageInfo& vkInfo,
268 sk_sp<GrVkImageLayout> layout);
269 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
Greg Daniel52e16d92018-04-10 09:34:07 -0400270#endif
271
272 // Free and release and resources being held by the GrBackendTexture.
273 void cleanup();
274
Greg Daniel9ca30652018-04-06 09:27:20 -0400275 bool fIsValid;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400276 GrProtected fIsProtected = GrProtected::kNo;
Greg Daniel94403452017-04-18 15:52:36 -0400277 int fWidth; //<! width in pixels
278 int fHeight; //<! height in pixels
279 GrPixelConfig fConfig;
Greg Daniel177e6952017-10-12 12:27:11 -0400280 GrMipMapped fMipMapped;
Greg Danielbdf12ad2018-10-12 09:31:11 -0400281 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400282
283 union {
Brian Salomone2826ab2019-06-04 15:58:31 -0400284#ifdef SK_GL
285 GrGLBackendTextureInfo fGLInfo;
286#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400287 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon8fe24272017-07-07 12:56:11 -0400288 GrMockTextureInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400289 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400290#ifdef SK_METAL
291 GrMtlTextureInfo fMtlInfo;
292#endif
Greg Daniel94403452017-04-18 15:52:36 -0400293};
294
Brian Salomonec045b42017-07-07 10:34:40 -0400295class SK_API GrBackendRenderTarget {
Greg Daniel94403452017-04-18 15:52:36 -0400296public:
Robert Phillips57e08282017-11-16 14:59:48 -0500297 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400298 GrBackendRenderTarget() : fIsValid(false) {}
Robert Phillips57e08282017-11-16 14:59:48 -0500299
Greg Danielfaa095e2017-12-19 13:15:02 -0500300 // The GrGLTextureInfo must have a valid fFormat.
301 GrBackendRenderTarget(int width,
302 int height,
303 int sampleCnt,
304 int stencilBits,
305 const GrGLFramebufferInfo& glInfo);
306
Brian Salomonafdc6b12018-03-09 12:02:32 -0500307 /** Deprecated, use version that does not take stencil bits. */
Greg Daniel94403452017-04-18 15:52:36 -0400308 GrBackendRenderTarget(int width,
309 int height,
310 int sampleCnt,
311 int stencilBits,
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000312 const GrVkImageInfo& vkInfo);
Brian Salomonafdc6b12018-03-09 12:02:32 -0500313 GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400314 GrBackendRenderTarget(int width,
315 int height,
316 int sampleCnt,
317 GrProtected isProtected,
318 const GrVkImageInfo& vkInfo);
Greg Daniel94403452017-04-18 15:52:36 -0400319
Timothy Liang4e85e802018-06-28 16:37:18 -0400320#ifdef SK_METAL
321 GrBackendRenderTarget(int width,
322 int height,
323 int sampleCnt,
324 const GrMtlTextureInfo& mtlInfo);
325#endif
326
Brian Salomon0c51eea2018-03-09 17:02:09 -0500327 GrBackendRenderTarget(int width,
328 int height,
329 int sampleCnt,
330 int stencilBits,
331 const GrMockRenderTargetInfo& mockInfo);
332
Greg Daniel323fbcf2018-04-10 13:46:30 -0400333 ~GrBackendRenderTarget();
334
335 GrBackendRenderTarget(const GrBackendRenderTarget& that);
336 GrBackendRenderTarget& operator=(const GrBackendRenderTarget&);
337
Greg Daniel94403452017-04-18 15:52:36 -0400338 int width() const { return fWidth; }
339 int height() const { return fHeight; }
340 int sampleCnt() const { return fSampleCnt; }
341 int stencilBits() const { return fStencilBits; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400342 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400343
Greg Daniel323fbcf2018-04-10 13:46:30 -0400344 // If the backend API is GL, copies a snapshot of the GrGLFramebufferInfo struct into the passed
345 // in pointer and returns true. Otherwise returns false if the backend API is not GL.
346 bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400347
Greg Daniel323fbcf2018-04-10 13:46:30 -0400348 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
349 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
350 // state. Otherwise returns false if the backend API is not Vulkan.
351 bool getVkImageInfo(GrVkImageInfo*) const;
352
353 // Anytime the client changes the VkImageLayout of the VkImage captured by this
354 // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout.
355 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000356
Timothy Liang4e85e802018-06-28 16:37:18 -0400357#ifdef SK_METAL
358 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
359 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
360 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
361#endif
362
Robert Phillipsf209e882019-06-25 15:59:50 -0400363 // Get the GrBackendFormat for this render target (or an invalid format if this is not valid).
364 GrBackendFormat getBackendFormat() const;
365
Greg Daniel323fbcf2018-04-10 13:46:30 -0400366 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
367 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
368 bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500369
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400370 // Returns true if we are working with protected content.
371 bool isProtected() const { return fIsProtected == GrProtected::kYes; }
372
Robert Phillips57e08282017-11-16 14:59:48 -0500373 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400374 bool isValid() const { return fIsValid; }
Robert Phillips57e08282017-11-16 14:59:48 -0500375
Robert Phillips8caf85f2018-04-05 09:30:38 -0400376
377#if GR_TEST_UTILS
Greg Daniel108bb232018-07-03 16:18:29 -0400378 // We can remove the pixelConfig getter and setter once we remove the pixel config from the
379 // GrBackendRenderTarget and plumb the pixel config manually throughout our code (or remove all
380 // use of GrPixelConfig in general).
381 GrPixelConfig pixelConfig() const { return fConfig; }
382 void setPixelConfig(GrPixelConfig config) { fConfig = config; }
383
Robert Phillips8caf85f2018-04-05 09:30:38 -0400384 static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&);
385#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500386
Greg Daniel94403452017-04-18 15:52:36 -0400387private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500388 // Friending for access to the GrPixelConfig
389 friend class SkSurface;
Greg Danielfaa095e2017-12-19 13:15:02 -0500390 friend class SkSurface_Gpu;
391 friend class SkImage_Gpu;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500392 friend class GrGpu;
393 friend class GrGLGpu;
Greg Daniel2a303902018-02-20 10:25:54 -0500394 friend class GrProxyProvider;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500395 friend class GrVkGpu;
Timothy Liang4e85e802018-06-28 16:37:18 -0400396 friend class GrMtlGpu;
Greg Daniel5254ccc2017-11-13 11:05:52 -0500397 GrPixelConfig config() const { return fConfig; }
398
Greg Daniel323fbcf2018-04-10 13:46:30 -0400399 // Requires friending of GrVkGpu (done above already)
400 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
401
402 friend class GrVkRenderTarget;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400403 GrBackendRenderTarget(int width, int height, int sampleCnt, GrProtected isProtected,
404 const GrVkImageInfo& vkInfo, sk_sp<GrVkImageLayout> layout);
Greg Daniel323fbcf2018-04-10 13:46:30 -0400405
406 // Free and release and resources being held by the GrBackendTexture.
407 void cleanup();
408
Greg Daniel9ca30652018-04-06 09:27:20 -0400409 bool fIsValid;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400410 GrProtected fIsProtected = GrProtected::kNo;
Greg Daniel94403452017-04-18 15:52:36 -0400411 int fWidth; //<! width in pixels
412 int fHeight; //<! height in pixels
413
414 int fSampleCnt;
415 int fStencilBits;
416 GrPixelConfig fConfig;
Jim Van Verth7730d7c2019-05-28 03:03:45 +0000417
Greg Danielbdf12ad2018-10-12 09:31:11 -0400418 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400419
420 union {
Robert Phillipsf209e882019-06-25 15:59:50 -0400421#ifdef SK_GL
Robert Phillipsfad9e3f2017-06-13 22:16:08 +0000422 GrGLFramebufferInfo fGLInfo;
Robert Phillipsf209e882019-06-25 15:59:50 -0400423#endif
Greg Daniel323fbcf2018-04-10 13:46:30 -0400424 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500425 GrMockRenderTargetInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400426 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400427#ifdef SK_METAL
428 GrMtlTextureInfo fMtlInfo;
429#endif
Greg Daniel94403452017-04-18 15:52:36 -0400430};
431
432#endif
433
Robert Phillips8caf85f2018-04-05 09:30:38 -0400434#endif
435