Ignore:
Timestamp:
Jan 11, 2004, 12:42:14 PM (22 years ago)
Author:
sandervl
Message:

Update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/dibsect.h

    r10321 r10373  
    1 /* $Id: dibsect.h,v 1.27 2003-11-14 17:31:47 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.28 2004-01-11 11:42:11 sandervl Exp $ */
    22
    33/*
     
    7575#endif
    7676
     77//
     78//Mark DIB section as invalid (dib section memory is out of sync with
     79//GDI bitmap).
     80//
     81//This must be done for any GDI function that modifies the bitmap
     82//
     83#define DIBSECTION_MARK_INVALID(hdc)                              \
     84    if(DIBSection::getSection() != NULL) {                        \
     85        DIBSection *dib = DIBSection::findHDC(hdc);               \
     86        if(dib) {                                                 \
     87            dib->setInvalid();                                    \
     88        }                                                         \
     89    }
     90
     91#define DIBSECTION_MARK_INVALID_BMP(hBitmap)                      \
     92    if(DIBSection::getSection() != NULL) {                        \
     93        DIBSection *dib = DIBSection::findObj(hBitmap);           \
     94        if(dib) {                                                 \
     95            dib->setInvalid();                                    \
     96        }                                                         \
     97    }
     98
     99//
     100//Check if DIB section is marked dirty (bitmap data modified by application)
     101//If true, then update the GDI bitmap
     102//
     103//This must be done for any GDI function that accesses the bitmap
     104//
     105#define DIBSECTION_CHECK_IF_DIRTY(hdc)                            \
     106    if(DIBSection::getSection() != NULL) {                        \
     107        DIBSection *dib = DIBSection::findHDC(hdc);               \
     108        if(dib && dib->isDirty()) {                               \
     109            dib->flush();                                         \
     110        }                                                         \
     111    }
     112
     113#define DIBSECTION_CHECK_IF_DIRTY_BMP(hBitmap)                    \
     114    if(DIBSection::getSection() != NULL) {                        \
     115        DIBSection *dib = DIBSection::findObj(hBitmap);           \
     116        if(dib && dib->isDirty()) {                               \
     117            dib->flush();                                         \
     118        }                                                         \
     119    }
     120
     121
    77122class DIBSection
    78123{
    79124public:
    80               DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip);
     125              DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, HBITMAP hBitmap, int fFlip);
    81126             ~DIBSection();
    82127
     
    88133              void  UnSelectDIBObject()      { this->hdc = 0;   };
    89134
    90         DWORD GetBitmapHandle()      { return handle; };
    91               void  SetBitmapHandle(DWORD bmphandle) { handle = bmphandle; };
     135              void  setDirty()               { fDirty = TRUE;   };
     136              BOOL  isDirty()                { return fDirty;   }
     137              void  setInvalid();
     138              BOOL  isInvalid()              { return fInvalid; };
     139
     140        DWORD GetBitmapHandle()              { return hBitmap; };
     141              void  SetBitmapHandle(DWORD bmphandle) { hBitmap = bmphandle; };
    92142        DWORD GetRGBUsage()            { return iUsage; };
    93143
     
    97147                           int nSrcWidth, int nSrcHeight,
    98148                           DWORD Rop);
     149
     150              void  flush();
     151              void  sync();
     152
    99153              void  sync(HDC hdc, DWORD nYdest, DWORD nDestHeight, BOOL orgYInversion = TRUE);
     154              void  flush(HDC hdc, DWORD nYdest, DWORD nDestHeight, BOOL orgYInversion = TRUE);
    100155              void  sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits);
     156
    101157               int  SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
    102158               int  GetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
    103159               int  SetDIBColorTable(int startIdx, int cEntries, PALETTEENTRY *rgb);
    104160
    105                int  SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
    106                               lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
    107                               UINT coloruse);
    108 
    109161               int  GetDIBSection(int iSize , void *lpBuffer);
    110162
    111163 static DIBSection *getSection() { return section; } ;
    112  static DIBSection *findObj(HANDLE handle);
     164 static DIBSection *findObj(HBITMAP hBitmap);
    113165 static DIBSection *findHDC(HDC hdc);
    114  static       void  deleteSection(HANDLE handle);
     166 static       void  deleteSection(HBITMAP hBitmap);
    115167
    116168 static       void  initDIBSection();
     
    119171 static       void  unlock() { LeaveCriticalSection(&dibcritsect); };
    120172
     173 static       void  syncAll();
     174
    121175protected:
    122176
    123177private:
    124           DWORD handle, iUsage;
    125           DWORD hSection, dwOffset;
     178          HBITMAP hBitmap;
     179 
     180          DWORD hSection, dwOffset, iUsage, dwSize;
    126181          HWND  hwndParent;
    127182          HDC   hdc;
     
    131186    DIBSECTION  dibinfo;
    132187
     188          BOOL  fDirty;         //bitmap is out of sync with dib memory
     189          BOOL  fInvalid;       //dib memory is out of sync with bitmap
     190
    133191    BITMAPINFO2 *pOS2bmp;
    134192                             // Linked list management
     
    139197};
    140198
    141 #define DIBSECTION_MARK_INVALID(a)
    142 #define DIBSECTION_CHECK_IF_DIRTY(a)
    143 
    144199#endif
    145200
Note: See TracChangeset for help on using the changeset viewer.