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>
diff --git a/BUILD.gn b/BUILD.gn
index 3e8b240..886c275 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 5c41532..828cdcb 100644
--- a/include/gpu/GrBackendSemaphore.h
+++ b/include/gpu/GrBackendSemaphore.h
@@ -11,10 +11,7 @@
 #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.
@@ -31,13 +28,15 @@
         fIsInitialized = true;
     }
 
-#ifdef SK_VULKAN
     void initVulkan(VkSemaphore semaphore) {
         fBackend = kVulkan_GrBackend;
         fVkSemaphore = semaphore;
+#ifdef SK_VULKAN
         fIsInitialized = true;
-    }
+#else
+        fIsInitialized = false;
 #endif
+    }
 
     bool isInitialized() const { return fIsInitialized; }
 
@@ -48,22 +47,18 @@
         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 8caebb8..e0db0a4 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -11,13 +11,10 @@
 #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"
@@ -50,11 +47,9 @@
         return GrBackendFormat(format, target);
     }
 
-#ifdef SK_VULKAN
     static GrBackendFormat MakeVk(VkFormat format) {
         return GrBackendFormat(format);
     }
-#endif
 
 #ifdef SK_METAL
     static GrBackendFormat MakeMtl(GrMTLPixelFormat format) {
@@ -73,11 +68,9 @@
     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
@@ -95,9 +88,7 @@
 private:
     GrBackendFormat(GrGLenum format, GrGLenum target);
 
-#ifdef SK_VULKAN
     GrBackendFormat(const VkFormat vkFormat);
-#endif
 
 #ifdef SK_METAL
     GrBackendFormat(const GrMTLPixelFormat mtlFormat);
@@ -113,9 +104,7 @@
             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
@@ -134,11 +123,9 @@
                      GrMipMapped,
                      const GrGLTextureInfo& glInfo);
 
-#ifdef SK_VULKAN
     GrBackendTexture(int width,
                      int height,
                      const GrVkImageInfo& vkInfo);
-#endif
 
 #ifdef SK_METAL
     GrBackendTexture(int width,
@@ -167,7 +154,6 @@
     // 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.
@@ -176,7 +162,6 @@
     // 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
@@ -218,11 +203,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,
@@ -241,9 +226,7 @@
 
     union {
         GrGLTextureInfo fGLInfo;
-#ifdef SK_VULKAN
         GrVkBackendSurfaceInfo fVkInfo;
-#endif
 #ifdef SK_METAL
         GrMtlTextureInfo fMtlInfo;
 #endif
@@ -263,7 +246,6 @@
                           int stencilBits,
                           const GrGLFramebufferInfo& glInfo);
 
-#ifdef SK_VULKAN
     /** Deprecated, use version that does not take stencil bits. */
     GrBackendRenderTarget(int width,
                           int height,
@@ -271,7 +253,6 @@
                           int stencilBits,
                           const GrVkImageInfo& vkInfo);
     GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo);
-#endif
 
 #ifdef SK_METAL
     GrBackendRenderTarget(int width,
@@ -301,7 +282,6 @@
     // 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.
@@ -310,7 +290,6 @@
     // 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
@@ -348,14 +327,12 @@
     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();
@@ -372,9 +349,7 @@
 
     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 a85a6d5..6258c50 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -63,10 +63,8 @@
     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 d30615e..e8bb63b 100644
--- a/include/gpu/vk/GrVkDefines.h
+++ b/include/gpu/vk/GrVkDefines.h
@@ -11,12 +11,8 @@
 
 #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 7e10cb2..0e6df50 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -39,10 +39,13 @@
     return nullptr;
 }
 
-#ifdef SK_VULKAN
 GrBackendFormat::GrBackendFormat(VkFormat vkFormat)
         : fBackend(kVulkan_GrBackend)
+#ifdef SK_VULKAN
         , fValid(true)
+#else
+        ,fValid(false)
+#endif
         , fVkFormat(vkFormat) {
 }
 
@@ -52,7 +55,6 @@
     }
     return nullptr;
 }
-#endif
 
 #ifdef SK_METAL
 GrBackendFormat::GrBackendFormat(GrMTLPixelFormat mtlFormat)
@@ -82,13 +84,17 @@
     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,
@@ -173,11 +179,11 @@
         case kOpenGL_GrBackend:
             fGLInfo = that.fGLInfo;
             break;
-#ifdef SK_VULKAN
         case kVulkan_GrBackend:
+#ifdef SK_VULKAN
             fVkInfo.assign(that.fVkInfo, this->isValid());
-            break;
 #endif
+            break;
 #ifdef SK_METAL
         case kMetal_GrBackend:
             fMtlInfo = that.fMtlInfo;
@@ -193,28 +199,39 @@
     return *this;
 }
 
-#ifdef SK_VULKAN
 bool GrBackendTexture::getVkImageInfo(GrVkImageInfo* outInfo) const {
+#ifdef SK_VULKAN
     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 {
@@ -284,7 +301,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-#ifdef SK_VULKAN
 GrBackendRenderTarget::GrBackendRenderTarget(int width,
                                              int height,
                                              int sampleCnt,
@@ -299,9 +315,14 @@
                                              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,
@@ -392,11 +413,11 @@
         case kOpenGL_GrBackend:
             fGLInfo = that.fGLInfo;
             break;
-#ifdef SK_VULKAN
         case kVulkan_GrBackend:
+#ifdef SK_VULKAN
             fVkInfo.assign(that.fVkInfo, this->isValid());
-            break;
 #endif
+            break;
 #ifdef SK_METAL
         case kMetal_GrBackend:
             fMtlInfo = that.fMtlInfo;
@@ -412,28 +433,32 @@
     return *this;
 }
 
-#ifdef SK_VULKAN
 bool GrBackendRenderTarget::getVkImageInfo(GrVkImageInfo* outInfo) const {
+#ifdef SK_VULKAN
     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 14133cd..59b984c 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -147,14 +147,19 @@
     return context;
 }
 
-#ifdef SK_VULKAN
 sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext) {
+#ifdef SK_VULKAN
     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());
@@ -167,8 +172,10 @@
         return nullptr;
     }
     return context;
-}
+#else
+    return nullptr;
 #endif
+}
 
 #ifdef SK_METAL
 sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {