home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / Riza / h / displaymgr.h < prev   
Encoding:
C/C++ Source or Header  |  2009-09-14  |  3.7 KB  |  147 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    A/V interface library
  3. //    Copyright (C) 1998-2007 Avery Lee
  4. //
  5. //    This program is free software; you can redistribute it and/or modify
  6. //    it under the terms of the GNU General Public License as published by
  7. //    the Free Software Foundation; either version 2 of the License, or
  8. //    (at your option) any later version.
  9. //
  10. //    This program is distributed in the hope that it will be useful,
  11. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //    GNU General Public License for more details.
  14. //
  15. //    You should have received a copy of the GNU General Public License
  16. //    along with this program; if not, write to the Free Software
  17. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #ifndef f_VD2_RIZA_DISPLAYMGR_H
  20. #define f_VD2_RIZA_DISPLAYMGR_H
  21.  
  22. #ifdef _MSC_VER
  23.     #pragma once
  24. #endif
  25.  
  26. #include <vd2/system/vdstl.h>
  27. #include <vd2/system/thread.h>
  28.  
  29. class VDVideoDisplayManager;
  30.  
  31. class VDVideoDisplayClient : public vdlist_node {
  32. public:
  33.     VDVideoDisplayClient();
  34.     ~VDVideoDisplayClient();
  35.  
  36.     void Attach(VDVideoDisplayManager *pManager);
  37.     void Detach(VDVideoDisplayManager *pManager);
  38.     void SetPreciseMode(bool enabled);
  39.     void SetTicksEnabled(bool enabled);
  40.     void SetRequiresFullScreen(bool fs);
  41.  
  42.     const uint8 *GetLogicalPalette() const;
  43.     struct HPALETTE__ *GetPalette() const;
  44.     void RemapPalette();
  45.  
  46.     virtual void OnTick() {}
  47.     virtual void OnDisplayChange() {}
  48.     virtual void OnForegroundChange(bool foreground) {}
  49.     virtual void OnRealizePalette() {}
  50.  
  51. protected:
  52.     friend class VDVideoDisplayManager;
  53.  
  54.     VDVideoDisplayManager    *mpManager;
  55.  
  56.     bool    mbPreciseMode;
  57.     bool    mbTicksEnabled;
  58.     bool    mbRequiresFullScreen;
  59. };
  60.  
  61. class IVDVideoDisplayManager {
  62. };
  63.  
  64. class VDVideoDisplayManager : public VDThread, public IVDVideoDisplayManager {
  65. public:
  66.     VDVideoDisplayManager();
  67.     ~VDVideoDisplayManager();
  68.  
  69.     bool    Init();
  70.     void    Shutdown();
  71.  
  72.     void    SetBackgroundFallbackEnabled(bool enabled);
  73.  
  74.     void    RemoteCall(void (*function)(void *), void *data);
  75.  
  76.     void    AddClient(VDVideoDisplayClient *pClient);
  77.     void    RemoveClient(VDVideoDisplayClient *pClient);
  78.     void    ModifyPreciseMode(bool enabled);
  79.     void    ModifyTicksEnabled(bool enabled);
  80.  
  81.     void RemapPalette();
  82.     HPALETTE    GetPalette() const { return mhPalette; }
  83.     const uint8 *GetLogicalPalette() const { return mLogicalPalette; }
  84.  
  85. protected:
  86.     void    ThreadRun();
  87.     void    ThreadRunFullRemote();
  88.     void    ThreadRunTimerOnly();
  89.  
  90.     void    DispatchTicks();
  91.     void    PostTick();
  92.     void    DispatchRemoteCalls();
  93.  
  94.     bool    RegisterWindowClass();
  95.     void    UnregisterWindowClass();
  96.  
  97.     bool    IsDisplayPaletted();
  98.     void    CreateDitheringPalette();
  99.     void    DestroyDitheringPalette();
  100.     void    CheckForegroundState();
  101.  
  102.     static LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  103.     LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  104.  
  105. protected:
  106.     enum {
  107.         kTimerID_ForegroundPoll    = 10,
  108.         kTimerID_Tick            = 11
  109.     };
  110.  
  111.     VDAtomicInt    mTicksEnabledCount;
  112.     uintptr    mTickTimerId;
  113.  
  114.     int        mPreciseModeCount;
  115.     uint32    mPreciseModePeriod;
  116.  
  117.     HPALETTE    mhPalette;
  118.     ATOM        mWndClass;
  119.     HWND        mhwnd;
  120.  
  121.     bool        mbMultithreaded;
  122.     bool        mbAppActive;
  123.     bool        mbBackgroundFallbackEnabled;
  124.  
  125.     typedef vdlist<VDVideoDisplayClient> Clients;
  126.     Clients        mClients;
  127.  
  128.     VDThreadID            mThreadID;
  129.     VDAtomicInt            mOutstandingTicks;
  130.  
  131.     VDSignal            mStarted;
  132.     VDCriticalSection    mMutex;
  133.  
  134.     struct RemoteCallNode : vdlist_node {
  135.         void (*mpFunction)(void *data);
  136.         void *mpData;
  137.         VDSignal mSignal;
  138.     };
  139.  
  140.     typedef vdlist<RemoteCallNode> RemoteCalls;
  141.     RemoteCalls    mRemoteCalls;
  142.  
  143.     uint8    mLogicalPalette[256];
  144. };
  145.  
  146. #endif
  147.