Rename msaa attachment usage to color usage.

In the long run msaa isn't really a usage and the usage is as a color
attachment. The msaa-ness can be inferred by the sample count.

Bug: skia:10727
Change-Id: Ibd3671301f86e542e147ea3ada5e7a5caac25849
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331596
Auto-Submit: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/GrAttachment.cpp b/src/gpu/GrAttachment.cpp
index 310078a..f465153 100644
--- a/src/gpu/GrAttachment.cpp
+++ b/src/gpu/GrAttachment.cpp
@@ -75,7 +75,7 @@
 }
 
 void GrAttachment::computeScratchKey(GrScratchKey* key) const {
-    if (fSupportedUsages & UsageFlags::kMSAA) {
+    if (fSupportedUsages & UsageFlags::kColorAttachment) {
         auto isProtected = this->isProtected() ? GrProtected::kYes : GrProtected::kNo;
         ComputeScratchKey(*this->getGpu()->caps(), this->backendFormat(), this->dimensions(),
                           fSupportedUsages, this->numSamples(), isProtected, key);
diff --git a/src/gpu/GrAttachment.h b/src/gpu/GrAttachment.h
index 4d7b8eb..0cd26ee 100644
--- a/src/gpu/GrAttachment.h
+++ b/src/gpu/GrAttachment.h
@@ -25,8 +25,8 @@
 class GrAttachment : public GrSurface {
 public:
     enum class UsageFlags : uint8_t {
-        kStencil = 0x1,
-        kMSAA    = 0x2,
+        kStencilAttachment = 0x1,
+        kColorAttachment   = 0x2,
     };
     GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(UsageFlags);
 
@@ -77,10 +77,10 @@
     const char* getResourceType() const override {
         // TODO: Once attachments can have multiple usages this needs to be updated
         switch (fSupportedUsages) {
-            case (UsageFlags::kMSAA):
-                return "MSAA";
-            case (UsageFlags::kStencil):
-                return "Stencil";
+            case (UsageFlags::kColorAttachment):
+                return "ColorAttachment";
+            case (UsageFlags::kStencilAttachment):
+                return "StencilAttachment";
             default:
                 SkUNREACHABLE;
         }
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index ce3cf90..f0513ec 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -512,8 +512,9 @@
         }
         GrProtected isProtected = rt->isProtected() ? GrProtected::kYes : GrProtected::kNo;
         GrAttachment::ComputeSharedAttachmentUniqueKey(
-                *this->caps(), stencilFormat, rt->dimensions(), GrAttachment::UsageFlags::kStencil,
-                numStencilSamples, isProtected, &sbKey);
+                *this->caps(), stencilFormat, rt->dimensions(),
+                GrAttachment::UsageFlags::kStencilAttachment, numStencilSamples, isProtected,
+                &sbKey);
         auto stencil = this->findByUniqueKey<GrAttachment>(sbKey);
         if (!stencil) {
             // Need to try and create a new stencil
@@ -570,7 +571,8 @@
 
     GrScratchKey key;
     GrAttachment::ComputeScratchKey(*this->caps(), format, dimensions,
-                                    GrAttachment::UsageFlags::kMSAA, sampleCnt, isProtected, &key);
+                                    GrAttachment::UsageFlags::kColorAttachment, sampleCnt,
+                                    isProtected, &key);
     GrGpuResource* resource = fCache->findAndRefScratchResource(key);
     if (resource) {
         fGpu->stats()->incNumScratchMSAAAttachmentsReused();
diff --git a/src/gpu/d3d/GrD3DAttachment.cpp b/src/gpu/d3d/GrD3DAttachment.cpp
index e4992c2..13d9da4 100644
--- a/src/gpu/d3d/GrD3DAttachment.cpp
+++ b/src/gpu/d3d/GrD3DAttachment.cpp
@@ -57,7 +57,8 @@
             gpu->resourceProvider().createDepthStencilView(info.fResource.get());
 
     sk_sp<GrD3DResourceState> state(new GrD3DResourceState(info.fResourceState));
-    return sk_sp<GrD3DAttachment>(new GrD3DAttachment(gpu, dimensions, UsageFlags::kStencil,
+    return sk_sp<GrD3DAttachment>(new GrD3DAttachment(gpu, dimensions,
+                                                      UsageFlags::kStencilAttachment,
                                                       format, resourceDesc, info,
                                                       std::move(state), view));
 }
diff --git a/src/gpu/dawn/GrDawnAttachment.cpp b/src/gpu/dawn/GrDawnAttachment.cpp
index ddea0b4..d88d7d4 100644
--- a/src/gpu/dawn/GrDawnAttachment.cpp
+++ b/src/gpu/dawn/GrDawnAttachment.cpp
@@ -42,7 +42,8 @@
         return nullptr;
     }
     return sk_sp<GrDawnAttachment>(
-            new GrDawnAttachment(gpu, dimensions, UsageFlags::kStencil, sampleCnt, texture, view));
+            new GrDawnAttachment(gpu, dimensions, UsageFlags::kStencilAttachment, sampleCnt,
+                                 texture, view));
 }
 
 GrDawnAttachment::~GrDawnAttachment() {}
diff --git a/src/gpu/gl/GrGLAttachment.h b/src/gpu/gl/GrGLAttachment.h
index 55b58c0..ba5a1d40 100644
--- a/src/gpu/gl/GrGLAttachment.h
+++ b/src/gpu/gl/GrGLAttachment.h
@@ -24,7 +24,7 @@
             : GrAttachment(gpu, dimensions, supportedUsages, sampleCnt, GrProtected::kNo)
             , fFormat(format)
             , fRenderbufferID(idDesc.fRenderbufferID) {
-        SkASSERT(supportedUsages == UsageFlags::kStencil);
+        SkASSERT(supportedUsages == UsageFlags::kStencilAttachment);
         this->registerWithCache(SkBudgeted::kYes);
     }
 
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 0288899..53a2085 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1714,7 +1714,8 @@
     fStats.incStencilAttachmentCreates();
 
     return sk_sp<GrAttachment>(new GrGLAttachment(
-            this, sbDesc, dimensions, GrAttachment::UsageFlags::kStencil, numStencilSamples, sFmt));
+            this, sbDesc, dimensions, GrAttachment::UsageFlags::kStencilAttachment,
+            numStencilSamples, sFmt));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index d0e58ca..bda8529 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -92,8 +92,8 @@
         GrGLFormat sFmt = stencil_bits_to_format(stencilBits);
 
         // Ownership of sb is passed to the GrRenderTarget so doesn't need to be deleted
-        sb = new GrGLAttachment(gpu, sbDesc, dimensions, GrAttachment::UsageFlags::kStencil,
-                                sampleCount, sFmt);
+        sb = new GrGLAttachment(gpu, sbDesc, dimensions,
+                                GrAttachment::UsageFlags::kStencilAttachment, sampleCount, sFmt);
     }
     return sk_sp<GrGLRenderTarget>(
             new GrGLRenderTarget(gpu, dimensions, format, sampleCount, idDesc, sb));
diff --git a/src/gpu/mock/GrMockAttachment.h b/src/gpu/mock/GrMockAttachment.h
index fc268e8..062ae4d 100644
--- a/src/gpu/mock/GrMockAttachment.h
+++ b/src/gpu/mock/GrMockAttachment.h
@@ -16,7 +16,7 @@
 public:
     GrMockAttachment(GrMockGpu* gpu, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt)
             : INHERITED(gpu, dimensions, supportedUsages, sampleCnt, GrProtected::kNo) {
-        SkASSERT(supportedUsages == UsageFlags::kStencil);
+        SkASSERT(supportedUsages == UsageFlags::kStencilAttachment);
         this->registerWithCache(SkBudgeted::kYes);
     }
 
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index b9059e1..868126e 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -261,7 +261,7 @@
     SkASSERT(numStencilSamples == rt->numSamples());
     fStats.incStencilAttachmentCreates();
     return sk_sp<GrAttachment>(
-            new GrMockAttachment(this, dimensions, GrAttachment::UsageFlags::kStencil,
+            new GrMockAttachment(this, dimensions, GrAttachment::UsageFlags::kStencilAttachment,
                                  rt->numSamples()));
 }
 
diff --git a/src/gpu/mtl/GrMtlAttachment.mm b/src/gpu/mtl/GrMtlAttachment.mm
index d31c27e..ad2824e 100644
--- a/src/gpu/mtl/GrMtlAttachment.mm
+++ b/src/gpu/mtl/GrMtlAttachment.mm
@@ -41,7 +41,7 @@
         desc.textureType = MTLTextureType2DMultisample;
     }
     return sk_sp<GrMtlAttachment>(
-            new GrMtlAttachment(gpu, dimensions, UsageFlags::kStencil,
+            new GrMtlAttachment(gpu, dimensions, UsageFlags::kStencilAttachment,
                                 [gpu->device() newTextureWithDescriptor:desc]));
 }
 
diff --git a/src/gpu/vk/GrVkAttachment.cpp b/src/gpu/vk/GrVkAttachment.cpp
index 1f965ac..919ca6d 100644
--- a/src/gpu/vk/GrVkAttachment.cpp
+++ b/src/gpu/vk/GrVkAttachment.cpp
@@ -47,7 +47,7 @@
                                                   VkFormat format) {
     VkImageUsageFlags vkUsageFlags = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
                                      VK_IMAGE_USAGE_TRANSFER_DST_BIT;
-    return GrVkAttachment::Make(gpu, dimensions, UsageFlags::kStencil, sampleCnt, format,
+    return GrVkAttachment::Make(gpu, dimensions, UsageFlags::kStencilAttachment, sampleCnt, format,
                                 vkUsageFlags, GrProtected::kNo, SkBudgeted::kYes);
 }
 
@@ -61,7 +61,7 @@
     VkImageUsageFlags vkUsageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
                                      VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
                                      VK_IMAGE_USAGE_TRANSFER_DST_BIT;
-    return GrVkAttachment::Make(gpu, dimensions, UsageFlags::kMSAA, numSamples, format,
+    return GrVkAttachment::Make(gpu, dimensions, UsageFlags::kColorAttachment, numSamples, format,
                                 vkUsageFlags, isProtected, SkBudgeted::kYes);
 }
 
@@ -90,9 +90,9 @@
     }
 
     GrVkImageView::Type viewType;
-    if (attachmentUsages & UsageFlags::kStencil) {
+    if (attachmentUsages & UsageFlags::kStencilAttachment) {
         // If we have stencil usage than we should have any other usages
-        SkASSERT(attachmentUsages == UsageFlags::kStencil);
+        SkASSERT(attachmentUsages == UsageFlags::kStencilAttachment);
         viewType = GrVkImageView::kStencil_Type;
     } else {
         viewType = GrVkImageView::kColor_Type;
@@ -121,9 +121,9 @@
         GrWrapOwnership ownership,
         GrWrapCacheable cacheable) {
     GrVkImageView::Type viewType;
-    if (attachmentUsages & UsageFlags::kStencil) {
+    if (attachmentUsages & UsageFlags::kStencilAttachment) {
         // If we have stencil usage than we should not have any other usages
-        SkASSERT(attachmentUsages == UsageFlags::kStencil);
+        SkASSERT(attachmentUsages == UsageFlags::kStencilAttachment);
         viewType = GrVkImageView::kStencil_Type;
     } else {
         viewType = GrVkImageView::kColor_Type;