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

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: nit Created 6 years, 2 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
« no previous file with comments | « include/gpu/GrProcessorUnitTest.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrProcessor.cpp
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 26e00530be848491e87d9ecb82035f29dd4c680f..71dfaae9129a7d819048636ef767d4c17eb34f45 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];
« no previous file with comments | « include/gpu/GrProcessorUnitTest.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698