Add GrThreadSafePipelineBuilder

GrThreadSafePipelineBuilder is the generic, base object the
GrContextThreadSafeProxy will hold. Each backend will create a
backend-specific version that is shared between the direct context
and the (possibly many) utility contexts.

Right now GrThreadSafePipelineBuilder just holds the pipeline
creation stats. Relatedly only GrGLGpu::ProgramCache and
GrVkResourceProvider::PipelineStateCache currently derive from
the new class (since they are the only backends that generate
pipeline stats).

Change-Id: I58f441c5c2b870bb5970c29cba19d1775864d52e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378320
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp
index 9916aaa..4bc0e78 100644
--- a/src/gpu/gl/GrGLGpuProgramCache.cpp
+++ b/src/gpu/gl/GrGLGpuProgramCache.cpp
@@ -61,9 +61,9 @@
     Stats::ProgramCacheResult stat;
     sk_sp<GrGLProgram> tmp = this->findOrCreateProgram(renderTarget, desc, programInfo, &stat);
     if (!tmp) {
-        fGpu->fStats.incNumInlineCompilationFailures();
+        fStats.incNumInlineCompilationFailures();
     } else {
-        fGpu->fStats.incNumInlineProgramCacheResult(stat);
+        fStats.incNumInlineProgramCacheResult(stat);
     }
 
     return tmp;
@@ -84,20 +84,20 @@
         if (!(*entry)->fProgram) {
             // Should we purge the program ID from the cache at this point?
             SkDEBUGFAIL("Couldn't create program from precompiled program");
-            fGpu->fStats.incNumCompilationFailures();
+            fStats.incNumCompilationFailures();
             return nullptr;
         }
-        fGpu->fStats.incNumPartialCompilationSuccesses();
+        fStats.incNumPartialCompilationSuccesses();
         *stat = Stats::ProgramCacheResult::kPartial;
     } else if (!entry) {
         // We have a cache miss
         sk_sp<GrGLProgram> program = GrGLProgramBuilder::CreateProgram(fGpu, renderTarget,
                                                                        desc, programInfo);
         if (!program) {
-            fGpu->fStats.incNumCompilationFailures();
+            fStats.incNumCompilationFailures();
             return nullptr;
         }
-        fGpu->fStats.incNumCompilationSuccesses();
+        fStats.incNumCompilationSuccesses();
         entry = fMap.insert(desc, std::make_unique<Entry>(std::move(program)));
         *stat = Stats::ProgramCacheResult::kMiss;
     }