Leaked source code of windows server 2003
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.

166 lines
4.7 KiB

  1. /***************************************************************************\
  2. *
  3. * File: Buffer.inl
  4. *
  5. * History:
  6. * 1/18/2000: JStall: Created
  7. *
  8. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  9. *
  10. \***************************************************************************/
  11. #if !defined(SERVICES__Buffer_inl__INCLUDED)
  12. #define SERVICES__Buffer_inl__INCLUDED
  13. /***************************************************************************\
  14. *****************************************************************************
  15. *
  16. * class DCBmpBufferCache
  17. *
  18. *****************************************************************************
  19. \***************************************************************************/
  20. //------------------------------------------------------------------------------
  21. inline DCBmpBuffer *
  22. DCBmpBufferCache::Get()
  23. {
  24. return static_cast<DCBmpBuffer *> (Pop());
  25. }
  26. //------------------------------------------------------------------------------
  27. inline void
  28. DCBmpBufferCache::Release(DCBmpBuffer * pbufBmp)
  29. {
  30. Push(pbufBmp);
  31. }
  32. /***************************************************************************\
  33. *****************************************************************************
  34. *
  35. * class GpBmpBufferCache
  36. *
  37. *****************************************************************************
  38. \***************************************************************************/
  39. //------------------------------------------------------------------------------
  40. inline GpBmpBuffer *
  41. GpBmpBufferCache::Get()
  42. {
  43. return static_cast<GpBmpBuffer *> (Pop());
  44. }
  45. //------------------------------------------------------------------------------
  46. inline void
  47. GpBmpBufferCache::Release(GpBmpBuffer * pbufBmp)
  48. {
  49. Push(pbufBmp);
  50. }
  51. /***************************************************************************\
  52. *****************************************************************************
  53. *
  54. * class TrxBuffer
  55. *
  56. *****************************************************************************
  57. \***************************************************************************/
  58. //------------------------------------------------------------------------------
  59. DxSurface *
  60. TrxBuffer::GetSurface(int idxSurface) const
  61. {
  62. AssertMsg((idxSurface < m_cSurfaces) && (idxSurface >= 0), "Ensure valid index");
  63. return m_rgpsur[idxSurface];
  64. }
  65. //------------------------------------------------------------------------------
  66. inline SIZE
  67. TrxBuffer::GetSize() const
  68. {
  69. return m_sizePxl;
  70. }
  71. //------------------------------------------------------------------------------
  72. inline BOOL
  73. TrxBuffer::GetInUse() const
  74. {
  75. return m_fInUse;
  76. }
  77. //------------------------------------------------------------------------------
  78. inline void
  79. TrxBuffer::SetInUse(BOOL fInUse)
  80. {
  81. m_fInUse = fInUse;
  82. }
  83. /***************************************************************************\
  84. *****************************************************************************
  85. *
  86. * class BufferManager
  87. *
  88. *****************************************************************************
  89. \***************************************************************************/
  90. //------------------------------------------------------------------------------
  91. inline HRESULT
  92. BufferManager::GetSharedBuffer(const RECT * prcInvalid, DCBmpBuffer ** ppbuf)
  93. {
  94. UNREFERENCED_PARAMETER(prcInvalid);
  95. AssertWritePtr(ppbuf);
  96. AssertMsg(!m_bufDCBmpShared.InUse(), "Only should setup buffering once per subtree");
  97. *ppbuf = &m_bufDCBmpShared;
  98. return S_OK;
  99. }
  100. //------------------------------------------------------------------------------
  101. inline HRESULT
  102. BufferManager::GetSharedBuffer(const RECT * prcInvalid, GpBmpBuffer ** ppbuf)
  103. {
  104. UNREFERENCED_PARAMETER(prcInvalid);
  105. AssertWritePtr(ppbuf);
  106. AssertMsg((m_pbufGpBmpShared == NULL) || !m_pbufGpBmpShared->InUse(),
  107. "Only should setup buffering once per subtree");
  108. if (m_pbufGpBmpShared == NULL) {
  109. m_pbufGpBmpShared = ProcessNew(GpBmpBuffer);
  110. if (m_pbufGpBmpShared == NULL) {
  111. return E_OUTOFMEMORY;
  112. }
  113. }
  114. AssertMsg(m_pbufGpBmpShared != NULL, "Must be properly allocated");
  115. *ppbuf = m_pbufGpBmpShared;
  116. return S_OK;
  117. }
  118. //------------------------------------------------------------------------------
  119. inline void
  120. BufferManager::ReleaseSharedBuffer(BmpBuffer * pbuf)
  121. {
  122. AssertMsg(!pbuf->InUse(), "Buffer should no longer be in use when released");
  123. if ((pbuf != &m_bufDCBmpShared) &&
  124. (pbuf != m_pbufGpBmpShared)) {
  125. AssertMsg(0, "Unknown shared buffer");
  126. }
  127. }
  128. #endif // SERVICES__Buffer_inl__INCLUDED