Ignore:
Timestamp:
Dec 31, 2001, 1:08:23 PM (24 years ago)
Author:
sandervl
Message:

use critical section in dib section class instead of vmutex

File:
1 edited

Legend:

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

    r7662 r7717  
    1 /* $Id: dibsect.cpp,v 1.61 2001-12-20 19:57:01 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.62 2001-12-31 12:08:20 sandervl Exp $ */
    22
    33/*
     
    2020#include <win32type.h>
    2121#include <misc.h>
    22 #define  OS2_ONLY
    23 #include "dibsect.h"
    24 #include <vmutex.h>
    2522#include <win32api.h>
    2623#include <winconst.h>
     
    2825#include <cpuhlp.h>
    2926#include <dcdata.h>
     27#include "dibsect.h"
    3028#include "oslibgpi.h"
    3129#include "rgbcvt.h"
     
    3331#define DBG_LOCALLOG  DBG_dibsect
    3432#include "dbglocal.h"
    35 
    36 static VMutex dibMutex;
    3733
    3834//******************************************************************************
     
    176172   this->iUsage = iUsage;
    177173
    178    dibMutex.enter();
     174   lock();
    179175   if(section == NULL)
    180176   {
     
    195191     dsect->next = this;
    196192   }
    197    dibMutex.leave();
     193   unlock();
    198194}
    199195//******************************************************************************
     
    216212        free(pOS2bmp);
    217213
    218    dibMutex.enter();
     214   lock();
    219215   if(section == this)
    220216   {
     
    231227     dsect->next = this->next;
    232228   }
    233    dibMutex.leave();
     229   unlock();
    234230}
    235231//******************************************************************************
     
    489485        hdcHeight = rect.bottom - rect.top;
    490486        hdcWidth  = rect.right - rect.left;
     487        dprintf(("DIBSection::BitBlt hdc size (%d,%d) (WINDOW)", hdcWidth, hdcHeight));
    491488  }
    492489  else {
    493490        hdcHeight = pHps->bitmapHeight;
    494491        hdcWidth  = pHps->bitmapWidth;
     492        dprintf(("DIBSection::BitBlt hdc size (%d,%d) (BMP)", hdcWidth, hdcHeight));
    495493  }
    496494
     
    498496  //This messes up the two bitmaps in the opening window of Opera 6
    499497  //(choice between MDI & SDI interface)
    500 #if 0
    501   if(nXdest + nDestWidth > hdcWidth) {
    502         nDestWidth  = hdcWidth - nXdest;
    503   }
    504 
    505   if(nYdest + nDestHeight > hdcHeight) {
    506         nDestHeight = hdcHeight - nYdest;
    507   }
    508 #endif
    509498
    510499  //win32 coordinates are relative to left top, OS/2 expects left bottom
     
    513502
    514503  point[0].x = nXdest;
     504  point[1].x = nXdest + nDestWidth - 1;
     505#ifdef INVERT
    515506  point[0].y = hdcHeight - nYdest - nDestHeight;
    516   point[1].x = nXdest + nDestWidth - 1;
    517507  point[1].y = hdcHeight - nYdest - 1;
    518 
    519 #if 0
    520   //Don't check size here either. Let GpiDrawBits do that for us
    521   if(nXsrc + nSrcWidth > pOS2bmp->cx) {
    522         nSrcWidth  = pOS2bmp->cx - nXsrc;
    523   }
    524   if(nYsrc + nSrcHeight > pOS2bmp->cy) {
    525         nSrcHeight = pOS2bmp->cy - nYsrc;
    526   }
     508#else
     509  point[0].y = nYdest;
     510  point[1].y = nYdest + nDestHeight - 1;
    527511#endif
    528512
    529513  //target rectangle is inclusive-inclusive
    530514  point[2].x = nXsrc;
     515  point[3].x = nXsrc + nSrcWidth;
     516#ifdef INVERT
    531517  point[2].y = pOS2bmp->cy - nYsrc - nSrcHeight;
    532   point[3].x = nXsrc + nSrcWidth;
    533518  point[3].y = pOS2bmp->cy - nYsrc;
     519#else
     520  point[2].y = nYsrc;
     521  point[3].y = nYsrc + nSrcHeight - 1;
     522#endif
    534523
    535524  dprintf(("DIBSection::BitBlt (%d,%d)(%d,%d) from (%d,%d)(%d,%d) dim (%d,%d)(%d,%d)", point[0].x, point[0].y,
     
    540529  oldyinversion = GpiQueryYInversion(hps);
    541530  if(oldyinversion != 0) {
     531#ifdef DEBUG
     532        POINT point;
     533        GetViewportOrgEx(hps, &point);
     534        dprintf(("Viewport origin (%d,%d)", point.x, point.y));
     535#endif
    542536        GpiEnableYInversion(hps, 0);
    543537        fRestoryYInversion = TRUE;
     
    631625        if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
    632626#endif
    633             SetLastError(ERROR_SUCCESS_W);
     627        SetLastError(ERROR_SUCCESS_W);
    634628
    635629        return(TRUE);
     
    661655      dprintf(("Sync destination dibsection: hdc y inversion = %d", oldyinversion));
    662656      if(oldyinversion != 0) {
     657#ifdef DEBUG
     658          POINT point;
     659          GetViewportOrgEx(hdc, &point);
     660          dprintf(("Viewport origin (%d,%d)", point.x, point.y));
     661#endif
    663662          GpiEnableYInversion(hdc, 0);
    664663      }
     
    774773
    775774  DIBSection *dsect = section;
    776   dibMutex.enter();
     775  lock();
    777776
    778777  do
     
    780779    if(dsect->handle == handle)
    781780    {
    782         dibMutex.leave();
     781        unlock();
    783782        return(dsect);
    784783    }
     
    787786  while(dsect);
    788787
    789   dibMutex.leave();
     788  unlock();
    790789  return(NULL);
    791790}
     
    801800  DIBSection *dsect = section;
    802801 
     802  lock();
    803803  do
    804804  {
    805805        if(dsect->hdc == hdc)
    806806        {
     807            unlock();
    807808            return(dsect);
    808809        }
     
    810811  }
    811812  while(dsect);
    812    
     813
     814  unlock();   
    813815  return(NULL);
    814816}
     
    873875//******************************************************************************
    874876//******************************************************************************
    875 DIBSection *DIBSection::section = NULL;
     877void DIBSection::initDIBSection()
     878{
     879    InitializeCriticalSection(&dibcritsect);
     880}
     881//******************************************************************************
     882//******************************************************************************
     883DIBSection      *DIBSection::section = NULL;
     884CRITICAL_SECTION DIBSection::dibcritsect;
Note: See TracChangeset for help on using the changeset viewer.