Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.3 KiB

  1. /*****************************************************************************\
  2. FILE: pictures.h
  3. DESCRIPTION:
  4. Manage the pictures in the user's directories. Convert them when needed.
  5. Handle caching and making sure we don't use too much diskspace. Also add
  6. picture frames when needed.
  7. PERF:
  8. The biggest perf impact on this screen saver is how we handle loading the pictures.
  9. 1. If we load to many pictures, we will start paging and blow the texture
  10. memory.
  11. 2. If we recycle too much or too little, we will either use too much memory or look too repeative.
  12. 3. Latency is a killer. We want the main thread being CPU and video card bound while
  13. we have a background thread loading and uncompressing images. This will allow
  14. the background thread to be I/O bound so the forground can still render fairly well.
  15. We need to decide a size and scale pictures down to that size. This will reduce the memory
  16. requirements. If we determine that smallest picture we can use that will still look good,
  17. we should be okay.
  18. Here are some numbers:
  19. Images Size Each Picture For 18 Images
  20. =========== ============= =============
  21. 320x240 .152 MB 5.47 MB
  22. 640x480 .6 MB 21 MB
  23. 800x600 .96 MB 34 MB
  24. 1024x768 1.5 MB 54 MB
  25. BryanSt 12/24/2000
  26. Copyright (C) Microsoft Corp 2000-2001. All rights reserved.
  27. \*****************************************************************************/
  28. #ifndef PICTURES_H
  29. #define PICTURES_H
  30. #include "util.h"
  31. #include "main.h"
  32. #include "config.h"
  33. class CPictureManager;
  34. extern CPictureManager * g_pPictureMgr;
  35. #define GNPF_NONE 0x00000000
  36. #define GNPF_RECYCLEPAINTINGS 0x00000001 // The picture is probably in a side room so reuse pictures to keep memory use down.
  37. #define MAX_PICTURES_IN_BATCH 7
  38. typedef struct
  39. {
  40. LPTSTR pszPath;
  41. CTexture * pTexture;
  42. BOOL fInABatch; // Has this painting been loaded?
  43. } SSPICTURE_INFO;
  44. typedef struct
  45. {
  46. SSPICTURE_INFO * pInfo[MAX_PICTURES_IN_BATCH];
  47. } SSPICTURES_BATCH;
  48. class CPictureManager
  49. {
  50. public:
  51. // Member Functions
  52. HRESULT GetPainting(int nBatch, int nIndex, DWORD dwFlags, CTexture ** ppTexture);
  53. HRESULT PreFetch(int nBatch, int nToFetch);
  54. HRESULT ReleaseBatch(int nBatch);
  55. CPictureManager(CMSLogoDXScreenSaver * pMain);
  56. virtual ~CPictureManager();
  57. private:
  58. // Private Functions
  59. // Enum and build of picture list
  60. HRESULT _PInfoCreate(int nIndex, LPCTSTR pszPath);
  61. HRESULT _EnumPaintings(void);
  62. HRESULT _AddPaintingsFromDir(LPCTSTR pszPath);
  63. // Create a batch
  64. HRESULT _LoadTexture(SSPICTURE_INFO * pInfo, BOOL fFaultInTexture);
  65. HRESULT _GetNextWithWrap(SSPICTURE_INFO ** ppInfo, BOOL fAlreadyLoaded, BOOL fFaultInTexture);
  66. HRESULT _TryGetNextPainting(SSPICTURE_INFO ** ppInfo, DWORD dwFlags);
  67. HRESULT _CreateNewBatch(int nBatch, BOOL fFaultInTexture);
  68. // Member Variables
  69. HDSA m_hdsaPictures; // Contains SSPICTURE_INFO. We want each painting in m_hdpaPaintings to be ref-counted.
  70. int m_nCurrent;
  71. HDSA m_hdsaBatches; // Contains Batches (SSPICTURES_BATCH)
  72. int m_nCurrentBatch; //
  73. CMSLogoDXScreenSaver * m_pMain; // Weak reference
  74. };
  75. #endif // PICTURES_H