aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-06-13 13:47:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-13 18:50:03 +0000
commitc0f8e426c59eec6c720b8e1329dcb966cf1b6800 (patch)
tree78aa6ac1eb1196c0a9b86c5f20d893d004456130
parent3809bab7ed344ad140346c38e149dabf10bd525f (diff)
Update skia to use ifdefs for Vulkan code instead of dummy header
Bug: skia:6721 Change-Id: I80a4c9f2acc09c174497f625c50ed12a8bb76505 Reviewed-on: https://skia-review.googlesource.com/19547 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
-rw-r--r--BUILD.gn14
-rwxr-xr-xgn/find_headers.py6
-rw-r--r--include/gpu/GrBackendSurface.h47
-rw-r--r--include/gpu/vk/GrVkDefines.h4
-rw-r--r--src/gpu/GrBackendSurface.cpp24
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp11
-rw-r--r--src/image/SkImage_Gpu.cpp12
-rw-r--r--tools/gpu/GrTest.cpp11
8 files changed, 71 insertions, 58 deletions
diff --git a/BUILD.gn b/BUILD.gn
index bb355c67c2..e3f87bce65 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -55,17 +55,14 @@ declare_args() {
}
}
declare_args() {
+ skia_vulkan_headers = ""
if (skia_use_vulkan) {
+ # When buliding on Android we get the header via the NDK so no need for any extra path.
if (is_fuchsia) {
skia_vulkan_headers = "$fuchsia_vulkan_sdk/include"
} else if (is_linux || is_win) {
skia_vulkan_headers = "$skia_vulkan_sdk/include"
- } else {
- # When buliding on Android we get the header via the NDK
- skia_vulkan_headers = ""
}
- } else {
- skia_vulkan_headers = "third_party/vulkan"
}
}
@@ -91,6 +88,10 @@ skia_public_includes = [
"include/utils/mac",
]
+if (skia_use_vulkan) {
+ skia_public_includes += [ "include/gpu/vk" ]
+}
+
# Skia public API, generally provided by :skia.
config("skia_public") {
include_dirs = skia_public_includes
@@ -748,8 +749,7 @@ if (skia_enable_tools) {
skia_h = "$target_gen_dir/skia.h"
script = "gn/find_headers.py"
args = [ rebase_path(skia_h, root_build_dir) ] +
- rebase_path(skia_public_includes) +
- [ rebase_path("third_party/vulkan") ]
+ rebase_path(skia_public_includes)
depfile = "$skia_h.deps"
outputs = [
skia_h,
diff --git a/gn/find_headers.py b/gn/find_headers.py
index 8cff31d697..1baca2fab4 100755
--- a/gn/find_headers.py
+++ b/gn/find_headers.py
@@ -24,10 +24,10 @@ blacklist = {
headers = []
for directory in include_dirs:
- for d, _, files in os.walk(directory):
- for f in files:
+ for f in os.listdir(directory):
+ if os.path.isfile(os.path.join(directory, f)):
if f.endswith('.h') and f not in blacklist:
- headers.append(os.path.join(d,f))
+ headers.append(os.path.join(directory,f))
headers.sort()
with open(skia_h, "w") as f:
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 232f220282..60a9eb5009 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -10,32 +10,39 @@
#include "GrTypes.h"
#include "gl/GrGLTypes.h"
+
+#ifdef SK_VULKAN
#include "vk/GrVkTypes.h"
+#endif
class GrBackendTexture {
public:
GrBackendTexture(int width,
int height,
- const GrVkImageInfo& vkInfo);
+ GrPixelConfig config,
+ const GrGLTextureInfo& glInfo);
+#ifdef SK_VULKAN
GrBackendTexture(int width,
int height,
- GrPixelConfig config,
- const GrGLTextureInfo& glInfo);
+ const GrVkImageInfo& vkInfo);
+#endif
int width() const { return fWidth; }
int height() const { return fHeight; }
GrPixelConfig config() const { return fConfig; }
GrBackend backend() const {return fBackend; }
- // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
- // it returns nullptr.
- const GrVkImageInfo* getVkImageInfo() const;
-
// If the backend API is GL, this returns a pointer to the GrGLTextureInfo struct. Otherwise
// it returns nullptr.
const GrGLTextureInfo* getGLTextureInfo() const;
+#ifdef SK_VULKAN
+ // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
+ // it returns nullptr.
+ const GrVkImageInfo* getVkImageInfo() const;
+#endif
+
private:
// Temporary constructor which can be used to convert from a GrBackendTextureDesc.
GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend backend);
@@ -50,8 +57,10 @@ private:
GrBackend fBackend;
union {
- GrVkImageInfo fVkInfo;
GrGLTextureInfo fGLInfo;
+#ifdef SK_VULKAN
+ GrVkImageInfo fVkInfo;
+#endif
};
};
@@ -61,14 +70,16 @@ public:
int height,
int sampleCnt,
int stencilBits,
- const GrVkImageInfo& vkInfo);
+ GrPixelConfig config,
+ const GrGLFramebufferInfo& glInfo);
+#ifdef SK_VULKAN
GrBackendRenderTarget(int width,
int height,
int sampleCnt,
int stencilBits,
- GrPixelConfig config,
- const GrGLFramebufferInfo& glInfo);
+ const GrVkImageInfo& vkInfo);
+#endif
int width() const { return fWidth; }
int height() const { return fHeight; }
@@ -77,14 +88,16 @@ public:
GrPixelConfig config() const { return fConfig; }
GrBackend backend() const {return fBackend; }
- // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
- // it returns nullptr
- const GrVkImageInfo* getVkImageInfo() const;
-
// If the backend API is GL, this returns a pointer to the GrGLFramebufferInfo struct. Otherwise
// it returns nullptr.
const GrGLFramebufferInfo* getGLFramebufferInfo() const;
+#ifdef SK_VULKAN
+ // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
+ // it returns nullptr
+ const GrVkImageInfo* getVkImageInfo() const;
+#endif
+
private:
// Temporary constructor which can be used to convert from a GrBackendRenderTargetDesc.
GrBackendRenderTarget(const GrBackendRenderTargetDesc& desc, GrBackend backend);
@@ -102,8 +115,10 @@ private:
GrBackend fBackend;
union {
- GrVkImageInfo fVkInfo;
GrGLFramebufferInfo fGLInfo;
+#ifdef SK_VULKAN
+ GrVkImageInfo fVkInfo;
+#endif
};
};
diff --git a/include/gpu/vk/GrVkDefines.h b/include/gpu/vk/GrVkDefines.h
index 7defed2ad5..0bc6fb0343 100644
--- a/include/gpu/vk/GrVkDefines.h
+++ b/include/gpu/vk/GrVkDefines.h
@@ -31,8 +31,6 @@
# endif
#endif
-#endif
-
#include <vulkan/vulkan.h>
#define SKIA_REQUIRED_VULKAN_HEADER_VERSION 17
@@ -41,3 +39,5 @@
#endif
#endif
+
+#endif
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 63044759d4..6c715228b2 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -12,20 +12,16 @@
#include "vk/GrVkUtil.h"
#endif
+#ifdef SK_VULKAN
GrBackendTexture::GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo)
: fWidth(width)
, fHeight(height)
- , fConfig(
-#ifdef SK_VULKAN
- GrVkFormatToPixelConfig(vkInfo.fFormat)
-#else
- kUnknown_GrPixelConfig
-#endif
- )
+ , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fBackend(kVulkan_GrBackend)
, fVkInfo(vkInfo) {}
+#endif
GrBackendTexture::GrBackendTexture(int width,
int height,
@@ -57,12 +53,14 @@ GrBackendTexture::GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend b
}
}
+#ifdef SK_VULKAN
const GrVkImageInfo* GrBackendTexture::getVkImageInfo() const {
if (kVulkan_GrBackend == fBackend) {
return &fVkInfo;
}
return nullptr;
}
+#endif
const GrGLTextureInfo* GrBackendTexture::getGLTextureInfo() const {
if (kOpenGL_GrBackend == fBackend) {
@@ -73,6 +71,7 @@ const GrGLTextureInfo* GrBackendTexture::getGLTextureInfo() const {
////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef SK_VULKAN
GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
int sampleCnt,
@@ -82,15 +81,10 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
, fHeight(height)
, fSampleCnt(sampleCnt)
, fStencilBits(stencilBits)
- , fConfig(
-#ifdef SK_VULKAN
- GrVkFormatToPixelConfig(vkInfo.fFormat)
-#else
- kUnknown_GrPixelConfig
-#endif
- )
+ , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fBackend(kVulkan_GrBackend)
, fVkInfo(vkInfo) {}
+#endif
GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
@@ -129,12 +123,14 @@ GrBackendRenderTarget::GrBackendRenderTarget(const GrBackendRenderTargetDesc& de
}
}
+#ifdef SK_VULKAN
const GrVkImageInfo* GrBackendRenderTarget::getVkImageInfo() const {
if (kVulkan_GrBackend == fBackend) {
return &fVkInfo;
}
return nullptr;
}
+#endif
const GrGLFramebufferInfo* GrBackendRenderTarget::getGLFramebufferInfo() const {
if (kOpenGL_GrBackend == fBackend) {
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 8446489c70..c7e77d65a5 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -33,14 +33,15 @@ static GrBackendTexture make_backend_texture_from_handle(GrBackend backend,
int width, int height,
GrPixelConfig config,
GrBackendObject handle) {
- if (kOpenGL_GrBackend == backend) {
- GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
- return GrBackendTexture(width, height, config, *glInfo);
- } else {
- SkASSERT(kVulkan_GrBackend == backend);
+#if SK_VULKAN
+ if (kVulkan_GrBackend == backend) {
GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
return GrBackendTexture(width, height, *vkInfo);
}
+#endif
+ SkASSERT(kOpenGL_GrBackend == backend);
+ GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
+ return GrBackendTexture(width, height, config, *glInfo);
}
std::unique_ptr<SkImageGenerator>
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 002e966da5..57b8b7f592 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -325,15 +325,15 @@ static GrBackendTexture make_backend_texture_from_handle(GrBackend backend,
int width, int height,
GrPixelConfig config,
GrBackendObject handle) {
-
- if (kOpenGL_GrBackend == backend) {
- GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
- return GrBackendTexture(width, height, config, *glInfo);
- } else {
- SkASSERT(kVulkan_GrBackend == backend);
+#if SK_VULKAN
+ if (kVulkan_GrBackend == backend) {
GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
return GrBackendTexture(width, height, *vkInfo);
}
+#endif
+ SkASSERT(kOpenGL_GrBackend == backend);
+ GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
+ return GrBackendTexture(width, height, config, *glInfo);
}
static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpace colorSpace,
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 5a9fc9690e..f486993bbc 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -61,14 +61,15 @@ void SetupAlwaysEvictAtlas(GrContext* context) {
GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
GrPixelConfig config, GrBackendObject handle) {
- if (kOpenGL_GrBackend == backend) {
- GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
- return GrBackendTexture(width, height, config, *glInfo);
- } else {
- SkASSERT(kVulkan_GrBackend == backend);
+#if SK_VULKAN
+ if (kVulkan_GrBackend == backend) {
GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
return GrBackendTexture(width, height, *vkInfo);
}
+#endif
+ SkASSERT(kOpenGL_GrBackend == backend);
+ GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
+ return GrBackendTexture(width, height, config, *glInfo);
}
};