DXGL r255 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r254‎ | r255 | r256 >
Date:23:16, 3 September 2012
Author:admin
Status:new
Tags:
Comment:
Cache legacy DDraw interfaces.
Add reference when adding texture to D3D interface.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -610,26 +610,54 @@
611611 }
612612 if(riid == IID_IDirectDraw)
613613 {
614 - // Create an IDirectDraw1 interface
615 - this->AddRef();
616 - *ppvObj = new glDirectDraw1(this);
617 - this->Release();
618 - return DD_OK;
 614+ if(glDD1)
 615+ {
 616+ *ppvObj = glDD1;
 617+ glDD1->AddRef();
 618+ return DD_OK;
 619+ }
 620+ else
 621+ {
 622+ // Create an IDirectDraw1 interface
 623+ this->AddRef();
 624+ *ppvObj = new glDirectDraw1(this);
 625+ glDD1 = (glDirectDraw1*)*ppvObj;
 626+ return DD_OK;
 627+ }
619628 }
620629 if(riid == IID_IDirectDraw2)
621630 {
622 - // Create an IDirectDraw2 interface
623 - this->AddRef();
624 - *ppvObj = new glDirectDraw2(this);
625 - this->Release();
626 - return DD_OK;
 631+ if(glDD2)
 632+ {
 633+ *ppvObj = glDD2;
 634+ glDD2->AddRef();
 635+ return DD_OK;
 636+ }
 637+ else
 638+ {
 639+ // Create an IDirectDraw2 interface
 640+ this->AddRef();
 641+ *ppvObj = new glDirectDraw2(this);
 642+ glDD2 = (glDirectDraw2*)*ppvObj;
 643+ return DD_OK;
 644+ }
627645 }
628646 if(riid == IID_IDirectDraw4)
629647 {
630 - // Create an IDirectDraw4 interface
631 - this->AddRef();
632 - *ppvObj = new glDirectDraw4(this);
633 - return DD_OK;
 648+ if(glDD4)
 649+ {
 650+ *ppvObj = glDD4;
 651+ glDD4->AddRef();
 652+ return DD_OK;
 653+ }
 654+ else
 655+ {
 656+ // Create an IDirectDraw4 interface
 657+ this->AddRef();
 658+ *ppvObj = new glDirectDraw4(this);
 659+ glDD4 = (glDirectDraw4*)*ppvObj;
 660+ return DD_OK;
 661+ }
634662 }
635663 if(riid == IID_IDirectDraw7)
636664 {
@@ -963,6 +991,9 @@
964992 if(initialized) return DDERR_ALREADYINITIALIZED;
965993 primarylost = true;
966994 glD3D7 = NULL;
 995+ glDD1 = NULL;
 996+ glDD2 = NULL;
 997+ glDD4 = NULL;
967998 renderer = NULL;
968999 primary = NULL;
9691000 fullscreen = false;
@@ -1424,7 +1455,6 @@
14251456 glDirectDraw1::glDirectDraw1(glDirectDraw7 *gl_DD7)
14261457 {
14271458 glDD7 = gl_DD7;
1428 - glDD7->AddRef();
14291459 refcount = 1;
14301460 }
14311461 glDirectDraw1::~glDirectDraw1()
@@ -1572,7 +1602,6 @@
15731603 glDirectDraw2::glDirectDraw2(glDirectDraw7 *gl_DD7)
15741604 {
15751605 glDD7 = gl_DD7;
1576 - glDD7->AddRef();
15771606 refcount = 1;
15781607 }
15791608 glDirectDraw2::~glDirectDraw2()
Index: ddraw/glDirectDraw.h
@@ -24,6 +24,9 @@
2525 class glDirect3D7;
2626 class glRenderer;
2727
 28+class glDirectDraw1;
 29+class glDirectDraw2;
 30+class glDirectDraw4;
2831 class glDirectDraw7 : public IDirectDraw7
2932 {
3033 public:
@@ -81,6 +84,9 @@
8285 void DeleteClipper(glDirectDrawClipper *clipper);
8386 glDirectDrawSurface7 *primary;
8487 bool primarylost;
 88+ glDirectDraw1 *glDD1;
 89+ glDirectDraw2 *glDD2;
 90+ glDirectDraw4 *glDD4;
8591 private:
8692 HRESULT error;
8793 ULONG refcount;
Index: ddraw/glDirectDrawSurface.cpp
@@ -1168,6 +1168,7 @@
11691169 }
11701170 device = glD3DDev7;
11711171 handle = device->AddTexture(this);
 1172+ device->AddRef();
11721173 *lpHandle = handle;
11731174 return D3D_OK;
11741175 }