diff options
author | Mike Reed <reed@google.com> | 2017-07-23 10:28:31 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-23 15:59:48 +0000 |
commit | 7b215bcad3034aca262ca4eeebe31b5e8868638b (patch) | |
tree | 6a1950a9ad5c03fb92eefcbed7d682e7464c50ee /samplecode | |
parent | 91ff3c15df0c93779710783c24c8167e22f1d989 (diff) |
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>
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 17 | ||||
-rw-r--r-- | samplecode/SampleApp.h | 6 |
2 files changed, 14 insertions, 9 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 1676fc3b13..102c67a90b 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -332,8 +332,8 @@ public: return nullptr; } - void publishCanvas(SampleWindow::DeviceType dType, - SkCanvas* renderingCanvas, SampleWindow* win) override { + void publishCanvas(SampleWindow::DeviceType dType, SkSurface* surface, + SampleWindow* win) override { #if SK_SUPPORT_GPU if (!IsGpuDeviceType(dType) || kRGBA_F16_SkColorType == win->info().colorType() || @@ -345,7 +345,7 @@ public: auto data = SkData::MakeUninitialized(size); SkASSERT(data); - if (!renderingCanvas->readPixels(info, data->writable_data(), rowBytes, 0, 0)) { + if (!surface->readPixels(info, data->writable_data(), rowBytes, 0, 0)) { SkDEBUGFAIL("Failed to read canvas pixels"); return; } @@ -1091,6 +1091,14 @@ static void drawText(SkCanvas* canvas, SkString str, SkScalar left, SkScalar top #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; @@ -1164,9 +1172,6 @@ void SampleWindow::draw(SkCanvas* canvas) { } 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 6ddb5c5a0d..954b855d27 100644 --- a/samplecode/SampleApp.h +++ b/samplecode/SampleApp.h @@ -92,9 +92,7 @@ public: // called after drawing, should get the results onto the // screen. - virtual void publishCanvas(DeviceType dType, - SkCanvas* canvas, - SampleWindow* win) = 0; + virtual void publishCanvas(DeviceType, SkSurface*, SampleWindow*) = 0; // called when window changes size, guaranteed to be called // at least once before first draw (after init) @@ -127,6 +125,8 @@ public: return surface; } + void drawIntoSurface() override; + void draw(SkCanvas*) override; void setDeviceType(DeviceType type); |