Added code to enable the pipe module to record to a file
http://codereview.appspot.com/4564052/
git-svn-id: http://skia.googlecode.com/svn/trunk@1469 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index bee965c..3efffe6 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -14,6 +14,13 @@
#include "SkTouchGesture.h"
#include "SkTypeface.h"
+#define TEST_GPIPEx
+
+#ifdef TEST_GPIPE
+#define PIPE_FILE
+#define FILE_PATH "/path/to/drawing.data"
+#endif
+
#define USE_ARROWS_FOR_ZOOM true
//#define DEFAULT_TO_GPU
@@ -423,6 +430,12 @@
}
SampleWindow::SampleWindow(void* hwnd) : INHERITED(hwnd) {
+#ifdef PIPE_FILE
+ //Clear existing file or create file if it doesn't exist
+ FILE* f = fopen(FILE_PATH, "wb");
+ fclose(f);
+#endif
+
fPicture = NULL;
fGpuCanvas = NULL;
@@ -1410,8 +1423,6 @@
return this->INHERITED::onQuery(evt);
}
-#define TEST_GPIPEx
-
#ifdef TEST_GPIPE
#include "SkGPipe.h"
@@ -1464,7 +1475,15 @@
void SimplePC::notifyWritten(size_t bytes) {
SkASSERT(fBytesWritten + bytes <= fBlockSize);
-
+
+#ifdef PIPE_FILE
+ //File is open in append mode
+ FILE* f = fopen(FILE_PATH, "ab");
+ SkASSERT(f != NULL);
+ fwrite((const char*)fBlock + fBytesWritten, 1, bytes, f);
+ fclose(f);
+#endif
+
fStatus = fReader.playback((const char*)fBlock + fBytesWritten, bytes);
SkASSERT(SkGPipeReader::kError_Status != fStatus);
fBytesWritten += bytes;