static void yv12_test(void) { HRESULT hr; DDSURFACEDESC2 desc; IDirectDrawSurface7 *surface; surface = create_overlay(256, 256, MAKEFOURCC('Y','V','1','2')); if(!surface) { skip("YV12 surfaces not available\n"); return; } memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); hr = IDirectDrawSurface7_Lock(surface, NULL, &desc, 0, NULL); ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned 0x%08x, expected DD_OK\n", hr); ok(desc.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_PITCH), "Unexpected desc.dwFlags 0x%08x\n", desc.dwFlags); ok(desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM) || desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_HWCODEC), "Unexpected desc.ddsCaps.dwCaps 0x%08x\n", desc.ddsCaps.dwCaps); ok(desc.dwWidth == 256 && desc.dwHeight == 256, "Expected size 256x256, got %ux%u\n", desc.dwWidth, desc.dwHeight); /* The overlay pitch seems to have 256 byte alignment */ ok((U1(desc).lPitch & 0xff) == 0, "Expected 256 byte aligned pitch, got %u\n", U1(desc).lPitch); hr = IDirectDrawSurface7_Unlock(surface, NULL); ok(hr == DD_OK, "IDirectDrawSurface7_Unlock returned 0x%08x, expected DD_OK\n", hr); IDirectDrawSurface7_Release(surface); }
static void rectangle_settings(void) { IDirectDrawSurface7 *overlay = create_overlay(64, 64, MAKEFOURCC('U','Y','V','Y')); HRESULT hr, hr2; RECT rect = {0, 0, 64, 64}; LONG posx, posy; /* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is used. This is not true * in Windows Vista and earlier, but changed in Win7 */ hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL); ok(hr == DD_OK, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_HIDE, NULL); ok(hr == DD_OK, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_SHOW, NULL); ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); /* Show that the overlay position is the (top, left) coordinate of the dest rectangle */ rect.top += 16; rect.left += 32; rect.bottom += 16; rect.right += 32; hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL); ok(hr == DD_OK, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); posx = -1; posy = -1; hr = IDirectDrawSurface7_GetOverlayPosition(overlay, &posx, &posy); ok(hr == DD_OK, "IDirectDrawSurface7_GetOverlayPosition failed with hr=0x%08x\n", hr); ok(posx == rect.left && posy == rect.top, "Overlay position is (%d, %d), expected (%d, %d)\n", posx, posy, rect.left, rect.top); /* Passing a NULL dest rect sets the position to 0/0 . Visually it can be seen that the overlay overlays the whole primary(==screen)*/ hr2 = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, NULL, 0, NULL); ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr2); hr = IDirectDrawSurface7_GetOverlayPosition(overlay, &posx, &posy); ok(hr == DD_OK, "IDirectDrawSurface7_GetOverlayPosition failed with hr=0x%08x\n", hr); if (SUCCEEDED(hr2)) { ok(posx == 0 && posy == 0, "Overlay position is (%d, %d), expected (%d, %d)\n", posx, posy, 0, 0); } else { /* Otherwise the position remains untouched */ ok(posx == 32 && posy == 16, "Overlay position is (%d, %d), expected (%d, %d)\n", posx, posy, 32, 16); } /* The position cannot be retrieved when the overlay is not shown */ hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_HIDE, NULL); ok(hr == DD_OK, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); posx = -1; posy = -1; hr = IDirectDrawSurface7_GetOverlayPosition(overlay, &posx, &posy); ok(hr == DDERR_OVERLAYNOTVISIBLE, "IDirectDrawSurface7_GetOverlayPosition failed with hr=0x%08x\n", hr); ok(posx == 0 && posy == 0, "Overlay position is (%d, %d), expected (%d, %d)\n", posx, posy, 0, 0); IDirectDrawSurface7_Release(overlay); }
void setup_x(void) { screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); XSetErrorHandler(on_xerror); XSelectInput (dpy, root, SubstructureNotifyMask|KeyPressMask|VisibilityChangeMask|ExposureMask); XCompositeRedirectSubwindows(dpy, root, CompositeRedirectAutomatic); overlay = create_overlay(); canvas = create_canvas(); debug("Root 0x%x, Overlay 0x%x, Canvas 0x%x\n", root, overlay, canvas); stop = 0; }
static BOOL CreateDirectDraw(void) { HRESULT hr; DDSURFACEDESC2 ddsd; IDirectDrawSurface7 *overlay = NULL; HMODULE hmod = GetModuleHandleA("ddraw.dll"); pDirectDrawCreateEx = (void*)GetProcAddress(hmod, "DirectDrawCreateEx"); if (!pDirectDrawCreateEx) { win_skip("DirectDrawCreateEx is not available\n"); return FALSE; } hr = pDirectDrawCreateEx(NULL, (void**)&ddraw, &IID_IDirectDraw7, NULL); ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr); if (!ddraw) { trace("DirectDrawCreateEx() failed with an error %x\n", hr); return FALSE; } hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); ok(hr == DD_OK, "SetCooperativeLevel returned: %x\n", hr ); memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL); if (FAILED(hr)) { IDirectDraw7_Release(ddraw); trace("IDirectDraw7_CreateSurface() failed with an error %x\n", hr); return FALSE; } overlay = create_overlay(64, 64, MAKEFOURCC('U','Y','V','Y')); if (!overlay) { IDirectDrawSurface7_Release(primary); IDirectDraw7_Release(ddraw); skip("Failed to create an overlay - assuming not supported\n"); return FALSE; } IDirectDraw7_Release(overlay); return TRUE; }
static void offscreen_test(void) { IDirectDrawSurface7 *overlay = create_overlay(64, 64, MAKEFOURCC('U','Y','V','Y')), *offscreen = NULL; HRESULT hr; DDSURFACEDESC2 ddsd; /* Try to overlay a NULL surface */ hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL); ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL); ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); /* Try to overlay an offscreen surface */ memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.dwWidth = 64; ddsd.dwHeight = 64; U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat); U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_RGB; U4(ddsd).ddpfPixelFormat.dwFourCC = 0; U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 16; U2(U4(ddsd).ddpfPixelFormat).dwRBitMask = 0xF800; U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x07e0; U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &offscreen, NULL); ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed with hr=0x%08x\n", hr); hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL); ok(hr == DD_OK || broken(hr == E_NOTIMPL), "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); /* Try to overlay the primary with a non-overlay surface */ hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL); ok(hr == DDERR_NOTAOVERLAYSURFACE, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr); IDirectDrawSurface7_Release(offscreen); IDirectDrawSurface7_Release(overlay); }
/* * Create a frame in a stream that displays a row that moves * from the top to the bottom repeatedly. * Upon the OVERLAY_FRAME-th, a drawable is created on top of a part of the stream, * and from then on, all the stream frames has a clipping that keeps this drawable * visible, and in addition a clipping_factor is subtracted from the right limit of their clipping. * If sized=TRUE, a higher and wider frame than the original stream is created every SIZED_INTERVAL. * The sized frames can be distinguished by a change in the color of the top and bottom limits of the * surface. */ static void create_clipped_frame(Test *test, Command *command, int clipping_factor) { static int count = 0; CommandDrawBitmap *cmd = &command->bitmap; int max_height = test->height; int max_width = test->width; int width; int height; int cur_line, end_line; uint32_t *dst; count++; if (count == NUM_COMMANDS) { count = 0; } if (count == OVERLAY_FRAME) { create_overlay(command, OVERLAY_WIDTH, OVERLAY_HEIGHT); return; } cmd->surface_id = 0; cmd->bbox.left = 0; cmd->bbox.right = max_width - 50; assert(max_height > 600); cmd->bbox.top = 50; cmd->bbox.bottom = max_height - 50; height = cmd->bbox.bottom - cmd->bbox.top; width = cmd->bbox.right - cmd->bbox.left; cur_line = (height/30)*(count % 30); end_line = cur_line + (height/30); if (end_line >= height || height - end_line < 8) { end_line = height; } if (sized && count % SIZED_INTERVAL == 0) { cmd->bbox.top = 0; cmd->bbox.bottom = max_height; cmd->bbox.left = 0; cmd->bbox.right = max_width; height = max_height; width = max_width; cur_line += 50; end_line += 50; } cmd->bitmap = g_malloc(width*height*4); memset(cmd->bitmap, 0xff, width*height*4); dst = (uint32_t *)(cmd->bitmap + cur_line*width*4); for (; cur_line < end_line; cur_line++) { int col; for (col = 0; col < width; col++, dst++) { *dst = 0x00FF00; } } if (sized && count % SIZED_INTERVAL == 0) { int i; uint32_t color = 0xffffff & rand(); dst = (uint32_t *)cmd->bitmap; for (i = 0; i < 50*width; i++, dst++) { *dst = color; } dst = ((uint32_t *)(cmd->bitmap + (height - 50)*4*width)); for (i = 0; i < 50*width; i++, dst++) { *dst = color; } } if (count < OVERLAY_FRAME) { cmd->num_clip_rects = 0; } else { cmd->num_clip_rects = 2; cmd->clip_rects = calloc(sizeof(QXLRect), 2); cmd->clip_rects[0].left = OVERLAY_WIDTH; cmd->clip_rects[0].top = cmd->bbox.top; cmd->clip_rects[0].right = cmd->bbox.right - clipping_factor; cmd->clip_rects[0].bottom = OVERLAY_HEIGHT; cmd->clip_rects[1].left = cmd->bbox.left; cmd->clip_rects[1].top = OVERLAY_HEIGHT; cmd->clip_rects[1].right = cmd->bbox.right - clipping_factor; cmd->clip_rects[1].bottom = cmd->bbox.bottom; } }