simplify code in SkRecords.h

   - use C++11 features ({} init, move constructors) to eliminate the need
     for explicit constructors
   - collapse RECORD0...RECORD8 into just one RECORD macro
   - explicitly tag record types instead of using member detectors.

Removing member detectors makes this code significantly less fragile.

This exposes a few places where we didn't really think through what to do
with SkDrawable.  I've marked them TODO for now.

BUG=skia:

Review URL: https://codereview.chromium.org/1360943003
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
index 0a4859f..ea179d7 100644
--- a/src/core/SkMiniRecorder.cpp
+++ b/src/core/SkMiniRecorder.cpp
@@ -70,7 +70,7 @@
 #define TRY_TO_STORE(Type, ...)                    \
     if (fState != State::kEmpty) { return false; } \
     fState = State::k##Type;                       \
-    new (fBuffer.get()) Type(__VA_ARGS__);         \
+    new (fBuffer.get()) Type{__VA_ARGS__};         \
     return true
 
 bool SkMiniRecorder::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
diff --git a/src/core/SkPictureCommon.h b/src/core/SkPictureCommon.h
index c9c023d..6e95b29 100644
--- a/src/core/SkPictureCommon.h
+++ b/src/core/SkPictureCommon.h
@@ -16,28 +16,18 @@
 
 struct SkTextHunter {
     // Most ops never have text.  Some always do.  Subpictures know themeselves.
-    template <typename T> bool operator()(const T&) { return false; }
-    bool operator()(const SkRecords::DrawPosText&)    { return true; }
-    bool operator()(const SkRecords::DrawPosTextH&)   { return true; }
-    bool operator()(const SkRecords::DrawText&)       { return true; }
-    bool operator()(const SkRecords::DrawTextBlob&)   { return true; }
-    bool operator()(const SkRecords::DrawTextOnPath&) { return true; }
     bool operator()(const SkRecords::DrawPicture& op) { return op.picture->hasText(); }
+    bool operator()(const SkRecords::DrawDrawable&) { /*TODO*/ return false; }
+
+    template <typename T>
+    SK_WHEN(T::kTags & SkRecords::kHasText_Tag, bool) operator()(const T&) { return true; }
+    template <typename T>
+    SK_WHEN(!(T::kTags & SkRecords::kHasText_Tag), bool) operator()(const T&) { return false; }
 };
 
 
 // N.B. This name is slightly historical: hunting season is now open for SkImages too.
 struct SkBitmapHunter {
-    // Helpers.  These let us detect the presence of struct members with particular names.
-    SK_CREATE_MEMBER_DETECTOR(bitmap);
-    SK_CREATE_MEMBER_DETECTOR(image);
-    SK_CREATE_MEMBER_DETECTOR(paint);
-
-    template <typename T>
-    struct HasMember_bitmap_or_image {
-        static const bool value = HasMember_bitmap<T>::value || HasMember_image<T>::value;
-    };
-
     // Some ops have a paint, some have an optional paint.  Either way, get back a pointer.
     static const SkPaint* AsPtr(const SkPaint& p) { return &p; }
     static const SkPaint* AsPtr(const SkRecords::Optional<SkPaint>& p) { return p; }
@@ -48,26 +38,42 @@
     // If the op has a paint and the paint has a bitmap, return true.
     // Otherwise, return false.
     bool operator()(const SkRecords::DrawPicture& op) { return op.picture->willPlayBackBitmaps(); }
+    bool operator()(const SkRecords::DrawDrawable&) { /*TODO*/ return false; }
 
     template <typename T>
-    bool operator()(const T& r) { return CheckBitmap(r); }
+    bool operator()(const T& op) { return CheckBitmap(op); }
 
-    // If the op has a bitmap, of course we're going to play back bitmaps.
+    // If the op is tagged as having an image, return true.
     template <typename T>
-    static SK_WHEN(HasMember_bitmap_or_image<T>, bool) CheckBitmap(const T&) {
+    static SK_WHEN(T::kTags & SkRecords::kHasImage_Tag, bool) CheckBitmap(const T&) {
         return true;
     }
 
     // If not, look for one in its paint (if it has a paint).
     template <typename T>
-    static SK_WHEN(!HasMember_bitmap_or_image<T>, bool) CheckBitmap(const T& r) {
-        return CheckPaint(r);
+    static SK_WHEN(!(T::kTags & SkRecords::kHasImage_Tag), bool) CheckBitmap(const T& op) {
+        return CheckPaint(op);
     }
 
-    // If we have a paint, dig down into the effects looking for a bitmap.
+    // Most draws-type ops have paints.
     template <typename T>
-    static SK_WHEN(HasMember_paint<T>, bool) CheckPaint(const T& r) {
-        const SkPaint* paint = AsPtr(r.paint);
+    static SK_WHEN(T::kTags & SkRecords::kDraw_Tag, bool) CheckPaint(const T& op) {
+        return PaintHasBitmap(AsPtr(op.paint));
+    }
+
+    // SaveLayers also have a paint to check.
+    static bool CheckPaint(const SkRecords::SaveLayer& op) {
+        return PaintHasBitmap(AsPtr(op.paint));
+    }
+
+    // Shouldn't be any non-Draw non-SaveLayer ops with paints.
+    template <typename T>
+    static SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), bool) CheckPaint(const T&) {
+        return false;
+    }
+
+private:
+    static bool PaintHasBitmap(const SkPaint* paint) {
         if (paint) {
             const SkShader* shader = paint->getShader();
             if (shader && shader->isABitmap()) {
@@ -76,16 +82,10 @@
         }
         return false;
     }
-
-    // If we don't have a paint, that non-paint has no bitmap.
-    template <typename T>
-    static SK_WHEN(!HasMember_paint<T>, bool) CheckPaint(const T&) { return false; }
 };
 
 // TODO: might be nicer to have operator() return an int (the number of slow paths) ?
 struct SkPathCounter {
-    SK_CREATE_MEMBER_DETECTOR(paint);
-
     // Some ops have a paint, some have an optional paint.  Either way, get back a pointer.
     static const SkPaint* AsPtr(const SkPaint& p) { return &p; }
     static const SkPaint* AsPtr(const SkRecords::Optional<SkPaint>& p) { return p; }
@@ -96,6 +96,7 @@
     void operator()(const SkRecords::DrawPicture& op) {
         fNumSlowPathsAndDashEffects += op.picture->numSlowPaths();
     }
+    void operator()(const SkRecords::DrawDrawable&) { /* TODO */ }
 
     void checkPaint(const SkPaint* paint) {
         if (paint && paint->getPathEffect()) {
@@ -134,13 +135,17 @@
         }
     }
 
-    template <typename T>
-    SK_WHEN(HasMember_paint<T>, void) operator()(const T& op) {
+    void operator()(const SkRecords::SaveLayer& op) {
         this->checkPaint(AsPtr(op.paint));
     }
 
     template <typename T>
-    SK_WHEN(!HasMember_paint<T>, void) operator()(const T& op) { /* do nothing */ }
+    SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) {
+        this->checkPaint(AsPtr(op.paint));
+    }
+
+    template <typename T>
+    SK_WHEN(!(T::kTags & SkRecords::kDraw_Tag), void) operator()(const T& op) { /* do nothing */ }
 
     int fNumSlowPathsAndDashEffects;
 };
diff --git a/src/core/SkRecord.h b/src/core/SkRecord.h
index 6893cb0..ee10b15 100644
--- a/src/core/SkRecord.h
+++ b/src/core/SkRecord.h
@@ -134,13 +134,13 @@
     };
 
     template <typename T>
-    SK_WHEN(skstd::is_empty<T>, T*) allocCommand() {
+    SK_WHEN(skstd::is_empty<T>::value, T*) allocCommand() {
         static T singleton = {};
         return &singleton;
     }
 
     template <typename T>
-    SK_WHEN(!skstd::is_empty<T>, T*) allocCommand() { return this->alloc<T>(); }
+    SK_WHEN(!skstd::is_empty<T>::value, T*) allocCommand() { return this->alloc<T>(); }
 
     void grow();
 
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 1a03348..12920da 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -116,7 +116,7 @@
 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.paint));
 DRAW(DrawAtlas, drawAtlas(r.atlas, r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint));
 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
-                                r.xmode.get(), r.indices, r.indexCount, r.paint));
+                                r.xmode, r.indices, r.indexCount, r.paint));
 #undef DRAW
 
 template <> void Draw::draw(const DrawDrawable& r) {
diff --git a/src/core/SkRecordPattern.h b/src/core/SkRecordPattern.h
index ecc61b3..d9568b3 100644
--- a/src/core/SkRecordPattern.h
+++ b/src/core/SkRecordPattern.h
@@ -41,7 +41,6 @@
 
 // Matches any command that draws, and stores its paint.
 class IsDraw {
-    SK_CREATE_MEMBER_DETECTOR(paint);
 public:
     IsDraw() : fPaint(nullptr) {}
 
@@ -49,19 +48,19 @@
     type* get() { return fPaint; }
 
     template <typename T>
-    SK_WHEN(HasMember_paint<T>, bool) operator()(T* draw) {
+    SK_WHEN(T::kTags & kDraw_Tag, bool) operator()(T* draw) {
         fPaint = AsPtr(draw->paint);
         return true;
     }
 
-    template <typename T>
-    SK_WHEN(!HasMember_paint<T>, bool) operator()(T*) {
+    bool operator()(DrawDrawable*) {
+        static_assert(DrawDrawable::kTags & kDraw_Tag, "");
         fPaint = nullptr;
-        return false;
+        return true;
     }
 
-    // SaveLayer has an SkPaint named paint, but it's not a draw.
-    bool operator()(SaveLayer*) {
+    template <typename T>
+    SK_WHEN(!(T::kTags & kDraw_Tag), bool) operator()(T* draw) {
         fPaint = nullptr;
         return false;
     }
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 9eccca1..0605d17 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -70,7 +70,7 @@
     if (fMiniRecorder) {           \
         this->flushMiniRecorder(); \
     }                              \
-    new (fRecord->append<SkRecords::T>()) SkRecords::T(__VA_ARGS__)
+    new (fRecord->append<SkRecords::T>()) SkRecords::T{__VA_ARGS__}
 
 #define TRY_MINIRECORDER(method, ...)                       \
     if (fMiniRecorder && fMiniRecorder->method(__VA_ARGS__)) { return; }