Fix layer hoisting bug in SkCanvas::drawPicture path

Most of this CL is just reordering to better match the MultiPictureDraw variant. The only functional change is that we now use the device space bounds as the queryRect to the layer hoisting code. This is necessary since the layer hoisting does all its work in device space.

Review URL: https://codereview.chromium.org/942853002
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9760968..5781a58 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1861,17 +1861,22 @@
         return false;
     }
 
-    SkRect clipBounds;
-    if (!mainCanvas->getClipBounds(&clipBounds)) {
-        return true;
+    const SkLayerInfo *gpuData = static_cast<const SkLayerInfo*>(data);
+    if (0 == gpuData->numBlocks()) {
+        return false;
     }
 
-    SkAutoCanvasMatrixPaint acmp(mainCanvas, matrix, paint, mainPicture->cullRect());
-
-    const SkMatrix initialMatrix = mainCanvas->getTotalMatrix();
-
     SkTDArray<GrHoistedLayer> atlasedNeedRendering, atlasedRecycled;
 
+    SkIRect iBounds;
+    if (!mainCanvas->getClipDeviceBounds(&iBounds)) {
+        return false;
+    }
+
+    SkRect clipBounds = SkRect::Make(iBounds);
+
+    SkMatrix initialMatrix = mainCanvas->getTotalMatrix();
+
     GrLayerHoister::FindLayersToAtlas(fContext, mainPicture,
                                       initialMatrix,
                                       clipBounds,
@@ -1882,6 +1887,8 @@
 
     SkTDArray<GrHoistedLayer> needRendering, recycled;
 
+    SkAutoCanvasMatrixPaint acmp(mainCanvas, matrix, paint, mainPicture->cullRect());
+
     GrLayerHoister::FindLayersToHoist(fContext, mainPicture,
                                       initialMatrix,
                                       clipBounds,