Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: src/gpu/GrProcessor.cpp

Issue 614163002: Force linking of static member variables for GLPrograms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrProcessor.cpp
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 45298b522d3ef9e1bf367c19ea8989a8b02f900e..502c518969ba45b7fbca6f36bdd3f1a13fab2e49 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -12,6 +12,48 @@
#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 = 36;
+static const int kGPFactoryCount = 14;
+
+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];

Powered by Google App Engine
This is Rietveld 408576698