Add possibility of not compiling OGA files
The plan is to be able to compile and test NGA-only, OGA-only and both
Bug: skia:11837
Change-Id: Ib79cc2c2c437c72def8649392b345648f49300fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416799
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 48c92e6..329c859 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -55,7 +55,10 @@
]
}
if (skia_enable_nga) {
- defines += [ "SK_NGA" ]
+ defines += [ "GR_NGA=1" ]
+ }
+ if (!skia_enable_oga) {
+ defines += [ "GR_OGA=0" ]
}
# Some older versions of the Clang toolchain change the visibility of
@@ -913,6 +916,9 @@
if (skia_enable_nga) {
sources += skia_nga_sources
}
+ if (!skia_enable_oga) {
+ sources -= skia_oga_sources
+ }
libs = []
frameworks = []
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 7b85583..3337a09 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -543,9 +543,6 @@
# Sk files
"$_src/gpu/SkBaseGpuDevice.cpp",
"$_src/gpu/SkBaseGpuDevice.h",
- "$_src/gpu/SkGpuDevice.cpp",
- "$_src/gpu/SkGpuDevice.h",
- "$_src/gpu/SkGpuDevice_drawTexture.cpp",
"$_src/gpu/SkGr.cpp",
"$_src/gpu/SkGr.h",
"$_src/image/SkImage_Gpu.cpp",
@@ -641,6 +638,15 @@
"$_src/gpu/SkGpuDevice_nga.h",
]
+skia_oga_sources = [
+ # Sk files
+ "$_src/gpu/SkGpuDevice.cpp",
+ "$_src/gpu/SkGpuDevice.h",
+ "$_src/gpu/SkGpuDevice_drawTexture.cpp",
+]
+
+skia_gpu_sources += skia_oga_sources
+
skia_vk_sources = [
"$_include/gpu/vk/GrVkBackendContext.h",
"$_include/gpu/vk/GrVkExtensions.h",
diff --git a/gn/skia.gni b/gn/skia.gni
index 4c13cc2..06c5157 100644
--- a/gn/skia.gni
+++ b/gn/skia.gni
@@ -15,6 +15,7 @@
skia_enable_android_utils = is_skia_dev_build
skia_enable_ccpr = true
skia_enable_nga = false
+ skia_enable_oga = true
skia_enable_discrete_gpu = true
skia_enable_flutter_defines = false
skia_enable_fontmgr_empty = false
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index f30fa8a..0b09cd3 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -396,6 +396,14 @@
# define GR_TEST_UTILS 0
#endif
+#ifndef GR_NGA
+# define GR_NGA 0
+#endif
+
+#ifndef GR_OGA
+# define GR_OGA 1
+#endif
+
#if defined(SK_HISTOGRAM_ENUMERATION) || \
defined(SK_HISTOGRAM_BOOLEAN) || \
defined(SK_HISTOGRAM_EXACT_LINEAR) || \
diff --git a/src/gpu/GrRecordingContextPriv.cpp b/src/gpu/GrRecordingContextPriv.cpp
index 8204f45..bacae84 100644
--- a/src/gpu/GrRecordingContextPriv.cpp
+++ b/src/gpu/GrRecordingContextPriv.cpp
@@ -9,8 +9,11 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDrawingManager.h"
+
+#if GR_OGA
#include "src/gpu/SkGpuDevice.h"
-#ifdef SK_NGA
+#endif
+#if GR_NGA
#include "src/gpu/SkGpuDevice_nga.h"
#endif
@@ -22,7 +25,7 @@
SkBaseGpuDevice::InitContents init) {
#if GR_TEST_UTILS
if (this->options().fUseNGA == GrContextOptions::Enable::kYes) {
-#ifdef SK_NGA
+#if GR_NGA
return SkGpuDevice_nga::Make(fContext, colorType, std::move(proxy), std::move(colorSpace),
origin, props, init);
#else
@@ -31,8 +34,12 @@
} else
#endif
{
+#if GR_OGA
return SkGpuDevice::Make(fContext, colorType, std::move(proxy), std::move(colorSpace),
origin, props, init);
+#else
+ return nullptr;
+#endif
}
}
@@ -47,7 +54,7 @@
SkBaseGpuDevice::InitContents init) {
#if GR_TEST_UTILS
if (this->options().fUseNGA == GrContextOptions::Enable::kYes) {
-#ifdef SK_NGA
+#if GR_NGA
return SkGpuDevice_nga::Make(fContext, budgeted, ii, fit, sampleCount,
mipmapped, isProtected, origin, props, init);
#else
@@ -56,8 +63,12 @@
} else
#endif
{
+#if GR_OGA
return SkGpuDevice::Make(fContext, budgeted, ii, fit, sampleCount,
mipmapped, isProtected, origin, props, init);
+#else
+ return nullptr;
+#endif
}
}
diff --git a/src/gpu/SkGpuDevice_nga.cpp b/src/gpu/SkGpuDevice_nga.cpp
index 1690c5e..51e6017 100644
--- a/src/gpu/SkGpuDevice_nga.cpp
+++ b/src/gpu/SkGpuDevice_nga.cpp
@@ -7,8 +7,6 @@
#include "src/gpu/SkGpuDevice_nga.h"
-#ifdef SK_NGA
-
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkImageFilterCache.h"
#include "src/gpu/GrRecordingContextPriv.h"
@@ -296,5 +294,3 @@
// We always return a transient cache, so it is freed after each filter traversal.
return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize);
}
-
-#endif // SK_NGA
diff --git a/src/gpu/SkGpuDevice_nga.h b/src/gpu/SkGpuDevice_nga.h
index 42670a1..ddb4872 100644
--- a/src/gpu/SkGpuDevice_nga.h
+++ b/src/gpu/SkGpuDevice_nga.h
@@ -8,10 +8,6 @@
#ifndef SkGpuDevice_nga_DEFINED
#define SkGpuDevice_nga_DEFINED
-#include "include/gpu/GrTypes.h"
-
-#ifdef SK_NGA
-
#include "src/gpu/SkBaseGpuDevice.h"
/**
@@ -153,6 +149,4 @@
using INHERITED = SkBaseGpuDevice;
};
-#endif // SK_NGA
-
#endif // SkGpuDevice_nga_DEFINED