home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-23 | 2.6 KB | 104 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CInvertBehavior.cp ©1999 Eric Traut
- // ===========================================================================
-
- #include "CInvertBehavior.h"
- #include "CShadowWindow.h"
-
-
- // ---------------------------------------------------------------------------
- // • CInvertBehavior
- // ---------------------------------------------------------------------------
-
- CInvertBehavior::CInvertBehavior(
- CShadowWindow & inShadowWindow)
- : COffscreenBehavior(inShadowWindow, true)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • SyncWithShadowWindow
- // ---------------------------------------------------------------------------
-
- Boolean
- CInvertBehavior::SyncWithShadowWindow(void)
- {
- Boolean didSync;
-
- didSync = COffscreenBehavior::SyncWithShadowWindow();
-
- if (didSync)
- {
- // Recalculate our blur rect
- CWindowRecord * macWindow = mShadowWindow.GetMacWindow();
- mInvertRect = macWindow->port.portRect;
-
- mInvertRect.right -= 15;
- mInvertRect.bottom -= 15;
- mInvertRect.top += 21;
- }
-
- return didSync;
- }
-
-
- // ---------------------------------------------------------------------------
- // • RenderToGWorld
- // ---------------------------------------------------------------------------
-
- Boolean
- CInvertBehavior::RenderToGWorld(
- StGWorldLocker & inBackingLocker,
- StGWorldLocker & inRenderingLocker)
- {
- UInt16 row;
- UInt16 column;
- UInt16 maxRow;
- UInt16 maxColumn;
- UInt16 srcRowWords;
- UInt16 destRowWords;
- UInt16 * srcRowPtr;
- UInt16 * destRowPtr;
- PixMapPtr tempPixMap;
-
- tempPixMap = *inBackingLocker.GetPixMap();
- srcRowWords = (tempPixMap->rowBytes & 0x3FFF) / 2;
- srcRowPtr = reinterpret_cast<UInt16 *>(tempPixMap->baseAddr);
-
- tempPixMap = *inRenderingLocker.GetPixMap();
- destRowWords = (tempPixMap->rowBytes & 0x3FFF) / 2;
- destRowPtr = reinterpret_cast<UInt16 *>(tempPixMap->baseAddr);
-
- maxRow = tempPixMap->bounds.bottom - tempPixMap->bounds.top;
- maxColumn = tempPixMap->bounds.right - tempPixMap->bounds.left;
-
- // Simply invert everything in the specified rectangle
- for (row = 0; row < maxRow; row++)
- {
- for (column = 0; column < maxColumn; column++)
- {
- UInt32 accumRed = 0;
- UInt32 accumGreen = 0;
- UInt32 accumBlue = 0;
-
- if (column >= mInvertRect.left && column < mInvertRect.right &&
- row >= mInvertRect.top && row < mInvertRect.bottom)
- {
- destRowPtr[column] = ~srcRowPtr[column];
- }
- else
- {
- destRowPtr[column] = srcRowPtr[column];
- }
- }
-
- srcRowPtr += srcRowWords;
- destRowPtr += destRowWords;
- }
-
- return true;
- }
-
-
-