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
|
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
#include "include/gpu/GrBackendSurfaceMutableState.h"
|
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
|
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
class GrBackendSurfaceMutableStateImpl;
|
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
|
2019-12-04 14:57:48 +00:00
|
|
|
#include "dawn/webgpu_cpp.h"
|
2019-07-18 15:43:45 +00:00
|
|
|
#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
|
|
|
|
|
2020-02-27 20:48:24 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
2020-03-31 15:34:00 +00:00
|
|
|
#include "include/gpu/d3d/GrD3DTypesMinimal.h"
|
2020-03-20 15:23:39 +00:00
|
|
|
#include "include/private/GrD3DTypesPriv.h"
|
|
|
|
class GrD3DResourceState;
|
2020-02-27 20:48:24 +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
|
|
|
|
|
2020-02-13 18:24:47 +00:00
|
|
|
// SkSurfaceCharacterization always needs a minimal version of this
|
|
|
|
class SK_API GrBackendFormat {
|
|
|
|
public:
|
|
|
|
bool isValid() const { return false; }
|
|
|
|
};
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
// 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; }
|
2020-01-16 23:19:54 +00:00
|
|
|
bool isFramebufferOnly() const { return false; }
|
2018-04-05 13:30:38 +00:00
|
|
|
};
|
|
|
|
#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() {}
|
2020-03-23 21:22:24 +00:00
|
|
|
GrBackendFormat(const GrBackendFormat&);
|
|
|
|
GrBackendFormat& operator=(const GrBackendFormat&);
|
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
|
2019-10-30 13:56:23 +00:00
|
|
|
static GrBackendFormat MakeDawn(wgpu::TextureFormat format) {
|
2019-07-18 15:43:45 +00:00
|
|
|
return GrBackendFormat(format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
|
|
|
|
return GrBackendFormat(format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-02-27 20:48:24 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
static GrBackendFormat MakeDxgi(DXGI_FORMAT format) {
|
|
|
|
return GrBackendFormat(format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-12-10 19:48:36 +00:00
|
|
|
static GrBackendFormat MakeMock(GrColorType colorType, SkImage::CompressionType compression);
|
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
|
|
|
|
2020-03-26 20:45:05 +00:00
|
|
|
/**
|
|
|
|
* Gets the channels present in the format as a bitfield of SkColorChannelFlag values.
|
|
|
|
* Luminance channels are reported as kGray_SkColorChannelFlag.
|
|
|
|
*/
|
|
|
|
uint32_t channelMask() const;
|
|
|
|
|
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
|
|
|
/**
|
2019-10-30 13:56:23 +00:00
|
|
|
* If the backend API is Dawn this gets the format as a wgpu::TextureFormat and returns true.
|
2019-08-08 16:08:24 +00:00
|
|
|
* Otherwise, returns false.
|
|
|
|
*/
|
2019-10-30 13:56:23 +00:00
|
|
|
bool asDawnFormat(wgpu::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
|
|
|
|
|
2020-02-27 20:48:24 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
/**
|
|
|
|
* If the backend API is Direct3D this gets the format as a DXGI_FORMAT and returns true.
|
|
|
|
* Otherwise, returns false.
|
|
|
|
*/
|
2020-02-28 14:34:07 +00:00
|
|
|
bool asDxgiFormat(DXGI_FORMAT*) const;
|
2020-02-27 20:48:24 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-08 16:08:24 +00:00
|
|
|
/**
|
2019-12-10 19:48:36 +00:00
|
|
|
* If the backend API is not Mock these two calls will return kUnknown and kNone, respectively.
|
|
|
|
* Otherwise, if the compression type is kNone then the GrColorType will be valid. If the
|
|
|
|
* compression type is anything other then kNone than the GrColorType will be kUnknown.
|
2019-08-08 16:08:24 +00:00
|
|
|
*/
|
|
|
|
GrColorType asMockColorType() const;
|
2019-12-10 19:48:36 +00:00
|
|
|
SkImage::CompressionType asMockCompressionType() 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
|
2019-10-30 13:56:23 +00:00
|
|
|
GrBackendFormat(wgpu::TextureFormat format);
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrBackendFormat(const GrMTLPixelFormat mtlFormat);
|
|
|
|
#endif
|
|
|
|
|
2020-02-27 20:48:24 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
GrBackendFormat(DXGI_FORMAT dxgiFormat);
|
|
|
|
#endif
|
|
|
|
|
2019-12-10 19:48:36 +00:00
|
|
|
GrBackendFormat(GrColorType, SkImage::CompressionType);
|
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
|
2019-10-30 13:56:23 +00:00
|
|
|
wgpu::TextureFormat fDawnFormat;
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrMTLPixelFormat fMtlFormat;
|
|
|
|
#endif
|
2020-02-27 20:48:24 +00:00
|
|
|
|
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
DXGI_FORMAT fDxgiFormat;
|
|
|
|
#endif
|
2019-12-10 19:48:36 +00:00
|
|
|
struct {
|
|
|
|
GrColorType fColorType;
|
|
|
|
SkImage::CompressionType fCompressionType;
|
|
|
|
} fMock;
|
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.
|
2020-05-29 16:11:05 +00:00
|
|
|
GrBackendTexture();
|
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,
|
2020-07-21 13:27:25 +00:00
|
|
|
GrMipmapped,
|
2017-12-04 16:23:19 +00:00
|
|
|
const GrGLTextureInfo& glInfo);
|
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
#ifdef SK_VULKAN
|
2017-04-18 19:52:36 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2017-06-14 01:43:29 +00:00
|
|
|
const GrVkImageInfo& vkInfo);
|
2020-05-29 16:11:05 +00:00
|
|
|
#endif
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-06-28 20:37:18 +00:00
|
|
|
#ifdef SK_METAL
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2020-07-21 13:27:25 +00:00
|
|
|
GrMipmapped,
|
2018-06-28 20:37:18 +00:00
|
|
|
const GrMtlTextureInfo& mtlInfo);
|
|
|
|
#endif
|
|
|
|
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2020-03-26 15:47:26 +00:00
|
|
|
const GrD3DTextureResourceInfo& d3dInfo);
|
2020-03-20 15:23:39 +00:00
|
|
|
#endif
|
|
|
|
|
2019-07-18 15:43:45 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2020-01-28 17:39:45 +00:00
|
|
|
const GrDawnTextureInfo& dawnInfo);
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-07 16:56:11 +00:00
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2020-07-21 13:27:25 +00:00
|
|
|
GrMipmapped,
|
2017-10-12 16:27:11 +00:00
|
|
|
const GrMockTextureInfo& mockInfo);
|
|
|
|
|
2018-04-10 13:34:07 +00:00
|
|
|
GrBackendTexture(const GrBackendTexture& that);
|
|
|
|
|
|
|
|
~GrBackendTexture();
|
|
|
|
|
|
|
|
GrBackendTexture& operator=(const GrBackendTexture& that);
|
|
|
|
|
2020-02-07 19:17:25 +00:00
|
|
|
SkISize dimensions() const { return {fWidth, fHeight}; }
|
2017-04-18 19:52:36 +00:00
|
|
|
int width() const { return fWidth; }
|
|
|
|
int height() const { return fHeight; }
|
2020-07-21 14:32:07 +00:00
|
|
|
bool hasMipmaps() const { return fMipmapped == GrMipmapped::kYes; }
|
|
|
|
/** deprecated alias of hasMipmaps(). */
|
|
|
|
bool hasMipMaps() const { return this->hasMipmaps(); }
|
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
|
2020-01-28 17:39:45 +00:00
|
|
|
// If the backend API is Dawn, copies a snapshot of the GrDawnTextureInfo struct into the passed
|
2019-07-18 15:43:45 +00:00
|
|
|
// in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
|
2020-01-28 17:39:45 +00:00
|
|
|
bool getDawnTextureInfo(GrDawnTextureInfo*) const;
|
2019-07-18 15:43:45 +00:00
|
|
|
#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
|
|
|
|
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
2020-03-26 15:47:26 +00:00
|
|
|
// If the backend API is Direct3D, copies a snapshot of the GrD3DTextureResourceInfo struct into
|
|
|
|
// the passed in pointer and returns true. This snapshot will set the fResourceState to the
|
|
|
|
// current resource state. Otherwise returns false if the backend API is not D3D.
|
|
|
|
bool getD3DTextureResourceInfo(GrD3DTextureResourceInfo*) const;
|
2020-03-20 15:23:39 +00:00
|
|
|
|
|
|
|
// Anytime the client changes the D3D12_RESOURCE_STATES of the D3D12_RESOURCE captured by this
|
|
|
|
// GrBackendTexture, they must call this function to notify Skia of the changed layout.
|
|
|
|
void setD3DResourceState(GrD3DResourceStateEnum);
|
|
|
|
#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
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
// If the client changes any of the mutable backend of the GrBackendTexture they should call
|
|
|
|
// this function to inform Skia that those values have changed. The backend API specific state
|
|
|
|
// that can be set from this function are:
|
|
|
|
//
|
|
|
|
// Vulkan: VkImageLayout and QueueFamilyIndex
|
|
|
|
void setMutableState(const GrBackendSurfaceMutableState&);
|
|
|
|
|
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:
|
2020-05-29 16:11:05 +00:00
|
|
|
friend class GrVkGpu; // for getMutableState
|
|
|
|
sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState() const;
|
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,
|
2020-07-21 13:27:25 +00:00
|
|
|
GrMipmapped,
|
2019-06-04 19:58:31 +00:00
|
|
|
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;
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
const GrVkImageInfo& vkInfo,
|
2020-05-29 16:11:05 +00:00
|
|
|
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState);
|
2018-04-10 13:34:07 +00:00
|
|
|
#endif
|
|
|
|
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
friend class GrD3DTexture;
|
|
|
|
friend class GrD3DGpu; // for getGrD3DResourceState
|
|
|
|
GrBackendTexture(int width,
|
|
|
|
int height,
|
2020-03-26 15:47:26 +00:00
|
|
|
const GrD3DTextureResourceInfo& vkInfo,
|
2020-03-20 15:23:39 +00:00
|
|
|
sk_sp<GrD3DResourceState> state);
|
|
|
|
sk_sp<GrD3DResourceState> getGrD3DResourceState() const;
|
|
|
|
#endif
|
|
|
|
|
2018-04-10 13:34:07 +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
|
2020-07-21 14:32:07 +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;
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
GrD3DBackendSurfaceInfo fD3DInfo;
|
|
|
|
#endif
|
2019-05-28 03:03:45 +00:00
|
|
|
};
|
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
|
2020-01-28 17:39:45 +00:00
|
|
|
GrDawnTextureInfo fDawnInfo;
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
2020-05-29 16:11:05 +00:00
|
|
|
|
|
|
|
sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState;
|
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.
|
2020-05-29 16:11:05 +00:00
|
|
|
GrBackendRenderTarget();
|
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,
|
2020-01-28 17:39:45 +00:00
|
|
|
const GrDawnRenderTargetInfo& dawnInfo);
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
#ifdef SK_VULKAN
|
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);
|
2020-05-29 16:11:05 +00:00
|
|
|
#endif
|
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
|
|
|
|
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
2020-03-26 15:47:26 +00:00
|
|
|
const GrD3DTextureResourceInfo& d3dInfo);
|
2020-03-20 15:23:39 +00:00
|
|
|
#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&);
|
|
|
|
|
2020-02-07 19:17:25 +00:00
|
|
|
SkISize dimensions() const { return {fWidth, fHeight}; }
|
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; }
|
2020-01-16 23:19:54 +00:00
|
|
|
bool isFramebufferOnly() const { return fFramebufferOnly; }
|
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
|
2020-01-28 17:39:45 +00:00
|
|
|
// If the backend API is Dawn, copies a snapshot of the GrDawnRenderTargetInfo struct into the
|
|
|
|
// passed-in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
|
|
|
|
bool getDawnRenderTargetInfo(GrDawnRenderTargetInfo*) const;
|
2019-07-18 15:43:45 +00:00
|
|
|
#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
|
|
|
|
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
// If the backend API is Direct3D, copies a snapshot of the GrMtlTextureInfo struct into the
|
|
|
|
// passed in pointer and returns true. Otherwise returns false if the backend API is not D3D.
|
2020-03-30 19:00:39 +00:00
|
|
|
bool getD3DTextureResourceInfo(GrD3DTextureResourceInfo*) const;
|
2020-03-20 15:23:39 +00:00
|
|
|
|
|
|
|
// Anytime the client changes the D3D12_RESOURCE_STATES of the D3D12_RESOURCE captured by this
|
|
|
|
// GrBackendTexture, they must call this function to notify Skia of the changed layout.
|
|
|
|
void setD3DResourceState(GrD3DResourceStateEnum);
|
|
|
|
#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
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
// If the client changes any of the mutable backend of the GrBackendTexture they should call
|
|
|
|
// this function to inform Skia that those values have changed. The backend API specific state
|
|
|
|
// that can be set from this function are:
|
|
|
|
//
|
|
|
|
// Vulkan: VkImageLayout and QueueFamilyIndex
|
|
|
|
void setMutableState(const GrBackendSurfaceMutableState&);
|
|
|
|
|
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:
|
2020-05-29 16:11:05 +00:00
|
|
|
friend class GrVkGpu; // for getMutableState
|
|
|
|
sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState() const;
|
2018-04-10 17:46:30 +00:00
|
|
|
|
2020-05-29 16:11:05 +00:00
|
|
|
#ifdef SK_VULKAN
|
2019-07-18 19:05:11 +00:00
|
|
|
friend class GrVkRenderTarget;
|
|
|
|
GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo,
|
2020-05-29 16:11:05 +00:00
|
|
|
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState);
|
|
|
|
#endif
|
|
|
|
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
2020-03-26 19:33:02 +00:00
|
|
|
friend class GrD3DGpu;
|
|
|
|
friend class GrD3DRenderTarget;
|
2020-03-26 15:47:26 +00:00
|
|
|
GrBackendRenderTarget(int width, int height, int sampleCnt,
|
|
|
|
const GrD3DTextureResourceInfo& d3dInfo, sk_sp<GrD3DResourceState> state);
|
2020-03-20 15:23:39 +00:00
|
|
|
sk_sp<GrD3DResourceState> getGrD3DResourceState() const;
|
|
|
|
#endif
|
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;
|
2020-01-16 23:19:54 +00:00
|
|
|
bool fFramebufferOnly = false;
|
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;
|
2020-03-20 15:23:39 +00:00
|
|
|
#ifdef SK_DIRECT3D
|
|
|
|
GrD3DBackendSurfaceInfo fD3DInfo;
|
|
|
|
#endif
|
2019-05-28 03:03:45 +00:00
|
|
|
};
|
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
|
2020-01-28 17:39:45 +00:00
|
|
|
GrDawnRenderTargetInfo fDawnInfo;
|
2019-07-18 15:43:45 +00:00
|
|
|
#endif
|
2020-05-29 16:11:05 +00:00
|
|
|
sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState;
|
2017-04-18 19:52:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-04-05 13:30:38 +00:00
|
|
|
#endif
|
|
|
|
|