VirtualBox

Ignore:
Timestamp:
Sep 29, 2011 4:20:22 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74235
Message:

wddm/3d: offscreen rendering to solve one of win8 ie rendering issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dbg/VBoxVideoWinDbg.cpp

    r36867 r38903  
    106106    PCSTR pExpr = args;
    107107
     108    /* address */
    108109    if (!pExpr) { dprintf("address not specified\n"); return; }
    109110    if (!GetExpressionEx(pExpr, &u64Mem, &pExpr)) { dprintf("error evaluating address\n"); return; }
    110111    if (!u64Mem) { dprintf("address value can not be NULL\n"); return; }
    111112
     113    /* width */
    112114    if (!pExpr) { dprintf("width not specified\n"); return; }
    113115    if (!GetExpressionEx(pExpr, &u64Width, &pExpr)) { dprintf("error evaluating width\n"); return; }
    114116    if (!u64Width) { dprintf("width value can not be NULL\n"); return; }
    115117
     118    /* height */
    116119    if (!pExpr) { dprintf("height not specified\n"); return; }
    117120    if (!GetExpressionEx(pExpr, &u64Height, &pExpr)) { dprintf("error evaluating height\n"); return; }
    118121    if (!u64Height) { dprintf("height value can not be NULL\n"); return; }
    119122
     123#if 0
    120124    if (pExpr && GetExpressionEx(pExpr, &u64NumColors, &pExpr))
    121125    {
    122126        if (!u64NumColors) { dprintf("Num Colors value can not be NULL\n"); return; }
    123127    }
    124 
     128#endif
     129
     130    /* bpp */
    125131    if (pExpr && GetExpressionEx(pExpr, &u64Bpp, &pExpr))
    126132    {
     
    128134    }
    129135
     136    /* pitch */
    130137    u64DefaultPitch = (((((u64Width * u64Bpp) + 7) >> 3) + 3) & ~3ULL);
    131138    if (pExpr && GetExpressionEx(pExpr, &u64Pitch, &pExpr))
    132139    {
    133         if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (%I)\n", u64DefaultPitch); return; }
     140        if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (%d)\n", (UINT)u64DefaultPitch); return; }
    134141    }
    135142    else
     
    143150    ULONG64 cbSize = u64DefaultPitch * u64Height;
    144151    PVOID pvBuf = malloc(cbSize);
    145     if (pvBuf)
    146     {
    147         ULONG uRc = 0;
    148         if(u64DefaultPitch == u64Pitch)
     152    if (!pvBuf)
     153    {
     154        dprintf("failed to allocate memory buffer of size(%d)\n", (UINT)cbSize);
     155        return;
     156    }
     157    ULONG uRc = 0;
     158#if 0
     159    if(u64DefaultPitch == u64Pitch)
     160#else
     161    if(0)
     162#endif
     163    {
     164        ULONG cbRead = 0;
     165        dprintf("reading the entire memory buffer...\n");
     166        uRc = ReadMemory(u64Mem, pvBuf, cbSize, &cbRead);
     167        if (!uRc)
     168        {
     169            dprintf("Failed to read the memory buffer of size(%d)\n", (UINT)cbSize);
     170        }
     171        else if (cbRead != cbSize)
     172        {
     173            dprintf("the actual number of bytes read(%d) no equal the requested size(%d)\n", (UINT)cbRead, (UINT)cbSize);
     174            uRc = 0;
     175        }
     176
     177    }
     178    else
     179    {
     180        ULONG64 u64Offset = u64Mem;
     181        char* pvcBuf = (char*)pvBuf;
     182        ULONG64 i;
     183        dprintf("reading memory by chunks since custom pitch is specified...\n");
     184        for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch)
    149185        {
    150186            ULONG cbRead = 0;
    151             dprintf("reading the entire memory buffer...\n");
    152             uRc = ReadMemory(u64Mem, pvBuf, cbSize, &cbRead);
     187            uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead);
    153188            if (!uRc)
    154189            {
    155                 dprintf("Failed to read the memory buffer of size(%I)\n", cbSize);
    156             }
    157             else if (cbRead != cbSize)
    158             {
    159                 dprintf("the actual number of bytes read(%I) no equal the requested size(%I)\n", cbRead, cbSize);
    160                 uRc = 0;
    161             }
    162 
    163         }
    164         else
    165         {
    166             ULONG64 u64Offset = u64Mem;
    167             char* pvcBuf = (char*)pvBuf;
    168             ULONG64 i;
    169             dprintf("reading memory by chunks since custom pitch is specified...\n");
    170             for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch)
    171             {
    172                 ULONG cbRead = 0;
    173                 uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead);
    174                 if (!uRc)
     190                dprintf("WARNING!!! Failed to read the memory buffer of size(%d), chunk(%d)\n", (UINT)u64DefaultPitch, (UINT)i);
     191                dprintf("ignoring this one and the all the rest, using height(%d)\n", (UINT)i);
     192                u64Height = i;
     193                uRc = 1;
     194                break;
     195            }
     196            else if (cbRead != u64DefaultPitch)
     197            {
     198                dprintf("WARNING!!! the actual number of bytes read(%d) not equal the requested size(%d), chunk(%d)\n", (UINT)cbRead, (UINT)u64DefaultPitch, (UINT)i);
     199                dprintf("ignoring this one and the all the rest, using height(%d)\n", (UINT)i);
     200                u64Height = i;
     201                break;
     202            }
     203        }
     204    }
     205
     206    if (!uRc)
     207    {
     208        dprintf("read memory failed\n");
     209        free(pvBuf);
     210        return;
     211    }
     212
     213    if (!u64Height)
     214    {
     215        dprintf("no data to be processed since height it 0\n");
     216        free(pvBuf);
     217        return;
     218    }
     219
     220    switch (u64Bpp)
     221    {
     222        case 32:
     223        case 24:
     224        case 16:
     225#if 0
     226            if (u64NumColors != 3)
     227            {
     228                dprintf("WARNING: unsupported number colors: (%d)\n", (UINT)u64NumColors);
     229            }
     230#else
     231            u64NumColors = 3;
     232#endif
     233            break;
     234        case 8:
     235            {
     236#if 1
     237                u64NumColors = 1;
     238#endif
     239
     240                if (u64NumColors == 1)
    175241                {
    176                     dprintf("Failed to read the memory buffer of size(%I), chunk(%I)\n", u64DefaultPitch, i);
    177                     break;
    178                 }
    179                 else if (cbRead != u64DefaultPitch)
    180                 {
    181                     dprintf("the actual number of bytes read(%I) no equal the requested size(%I), chunk(%I)\n", cbRead, u64DefaultPitch, i);
    182                     uRc = 0;
    183                     break;
    184                 }
    185             }
    186         }
    187 
    188         if (uRc)
    189         {
    190             switch (u64Bpp)
    191             {
    192                 case 32:
    193                 case 24:
    194                 case 16:
    195                     if (u64NumColors != 3)
     242                    ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height;
     243                    PVOID pvBuf32 = malloc(cbSize32);
     244                    if (!pvBuf32)
    196245                    {
    197                         dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors);
     246                        dprintf("ERROR: failed to allocate memory buffer of size(%d)", cbSize32);
     247                        free(pvBuf);
     248                        return;
    198249                    }
    199                     break;
    200                 case 8:
     250                    byte* pByteBuf32 = (byte*)pvBuf32;
     251                    byte* pByteBuf = (byte*)pvBuf;
     252                    memset(pvBuf32, 0, cbSize32);
     253                    for (UINT i = 0; i < u64Height; ++i)
    201254                    {
    202                         if (u64NumColors == 1)
     255                        for (UINT j = 0; j < u64Width; ++j)
    203256                        {
    204                             ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height;
    205                             PVOID pvBuf32 = malloc(cbSize32);
    206                             if (pvBuf32)
    207                             {
    208                                 byte* pByteBuf32 = (byte*)pvBuf32;
    209                                 byte* pByteBuf = (byte*)pvBuf;
    210                                 memset(pvBuf32, 0, cbSize32);
    211                                 for (UINT i = 0; i < u64Height; ++i)
    212                                 {
    213                                     for (UINT j = 0; j < u64Width; ++j)
    214                                     {
    215                                         pByteBuf32[0] = pByteBuf[0];
    216                                         pByteBuf32[1] = pByteBuf[0];
    217                                         pByteBuf32[2] = pByteBuf[0];
    218                                         pByteBuf32 += 4;
    219                                         pByteBuf += 1;
    220                                     }
    221                                 }
    222                                 free(pvBuf);
    223                                 pvBuf = pvBuf32;
    224                                 u64DefaultPitch *= 4;
    225                                 u64Bpp *= 4;
    226                             }
    227                         }
    228                         else
    229                         {
    230                             dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors);
     257                            pByteBuf32[0] = pByteBuf[0];
     258                            pByteBuf32[1] = pByteBuf[0];
     259                            pByteBuf32[2] = pByteBuf[0];
     260                            pByteBuf32 += 4;
     261                            pByteBuf += 1;
    231262                        }
    232263                    }
    233                     break;
    234             }
    235             BITMAP Bmp = {0};
    236             HBITMAP hBmp;
    237             dprintf("read memory succeeded..\n");
    238             Bmp.bmType = 0;
    239             Bmp.bmWidth = (LONG)u64Width;
    240             Bmp.bmHeight = (LONG)u64Height;
    241             Bmp.bmWidthBytes = (LONG)u64DefaultPitch;
    242             Bmp.bmPlanes = 1;
    243             Bmp.bmBitsPixel = (WORD)u64Bpp;
    244             Bmp.bmBits = (LPVOID)pvBuf;
    245             hBmp = CreateBitmapIndirect(&Bmp);
    246             if (hBmp)
    247             {
    248                 if (OpenClipboard(GetDesktopWindow()))
     264                    free(pvBuf);
     265                    pvBuf = pvBuf32;
     266                    u64DefaultPitch *= 4;
     267                    u64Bpp *= 4;
     268                }
     269                else
    249270                {
    250                     if (EmptyClipboard())
    251                     {
    252                         if (SetClipboardData(CF_BITMAP, hBmp))
    253                         {
    254                             dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n");
    255                         }
    256                         else
    257                         {
    258                             DWORD winEr = GetLastError();
    259                             dprintf("SetClipboardData failed, err(%I)\n", winEr);
    260                         }
    261                     }
    262                     else
    263                     {
    264                         DWORD winEr = GetLastError();
    265                         dprintf("EmptyClipboard failed, err(%I)\n", winEr);
    266                     }
    267 
    268                     CloseClipboard();
     271                    dprintf("WARNING: unsupported number colors: (%d)\n", (UINT)u64NumColors);
     272                }
     273            }
     274            break;
     275    }
     276    BITMAP Bmp = {0};
     277    HBITMAP hBmp;
     278    dprintf("read memory succeeded..\n");
     279    Bmp.bmType = 0;
     280    Bmp.bmWidth = (LONG)u64Width;
     281    Bmp.bmHeight = (LONG)u64Height;
     282    Bmp.bmWidthBytes = (LONG)u64DefaultPitch;
     283    Bmp.bmPlanes = 1;
     284    Bmp.bmBitsPixel = (WORD)u64Bpp;
     285    Bmp.bmBits = (LPVOID)pvBuf;
     286    hBmp = CreateBitmapIndirect(&Bmp);
     287    if (hBmp)
     288    {
     289        if (OpenClipboard(GetDesktopWindow()))
     290        {
     291            if (EmptyClipboard())
     292            {
     293                if (SetClipboardData(CF_BITMAP, hBmp))
     294                {
     295                    dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n");
    269296                }
    270297                else
    271298                {
    272299                    DWORD winEr = GetLastError();
    273                     dprintf("OpenClipboard failed, err(%I)\n", winEr);
     300                    dprintf("SetClipboardData failed, err(%d)\n", winEr);
    274301                }
    275 
    276                 DeleteObject(hBmp);
    277302            }
    278303            else
    279304            {
    280305                DWORD winEr = GetLastError();
    281                 dprintf("CreateBitmapIndirect failed, err(%I)\n", winEr);
    282             }
     306                dprintf("EmptyClipboard failed, err(%d)\n", winEr);
     307            }
     308
     309            CloseClipboard();
    283310        }
    284311        else
    285312        {
    286             dprintf("read memory failed\n");
    287         }
    288         free(pvBuf);
     313            DWORD winEr = GetLastError();
     314            dprintf("OpenClipboard failed, err(%d)\n", winEr);
     315        }
     316
     317        DeleteObject(hBmp);
    289318    }
    290319    else
    291320    {
    292         dprintf("failed to allocate memory buffer of size(%I)\n", cbSize);
    293     }
    294 }
     321        DWORD winEr = GetLastError();
     322        dprintf("CreateBitmapIndirect failed, err(%d)\n", winEr);
     323    }
     324}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette