blob: 1695f4c82809eaa8b83a16305b40e2d733d4d925 [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
Stephen White985741a2019-07-18 11:43:45 -040018#ifdef SK_DAWN
19#include "include/gpu/dawn/GrDawnTypes.h"
20#endif
21
Greg Daniel52e16d92018-04-10 09:34:07 -040022class GrVkImageLayout;
Brian Salomone2826ab2019-06-04 15:58:31 -040023class GrGLTextureParameters;
Greg Daniel94403452017-04-18 15:52:36 -040024
Stephen White985741a2019-07-18 11:43:45 -040025#ifdef SK_DAWN
26#include "dawn/dawncpp.h"
27#endif
28
Timothy Liang4e85e802018-06-28 16:37:18 -040029#ifdef SK_METAL
Mike Kleinc0bd9f92019-04-23 12:05:21 -050030#include "include/gpu/mtl/GrMtlTypes.h"
Timothy Liang4e85e802018-06-28 16:37:18 -040031#endif
32
Robert Phillipsbac46722019-08-01 15:09:17 -040033#if GR_TEST_UTILS
34class SkString;
35#endif
36
Robert Phillips8caf85f2018-04-05 09:30:38 -040037#if !SK_SUPPORT_GPU
38
39// SkSurface and SkImage rely on a minimal version of these always being available
40class SK_API GrBackendTexture {
41public:
42 GrBackendTexture() {}
43
44 bool isValid() const { return false; }
45};
46
47class SK_API GrBackendRenderTarget {
48public:
49 GrBackendRenderTarget() {}
50
51 bool isValid() const { return false; }
52};
53#else
54
Brian Salomond4764a12019-08-08 12:08:24 -040055enum class GrGLFormat;
56
Robert Phillipsfc711a22018-02-13 17:03:00 -050057class SK_API GrBackendFormat {
58public:
59 // Creates an invalid backend format.
Robert Phillipsb2adbef2019-07-02 16:33:05 -040060 GrBackendFormat() {}
61
62 GrBackendFormat(const GrBackendFormat& src);
Robert Phillipsfc711a22018-02-13 17:03:00 -050063
64 static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target) {
65 return GrBackendFormat(format, target);
66 }
67
Greg Daniela8d92112018-03-09 12:05:04 -050068 static GrBackendFormat MakeVk(VkFormat format) {
Greg Daniel7e000222018-12-03 10:08:21 -050069 return GrBackendFormat(format, GrVkYcbcrConversionInfo());
Robert Phillipsfc711a22018-02-13 17:03:00 -050070 }
Robert Phillipsfc711a22018-02-13 17:03:00 -050071
Greg Daniel7e000222018-12-03 10:08:21 -050072 // This is used for external textures and the VkFormat is assumed to be VK_FORMAT_UNDEFINED.
73 // This call is only supported on Android since the GrVkYcbcrConvesionInfo contains an android
74 // external format.
75 static GrBackendFormat MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo);
76
Stephen White985741a2019-07-18 11:43:45 -040077#ifdef SK_DAWN
78 static GrBackendFormat MakeDawn(dawn::TextureFormat format) {
79 return GrBackendFormat(format);
80 }
81#endif
82
Timothy Liang4e85e802018-06-28 16:37:18 -040083#ifdef SK_METAL
84 static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
85 return GrBackendFormat(format);
86 }
87#endif
88
Greg Daniele877dce2019-07-11 10:52:43 -040089 static GrBackendFormat MakeMock(GrColorType colorType) {
90 return GrBackendFormat(colorType);
Robert Phillipsfc711a22018-02-13 17:03:00 -050091 }
92
Greg Daniel45723ac2018-11-30 10:12:43 -050093 bool operator==(const GrBackendFormat& that) const;
94 bool operator!=(const GrBackendFormat& that) const { return !(*this == that); }
95
Greg Daniel4065d452018-11-16 15:43:41 -050096 GrBackendApi backend() const { return fBackend; }
97 GrTextureType textureType() const { return fTextureType; }
Robert Phillipsfc711a22018-02-13 17:03:00 -050098
Brian Salomond4764a12019-08-08 12:08:24 -040099 /**
100 * If the backend API is GL this gets the format as a GrGLFormat. Otherwise, returns
101 * GrGLFormat::kUnknown.
102 */
103 GrGLFormat asGLFormat() const;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500104
Brian Salomond4764a12019-08-08 12:08:24 -0400105 /**
106 * If the backend API is Vulkan this gets the format as a VkFormat and returns true. Otherwise,
107 * returns false.
108 */
109 bool asVkFormat(VkFormat*) const;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500110
Greg Daniel7e000222018-12-03 10:08:21 -0500111 const GrVkYcbcrConversionInfo* getVkYcbcrConversionInfo() const;
112
Stephen White985741a2019-07-18 11:43:45 -0400113#ifdef SK_DAWN
Brian Salomond4764a12019-08-08 12:08:24 -0400114 /**
115 * If the backend API is Dawn this gets the format as a dawn::TextureFormat and returns true.
116 * Otherwise, returns false.
117 */
118 bool asDawnFormat(dawn::TextureFormat*) const;
Stephen White985741a2019-07-18 11:43:45 -0400119#endif
120
Timothy Liang4e85e802018-06-28 16:37:18 -0400121#ifdef SK_METAL
Brian Salomond4764a12019-08-08 12:08:24 -0400122 /**
123 * If the backend API is Metal this gets the format as a GrMtlPixelFormat. Otherwise,
124 * Otherwise, returns MTLPixelFormatInvalid.
125 */
126 GrMTLPixelFormat asMtlFormat() const;
Timothy Liang4e85e802018-06-28 16:37:18 -0400127#endif
128
Brian Salomond4764a12019-08-08 12:08:24 -0400129 /**
130 * If the backend API is Mock this gets the format as a GrColorType. Otherwise, returns
131 * GrColorType::kUnknown.
132 */
133 GrColorType asMockColorType() const;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500134
Greg Daniel387ec9a2019-03-07 16:44:54 -0500135 // If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
136 // GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
137 // remove the conversion and set the format to be VK_FORMAT_R8G8B8A8_UNORM.
Greg Daniel4065d452018-11-16 15:43:41 -0500138 GrBackendFormat makeTexture2D() const;
139
Robert Phillipsfc711a22018-02-13 17:03:00 -0500140 // Returns true if the backend format has been initialized.
141 bool isValid() const { return fValid; }
142
Robert Phillipsbac46722019-08-01 15:09:17 -0400143#if GR_TEST_UTILS
144 SkString toStr() const;
145#endif
146
Robert Phillipsfc711a22018-02-13 17:03:00 -0500147private:
148 GrBackendFormat(GrGLenum format, GrGLenum target);
149
Greg Daniel7e000222018-12-03 10:08:21 -0500150 GrBackendFormat(const VkFormat vkFormat, const GrVkYcbcrConversionInfo&);
Robert Phillipsfc711a22018-02-13 17:03:00 -0500151
Stephen White985741a2019-07-18 11:43:45 -0400152#ifdef SK_DAWN
153 GrBackendFormat(dawn::TextureFormat format);
154#endif
155
Timothy Liang4e85e802018-06-28 16:37:18 -0400156#ifdef SK_METAL
157 GrBackendFormat(const GrMTLPixelFormat mtlFormat);
158#endif
159
Greg Daniele877dce2019-07-11 10:52:43 -0400160 GrBackendFormat(GrColorType colorType);
Robert Phillipsfc711a22018-02-13 17:03:00 -0500161
Robert Phillipsb2adbef2019-07-02 16:33:05 -0400162 GrBackendApi fBackend = GrBackendApi::kMock;
163 bool fValid = false;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500164
165 union {
Greg Daniel4065d452018-11-16 15:43:41 -0500166 GrGLenum fGLFormat; // the sized, internal format of the GL resource
Greg Daniel7e000222018-12-03 10:08:21 -0500167 struct {
168 VkFormat fFormat;
169 GrVkYcbcrConversionInfo fYcbcrConversionInfo;
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400170 } fVk;
Stephen White985741a2019-07-18 11:43:45 -0400171#ifdef SK_DAWN
172 dawn::TextureFormat fDawnFormat;
173#endif
174
Timothy Liang4e85e802018-06-28 16:37:18 -0400175#ifdef SK_METAL
176 GrMTLPixelFormat fMtlFormat;
177#endif
Greg Daniele877dce2019-07-11 10:52:43 -0400178 GrColorType fMockColorType;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500179 };
Robert Phillipsb2adbef2019-07-02 16:33:05 -0400180 GrTextureType fTextureType = GrTextureType::kNone;
Robert Phillipsfc711a22018-02-13 17:03:00 -0500181};
182
Brian Salomonec045b42017-07-07 10:34:40 -0400183class SK_API GrBackendTexture {
Greg Daniel94403452017-04-18 15:52:36 -0400184public:
Brian Salomon8fe24272017-07-07 12:56:11 -0400185 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400186 GrBackendTexture() : fIsValid(false) {}
Brian Salomon8fe24272017-07-07 12:56:11 -0400187
Greg Daniele7d8da42017-12-04 11:23:19 -0500188 // The GrGLTextureInfo must have a valid fFormat.
189 GrBackendTexture(int width,
190 int height,
191 GrMipMapped,
192 const GrGLTextureInfo& glInfo);
193
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000194 GrBackendTexture(int width,
195 int height,
196 const GrVkImageInfo& vkInfo);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000197
Timothy Liang4e85e802018-06-28 16:37:18 -0400198#ifdef SK_METAL
199 GrBackendTexture(int width,
200 int height,
201 GrMipMapped,
202 const GrMtlTextureInfo& mtlInfo);
203#endif
204
Stephen White985741a2019-07-18 11:43:45 -0400205#ifdef SK_DAWN
206 GrBackendTexture(int width,
207 int height,
208 const GrDawnImageInfo& dawnInfo);
209#endif
210
Brian Salomon8fe24272017-07-07 12:56:11 -0400211 GrBackendTexture(int width,
212 int height,
Greg Daniel177e6952017-10-12 12:27:11 -0400213 GrMipMapped,
214 const GrMockTextureInfo& mockInfo);
215
Greg Daniel52e16d92018-04-10 09:34:07 -0400216 GrBackendTexture(const GrBackendTexture& that);
217
218 ~GrBackendTexture();
219
220 GrBackendTexture& operator=(const GrBackendTexture& that);
221
Greg Daniel94403452017-04-18 15:52:36 -0400222 int width() const { return fWidth; }
223 int height() const { return fHeight; }
Greg Daniel177e6952017-10-12 12:27:11 -0400224 bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400225 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400226
Greg Daniel52e16d92018-04-10 09:34:07 -0400227 // If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
228 // pointer and returns true. Otherwise returns false if the backend API is not GL.
229 bool getGLTextureInfo(GrGLTextureInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400230
Brian Salomone2826ab2019-06-04 15:58:31 -0400231 // Call this to indicate that the texture parameters have been modified in the GL context
232 // externally to GrContext.
233 void glTextureParametersModified();
234
Stephen White985741a2019-07-18 11:43:45 -0400235#ifdef SK_DAWN
236 // If the backend API is Dawn, copies a snapshot of the GrDawnImageInfo struct into the passed
237 // in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
238 bool getDawnImageInfo(GrDawnImageInfo*) const;
239#endif
240
Greg Daniel323fbcf2018-04-10 13:46:30 -0400241 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
Greg Daniel52e16d92018-04-10 09:34:07 -0400242 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
243 // state. Otherwise returns false if the backend API is not Vulkan.
244 bool getVkImageInfo(GrVkImageInfo*) const;
245
Greg Daniel323fbcf2018-04-10 13:46:30 -0400246 // Anytime the client changes the VkImageLayout of the VkImage captured by this
247 // GrBackendTexture, they must call this function to notify Skia of the changed layout.
Greg Daniel52e16d92018-04-10 09:34:07 -0400248 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000249
Timothy Liang4e85e802018-06-28 16:37:18 -0400250#ifdef SK_METAL
251 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
252 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
253 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
254#endif
255
Brian Salomonf391d0f2018-12-14 09:18:50 -0500256 // Get the GrBackendFormat for this texture (or an invalid format if this is not valid).
257 GrBackendFormat getBackendFormat() const;
258
Greg Daniel52e16d92018-04-10 09:34:07 -0400259 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
260 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
261 bool getMockTextureInfo(GrMockTextureInfo*) const;
Brian Salomon8fe24272017-07-07 12:56:11 -0400262
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400263 // Returns true if we are working with protected content.
Brian Salomon4456a0d2019-07-18 15:05:11 -0400264 bool isProtected() const;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400265
Eric Karl914a36b2017-10-12 12:44:50 -0700266 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400267 bool isValid() const { return fIsValid; }
Brian Salomon8fe24272017-07-07 12:56:11 -0400268
Brian Salomonaad83152019-05-24 10:16:35 -0400269 // Returns true if both textures are valid and refer to the same API texture.
270 bool isSameTexture(const GrBackendTexture&);
271
Robert Phillipsc5509952018-04-04 15:54:55 -0400272#if GR_TEST_UTILS
Robert Phillipsc5509952018-04-04 15:54:55 -0400273 static bool TestingOnly_Equals(const GrBackendTexture& , const GrBackendTexture&);
274#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500275
Eric Karl914a36b2017-10-12 12:44:50 -0700276private:
Greg Daniel5254ccc2017-11-13 11:05:52 -0500277
Brian Salomone2826ab2019-06-04 15:58:31 -0400278#ifdef SK_GL
279 friend class GrGLTexture;
Robert Phillips62221e72019-07-24 15:07:38 -0400280 friend class GrGLGpu; // for getGLTextureParams
Brian Salomone2826ab2019-06-04 15:58:31 -0400281 GrBackendTexture(int width,
282 int height,
283 GrMipMapped,
284 const GrGLTextureInfo,
285 sk_sp<GrGLTextureParameters>);
286 sk_sp<GrGLTextureParameters> getGLTextureParams() const;
287#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400288
Greg Danielb4d89562018-10-03 18:44:49 +0000289#ifdef SK_VULKAN
Brian Salomone2826ab2019-06-04 15:58:31 -0400290 friend class GrVkTexture;
Robert Phillips62221e72019-07-24 15:07:38 -0400291 friend class GrVkGpu; // for getGrVkImageLayout
Brian Salomone2826ab2019-06-04 15:58:31 -0400292 GrBackendTexture(int width,
293 int height,
294 const GrVkImageInfo& vkInfo,
295 sk_sp<GrVkImageLayout> layout);
296 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
Greg Daniel52e16d92018-04-10 09:34:07 -0400297#endif
298
299 // Free and release and resources being held by the GrBackendTexture.
300 void cleanup();
301
Greg Daniel9ca30652018-04-06 09:27:20 -0400302 bool fIsValid;
Greg Daniel94403452017-04-18 15:52:36 -0400303 int fWidth; //<! width in pixels
304 int fHeight; //<! height in pixels
Greg Daniel177e6952017-10-12 12:27:11 -0400305 GrMipMapped fMipMapped;
Greg Danielbdf12ad2018-10-12 09:31:11 -0400306 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400307
308 union {
Brian Salomone2826ab2019-06-04 15:58:31 -0400309#ifdef SK_GL
310 GrGLBackendTextureInfo fGLInfo;
311#endif
Greg Daniel52e16d92018-04-10 09:34:07 -0400312 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon8fe24272017-07-07 12:56:11 -0400313 GrMockTextureInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400314 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400315#ifdef SK_METAL
316 GrMtlTextureInfo fMtlInfo;
317#endif
Stephen White985741a2019-07-18 11:43:45 -0400318#ifdef SK_DAWN
319 GrDawnImageInfo fDawnInfo;
320#endif
Greg Daniel94403452017-04-18 15:52:36 -0400321};
322
Brian Salomonec045b42017-07-07 10:34:40 -0400323class SK_API GrBackendRenderTarget {
Greg Daniel94403452017-04-18 15:52:36 -0400324public:
Robert Phillips57e08282017-11-16 14:59:48 -0500325 // Creates an invalid backend texture.
Greg Daniel9ca30652018-04-06 09:27:20 -0400326 GrBackendRenderTarget() : fIsValid(false) {}
Robert Phillips57e08282017-11-16 14:59:48 -0500327
Greg Danielfaa095e2017-12-19 13:15:02 -0500328 // The GrGLTextureInfo must have a valid fFormat.
329 GrBackendRenderTarget(int width,
330 int height,
331 int sampleCnt,
332 int stencilBits,
333 const GrGLFramebufferInfo& glInfo);
334
Stephen White985741a2019-07-18 11:43:45 -0400335#ifdef SK_DAWN
336 GrBackendRenderTarget(int width,
337 int height,
338 int sampleCnt,
339 int stencilBits,
340 const GrDawnImageInfo& dawnInfo);
341#endif
342
Brian Salomonafdc6b12018-03-09 12:02:32 -0500343 /** Deprecated, use version that does not take stencil bits. */
Greg Daniel94403452017-04-18 15:52:36 -0400344 GrBackendRenderTarget(int width,
345 int height,
346 int sampleCnt,
347 int stencilBits,
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000348 const GrVkImageInfo& vkInfo);
Brian Salomonafdc6b12018-03-09 12:02:32 -0500349 GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
Greg Daniel94403452017-04-18 15:52:36 -0400350
Timothy Liang4e85e802018-06-28 16:37:18 -0400351#ifdef SK_METAL
352 GrBackendRenderTarget(int width,
353 int height,
354 int sampleCnt,
355 const GrMtlTextureInfo& mtlInfo);
356#endif
357
Brian Salomon0c51eea2018-03-09 17:02:09 -0500358 GrBackendRenderTarget(int width,
359 int height,
360 int sampleCnt,
361 int stencilBits,
362 const GrMockRenderTargetInfo& mockInfo);
363
Greg Daniel323fbcf2018-04-10 13:46:30 -0400364 ~GrBackendRenderTarget();
365
366 GrBackendRenderTarget(const GrBackendRenderTarget& that);
367 GrBackendRenderTarget& operator=(const GrBackendRenderTarget&);
368
Greg Daniel94403452017-04-18 15:52:36 -0400369 int width() const { return fWidth; }
370 int height() const { return fHeight; }
371 int sampleCnt() const { return fSampleCnt; }
372 int stencilBits() const { return fStencilBits; }
Greg Danielbdf12ad2018-10-12 09:31:11 -0400373 GrBackendApi backend() const {return fBackend; }
Greg Daniel94403452017-04-18 15:52:36 -0400374
Greg Daniel323fbcf2018-04-10 13:46:30 -0400375 // If the backend API is GL, copies a snapshot of the GrGLFramebufferInfo struct into the passed
376 // in pointer and returns true. Otherwise returns false if the backend API is not GL.
377 bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
Greg Danielc0f8e422017-06-13 13:47:53 -0400378
Stephen White985741a2019-07-18 11:43:45 -0400379#ifdef SK_DAWN
380 // If the backend API is Dawn, copies a snapshot of the GrDawnImageInfo struct into the passed
381 // in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
382 bool getDawnImageInfo(GrDawnImageInfo*) const;
383#endif
384
Greg Daniel323fbcf2018-04-10 13:46:30 -0400385 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
386 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
387 // state. Otherwise returns false if the backend API is not Vulkan.
388 bool getVkImageInfo(GrVkImageInfo*) const;
389
390 // Anytime the client changes the VkImageLayout of the VkImage captured by this
391 // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout.
392 void setVkImageLayout(VkImageLayout);
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000393
Timothy Liang4e85e802018-06-28 16:37:18 -0400394#ifdef SK_METAL
395 // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
396 // in pointer and returns true. Otherwise returns false if the backend API is not Metal.
397 bool getMtlTextureInfo(GrMtlTextureInfo*) const;
398#endif
399
Robert Phillipsf209e882019-06-25 15:59:50 -0400400 // Get the GrBackendFormat for this render target (or an invalid format if this is not valid).
401 GrBackendFormat getBackendFormat() const;
402
Greg Daniel323fbcf2018-04-10 13:46:30 -0400403 // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
404 // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
405 bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500406
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400407 // Returns true if we are working with protected content.
Brian Salomon4456a0d2019-07-18 15:05:11 -0400408 bool isProtected() const;
Emircan Uysaler23ca4e72019-06-24 10:53:09 -0400409
Robert Phillips57e08282017-11-16 14:59:48 -0500410 // Returns true if the backend texture has been initialized.
Greg Daniel9ca30652018-04-06 09:27:20 -0400411 bool isValid() const { return fIsValid; }
Robert Phillips57e08282017-11-16 14:59:48 -0500412
Robert Phillips8caf85f2018-04-05 09:30:38 -0400413
414#if GR_TEST_UTILS
Robert Phillips8caf85f2018-04-05 09:30:38 -0400415 static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&);
416#endif
Greg Daniel2a303902018-02-20 10:25:54 -0500417
Greg Daniel94403452017-04-18 15:52:36 -0400418private:
Robert Phillips62221e72019-07-24 15:07:38 -0400419 friend class GrVkGpu; // for getGrVkImageLayout
Brian Salomon4456a0d2019-07-18 15:05:11 -0400420 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
Greg Daniel323fbcf2018-04-10 13:46:30 -0400421
Brian Salomon4456a0d2019-07-18 15:05:11 -0400422 friend class GrVkRenderTarget;
423 GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo,
424 sk_sp<GrVkImageLayout> layout);
Greg Daniel323fbcf2018-04-10 13:46:30 -0400425
426 // Free and release and resources being held by the GrBackendTexture.
427 void cleanup();
428
Greg Daniel9ca30652018-04-06 09:27:20 -0400429 bool fIsValid;
Greg Daniel94403452017-04-18 15:52:36 -0400430 int fWidth; //<! width in pixels
431 int fHeight; //<! height in pixels
432
433 int fSampleCnt;
434 int fStencilBits;
Jim Van Verth7730d7c2019-05-28 03:03:45 +0000435
Greg Danielbdf12ad2018-10-12 09:31:11 -0400436 GrBackendApi fBackend;
Greg Daniel94403452017-04-18 15:52:36 -0400437
438 union {
Robert Phillipsf209e882019-06-25 15:59:50 -0400439#ifdef SK_GL
Robert Phillipsfad9e3f2017-06-13 22:16:08 +0000440 GrGLFramebufferInfo fGLInfo;
Robert Phillipsf209e882019-06-25 15:59:50 -0400441#endif
Greg Daniel323fbcf2018-04-10 13:46:30 -0400442 GrVkBackendSurfaceInfo fVkInfo;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500443 GrMockRenderTargetInfo fMockInfo;
Greg Daniel94403452017-04-18 15:52:36 -0400444 };
Jim Van Verthdac1e552019-05-31 09:10:55 -0400445#ifdef SK_METAL
446 GrMtlTextureInfo fMtlInfo;
447#endif
Stephen White985741a2019-07-18 11:43:45 -0400448#ifdef SK_DAWN
449 GrDawnImageInfo fDawnInfo;
450#endif
Greg Daniel94403452017-04-18 15:52:36 -0400451};
452
453#endif
454
Robert Phillips8caf85f2018-04-05 09:30:38 -0400455#endif
456