Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Unified Diff: samplecode/SampleApp.cpp

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drawVertices and drawTextOnPath Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 62970302df50d53de5e5ae7a221b23278b8afdaf..045da9afc1ea7fc1a89395bc743c379b6db174ce 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -34,6 +34,9 @@
#include "SkWindow.h"
#include "sk_tool_utils.h"
+#include "SkReadBuffer.h"
+#include "SkStream.h"
+
#if SK_SUPPORT_GPU
# include "gl/GrGLInterface.h"
# include "gl/GrGLUtil.h"
@@ -696,11 +699,14 @@ DEFINE_string(pdfPath, "", "Path to direcotry of pdf files.");
#endif
#include "SkTaskGroup.h"
+#include "SkForceLinking.h"
SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* devManager)
: INHERITED(hwnd)
, fDevManager(nullptr) {
+ SkForceLinking(false);
+
SkCommandLineFlags::Parse(argc, argv);
fCurrIndex = -1;
@@ -1305,7 +1311,10 @@ SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) {
} else if (fSaveToSKP) {
canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
} else if (fUsePicture) {
- canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
+ fPipeStream = new SkDynamicMemoryWStream;
+ canvas = fPipeSerializer.beginWrite(SkRect::MakeWH(this->width(), this->height()),
+ fPipeStream);
+// canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
} else {
canvas = this->INHERITED::beforeChildren(canvas);
}
@@ -1367,17 +1376,15 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
}
if (fUsePicture) {
- sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
-
- // serialize/deserialize?
- if (false) {
- SkDynamicMemoryWStream wstream;
- picture->serialize(&wstream);
-
- SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- picture = SkPicture::MakeFromStream(rstream);
+ if (true) {
+ fPipeSerializer.endWrite();
+ sk_sp<SkData> data(fPipeStream->copyToData());
+ fPipeDeserializer.playback(data->data(), data->size(), orig);
+ delete fPipeStream;
+ } else {
+ sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
+ orig->drawPicture(picture.get());
}
- orig->drawPicture(picture.get());
}
// Do this after presentGL and other finishing, rather than in afterChild
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/core/SkDeduper.h » ('j') | src/core/SkReadBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698