aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-10-09 13:12:35 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-09 13:12:35 -0700
commit9e87fa7c0e52a79ad85bf32eeb71570938e357bd (patch)
tree7ca929398b8daefee061b056530f6a66eca88d69 /src/gpu
parent00878a1f36a28082fe2370e9f05ea931c7d5fed4 (diff)
Force linking of static member variables for GLPrograms
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrProcessor.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 26e00530be..71dfaae912 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -12,6 +12,50 @@
#include "GrMemoryPool.h"
#include "SkTLS.h"
+#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+
+/*
+ * Originally these were both in the processor unit test header, but then it seemed to cause linker
+ * problems on android.
+ */
+template<>
+SkTArray<GrProcessorTestFactory<GrFragmentProcessor>*, true>*
+GrProcessorTestFactory<GrFragmentProcessor>::GetFactories() {
+ static SkTArray<GrProcessorTestFactory<GrFragmentProcessor>*, true> gFactories;
+ return &gFactories;
+}
+
+template<>
+SkTArray<GrProcessorTestFactory<GrGeometryProcessor>*, true>*
+GrProcessorTestFactory<GrGeometryProcessor>::GetFactories() {
+ static SkTArray<GrProcessorTestFactory<GrGeometryProcessor>*, true> gFactories;
+ return &gFactories;
+}
+
+/*
+ * To ensure we always have successful static initialization, before creating from the factories
+ * we verify the count is as expected. If a new factory is added, then these numbers must be
+ * manually adjusted.
+ */
+static const int kFPFactoryCount = 37;
+static const int kGPFactoryCount = 15;
+
+template<>
+void GrProcessorTestFactory<GrFragmentProcessor>::VerifyFactoryCount() {
+ if (kFPFactoryCount != GetFactories()->count()) {
+ SkFAIL("Wrong number of fragment processor factories!");
+ }
+}
+
+template<>
+void GrProcessorTestFactory<GrGeometryProcessor>::VerifyFactoryCount() {
+ if (kGPFactoryCount != GetFactories()->count()) {
+ SkFAIL("Wrong number of geometry processor factories!");
+ }
+}
+
+#endif
+
namespace GrProcessorUnitTest {
const SkMatrix& TestMatrix(SkRandom* random) {
static SkMatrix gMatrices[5];