# HG changeset patch # User sl # Date 1401440180 -7200 # Node ID cd6d76b9b47e2f26f49bf65d9bdb67d18ba44596 # Parent be04ffbb561cdefe87a2f222ca92df5b4d32cae3 Pixel diff logic for frame rate improvment now working. It's still working on a per pixels bases so too slow with full screen update. Thus it's still disabled. diff -r be04ffbb561c -r cd6d76b9b47e MiniDisplay/FutabaVfd.cpp --- a/MiniDisplay/FutabaVfd.cpp Thu May 29 21:42:07 2014 +0200 +++ b/MiniDisplay/FutabaVfd.cpp Fri May 30 10:56:20 2014 +0200 @@ -74,11 +74,13 @@ GP1212A01A::GP1212A01A(): iDisplayPositionX(0),iDisplayPositionY(0), iOffScreenMode(true), + iFrameNext(NULL), + iFrameCurrent(NULL), + iFramePrevious(NULL), iFrameAlpha(NULL), iFrameBeta(NULL), - iCurrentFrame(NULL), - iNextFrame(NULL), - iNeedFullFrameUpdate(true), + iFrameGamma(NULL), + iNeedFullFrameUpdate(0), iRequest(ERequestNone),iPowerOn(false) { //ResetBuffers(); @@ -94,10 +96,14 @@ delete iFrameBeta; iFrameBeta=NULL; // - iNextFrame=NULL; - iCurrentFrame=NULL; + delete iFrameGamma; + iFrameGamma=NULL; // - iNeedFullFrameUpdate=true; + iFrameNext=NULL; + iFrameCurrent=NULL; + iFramePrevious=NULL; + // + iNeedFullFrameUpdate=0; } /** @@ -116,10 +122,17 @@ iFrameBeta=NULL; iFrameBeta=new BitArray(KGP12xFrameBufferPixelCount); // - iCurrentFrame=iFrameAlpha; - iNextFrame=iFrameBeta; + delete iFrameGamma; + iFrameGamma=NULL; + iFrameGamma=new BitArray(KGP12xFrameBufferPixelCount); + // + iFrameNext=iFrameAlpha; + iFrameCurrent=iFrameBeta; + iFramePrevious=iFrameGamma; + + //To make sure it is synced properly - iNeedFullFrameUpdate=true; + iNeedFullFrameUpdate=0; // SetNonBlocking(1); //Since we can't get our display position we force it to our default @@ -143,11 +156,11 @@ { if (aOn) { - iNextFrame->SetBit(aX*HeightInPixels()+aY); + iFrameNext->SetBit(aX*HeightInPixels()+aY); } else { - iNextFrame->ClearBit(aX*HeightInPixels()+aY); + iFrameNext->ClearBit(aX*HeightInPixels()+aY); } } else @@ -166,12 +179,29 @@ { for (int j=0;jSetBitValue((aTargetX+i)*HeightInPixels()+aTargetY+j,aBitmap[+i*aSrcHeight+j]); + iFrameNext->SetBitValue((aTargetX+i)*HeightInPixels()+aTargetY+j,aBitmap[+i*aSrcHeight+j]); } } } /** +Clear our client side back buffer. +Call to SwapBuffers must follow to actually clear the display. +*/ +void GP1212A01A::Clear() + { + //memset(iNextFrame->Ptr(),0x00,FrameBufferSizeInBytes()); + if (iOffScreenMode) + { + iFrameNext->ClearAll(); + } + else + { + SendClearCommand(); + } + } + +/** Set all pixels on our screen to the desired value. This operation is performed off screen to avoid tearing. @param 8 pixels pattern @@ -186,7 +216,7 @@ if (iOffScreenMode) { - memset(iNextFrame->Ptr(),aPattern,FrameBufferSizeInBytes()); + memset(iFrameNext->Ptr(),aPattern,FrameBufferSizeInBytes()); } else { @@ -277,24 +307,6 @@ } } - -/** -Clear our client side back buffer. -Call to SwapBuffers must follow to actually clear the display. -*/ -void GP1212A01A::Clear() - { - //memset(iNextFrame->Ptr(),0x00,FrameBufferSizeInBytes()); - if (iOffScreenMode) - { - iNextFrame->ClearAll(); - } - else - { - SendClearCommand(); - } - } - /** Using this function is advised against as is causes tearing. Use Clear instead. @@ -363,11 +375,11 @@ if (OffScreenMode()) { //Send host back buffer to device back buffer - if (iNeedFullFrameUpdate) + if (iNeedFullFrameUpdate<3) { //TODO: enable this once SendModifiedPixelBlocks works - //iNeedFullFrameUpdate=false; - SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),iNextFrame->Ptr()); + //iNeedFullFrameUpdate++; + SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),iFrameNext->Ptr()); } else { @@ -376,9 +388,14 @@ //Swap device front and back buffer SetDisplayPosition(iDisplayPositionX,OffScreenY()); //Swap host buffers - BitArray* nextFrame=iCurrentFrame; - iCurrentFrame = iNextFrame; - iNextFrame = nextFrame; + //BitArray* nextFrame=iFrameNext; + //iFrameCurrent = iFramePrevious; + //iFrameNext = iFramePrevious; + + BitArray* previousFrame=iFramePrevious; + iFramePrevious = iFrameCurrent; + iFrameCurrent = iFrameNext; + iFrameNext = previousFrame; } } @@ -398,14 +415,34 @@ int h=HeightInPixels(); BitArray block(16*16); + + //TODO: optimize with memcmp and 16 inc + for (int i=0;iPtr()+offset); + } + } + } + + /* for (int i=0;iPtr()+offset,iCurrentFrame->Ptr()+offset,32 /*(16*16/8)*/)) + if (memcmp(iNextFrame->Ptr()+offset,iCurrentFrame->Ptr()+offset,32 )) //32=(16*16/8) { //We need to update that block @@ -424,6 +461,7 @@ } } } + */ } @@ -533,12 +571,7 @@ */ void GP1212A01A::ToggleOffScreenMode() { - iOffScreenMode=!iOffScreenMode; - //Clean up our buffers upon switching modes - SetDisplayPosition(0,0); - Clear(); - SwapBuffers(); - Clear(); + SetOffScreenMode(!iOffScreenMode); } /** diff -r be04ffbb561c -r cd6d76b9b47e MiniDisplay/FutabaVfd.h --- a/MiniDisplay/FutabaVfd.h Thu May 29 21:42:07 2014 +0200 +++ b/MiniDisplay/FutabaVfd.h Fri May 30 10:56:20 2014 +0200 @@ -191,13 +191,15 @@ //FutabaVfdReport iReport; /// //unsigned char iFrameBuffer[256*64]; - BitArray* iNextFrame; - BitArray* iCurrentFrame; + BitArray* iFrameNext; + BitArray* iFrameCurrent; + BitArray* iFramePrevious; // BitArray* iFrameAlpha; BitArray* iFrameBeta; + BitArray* iFrameGamma; // - bool iNeedFullFrameUpdate; + int iNeedFullFrameUpdate; //unsigned char iFrameBeta[256*64]; //unsigned char *iFrontBuffer; //unsigned char *iBackBuffer;