home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- #
- # GDeviceUtils.h
- #
- # by Eric Traut
- #
- ------------------------------------------------------------------------------*/
-
- #include <Types.h>
- #include <QDOffscreen.h>
- #include <Displays.h>
-
- // GraphicSurface
- // This class encapsulates a blitting surface, specifying
- // its base pointer, depth, dimensions and rowBytes values.
- // The actual surface may be real or virtual. In many ways,
- // it's comparable to a GWorld in the Mac toolbox.
- class GraphicSurface
- {
- public:
- GraphicSurface();
-
- void
- ExtractRealDeviceInfo(
- GDHandle inGDevice);
-
- UInt16
- GetRowBytes() const
- {
- return mRowBytes;
- }
-
- UInt8 *
- GetPixelDataPtr() const
- {
- return mPixelData;
- }
-
- UInt16
- GetBitDepth() const
- {
- return mBitDepth;
- }
-
- UInt16
- GetHeight() const
- {
- return mHeight;
- }
-
- UInt16
- GetWidth() const
- {
- return mWidth;
- }
-
- UInt32
- GetBackingSize() const
- {
- // Allocate two extra scan lines for some slop
- return GetRowBytes() * (GetHeight() + 2);
- }
-
- private:
- UInt16 mRowBytes;
- UInt8 * mPixelData;
- UInt16 mBitDepth;
- UInt16 mHeight;
- UInt16 mWidth;
- };
-
-
- class VirtualGDevice;
-
- class GraphicBlendEffect
- {
- public:
- GraphicBlendEffect()
- {
- }
-
- virtual
- ~GraphicBlendEffect()
- {
- }
-
- virtual Boolean
- Initialize()
- {
- return true;
- }
-
- virtual void
- RenderVirtualDevice(
- const GraphicSurface & inDestSurface,
- VirtualGDevice * inVDevice) = 0;
- };
-
-
- class LargeBlendEffect : public GraphicBlendEffect
- {
- public:
- enum
- {
- kCircleWidth = 128
- };
-
- LargeBlendEffect();
-
- UInt16
- AveragePixels(
- UInt16 inPixel1,
- UInt16 inPixel2,
- UInt16 inPixel3,
- UInt16 inPixel4);
-
- void
- EnableMagnify(
- Boolean inEnable)
- {
- mMagnify = inEnable;
- }
-
- virtual void
- RenderVirtualDevice(
- const GraphicSurface & inDestSurface,
- VirtualGDevice * inVDevice);
-
- UInt16
- BlendPixels(
- UInt16 inPixel1,
- UInt16 inPixel2,
- UInt32 inFraction);
-
- private:
- Handle mCircleData;
- Boolean mMagnify;
- };
-
-
- // CapturedGDevice
- // This class allows us to "capture" an existing GDevice (monitor).
- class CapturedGDevice
- {
- public:
- CapturedGDevice();
-
- virtual
- ~CapturedGDevice();
-
- void
- CaptureDevice(
- GDHandle inGDevice,
- VirtualGDevice * inVDevice);
-
- void
- UncaptureDevice();
-
- void
- UpdateCapturedScreen();
-
- void
- RecomputeGDHandle();
-
- GraphicSurface &
- GetGraphicSurface()
- {
- return mCapturedSurface;
- }
-
- void
- SetGraphicBlendEffect(
- GraphicBlendEffect * inBlendEffect);
-
- void
- SetGraphicBlendValue(
- UInt32 inValueIndex,
- double inValue);
-
- void
- SetPixelBase(
- UInt8 * inPixelBase);
-
- PixMapHandle
- GetPixMapHandle()
- {
- return mGDHandle[0]->gdPMap;
- }
-
- void
- ClearCapturedScreen();
-
- private:
- GraphicBlendEffect * mBlendEffect;
-
- GraphicSurface mCapturedSurface;
- GDHandle mGDHandle;
- DisplayIDType mDisplayID;
- Boolean mDeviceCaptured;
-
- VirtualGDevice * mVirtualDevice;
- };
-
-
- // VirtualGDevice
- // This class allows us to create a new "virtual" GDevice, effectively
- // adding a monitor to the system. One VirtualGDevice (and one only)
- // should be designated the "primary" device. This allows us to make
- // use of the existing GWorld handle in the system.
- class VirtualGDevice
- {
- public:
- VirtualGDevice();
-
- virtual
- ~VirtualGDevice();
-
- Boolean
- Initialize(
- CapturedGDevice & inRealGDevice,
- Handle inDMConfigHandle);
-
- void
- Uninitialize();
-
- void
- RecomputeGDHandle();
-
- GraphicSurface &
- GetGraphicSurface()
- {
- return mVirtualSurface;
- }
-
- GDHandle
- GetGDHandle()
- {
- RecomputeGDHandle();
- return mGDHandle;
- }
-
- private:
- GraphicSurface mVirtualSurface;
- Ptr mDeviceBacking;
- Boolean mAddedToDeviceList;
- GDHandle mGDHandle;
- DisplayIDType mDisplayID;
- };
-
-
-
-
-
-
-