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>
diff --git a/BUILD.gn b/BUILD.gn
index 886c275..3e8b240 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1362,8 +1362,8 @@
deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
}
- public_include_dirs += [ "third_party/vulkan" ]
if (skia_use_vulkan) {
+ public_include_dirs += [ "third_party/vulkan" ]
sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") {
diff --git a/include/gpu/GrBackendSemaphore.h b/include/gpu/GrBackendSemaphore.h
index 828cdcb..5c41532 100644
--- a/include/gpu/GrBackendSemaphore.h
+++ b/include/gpu/GrBackendSemaphore.h
@@ -11,7 +11,10 @@
#include "GrTypes.h"
#include "gl/GrGLTypes.h"
+
+#ifdef SK_VULKAN
#include "vk/GrVkTypes.h"
+#endif
/**
* Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object.
@@ -28,15 +31,13 @@
fIsInitialized = true;
}
+#ifdef SK_VULKAN
void initVulkan(VkSemaphore semaphore) {
fBackend = kVulkan_GrBackend;
fVkSemaphore = semaphore;
-#ifdef SK_VULKAN
fIsInitialized = true;
-#else
- fIsInitialized = false;
-#endif
}
+#endif
bool isInitialized() const { return fIsInitialized; }
@@ -47,18 +48,22 @@
return fGLSync;
}
+#ifdef SK_VULKAN
VkSemaphore vkSemaphore() const {
if (!fIsInitialized || kVulkan_GrBackend != fBackend) {
return VK_NULL_HANDLE;
}
return fVkSemaphore;
}
+#endif
private:
GrBackend fBackend;
union {
GrGLsync fGLSync;
+#ifdef SK_VULKAN
VkSemaphore fVkSemaphore;
+#endif
};
bool fIsInitialized;
};
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index e0db0a4..8caebb8 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -11,10 +11,13 @@
#include "GrTypes.h"
#include "gl/GrGLTypes.h"
#include "mock/GrMockTypes.h"
+
+#ifdef SK_VULKAN
#include "vk/GrVkTypes.h"
#include "../private/GrVkTypesPriv.h"
class GrVkImageLayout;
+#endif
#ifdef SK_METAL
#include "mtl/GrMtlTypes.h"
@@ -47,9 +50,11 @@
return GrBackendFormat(format, target);
}
+#ifdef SK_VULKAN
static GrBackendFormat MakeVk(VkFormat format) {
return GrBackendFormat(format);
}
+#endif
#ifdef SK_METAL
static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
@@ -68,9 +73,11 @@
const GrGLenum* getGLFormat() const;
const GrGLenum* getGLTarget() const;
+#ifdef SK_VULKAN
// If the backend API is Vulkan, this returns a pointer to a VkFormat. Otherwise
// it returns nullptr
const VkFormat* getVkFormat() const;
+#endif
#ifdef SK_METAL
// If the backend API is Metal, this returns a pointer to a GrMTLPixelFormat. Otherwise
@@ -88,7 +95,9 @@
private:
GrBackendFormat(GrGLenum format, GrGLenum target);
+#ifdef SK_VULKAN
GrBackendFormat(const VkFormat vkFormat);
+#endif
#ifdef SK_METAL
GrBackendFormat(const GrMTLPixelFormat mtlFormat);
@@ -104,7 +113,9 @@
GrGLenum fTarget; // GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE
GrGLenum fFormat; // the sized, internal format of the GL resource
} fGL;
+#ifdef SK_VULKAN
VkFormat fVkFormat;
+#endif
#ifdef SK_METAL
GrMTLPixelFormat fMtlFormat;
#endif
@@ -123,9 +134,11 @@
GrMipMapped,
const GrGLTextureInfo& glInfo);
+#ifdef SK_VULKAN
GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo);
+#endif
#ifdef SK_METAL
GrBackendTexture(int width,
@@ -154,6 +167,7 @@
// pointer and returns true. Otherwise returns false if the backend API is not GL.
bool getGLTextureInfo(GrGLTextureInfo*) const;
+#ifdef SK_VULKAN
// 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.
@@ -162,6 +176,7 @@
// 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.
void setVkImageLayout(VkImageLayout);
+#endif
#ifdef SK_METAL
// If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
@@ -203,11 +218,11 @@
GrPixelConfig config() const { return fConfig; }
+#ifdef SK_VULKAN
// Requires friending of GrVkGpu (done above already)
sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
friend class GrVkTexture;
-#ifdef SK_VULKAN
GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo,
@@ -226,7 +241,9 @@
union {
GrGLTextureInfo fGLInfo;
+#ifdef SK_VULKAN
GrVkBackendSurfaceInfo fVkInfo;
+#endif
#ifdef SK_METAL
GrMtlTextureInfo fMtlInfo;
#endif
@@ -246,6 +263,7 @@
int stencilBits,
const GrGLFramebufferInfo& glInfo);
+#ifdef SK_VULKAN
/** Deprecated, use version that does not take stencil bits. */
GrBackendRenderTarget(int width,
int height,
@@ -253,6 +271,7 @@
int stencilBits,
const GrVkImageInfo& vkInfo);
GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
+#endif
#ifdef SK_METAL
GrBackendRenderTarget(int width,
@@ -282,6 +301,7 @@
// in pointer and returns true. Otherwise returns false if the backend API is not GL.
bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
+#ifdef SK_VULKAN
// 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.
@@ -290,6 +310,7 @@
// 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);
+#endif
#ifdef SK_METAL
// If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed
@@ -327,12 +348,14 @@
friend class GrMtlGpu;
GrPixelConfig config() const { return fConfig; }
+#ifdef SK_VULKAN
// 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);
+#endif
// Free and release and resources being held by the GrBackendTexture.
void cleanup();
@@ -349,7 +372,9 @@
union {
GrGLFramebufferInfo fGLInfo;
+#ifdef SK_VULKAN
GrVkBackendSurfaceInfo fVkInfo;
+#endif
#ifdef SK_METAL
GrMtlTextureInfo fMtlInfo;
#endif
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 7fd76bc..c22705d 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -63,8 +63,10 @@
static sk_sp<GrContext> MakeGL(const GrContextOptions&);
static sk_sp<GrContext> MakeGL();
+#ifdef SK_VULKAN
static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&, const GrContextOptions&);
static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&);
+#endif
#ifdef SK_METAL
/**
diff --git a/include/gpu/vk/GrVkDefines.h b/include/gpu/vk/GrVkDefines.h
index e8bb63b..d30615e 100644
--- a/include/gpu/vk/GrVkDefines.h
+++ b/include/gpu/vk/GrVkDefines.h
@@ -11,8 +11,12 @@
#include "SkTypes.h"
+#ifdef SK_VULKAN
+
#ifndef VULKAN_H_
#include "../../../third_party/vulkan/SkiaVulkan.h"
#endif
#endif
+
+#endif
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 0e6df50..7e10cb2 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -39,13 +39,10 @@
return nullptr;
}
+#ifdef SK_VULKAN
GrBackendFormat::GrBackendFormat(VkFormat vkFormat)
: fBackend(kVulkan_GrBackend)
-#ifdef SK_VULKAN
, fValid(true)
-#else
- ,fValid(false)
-#endif
, fVkFormat(vkFormat) {
}
@@ -55,6 +52,7 @@
}
return nullptr;
}
+#endif
#ifdef SK_METAL
GrBackendFormat::GrBackendFormat(GrMTLPixelFormat mtlFormat)
@@ -84,17 +82,13 @@
return nullptr;
}
+#ifdef SK_VULKAN
GrBackendTexture::GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo)
-#ifdef SK_VULKAN
: GrBackendTexture(width, height, vkInfo,
sk_sp<GrVkImageLayout>(new GrVkImageLayout(vkInfo.fImageLayout))) {}
-#else
- : fIsValid(false) {}
-#endif
-#ifdef SK_VULKAN
GrBackendTexture::GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo,
@@ -179,11 +173,11 @@
case kOpenGL_GrBackend:
fGLInfo = that.fGLInfo;
break;
- case kVulkan_GrBackend:
#ifdef SK_VULKAN
+ case kVulkan_GrBackend:
fVkInfo.assign(that.fVkInfo, this->isValid());
-#endif
break;
+#endif
#ifdef SK_METAL
case kMetal_GrBackend:
fMtlInfo = that.fMtlInfo;
@@ -199,39 +193,28 @@
return *this;
}
-bool GrBackendTexture::getVkImageInfo(GrVkImageInfo* outInfo) const {
#ifdef SK_VULKAN
+bool GrBackendTexture::getVkImageInfo(GrVkImageInfo* outInfo) const {
if (this->isValid() && kVulkan_GrBackend == fBackend) {
*outInfo = fVkInfo.snapImageInfo();
return true;
}
-#endif
return false;
}
void GrBackendTexture::setVkImageLayout(VkImageLayout layout) {
-#ifdef SK_VULKAN
if (this->isValid() && kVulkan_GrBackend == fBackend) {
fVkInfo.setImageLayout(layout);
}
-#endif
}
-// We need a stubbed version of GrVkImageLayout for non vulkan builds
-#ifndef SK_VULKAN
-class GrVkImageLayout : public SkRefCnt {
- GrVkImageLayout(VkImageLayout layout) {}
-};
-#endif
-
sk_sp<GrVkImageLayout> GrBackendTexture::getGrVkImageLayout() const {
-#ifdef SK_VULKAN
if (this->isValid() && kVulkan_GrBackend == fBackend) {
return fVkInfo.getGrVkImageLayout();
}
-#endif
return nullptr;
}
+#endif
#ifdef SK_METAL
bool GrBackendTexture::getMtlTextureInfo(GrMtlTextureInfo* outInfo) const {
@@ -301,6 +284,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef SK_VULKAN
GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
int sampleCnt,
@@ -315,14 +299,9 @@
int height,
int sampleCnt,
const GrVkImageInfo& vkInfo)
-#ifdef SK_VULKAN
: GrBackendRenderTarget(width, height, sampleCnt, vkInfo,
sk_sp<GrVkImageLayout>(new GrVkImageLayout(vkInfo.fImageLayout))) {}
-#else
- : fIsValid(false) {}
-#endif
-#ifdef SK_VULKAN
GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
int sampleCnt,
@@ -413,11 +392,11 @@
case kOpenGL_GrBackend:
fGLInfo = that.fGLInfo;
break;
- case kVulkan_GrBackend:
#ifdef SK_VULKAN
+ case kVulkan_GrBackend:
fVkInfo.assign(that.fVkInfo, this->isValid());
-#endif
break;
+#endif
#ifdef SK_METAL
case kMetal_GrBackend:
fMtlInfo = that.fMtlInfo;
@@ -433,32 +412,28 @@
return *this;
}
-bool GrBackendRenderTarget::getVkImageInfo(GrVkImageInfo* outInfo) const {
#ifdef SK_VULKAN
+bool GrBackendRenderTarget::getVkImageInfo(GrVkImageInfo* outInfo) const {
if (this->isValid() && kVulkan_GrBackend == fBackend) {
*outInfo = fVkInfo.snapImageInfo();
return true;
}
-#endif
return false;
}
void GrBackendRenderTarget::setVkImageLayout(VkImageLayout layout) {
-#ifdef SK_VULKAN
if (this->isValid() && kVulkan_GrBackend == fBackend) {
fVkInfo.setImageLayout(layout);
}
-#endif
}
sk_sp<GrVkImageLayout> GrBackendRenderTarget::getGrVkImageLayout() const {
-#ifdef SK_VULKAN
if (this->isValid() && kVulkan_GrBackend == fBackend) {
return fVkInfo.getGrVkImageLayout();
}
-#endif
return nullptr;
}
+#endif
#ifdef SK_METAL
bool GrBackendRenderTarget::getMtlTextureInfo(GrMtlTextureInfo* outInfo) const {
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index 59b984c..14133cd 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -147,19 +147,14 @@
return context;
}
-sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext) {
#ifdef SK_VULKAN
+sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext) {
GrContextOptions defaultOptions;
return MakeVulkan(backendContext, defaultOptions);
-#else
- return nullptr;
-#endif
}
sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext,
const GrContextOptions& options) {
-#ifdef SK_VULKAN
- GrContextOptions defaultOptions;
sk_sp<GrContext> context(new GrDirectContext(kVulkan_GrBackend));
context->fGpu = GrVkGpu::Make(backendContext, options, context.get());
@@ -172,10 +167,8 @@
return nullptr;
}
return context;
-#else
- return nullptr;
-#endif
}
+#endif
#ifdef SK_METAL
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {