Reapply "Refactor setting an SkPaint onto a hwui Layer."

This reverts commit 90d0c75e94a32fb7d993fae69762820aabc2fcbb.

Change-Id: Ie807761231edf7c848b019931dccbf466208c0be
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 9b253a6..2da0fd3 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -868,14 +868,11 @@
 
     const bool fboLayer = flags & SkCanvas::kClipToLayer_SaveFlag;
 
-    SkXfermode::Mode mode = getXfermodeDirect(paint);
-    int alpha = getAlphaDirect(paint);
-
     // Window coordinates of the layer
     Rect clip;
     Rect bounds(left, top, right, bottom);
     calculateLayerBoundsAndClip(bounds, clip, fboLayer);
-    updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, alpha);
+    updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, getAlphaDirect(paint));
 
     // Bail out if we won't draw in this snapshot
     if (currentSnapshot()->isIgnored()) {
@@ -888,12 +885,11 @@
         return false;
     }
 
-    layer->setAlpha(alpha, mode);
+    layer->setPaint(paint);
     layer->layer.set(bounds);
     layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->getHeight()),
             bounds.getWidth() / float(layer->getWidth()), 0.0f);
 
-    layer->setColorFilter(getColorFilter(paint));
     layer->setBlend(true);
     layer->setDirty(false);
 
@@ -1011,7 +1007,6 @@
     }
 
     if (!fboLayer && layer->getAlpha() < 255) {
-        // TODO: this seems to point to the fact that the layer should store the paint
         SkPaint layerPaint;
         layerPaint.setAlpha(layer->getAlpha());
         layerPaint.setXfermodeMode(SkXfermode::kDstIn_Mode);