| Index: samplecode/SampleApp.cpp
|
| diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
|
| index c7a37e786cd6e163f7026a4f5a47684f29a5552b..199d18e4166db36966818a2ef4f973fc12672eec 100644
|
| --- a/samplecode/SampleApp.cpp
|
| +++ b/samplecode/SampleApp.cpp
|
| @@ -10,14 +10,12 @@
|
| #include "OverView.h"
|
| #include "Resources.h"
|
| #include "SampleCode.h"
|
| -#include "SamplePipeControllers.h"
|
| #include "SkAnimTimer.h"
|
| #include "SkCanvas.h"
|
| #include "SkCommandLineFlags.h"
|
| #include "SkData.h"
|
| #include "SkDevice.h"
|
| #include "SkDocument.h"
|
| -#include "SkGPipe.h"
|
| #include "SkGraphics.h"
|
| #include "SkImageEncoder.h"
|
| #include "SkOSFile.h"
|
| @@ -71,17 +69,6 @@ public:
|
| };
|
| #endif // SAMPLE_PDF_FILE_VIEWER
|
|
|
| -#define PIPE_FILEx
|
| -#ifdef PIPE_FILE
|
| -#define FILE_PATH "/path/to/drawing.data"
|
| -#endif
|
| -
|
| -#define PIPE_NETx
|
| -#ifdef PIPE_NET
|
| -#include "SkSockets.h"
|
| -SkTCPServer gServer;
|
| -#endif
|
| -
|
| #if SK_COMMAND_BUFFER
|
| #define DEFAULT_TO_COMMAND_BUFFER 1
|
| #elif SK_ANGLE
|
| @@ -835,12 +822,6 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
|
| static SkTaskGroup::Enabler enabled(-1);
|
| gSampleWindow = this;
|
|
|
| -#ifdef PIPE_FILE
|
| - //Clear existing file or create file if it doesn't exist
|
| - FILE* f = fopen(FILE_PATH, "wb");
|
| - fclose(f);
|
| -#endif
|
| -
|
| fDeviceType = kRaster_DeviceType;
|
| #if SK_SUPPORT_GPU
|
| if (FLAGS_gpu) {
|
| @@ -864,7 +845,6 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
|
| fRotate = false;
|
| fPerspAnim = false;
|
| fRequestGrabImage = false;
|
| - fPipeState = SkOSMenu::kOffState;
|
| fTilingMode = kNo_Tiling;
|
| fMeasureFPS = false;
|
| fLCDState = SkOSMenu::kMixedState;
|
| @@ -927,10 +907,6 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
|
| nullptr);
|
| fAppMenu->assignKeyEquivalentToItem(itemID, 'h');
|
|
|
| - fUsePipeMenuItemID = fAppMenu->appendTriState("Pipe", "Pipe" , sinkID,
|
| - fPipeState);
|
| - fAppMenu->assignKeyEquivalentToItem(fUsePipeMenuItemID, 'P');
|
| -
|
| itemID =fAppMenu->appendList("Tiling", "Tiling", sinkID, fTilingMode,
|
| gTilingInfo[kNo_Tiling].label,
|
| gTilingInfo[kAbs_128x128_Tiling].label,
|
| @@ -1624,16 +1600,6 @@ bool SampleWindow::onEvent(const SkEvent& evt) {
|
| this->setDeviceType((DeviceType)selected);
|
| return true;
|
| }
|
| - if (SkOSMenu::FindTriState(evt, "Pipe", &fPipeState)) {
|
| -#ifdef PIPE_NET
|
| - if (!fPipeState != SkOSMenu::kOnState)
|
| - gServer.disconnectAll();
|
| -#endif
|
| - (void)SampleView::SetUsePipe(curr_view(this), fPipeState);
|
| - this->updateTitle();
|
| - this->inval(nullptr);
|
| - return true;
|
| - }
|
| if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) {
|
| this->toggleSlideshow();
|
| return true;
|
| @@ -2018,12 +1984,6 @@ void SampleWindow::loadView(SkView* view) {
|
| //repopulate the slide menu when a view is loaded
|
| fSlideMenu->reset();
|
|
|
| - (void)SampleView::SetUsePipe(view, fPipeState);
|
| - if (SampleView::IsSampleView(view)) {
|
| - SampleView* sampleView = (SampleView*)view;
|
| - sampleView->requestMenu(fSlideMenu);
|
| - sampleView->onTileSizeChanged(this->tileSize());
|
| - }
|
| this->onUpdateMenu(fSlideMenu);
|
| this->updateTitle();
|
| }
|
| @@ -2103,22 +2063,6 @@ void SampleWindow::updateTitle() {
|
| title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT);
|
| }
|
|
|
| - SkView* view = curr_view(this);
|
| - if (SampleView::IsSampleView(view)) {
|
| - switch (fPipeState) {
|
| - case SkOSMenu::kOnState:
|
| - title.prepend("<Pipe> ");
|
| - break;
|
| - case SkOSMenu::kMixedState:
|
| - title.prepend("<Tiled Pipe> ");
|
| - break;
|
| -
|
| - default:
|
| - break;
|
| - }
|
| - title.prepend("! ");
|
| - }
|
| -
|
| #if SK_SUPPORT_GPU
|
| if (IsGpuDeviceType(fDeviceType) &&
|
| fDevManager &&
|
| @@ -2181,7 +2125,6 @@ void SampleWindow::onSizeChange() {
|
|
|
| static const char is_sample_view_tag[] = "sample-is-sample-view";
|
| static const char repeat_count_tag[] = "sample-set-repeat-count";
|
| -static const char set_use_pipe_tag[] = "sample-set-use-pipe";
|
|
|
| bool SampleView::IsSampleView(SkView* view) {
|
| SkEvent evt(is_sample_view_tag);
|
| @@ -2194,24 +2137,11 @@ bool SampleView::SetRepeatDraw(SkView* view, int count) {
|
| return view->doEvent(evt);
|
| }
|
|
|
| -bool SampleView::SetUsePipe(SkView* view, SkOSMenu::TriState state) {
|
| - SkEvent evt;
|
| - evt.setS32(set_use_pipe_tag, state);
|
| - return view->doEvent(evt);
|
| -}
|
| -
|
| bool SampleView::onEvent(const SkEvent& evt) {
|
| if (evt.isType(repeat_count_tag)) {
|
| fRepeatCount = evt.getFast32();
|
| return true;
|
| }
|
| -
|
| - int32_t pipeHolder;
|
| - if (evt.findS32(set_use_pipe_tag, &pipeHolder)) {
|
| - fPipeState = static_cast<SkOSMenu::TriState>(pipeHolder);
|
| - return true;
|
| - }
|
| -
|
| return this->INHERITED::onEvent(evt);
|
| }
|
|
|
| @@ -2222,102 +2152,6 @@ bool SampleView::onQuery(SkEvent* evt) {
|
| return this->INHERITED::onQuery(evt);
|
| }
|
|
|
| -
|
| -class SimplePC : public SkGPipeController {
|
| -public:
|
| - SimplePC(SkCanvas* target);
|
| - ~SimplePC();
|
| -
|
| - virtual void* requestBlock(size_t minRequest, size_t* actual);
|
| - virtual void notifyWritten(size_t bytes);
|
| -
|
| -private:
|
| - SkGPipeReader fReader;
|
| - void* fBlock;
|
| - size_t fBlockSize;
|
| - size_t fBytesWritten;
|
| - int fAtomsWritten;
|
| - SkGPipeReader::Status fStatus;
|
| -
|
| - size_t fTotalWritten;
|
| -};
|
| -
|
| -SimplePC::SimplePC(SkCanvas* target) : fReader(target) {
|
| - fBlock = nullptr;
|
| - fBlockSize = fBytesWritten = 0;
|
| - fStatus = SkGPipeReader::kDone_Status;
|
| - fTotalWritten = 0;
|
| - fAtomsWritten = 0;
|
| - fReader.setBitmapDecoder(&SkImageDecoder::DecodeMemory);
|
| -}
|
| -
|
| -SimplePC::~SimplePC() {
|
| -// SkASSERT(SkGPipeReader::kDone_Status == fStatus);
|
| - if (fTotalWritten) {
|
| - SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten,
|
| - fAtomsWritten, fStatus);
|
| -#ifdef PIPE_FILE
|
| - //File is open in append mode
|
| - FILE* f = fopen(FILE_PATH, "ab");
|
| - SkASSERT(f != nullptr);
|
| - fwrite((const char*)fBlock + fBytesWritten, 1, bytes, f);
|
| - fclose(f);
|
| -#endif
|
| -#ifdef PIPE_NET
|
| - if (fAtomsWritten > 1 && fTotalWritten > 4) { //ignore done
|
| - gServer.acceptConnections();
|
| - gServer.writePacket(fBlock, fTotalWritten);
|
| - }
|
| -#endif
|
| - }
|
| - sk_free(fBlock);
|
| -}
|
| -
|
| -void* SimplePC::requestBlock(size_t minRequest, size_t* actual) {
|
| - sk_free(fBlock);
|
| -
|
| - fBlockSize = minRequest * 4;
|
| - fBlock = sk_malloc_throw(fBlockSize);
|
| - fBytesWritten = 0;
|
| - *actual = fBlockSize;
|
| - return fBlock;
|
| -}
|
| -
|
| -void SimplePC::notifyWritten(size_t bytes) {
|
| - SkASSERT(fBytesWritten + bytes <= fBlockSize);
|
| - fStatus = fReader.playback((const char*)fBlock + fBytesWritten, bytes);
|
| - SkASSERT(SkGPipeReader::kError_Status != fStatus);
|
| - fBytesWritten += bytes;
|
| - fTotalWritten += bytes;
|
| -
|
| - fAtomsWritten += 1;
|
| -}
|
| -
|
| -void SampleView::draw(SkCanvas* canvas) {
|
| - if (SkOSMenu::kOffState == fPipeState) {
|
| - this->INHERITED::draw(canvas);
|
| - } else {
|
| - SkGPipeWriter writer;
|
| - SimplePC controller(canvas);
|
| - SkBitmap bitmap = capture_bitmap(canvas);
|
| - TiledPipeController tc(bitmap, &SkImageDecoder::DecodeMemory, &canvas->getTotalMatrix());
|
| - SkGPipeController* pc;
|
| - if (SkOSMenu::kMixedState == fPipeState) {
|
| - pc = &tc;
|
| - } else {
|
| - pc = &controller;
|
| - }
|
| - uint32_t flags = SkGPipeWriter::kCrossProcess_Flag;
|
| -
|
| - canvas = writer.startRecording(pc, flags);
|
| - //Must draw before controller goes out of scope and sends data
|
| - this->INHERITED::draw(canvas);
|
| - //explicitly end recording to ensure writer is flushed before the memory
|
| - //is freed in the deconstructor of the controller
|
| - writer.endRecording();
|
| - }
|
| -}
|
| -
|
| void SampleView::onDraw(SkCanvas* canvas) {
|
| if (!fHaveCalledOnceBeforeDraw) {
|
| fHaveCalledOnceBeforeDraw = true;
|
|
|