Revert "pass surface to device-manager"

This reverts commit 7b215bcad3034aca262ca4eeebe31b5e8868638b.

Reason for revert: SampleApp on Linux doesn't ever draw anything.

Original change's description:
> pass surface to device-manager
> 
> Bug: skia:3216
> Change-Id: I8e00e9eca3763593a4071c16a3ab04c46bf83a3e
> Reviewed-on: https://skia-review.googlesource.com/26020
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=bsalomon@google.com,reed@google.com

Change-Id: I55f1292ab772bfe8fb1efb74f591b05bbe24d054
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:3216
Reviewed-on: https://skia-review.googlesource.com/26161
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index e744b19..8b6c291 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -79,7 +79,6 @@
     void    postConcat(const SkMatrix&);
 
     virtual sk_sp<SkSurface> makeSurface();
-    virtual void drawIntoSurface();
 
 #if SK_SUPPORT_GPU
     sk_sp<SkSurface> makeGpuBackedSurface(const AttachmentInfo& attachmentInfo,
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 102c67a..1676fc3 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -332,8 +332,8 @@
         return nullptr;
     }
 
-    void publishCanvas(SampleWindow::DeviceType dType, SkSurface* surface,
-                       SampleWindow* win) override {
+    void publishCanvas(SampleWindow::DeviceType dType,
+                       SkCanvas* renderingCanvas, SampleWindow* win) override {
 #if SK_SUPPORT_GPU
         if (!IsGpuDeviceType(dType) ||
             kRGBA_F16_SkColorType == win->info().colorType() ||
@@ -345,7 +345,7 @@
             auto data = SkData::MakeUninitialized(size);
             SkASSERT(data);
 
-            if (!surface->readPixels(info, data->writable_data(), rowBytes, 0, 0)) {
+            if (!renderingCanvas->readPixels(info, data->writable_data(), rowBytes, 0, 0)) {
                 SkDEBUGFAIL("Failed to read canvas pixels");
                 return;
             }
@@ -1091,14 +1091,6 @@
 #include "SkDeferredCanvas.h"
 #include "SkDumpCanvas.h"
 
-void SampleWindow::drawIntoSurface() {
-    auto surf = this->makeSurface();
-
-    this->draw(surf->getCanvas());
-
-    fDevManager->publishCanvas(fDeviceType, surf.get(), this);
-}
-
 void SampleWindow::draw(SkCanvas* canvas) {
     std::unique_ptr<SkThreadedBMPDevice> tDev;
     std::unique_ptr<SkCanvas> tCanvas;
@@ -1172,6 +1164,9 @@
     }
 
     canvas->flush();
+
+    // do this last
+    fDevManager->publishCanvas(fDeviceType, canvas, this);
 }
 
 static float clipW = 200;
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 954b855..6ddb5c5 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -92,7 +92,9 @@
 
         // called after drawing, should get the results onto the
         // screen.
-        virtual void publishCanvas(DeviceType, SkSurface*, SampleWindow*) = 0;
+        virtual void publishCanvas(DeviceType dType,
+                                   SkCanvas* canvas,
+                                   SampleWindow* win) = 0;
 
         // called when window changes size, guaranteed to be called
         // at least once before first draw (after init)
@@ -125,8 +127,6 @@
         return surface;
     }
 
-    void drawIntoSurface() override;
-
     void draw(SkCanvas*) override;
 
     void setDeviceType(DeviceType type);
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index f01368b..ba06a1f 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -35,10 +35,6 @@
     return SkSurface::MakeRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(), &fSurfaceProps);
 }
 
-void SkWindow::drawIntoSurface() {
-    this->draw(this->makeSurface()->getCanvas());
-}
-
 void SkWindow::setMatrix(const SkMatrix& matrix) {
     if (fMatrix != matrix) {
         fMatrix = matrix;
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index 7366c5c..64c02ca 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -13,6 +13,7 @@
 static_assert(SK_SUPPORT_GPU, "not_implemented_for_non_gpu_build");
 #include <OpenGL/gl.h>
 
+//#define FORCE_REDRAW
 // Can be dropped when we no longer support 10.6.
 #if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     #define RETINA_API_AVAILABLE 1
@@ -139,7 +140,11 @@
 - (void)drawSkia {
     fRedrawRequestPending = false;
     if (fWind) {
-        fWind->drawIntoSurface();
+        sk_sp<SkSurface> surface(fWind->makeSurface());
+        fWind->draw(surface->getCanvas());
+#ifdef FORCE_REDRAW
+        fWind->inval(NULL);
+#endif
     }
 }