Cleanup program building a bit

This CL:
   now passes the GrProgramDesc as a const&
   returns GrGLProgram as an sk_sp
   makes the parameter ordering more consistent
   makes GrVkPipelineState no longer ref-counted

This is pulled out of the DDL pre-compile CL which touches this portion of the code.

Bug: skia:9455
Change-Id: Id4d06f93450e276de5a2662be330ae9523026244
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268777
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp
index c5f9f2a..6453bde 100644
--- a/src/gpu/gl/GrGLGpuProgramCache.cpp
+++ b/src/gpu/gl/GrGLGpuProgramCache.cpp
@@ -45,14 +45,13 @@
     fMap.reset();
 }
 
-GrGLProgram* GrGLGpu::ProgramCache::refProgram(GrGLGpu* gpu,
-                                               GrRenderTarget* renderTarget,
-                                               const GrProgramInfo& programInfo) {
-    const GrCaps& caps = *gpu->caps();
+sk_sp<GrGLProgram> GrGLGpu::ProgramCache::findOrCreateProgram(GrRenderTarget* renderTarget,
+                                                              const GrProgramInfo& programInfo) {
+    const GrCaps& caps = *fGpu->caps();
 
     GrProgramDesc desc = caps.makeDesc(renderTarget, programInfo);
     if (!desc.isValid()) {
-        GrCapsDebugf(gpu->caps(), "Failed to gl program descriptor!\n");
+        GrCapsDebugf(fGpu->caps(), "Failed to gl program descriptor!\n");
         return nullptr;
     }
 
@@ -61,26 +60,24 @@
         // We've pre-compiled the GL program, but don't have the GrGLProgram scaffolding
         const GrGLPrecompiledProgram* precompiledProgram = &((*entry)->fPrecompiledProgram);
         SkASSERT(precompiledProgram->fProgramID != 0);
-        GrGLProgram* program = GrGLProgramBuilder::CreateProgram(renderTarget, programInfo,
-                                                                 &desc, fGpu,
-                                                                 precompiledProgram);
-        if (nullptr == program) {
+        (*entry)->fProgram = GrGLProgramBuilder::CreateProgram(fGpu, renderTarget, desc,
+                                                               programInfo, precompiledProgram);
+        if (!(*entry)->fProgram) {
             // Should we purge the program ID from the cache at this point?
             SkDEBUGFAIL("Couldn't create program from precompiled program");
             return nullptr;
         }
-        (*entry)->fProgram.reset(program);
     } else if (!entry) {
         // We have a cache miss
-        GrGLProgram* program = GrGLProgramBuilder::CreateProgram(renderTarget, programInfo,
-                                                                 &desc, fGpu);
-        if (nullptr == program) {
+        sk_sp<GrGLProgram> program = GrGLProgramBuilder::CreateProgram(fGpu, renderTarget,
+                                                                       desc, programInfo);
+        if (!program) {
             return nullptr;
         }
-        entry = fMap.insert(desc, std::unique_ptr<Entry>(new Entry(sk_sp<GrGLProgram>(program))));
+        entry = fMap.insert(desc, std::unique_ptr<Entry>(new Entry(std::move(program))));
     }
 
-    return SkRef((*entry)->fProgram.get());
+    return (*entry)->fProgram;
 }
 
 bool GrGLGpu::ProgramCache::precompileShader(const SkData& key, const SkData& data) {