Add layer counting to SkPictureRecord

This will be used for a SkPicture::suitableForOptimization entry point.

Committed: https://skia.googlesource.com/skia/+/4a2b2e8ed2e35171bf98bad68a69daaced11ec7c

R=bsalomon@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/464433002
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 3e6bf1b..e459a11 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1850,6 +1850,10 @@
 void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
     fContext->getLayerCache()->processDeletedPictures();
 
+    if (NULL != picture->fData.get() && !picture->fData->suitableForLayerOptimization()) {
+        return;
+    }
+
     SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
 
     const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(key);