2017-04-18 19:52:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrBackendSurface_DEFINED
|
|
|
|
#define GrBackendSurface_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/GrTypes.h"
|
|
|
|
#include "include/gpu/gl/GrGLTypes.h"
|
|
|
|
#include "include/gpu/mock/GrMockTypes.h"
|
|
|
|
#include "include/gpu/vk/GrVkTypes.h"
|
|
|
|
#include "include/private/GrVkTypesPriv.h"
|
2018-04-10 13:34:07 +00:00
|
|
|
|
|
|
|
class GrVkImageLayout;
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/mtl/GrMtlTypes.h"
|
2018-06-28 20:37:18 +00:00
|
|
|
#endif
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
#if !SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
// SkSurface and SkImage rely on a minimal version of these always being available
|
|
|
|
class SK_API GrBackendTexture {
|
|
|
|
public:
|
|
|
|
GrBackendTexture() {}
|
|
|
|
|
|
|
|
bool isValid() const { return false; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class SK_API GrBackendRenderTarget {
|
|
|
|
public:
|
|
|
|
GrBackendRenderTarget() {}
|
|
|
|
|
|
|
|
bool isValid() const { return false; }
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
class SK_API GrBackendFormat {
|
|
|
|
public:
|
|
|
|
// Creates an invalid backend format.
|
|
|
|
GrBackendFormat() : fValid(false) {}
|
|
|
|
|
|
|
|
static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target) {
|
|
|
|
return GrBackendFormat(format, target);
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:05:04 +00:00
|
|
|
static GrBackendFormat MakeVk(VkFormat format) {
|
2018-12-03 15:08:21 +00:00
|
|
|
return GrBackendFormat(format, GrVkYcbcrConversionInfo());
|
2018-02-13 22:03:00 +00:00
|
|
|
}
|
|
|
|
|
2018-12-03 15:08:21 +00:00
|
|
|
// This is used for external textures and the VkFormat is assumed to be VK_FORMAT_UNDEFINED.
|
|
|
|
// This call is only supported on Android since the GrVkYcbcrConvesionInfo contains an android
|
|
|
|
// external format.
|
|
|
|
static GrBackendFormat MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo);
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
|
|
|
|
return GrBackendFormat(format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
static GrBackendFormat MakeMock(GrPixelConfig config) {
|
|
|
|
return GrBackendFormat(config);
|
|
|
|
}
|
|
|
|
|
2018-11-30 15:12:43 +00:00
|
|
|
bool operator==(const GrBackendFormat& that) const;
|
|
|
|
bool operator!=(const GrBackendFormat& that) const { return !(*this == that); }
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
GrBackendApi backend() const { return fBackend; }
|
|
|
|
GrTextureType textureType() const { return fTextureType; }
|
2018-02-13 22:03:00 +00:00
|
|
|
|
|
|
|
// If the backend API is GL, these return a pointer to the format and target. Otherwise
|
|
|
|
// it returns nullptr.
|
|
|
|
const GrGLenum* getGLFormat() const;
|
|
|
|
const GrGLenum* getGLTarget() const;
|
|
|
|
|
|
|
|
// If the backend API is Vulkan, this returns a pointer to a VkFormat. Otherwise
|
|
|
|
// it returns nullptr
|
|
|
|
const VkFormat* getVkFormat() const;
|
|
|
|
|
2018-12-03 15:08:21 +00:00
|
|
|
const GrVkYcbcrConversionInfo* getVkYcbcrConversionInfo() const;
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
// If the backend API is Metal, this returns a pointer to a GrMTLPixelFormat. Otherwise
|
|
|
|
// it returns nullptr
|
|
|
|
const GrMTLPixelFormat* getMtlFormat() const;
|
|
|
|
#endif
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
// If the backend API is Mock, this returns a pointer to a GrPixelConfig. Otherwise
|
|
|
|
// it returns nullptr.
|
|
|
|
const GrPixelConfig* getMockFormat() const;
|
|
|
|
|
2019-03-07 21:44:54 +00:00
|
|
|
// If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
|
|
|
|
// GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
|
|
|
|
// remove the conversion and set the format to be VK_FORMAT_R8G8B8A8_UNORM.
|
2018-11-16 20:43:41 +00:00
|
|
|
GrBackendFormat makeTexture2D() const;
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
// Returns true if the backend format has been initialized.
|
|
|
|
bool isValid() const { return fValid; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
GrBackendFormat(GrGLenum format, GrGLenum target);
|
|
|
|
|
2018-12-03 15:08:21 +00:00
|
|
|
GrBackendFormat(const VkFormat vkFormat, const GrVkYcbcrConversionInfo&);
|
2018-02-13 22:03:00 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrBackendFormat(const GrMTLPixelFormat mtlFormat);
|
|
|
|
#endif
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
GrBackendFormat(const GrPixelConfig config);
|
|
|
|
|
2018-10-12 13:31:11 +00:00
|
|
|
GrBackendApi fBackend;
|
2018-02-13 22:03:00 +00:00
|
|
|
bool fValid;
|
|
|
|
|
|
|
|
union {
|
2018-11-16 20:43:41 +00:00
|
|
|
GrGLenum fGLFormat; // the sized, internal format of the GL resource
|
2018-12-03 15:08:21 +00:00
|
|
|
struct {
|
|
|
|
VkFormat fFormat;
|
|
|
|
GrVkYcbcrConversionInfo fYcbcrConversionInfo;
|
|
|
|
} fVk;
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMTLPixelFormat fMtlFormat;
|
|
|
|
#endif
|
|
|
|
GrPixelConfig fMockFormat;
|
2018-02-13 22:03:00 +00:00
|
|
|
};
|
2018-11-16 20:43:41 +00:00
|
|
|
GrTextureType fTextureType;
|
2018-02-13 22:03:00 +00:00
|
|
|
};
|
|
|
|
|
2017-07-07 14:34:40 +00:00
|
|
|
class SK_API GrBackendTexture {
|
2017-04-18 19:52:36 +00:00
|
|
|
public:
|
2017-07-07 16:56:11 +00:00
|
|
|
// Creates an invalid backend texture.
|
2018-04-06 13:27:20 +00:00
|
|
|
GrBackendTexture() : fIsValid(false) {}
|
2017-07-07 16:56:11 +00:00
|
|
|
|
2017-12-04 16:23:19 +00:00
|
|
|
// The GrGLTextureInfo must have a valid fFormat.
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
GrMipMapped,
|
|
|
|
const GrGLTextureInfo& glInfo);
|
|
|
|
|
2017-04-18 19:52:36 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2017-06-14 01:43:29 +00:00
|
|
|
const GrVkImageInfo& vkInfo);
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
GrMipMapped,
|
|
|
|
const GrMtlTextureInfo& mtlInfo);
|
|
|
|
#endif
|
|
|
|
|
2017-07-07 16:56:11 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2017-10-12 16:27:11 +00:00
|
|
|
GrMipMapped,
|
|
|
|
const GrMockTextureInfo& mockInfo);
|
|
|
|
|
2018-04-10 13:34:07 +00:00
|
|
|
GrBackendTexture(const GrBackendTexture& that);
|
|
|
|
|
|
|
|
~GrBackendTexture();
|
|
|
|
|
|
|
|
GrBackendTexture& operator=(const GrBackendTexture& that);
|
|
|
|
|
2017-04-18 19:52:36 +00:00
|
|
|
int width() const { return fWidth; }
|
|
|
|
int height() const { return fHeight; }
|
2017-10-12 16:27:11 +00:00
|
|
|
bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
|
2018-10-12 13:31:11 +00:00
|
|
|
GrBackendApi backend() const {return fBackend; }
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-04-10 13:34:07 +00:00
|
|
|
// If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
|
|
|
|
// pointer and returns true. Otherwise returns false if the backend API is not GL.
|
|
|
|
bool getGLTextureInfo(GrGLTextureInfo*) const;
|
2017-06-13 17:47:53 +00:00
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
// If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
|
2018-04-10 13:34:07 +00:00
|
|
|
// in pointer and returns true. This snapshot will set the fImageLayout to the current layout
|
|
|
|
// state. Otherwise returns false if the backend API is not Vulkan.
|
|
|
|
bool getVkImageInfo(GrVkImageInfo*) const;
|
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
// Anytime the client changes the VkImageLayout of the VkImage captured by this
|
|
|
|
// GrBackendTexture, they must call this function to notify Skia of the changed layout.
|
2018-04-10 13:34:07 +00:00
|
|
|
void setVkImageLayout(VkImageLayout);
|
2017-06-14 01:43:29 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
// If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Metal.
|
|
|
|
bool getMtlTextureInfo(GrMtlTextureInfo*) const;
|
|
|
|
#endif
|
|
|
|
|
2018-12-14 14:18:50 +00:00
|
|
|
// Get the GrBackendFormat for this texture (or an invalid format if this is not valid).
|
|
|
|
GrBackendFormat getBackendFormat() const;
|
|
|
|
|
2018-04-10 13:34:07 +00:00
|
|
|
// If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Mock.
|
|
|
|
bool getMockTextureInfo(GrMockTextureInfo*) const;
|
2017-07-07 16:56:11 +00:00
|
|
|
|
2017-10-12 19:44:50 +00:00
|
|
|
// Returns true if the backend texture has been initialized.
|
2018-04-06 13:27:20 +00:00
|
|
|
bool isValid() const { return fIsValid; }
|
2017-07-07 16:56:11 +00:00
|
|
|
|
2018-04-04 19:54:55 +00:00
|
|
|
#if GR_TEST_UTILS
|
2018-07-03 20:18:29 +00:00
|
|
|
// We can remove the pixelConfig getter and setter once we remove the GrPixelConfig from the
|
|
|
|
// GrBackendTexture and plumb the GrPixelconfig manually throughout our code (or remove all use
|
|
|
|
// of GrPixelConfig in general).
|
|
|
|
GrPixelConfig pixelConfig() const { return fConfig; }
|
|
|
|
void setPixelConfig(GrPixelConfig config) { fConfig = config; }
|
|
|
|
|
2018-04-04 19:54:55 +00:00
|
|
|
static bool TestingOnly_Equals(const GrBackendTexture& , const GrBackendTexture&);
|
|
|
|
#endif
|
2018-02-20 15:25:54 +00:00
|
|
|
|
2017-10-12 19:44:50 +00:00
|
|
|
private:
|
2017-11-13 16:05:52 +00:00
|
|
|
// Friending for access to the GrPixelConfig
|
2017-12-19 18:15:02 +00:00
|
|
|
friend class SkImage;
|
2018-03-15 16:16:02 +00:00
|
|
|
friend class SkImage_Gpu;
|
2018-10-08 18:34:52 +00:00
|
|
|
friend class SkImage_GpuBase;
|
2018-10-02 16:07:20 +00:00
|
|
|
friend class SkImage_GpuYUVA;
|
2018-10-08 18:34:52 +00:00
|
|
|
friend class SkPromiseImageHelper;
|
2017-11-13 16:05:52 +00:00
|
|
|
friend class SkSurface;
|
2018-07-03 20:18:29 +00:00
|
|
|
friend class GrAHardwareBufferImageGenerator;
|
2018-01-17 15:52:04 +00:00
|
|
|
friend class GrBackendTextureImageGenerator;
|
2018-01-23 21:38:14 +00:00
|
|
|
friend class GrProxyProvider;
|
2017-11-13 16:05:52 +00:00
|
|
|
friend class GrGpu;
|
|
|
|
friend class GrGLGpu;
|
|
|
|
friend class GrVkGpu;
|
2018-06-28 20:37:18 +00:00
|
|
|
friend class GrMtlGpu;
|
2018-03-14 19:51:58 +00:00
|
|
|
friend class PromiseImageHelper;
|
2018-04-04 19:54:55 +00:00
|
|
|
|
2017-11-13 16:05:52 +00:00
|
|
|
GrPixelConfig config() const { return fConfig; }
|
|
|
|
|
2018-04-10 13:34:07 +00:00
|
|
|
// Requires friending of GrVkGpu (done above already)
|
|
|
|
sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
|
|
|
|
|
|
|
|
friend class GrVkTexture;
|
Reland "Reland "Always include public/include headers for vulkan and just guard src files with SK_VULKAN.""
This reverts commit a55e214bbe3942a098d97906a0f008d59dd1fafb.
Reason for revert:google3 should be fixed now
Original change's description:
> Revert "Reland "Always include public/include headers for vulkan and just guard src files with SK_VULKAN.""
>
> This reverts commit 55aea84baa53f2d7e7e876b09fd590f046ff9ab9.
>
> Reason for revert: Google3 roll failing like
>
> third_party/skia/HEAD/include/gpu/vk/GrVkDefines.h:15:10: fatal error: '../../../third_party/vulkan/SkiaVulkan.h' file not found
> #include "../../../third_party/vulkan/SkiaVulkan.h"
>
>
> Original change's description:
> > Reland "Always include public/include headers for vulkan and just guard src files with SK_VULKAN."
> >
> > This reverts commit 684b506f3589ecc78eebe8d92082be31a5fbe348.
> >
> > Reason for revert: Chrome change has landed to fix broken chrome roll.
> >
> > Original change's description:
> > > Revert "Always include public/include headers for vulkan and just guard src files with SK_VULKAN."
> > >
> > > This reverts commit 6e2d607334cc57c22e3a52179743763828ea84b2.
> > >
> > > Reason for revert: chrome roll
> > >
> > > Original change's description:
> > > > Always include public/include headers for vulkan and just guard src files with SK_VULKAN.
> > > >
> > > > This should allow a client to build a skia library that doesn't use vulkan but still
> > > > has all the public headers defined so that they don't have to build two versions of
> > > > their code.
> > > >
> > > > Bug: chromium:862144
> > > > Change-Id: I0eecbe0bc48123619f217e2cf318eb9a8c77ccb2
> > > > Reviewed-on: https://skia-review.googlesource.com/158661
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,cblume@chromium.org
> > >
> > > Change-Id: I76ae6f435333755fa5d546fc1e5999a324b4fd05
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: chromium:862144
> > > Reviewed-on: https://skia-review.googlesource.com/c/159000
> > > Reviewed-by: Mike Klein <mtklein@google.com>
> > > Commit-Queue: Mike Klein <mtklein@google.com>
> >
> > TBR=egdaniel@google.com,mtklein@google.com,bsalomon@google.com,cblume@chromium.org
> >
> > Change-Id: Id019b428f880efbd7ead8dee4178c6190469a290
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: chromium:862144
> > Reviewed-on: https://skia-review.googlesource.com/c/159145
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,mtklein@google.com,bsalomon@google.com,cblume@chromium.org
>
> Change-Id: I0e5c72e2d79dac28021b02168a9e11ac08db765c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:862144
> Reviewed-on: https://skia-review.googlesource.com/c/159155
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>
TBR=egdaniel@google.com,mtklein@google.com,bsalomon@google.com,cblume@chromium.org
Change-Id: I58f7f8ca5281cd5fe0c145c01e9b9465c9b9ec31
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:862144
Reviewed-on: https://skia-review.googlesource.com/159260
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-10-03 18:44:49 +00:00
|
|
|
#ifdef SK_VULKAN
|
2018-04-10 13:34:07 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
const GrVkImageInfo& vkInfo,
|
|
|
|
sk_sp<GrVkImageLayout> layout);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Free and release and resources being held by the GrBackendTexture.
|
|
|
|
void cleanup();
|
|
|
|
|
2018-04-06 13:27:20 +00:00
|
|
|
bool fIsValid;
|
2017-04-18 19:52:36 +00:00
|
|
|
int fWidth; //<! width in pixels
|
|
|
|
int fHeight; //<! height in pixels
|
|
|
|
GrPixelConfig fConfig;
|
2017-10-12 16:27:11 +00:00
|
|
|
GrMipMapped fMipMapped;
|
2018-10-12 13:31:11 +00:00
|
|
|
GrBackendApi fBackend;
|
2017-04-18 19:52:36 +00:00
|
|
|
|
|
|
|
union {
|
2017-06-13 22:16:08 +00:00
|
|
|
GrGLTextureInfo fGLInfo;
|
2018-04-10 13:34:07 +00:00
|
|
|
GrVkBackendSurfaceInfo fVkInfo;
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMtlTextureInfo fMtlInfo;
|
2017-06-14 01:43:29 +00:00
|
|
|
#endif
|
2017-07-07 16:56:11 +00:00
|
|
|
GrMockTextureInfo fMockInfo;
|
2017-04-18 19:52:36 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-07-07 14:34:40 +00:00
|
|
|
class SK_API GrBackendRenderTarget {
|
2017-04-18 19:52:36 +00:00
|
|
|
public:
|
2017-11-16 19:59:48 +00:00
|
|
|
// Creates an invalid backend texture.
|
2018-04-06 13:27:20 +00:00
|
|
|
GrBackendRenderTarget() : fIsValid(false) {}
|
2017-11-16 19:59:48 +00:00
|
|
|
|
2017-12-19 18:15:02 +00:00
|
|
|
// The GrGLTextureInfo must have a valid fFormat.
|
|
|
|
GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
int stencilBits,
|
|
|
|
const GrGLFramebufferInfo& glInfo);
|
|
|
|
|
2018-03-09 17:02:32 +00:00
|
|
|
/** Deprecated, use version that does not take stencil bits. */
|
2017-04-18 19:52:36 +00:00
|
|
|
GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
int stencilBits,
|
2017-06-14 01:43:29 +00:00
|
|
|
const GrVkImageInfo& vkInfo);
|
2018-03-09 17:02:32 +00:00
|
|
|
GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
const GrMtlTextureInfo& mtlInfo);
|
|
|
|
#endif
|
|
|
|
|
2018-03-09 22:02:09 +00:00
|
|
|
GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
int stencilBits,
|
|
|
|
const GrMockRenderTargetInfo& mockInfo);
|
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
~GrBackendRenderTarget();
|
|
|
|
|
|
|
|
GrBackendRenderTarget(const GrBackendRenderTarget& that);
|
|
|
|
GrBackendRenderTarget& operator=(const GrBackendRenderTarget&);
|
|
|
|
|
2017-04-18 19:52:36 +00:00
|
|
|
int width() const { return fWidth; }
|
|
|
|
int height() const { return fHeight; }
|
|
|
|
int sampleCnt() const { return fSampleCnt; }
|
|
|
|
int stencilBits() const { return fStencilBits; }
|
2018-10-12 13:31:11 +00:00
|
|
|
GrBackendApi backend() const {return fBackend; }
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
// If the backend API is GL, copies a snapshot of the GrGLFramebufferInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not GL.
|
|
|
|
bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
|
2017-06-13 17:47:53 +00:00
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
// If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
|
|
|
|
// in pointer and returns true. This snapshot will set the fImageLayout to the current layout
|
|
|
|
// state. Otherwise returns false if the backend API is not Vulkan.
|
|
|
|
bool getVkImageInfo(GrVkImageInfo*) const;
|
|
|
|
|
|
|
|
// Anytime the client changes the VkImageLayout of the VkImage captured by this
|
|
|
|
// GrBackendRenderTarget, they must call this function to notify Skia of the changed layout.
|
|
|
|
void setVkImageLayout(VkImageLayout);
|
2017-06-14 01:43:29 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
// If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Metal.
|
|
|
|
bool getMtlTextureInfo(GrMtlTextureInfo*) const;
|
|
|
|
#endif
|
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
// If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Mock.
|
|
|
|
bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const;
|
2018-03-09 22:02:09 +00:00
|
|
|
|
2017-11-16 19:59:48 +00:00
|
|
|
// Returns true if the backend texture has been initialized.
|
2018-04-06 13:27:20 +00:00
|
|
|
bool isValid() const { return fIsValid; }
|
2017-11-16 19:59:48 +00:00
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
|
|
|
|
#if GR_TEST_UTILS
|
2018-07-03 20:18:29 +00:00
|
|
|
// We can remove the pixelConfig getter and setter once we remove the pixel config from the
|
|
|
|
// GrBackendRenderTarget and plumb the pixel config manually throughout our code (or remove all
|
|
|
|
// use of GrPixelConfig in general).
|
|
|
|
GrPixelConfig pixelConfig() const { return fConfig; }
|
|
|
|
void setPixelConfig(GrPixelConfig config) { fConfig = config; }
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&);
|
|
|
|
#endif
|
2018-02-20 15:25:54 +00:00
|
|
|
|
2017-04-18 19:52:36 +00:00
|
|
|
private:
|
2017-11-13 16:05:52 +00:00
|
|
|
// Friending for access to the GrPixelConfig
|
|
|
|
friend class SkSurface;
|
2017-12-19 18:15:02 +00:00
|
|
|
friend class SkSurface_Gpu;
|
|
|
|
friend class SkImage_Gpu;
|
2017-11-13 16:05:52 +00:00
|
|
|
friend class GrGpu;
|
|
|
|
friend class GrGLGpu;
|
2018-02-20 15:25:54 +00:00
|
|
|
friend class GrProxyProvider;
|
2017-11-13 16:05:52 +00:00
|
|
|
friend class GrVkGpu;
|
2018-06-28 20:37:18 +00:00
|
|
|
friend class GrMtlGpu;
|
2017-11-13 16:05:52 +00:00
|
|
|
GrPixelConfig config() const { return fConfig; }
|
|
|
|
|
2018-04-10 17:46:30 +00:00
|
|
|
// Requires friending of GrVkGpu (done above already)
|
|
|
|
sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
|
|
|
|
|
|
|
|
friend class GrVkRenderTarget;
|
|
|
|
GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo,
|
|
|
|
sk_sp<GrVkImageLayout> layout);
|
|
|
|
|
|
|
|
// Free and release and resources being held by the GrBackendTexture.
|
|
|
|
void cleanup();
|
|
|
|
|
2018-04-06 13:27:20 +00:00
|
|
|
bool fIsValid;
|
2017-04-18 19:52:36 +00:00
|
|
|
int fWidth; //<! width in pixels
|
|
|
|
int fHeight; //<! height in pixels
|
|
|
|
|
|
|
|
int fSampleCnt;
|
|
|
|
int fStencilBits;
|
|
|
|
GrPixelConfig fConfig;
|
|
|
|
|
2018-10-12 13:31:11 +00:00
|
|
|
GrBackendApi fBackend;
|
2017-04-18 19:52:36 +00:00
|
|
|
|
|
|
|
union {
|
2017-06-13 22:16:08 +00:00
|
|
|
GrGLFramebufferInfo fGLInfo;
|
2018-04-10 17:46:30 +00:00
|
|
|
GrVkBackendSurfaceInfo fVkInfo;
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMtlTextureInfo fMtlInfo;
|
2017-06-14 01:43:29 +00:00
|
|
|
#endif
|
2018-03-09 22:02:09 +00:00
|
|
|
GrMockRenderTargetInfo fMockInfo;
|
2017-04-18 19:52:36 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
#endif
|
|
|
|
|