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"
|
2019-06-04 19:58:31 +00:00
|
|
|
#include "include/private/GrGLTypesPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/private/GrVkTypesPriv.h"
|
2018-04-10 13:34:07 +00:00
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
#include "include/gpu/dawn/GrDawnTypes.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-10 13:34:07 +00:00
|
|
|
class GrVkImageLayout;
|
2019-06-04 19:58:31 +00:00
|
|
|
class GrGLTextureParameters;
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
#include "dawn/dawncpp.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
2019-08-01 19:09:17 +00:00
|
|
|
#if GR_TEST_UTILS
|
|
|
|
class SkString;
|
|
|
|
#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
|
|
|
|
|
2019-08-08 16:08:24 +00:00
|
|
|
enum class GrGLFormat;
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
class SK_API GrBackendFormat {
|
|
|
|
public:
|
|
|
|
// Creates an invalid backend format.
|
2019-07-02 20:33:05 +00:00
|
|
|
GrBackendFormat() {}
|
|
|
|
|
|
|
|
GrBackendFormat(const GrBackendFormat& src);
|
2018-02-13 22:03:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
static GrBackendFormat MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo);
|
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
static GrBackendFormat MakeDawn(dawn::TextureFormat format) {
|
|
|
|
return GrBackendFormat(format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
|
|
|
|
return GrBackendFormat(format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-07-11 14:52:43 +00:00
|
|
|
static GrBackendFormat MakeMock(GrColorType colorType) {
|
|
|
|
return GrBackendFormat(colorType);
|
2018-02-13 22:03:00 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-08-08 16:08:24 +00:00
|
|
|
/**
|
|
|
|
* If the backend API is GL this gets the format as a GrGLFormat. Otherwise, returns
|
|
|
|
* GrGLFormat::kUnknown.
|
|
|
|
*/
|
|
|
|
GrGLFormat asGLFormat() const;
|
2018-02-13 22:03:00 +00:00
|
|
|
|
2019-08-08 16:08:24 +00:00
|
|
|
/**
|
|
|
|
* If the backend API is Vulkan this gets the format as a VkFormat and returns true. Otherwise,
|
|
|
|
* returns false.
|
|
|
|
*/
|
|
|
|
bool asVkFormat(VkFormat*) const;
|
2018-02-13 22:03:00 +00:00
|
|
|
|
2018-12-03 15:08:21 +00:00
|
|
|
const GrVkYcbcrConversionInfo* getVkYcbcrConversionInfo() const;
|
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
2019-08-08 16:08:24 +00:00
|
|
|
/**
|
|
|
|
* If the backend API is Dawn this gets the format as a dawn::TextureFormat and returns true.
|
|
|
|
* Otherwise, returns false.
|
|
|
|
*/
|
|
|
|
bool asDawnFormat(dawn::TextureFormat*) const;
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
2019-08-08 16:08:24 +00:00
|
|
|
/**
|
|
|
|
* If the backend API is Metal this gets the format as a GrMtlPixelFormat. Otherwise,
|
|
|
|
* Otherwise, returns MTLPixelFormatInvalid.
|
|
|
|
*/
|
|
|
|
GrMTLPixelFormat asMtlFormat() const;
|
2018-06-28 20:37:18 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-08 16:08:24 +00:00
|
|
|
/**
|
|
|
|
* If the backend API is Mock this gets the format as a GrColorType. Otherwise, returns
|
|
|
|
* GrColorType::kUnknown.
|
|
|
|
*/
|
|
|
|
GrColorType asMockColorType() const;
|
2018-02-13 22:03:00 +00:00
|
|
|
|
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; }
|
|
|
|
|
2019-08-01 19:09:17 +00:00
|
|
|
#if GR_TEST_UTILS
|
|
|
|
SkString toStr() const;
|
|
|
|
#endif
|
|
|
|
|
2018-02-13 22:03:00 +00:00
|
|
|
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
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
GrBackendFormat(dawn::TextureFormat format);
|
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrBackendFormat(const GrMTLPixelFormat mtlFormat);
|
|
|
|
#endif
|
|
|
|
|
2019-07-11 14:52:43 +00:00
|
|
|
GrBackendFormat(GrColorType colorType);
|
2018-02-13 22:03:00 +00:00
|
|
|
|
2019-07-02 20:33:05 +00:00
|
|
|
GrBackendApi fBackend = GrBackendApi::kMock;
|
|
|
|
bool fValid = false;
|
2018-02-13 22:03:00 +00:00
|
|
|
|
|
|
|
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;
|
2019-05-13 14:40:06 +00:00
|
|
|
} fVk;
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
dawn::TextureFormat fDawnFormat;
|
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMTLPixelFormat fMtlFormat;
|
|
|
|
#endif
|
2019-07-11 14:52:43 +00:00
|
|
|
GrColorType fMockColorType;
|
2018-02-13 22:03:00 +00:00
|
|
|
};
|
2019-07-02 20:33:05 +00:00
|
|
|
GrTextureType fTextureType = GrTextureType::kNone;
|
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
|
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
const GrDawnImageInfo& dawnInfo);
|
|
|
|
#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
|
|
|
|
2019-06-04 19:58:31 +00:00
|
|
|
// Call this to indicate that the texture parameters have been modified in the GL context
|
|
|
|
// externally to GrContext.
|
|
|
|
void glTextureParametersModified();
|
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
// If the backend API is Dawn, copies a snapshot of the GrDawnImageInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
|
|
|
|
bool getDawnImageInfo(GrDawnImageInfo*) const;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2019-06-24 14:53:09 +00:00
|
|
|
// Returns true if we are working with protected content.
|
2019-07-18 19:05:11 +00:00
|
|
|
bool isProtected() const;
|
2019-06-24 14:53:09 +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
|
|
|
|
2019-05-24 14:16:35 +00:00
|
|
|
// Returns true if both textures are valid and refer to the same API texture.
|
|
|
|
bool isSameTexture(const GrBackendTexture&);
|
|
|
|
|
2018-04-04 19:54:55 +00:00
|
|
|
#if GR_TEST_UTILS
|
|
|
|
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
|
|
|
|
2019-06-04 19:58:31 +00:00
|
|
|
#ifdef SK_GL
|
|
|
|
friend class GrGLTexture;
|
2019-07-24 19:07:38 +00:00
|
|
|
friend class GrGLGpu; // for getGLTextureParams
|
2019-06-04 19:58:31 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
GrMipMapped,
|
|
|
|
const GrGLTextureInfo,
|
|
|
|
sk_sp<GrGLTextureParameters>);
|
|
|
|
sk_sp<GrGLTextureParameters> getGLTextureParams() const;
|
|
|
|
#endif
|
2018-04-10 13:34:07 +00:00
|
|
|
|
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
|
2019-06-04 19:58:31 +00:00
|
|
|
friend class GrVkTexture;
|
2019-07-24 19:07:38 +00:00
|
|
|
friend class GrVkGpu; // for getGrVkImageLayout
|
2019-06-04 19:58:31 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
const GrVkImageInfo& vkInfo,
|
|
|
|
sk_sp<GrVkImageLayout> layout);
|
|
|
|
sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
|
2018-04-10 13:34:07 +00:00
|
|
|
#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
|
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 {
|
2019-06-04 19:58:31 +00:00
|
|
|
#ifdef SK_GL
|
|
|
|
GrGLBackendTextureInfo fGLInfo;
|
|
|
|
#endif
|
2018-04-10 13:34:07 +00:00
|
|
|
GrVkBackendSurfaceInfo fVkInfo;
|
2019-05-28 03:03:45 +00:00
|
|
|
GrMockTextureInfo fMockInfo;
|
|
|
|
};
|
2019-05-31 13:10:55 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMtlTextureInfo fMtlInfo;
|
|
|
|
#endif
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
GrDawnImageInfo fDawnInfo;
|
|
|
|
#endif
|
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);
|
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
int stencilBits,
|
|
|
|
const GrDawnImageInfo& dawnInfo);
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
// If the backend API is Dawn, copies a snapshot of the GrDawnImageInfo struct into the passed
|
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
|
|
|
|
bool getDawnImageInfo(GrDawnImageInfo*) const;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
2019-06-25 19:59:50 +00:00
|
|
|
// Get the GrBackendFormat for this render target (or an invalid format if this is not valid).
|
|
|
|
GrBackendFormat getBackendFormat() const;
|
|
|
|
|
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
|
|
|
|
2019-06-24 14:53:09 +00:00
|
|
|
// Returns true if we are working with protected content.
|
2019-07-18 19:05:11 +00:00
|
|
|
bool isProtected() const;
|
2019-06-24 14:53: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
|
|
|
|
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:
|
2019-07-24 19:07:38 +00:00
|
|
|
friend class GrVkGpu; // for getGrVkImageLayout
|
2019-07-18 19:05:11 +00:00
|
|
|
sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
|
2018-04-10 17:46:30 +00:00
|
|
|
|
2019-07-18 19:05:11 +00:00
|
|
|
friend class GrVkRenderTarget;
|
|
|
|
GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo,
|
|
|
|
sk_sp<GrVkImageLayout> layout);
|
2018-04-10 17:46:30 +00:00
|
|
|
|
|
|
|
// 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;
|
2019-05-28 03:03:45 +00:00
|
|
|
|
2018-10-12 13:31:11 +00:00
|
|
|
GrBackendApi fBackend;
|
2017-04-18 19:52:36 +00:00
|
|
|
|
|
|
|
union {
|
2019-06-25 19:59:50 +00:00
|
|
|
#ifdef SK_GL
|
2017-06-13 22:16:08 +00:00
|
|
|
GrGLFramebufferInfo fGLInfo;
|
2019-06-25 19:59:50 +00:00
|
|
|
#endif
|
2018-04-10 17:46:30 +00:00
|
|
|
GrVkBackendSurfaceInfo fVkInfo;
|
2019-05-28 03:03:45 +00:00
|
|
|
GrMockRenderTargetInfo fMockInfo;
|
|
|
|
};
|
2019-05-31 13:10:55 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMtlTextureInfo fMtlInfo;
|
|
|
|
#endif
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
GrDawnImageInfo fDawnInfo;
|
|
|
|
#endif
|
2017-04-18 19:52:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
#endif
|
|
|
|
|