Make defaultBackendFormat callable from anywhere in the GrContext hierarchy

This is probably overkill but yields an officially thread-safe means of calling defaultBackendFormat.

Change-Id: Ibf344acf11102d938e335e9ea38bfaee575e00c5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234324
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrContext_Base.cpp b/src/gpu/GrContext_Base.cpp
index 31e7ff1..aba1b82 100644
--- a/src/gpu/GrContext_Base.cpp
+++ b/src/gpu/GrContext_Base.cpp
@@ -43,6 +43,24 @@
 
 sk_sp<GrSkSLFPFactoryCache> GrContext_Base::fpFactoryCache() { return fFPFactoryCache; }
 
+GrBackendFormat GrContext_Base::defaultBackendFormat(SkColorType skColorType,
+                                                     GrRenderable renderable) const {
+    const GrCaps* caps = this->caps();
+
+    GrColorType grColorType = SkColorTypeToGrColorType(skColorType);
+
+    GrBackendFormat format = caps->getDefaultBackendFormat(grColorType, renderable);
+    if (!format.isValid()) {
+        return GrBackendFormat();
+    }
+
+    SkASSERT(caps->isFormatTexturable(grColorType, format));
+    SkASSERT(renderable == GrRenderable::kNo ||
+             caps->isFormatAsColorTypeRenderable(grColorType, format));
+
+    return format;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 sk_sp<const GrCaps> GrBaseContextPriv::refCaps() const {
     return fContext->refCaps();