Clarify that the GrDirectContext uniquely holds the text atlas manager

Bug: 1108408
Change-Id: Iad0b634a8a0d6dac64e3571a32e755d124401f66
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309077
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/gpu/GrDirectContext.h b/include/gpu/GrDirectContext.h
index 8a0b237..631c951 100644
--- a/include/gpu/GrDirectContext.h
+++ b/include/gpu/GrDirectContext.h
@@ -79,12 +79,12 @@
 
     bool init() override;
 
-    GrAtlasManager* onGetAtlasManager() override { return fAtlasManager; }
+    GrAtlasManager* onGetAtlasManager() override { return fAtlasManager.get(); }
 
     GrDirectContext* asDirectContext() override { return this; }
 
 private:
-    GrAtlasManager* fAtlasManager;
+    std::unique_ptr<GrAtlasManager> fAtlasManager;
 
     typedef GrContext INHERITED;
 };
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index d03726e..f5c6f95 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -45,8 +45,7 @@
 #endif
 
 GrDirectContext::GrDirectContext(GrBackendApi backend, const GrContextOptions& options)
-        : INHERITED(GrContextThreadSafeProxyPriv::Make(backend, options))
-        , fAtlasManager(nullptr) {
+        : INHERITED(GrContextThreadSafeProxyPriv::Make(backend, options)) {
 }
 
 GrDirectContext::~GrDirectContext() {
@@ -55,8 +54,6 @@
     if (this->priv().getGpu()) {
         this->flushAndSubmit();
     }
-
-    delete fAtlasManager;
 }
 
 void GrDirectContext::abandonContext() {
@@ -108,10 +105,10 @@
 
     GrProxyProvider* proxyProvider = this->priv().proxyProvider();
 
-    fAtlasManager = new GrAtlasManager(proxyProvider,
-                                       this->options().fGlyphCacheTextureMaximumBytes,
-                                       allowMultitexturing);
-    this->priv().addOnFlushCallbackObject(fAtlasManager);
+    fAtlasManager = std::make_unique<GrAtlasManager>(proxyProvider,
+                                                     this->options().fGlyphCacheTextureMaximumBytes,
+                                                     allowMultitexturing);
+    this->priv().addOnFlushCallbackObject(fAtlasManager.get());
 
     return true;
 }