move around - flatter.
[profile/ivi/evas.git] / src / modules / engines / software_16_ddraw / evas_ddraw_main.cpp
1 #include "evas_engine.h"
2
3
4 void *
5 evas_software_ddraw_lock(DDraw_Output_Buffer *ddob, int *ddraw_width, int *ddraw_height, int *ddraw_pitch, int *ddraw_depth)
6 {
7    DDSURFACEDESC surface_desc;
8
9    ZeroMemory(&surface_desc, sizeof(surface_desc));
10    surface_desc.dwSize = sizeof(surface_desc);
11
12    if (FAILED(ddob->dd.surface_back->Lock(NULL,
13                                           &surface_desc,
14                                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY,
15                                           NULL)))
16      return NULL;
17
18    *ddraw_width = surface_desc.dwWidth;
19    *ddraw_height = surface_desc.dwHeight;
20    *ddraw_pitch = surface_desc.lPitch;
21    *ddraw_depth = surface_desc.ddpfPixelFormat.dwRGBBitCount >> 3;
22
23    return surface_desc.lpSurface;
24 }
25
26 void
27 evas_software_ddraw_unlock_and_flip(DDraw_Output_Buffer *ddob)
28 {
29    RECT    dst_rect;
30    RECT    src_rect;
31    POINT   p;
32
33    if (FAILED(ddob->dd.surface_back->Unlock(NULL)))
34      return;
35
36    /* we figure out where on the primary surface our window lives */
37    p.x = 0;
38    p.y = 0;
39    ClientToScreen(ddob->dd.window, &p);
40    GetClientRect(ddob->dd.window, &dst_rect);
41    OffsetRect(&dst_rect, p.x, p.y);
42    SetRect(&src_rect, 0, 0, ddob->width, ddob->height);
43
44    /* nothing to do if the function fails, so we don't check the result */
45    ddob->dd.surface_primary->BltFast(0, 0,
46                                      ddob->dd.surface_back, &dst_rect,
47                                      DDBLTFAST_WAIT || DDBLTFAST_NOCOLORKEY);
48 }
49
50 void
51 evas_software_ddraw_surface_resize(DDraw_Output_Buffer *ddob)
52 {
53    DDSURFACEDESC surface_desc;
54
55    ddob->dd.surface_back->Release();
56    memset (&surface_desc, 0, sizeof (surface_desc));
57    surface_desc.dwSize = sizeof (surface_desc);
58    /* FIXME: that code does not compile. Must know why */
59 #if 0
60    surface_desc.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
61    surface_desc.dwWidth = width;
62    surface_desc.dwHeight = height;
63    IDirectDrawSurface7_SetSurfaceDesc(ddob->dd.surface_back, &surface_desc, NULL);
64 #else
65    surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
66    surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
67    surface_desc.dwWidth = ddob->width;
68    surface_desc.dwHeight = ddob->height;
69    ddob->dd.object->CreateSurface(&surface_desc, &ddob->dd.surface_back, NULL);
70 #endif
71 }