DXGL r679 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r678‎ | r679 | r680 >
Date:23:12, 17 August 2016
Author:admin
Status:new
Tags:
Comment:
Fix item highlight and add focus rectangle to application list in dxglcfg
Note: Contains yet-to-be-enabled WIP code.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/struct.h (modified) (history)
  • /ddraw/struct_command.h (modified) (history)
  • /dxglcfg/dxglcfg.c (modified) (history)
  • /dxglcfg2/dxglcfg2.c (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -138,7 +138,7 @@
139139 * @return
140140 * Return value specific to command, DD_OK if succeeded.
141141 */
142 -HRESULT glRenderer_AddCommand(glRenderer *This, BYTE *command)
 142+HRESULT glRenderer_AddCommand(glRenderer *This, BYTE *command, BOOL inner)
143143 {
144144 DWORD opcode = (DWORD)*command;
145145 DWORD cmdsize = (DWORD)*((unsigned char*)command + 4);
@@ -149,7 +149,8 @@
150150 RECT wndrect;
151151 int screenx, screeny;
152152 LONG_PTR winstyle, winstyleex;
153 - EnterCriticalSection(&This->cs);
 153+ BOOL restart_cmd = FALSE;
 154+ if (!inner) EnterCriticalSection(&This->cs);
154155 switch (opcode)
155156 {
156157 case OP_NULL:
@@ -202,6 +203,14 @@
203204 break;
204205 case OP_BLT: // Perform a Blt() operation, issuing necessary commands to set it
205206 // up.
 207+ if (This->state.last_cmd == OP_BLT)
 208+ {
 209+
 210+ }
 211+ if(restart_cmd)
 212+ {
 213+
 214+ }
206215 error = DDERR_CURRENTLYNOTAVAIL;
207216 break;
208217 case OP_DRAWSCREEN: // Draws the screen. Flip command buffer after executing.
@@ -264,7 +273,8 @@
265274 error = DDERR_INVALIDPARAMS;
266275 break;
267276 }
268 - LeaveCriticalSection(&This->cs);
 277+ This->state.last_cmd = opcode;
 278+ if (!inner) LeaveCriticalSection(&This->cs);
269279 return error;
270280 }
271281
@@ -1713,7 +1723,7 @@
17141724 if (cmd->flags & 0x20000000) SetColorKeyUniform(cmd->src->levels[cmd->srclevel].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue, cmd->src->colorsizes,
17151725 cmd->src->colororder, shader->shader.uniforms[7], cmd->src->colorbits, This->ext);
17161726 }
1717 - if (!(cmd->flags & DDBLT_COLORFILL)) This->ext->glUniform1i(shader->shader.uniforms[1], 0);
 1727+ if (!(cmd->flags & DDBLT_COLORFILL)) This->ext->glUniform1i(shader->shader.uniforms[1], 8);
17181728 if ((cmd->flags & DDBLT_KEYDEST) && (This && (cmd->dest->levels[cmd->destlevel].ddsd.dwFlags & DDSD_CKDESTBLT)))
17191729 {
17201730 SetColorKeyUniform(cmd->dest->levels[cmd->destlevel].ddsd.ddckCKDestBlt.dwColorSpaceLowValue, cmd->dest->colorsizes,
@@ -1723,27 +1733,27 @@
17241734 }
17251735 if (usedest && (shader->shader.uniforms[2] != -1))
17261736 {
1727 - glUtil_SetTexture(This->util, 1, This->backbuffer);
1728 - This->ext->glUniform1i(shader->shader.uniforms[2], 1);
 1737+ glUtil_SetTexture(This->util, 9, This->backbuffer);
 1738+ This->ext->glUniform1i(shader->shader.uniforms[2], 9);
17291739 }
17301740 if (usepattern && (shader->shader.uniforms[3] != -1))
17311741 {
17321742 if (cmd->pattern->levels[cmd->patternlevel].dirty & 1) glTexture__Upload(cmd->pattern, cmd->patternlevel);
1733 - glUtil_SetTexture(This->util, 2, cmd->pattern);
1734 - This->ext->glUniform1i(shader->shader.uniforms[3], 2);
 1743+ glUtil_SetTexture(This->util, 10, cmd->pattern);
 1744+ This->ext->glUniform1i(shader->shader.uniforms[3], 10);
17351745 This->ext->glUniform2i(shader->shader.uniforms[9],
17361746 cmd->pattern->levels[cmd->patternlevel].ddsd.dwWidth, cmd->pattern->levels[cmd->patternlevel].ddsd.dwHeight);
17371747 }
17381748 if (cmd->flags & 0x10000000) // Use clipper
17391749 {
1740 - glUtil_SetTexture(This->util, 3, cmd->dest->stencil);
1741 - This->ext->glUniform1i(shader->shader.uniforms[4],3);
 1750+ glUtil_SetTexture(This->util, 11, cmd->dest->stencil);
 1751+ This->ext->glUniform1i(shader->shader.uniforms[4],11);
17421752 glUtil_EnableArray(This->util, shader->shader.attribs[5], TRUE);
17431753 This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].stencils);
17441754 }
17451755 if (cmd->src)
17461756 {
1747 - glUtil_SetTexture(This->util, 0, cmd->src);
 1757+ glUtil_SetTexture(This->util, 8, cmd->src);
17481758 if(This->ext->GLEXT_ARB_sampler_objects)
17491759 {
17501760 if((dxglcfg.scalingfilter == 0) || (This->ddInterface->GetBPP() == 8))\
@@ -1751,7 +1761,7 @@
17521762 else glTexture__SetFilter(cmd->src, 0, GL_LINEAR, GL_LINEAR, This);
17531763 }
17541764 }
1755 - else glUtil_SetTexture(This->util,0,NULL);
 1765+ else glUtil_SetTexture(This->util,8,NULL);
17561766 This->ext->glUniform4f(shader->shader.uniforms[0], 0,
17571767 (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwWidth, 0, (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwHeight);
17581768 if (cmd->src) This->ext->glUniform4i(shader->shader.uniforms[10], cmd->src->colorsizes[0], cmd->src->colorsizes[1],
Index: ddraw/glRenderer.h
@@ -162,7 +162,7 @@
163163 size_t scenesize, scenesizevertex, scenesizeindex;
164164 } glRenderer;
165165
166 -HRESULT glRenderer_AddCommand(glRenderer *This, BYTE *command);
 166+HRESULT glRenderer_AddCommand(glRenderer *This, BYTE *command, BOOL inner);
167167 void glRenderer_Init(glRenderer *This, int width, int height, int bpp, BOOL fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
168168 void glRenderer_Delete(glRenderer *This);
169169 DWORD glRenderer_GetBPP(glRenderer *This);
Index: ddraw/struct.h
@@ -450,6 +450,9 @@
451451 typedef struct RenderState
452452 {
453453 CommandBuffer *cmd;
 454+ DWORD last_cmd;
 455+ BYTE *last_cmd_start;
 456+ BltCommand last_blt;
454457 } RenderState;
455458
456459 #endif //__STRUCT_H
\ No newline at end of file
Index: ddraw/struct_command.h
@@ -48,10 +48,13 @@
4949 DWORD size;
5050 glTexture *texture;
5151 } DeleteTextureCmd;
52 -typedef struct BltCmd // Frontend command structure for Blt command.
 52+typedef struct BltCmd
5353 {
5454 DWORD opcode;
5555 DWORD size;
5656 BltCommand cmd;
 57+ DWORD count;
 58+ GLsizeiptr vertex_start;
 59+ GLsizeiptr index_start;
5760 } BltCmd;
5861 #endif //__STRUCT_COMMAND_H
\ No newline at end of file
Index: dxglcfg/dxglcfg.c
@@ -926,8 +926,7 @@
927927 case IDC_APPS:
928928 OldTextColor = GetTextColor(drawitem->hDC);
929929 OldBackColor = GetBkColor(drawitem->hDC);
930 - if((drawitem->itemAction & ODA_SELECT) && (drawitem->itemState & ODS_SELECTED) &&
931 - !(drawitem->itemState & ODS_COMBOBOXEDIT))
 930+ if((drawitem->itemState & ODS_SELECTED) && !(drawitem->itemState & ODS_COMBOBOXEDIT))
932931 {
933932 SetTextColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));
934933 SetBkColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHT));
@@ -942,6 +941,8 @@
943942 DT_LEFT|DT_SINGLELINE|DT_VCENTER);
944943 SetTextColor(drawitem->hDC,OldTextColor);
945944 SetBkColor(drawitem->hDC,OldBackColor);
 945+ drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON) + 5;
 946+ if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
946947 DefWindowProc(hWnd,Msg,wParam,lParam);
947948 break;
948949 default:
Index: dxglcfg2/dxglcfg2.c
@@ -506,8 +506,7 @@
507507 case IDC_EXTRAMODES:
508508 OldTextColor = GetTextColor(drawitem->hDC);
509509 OldBackColor = GetBkColor(drawitem->hDC);
510 - if ((drawitem->itemAction | ODA_SELECT) && (drawitem->itemState & ODS_SELECTED) &&
511 - !(drawitem->itemState & ODS_COMBOBOXEDIT))
 510+ if ((drawitem->itemState & ODS_SELECTED) && !(drawitem->itemState & ODS_COMBOBOXEDIT))
512511 {
513512 SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
514513 SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
@@ -527,6 +526,8 @@
528527 DT_LEFT | DT_SINGLELINE | DT_VCENTER);
529528 SetTextColor(drawitem->hDC, OldTextColor);
530529 SetBkColor(drawitem->hDC, OldBackColor);
 530+ drawitem->rcItem.left -= GetSystemMetrics(SM_CXMENUCHECK) + 5;
 531+ if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
531532 DefWindowProc(hWnd, Msg, wParam, lParam);
532533 break;
533534 default: