2 * 2D Surface implementation without OpenGL
4 * Copyright 1997-2000 Marcus Meissner
5 * Copyright 1998-2000 Lionel Ulmer
6 * Copyright 2000-2001 TransGaming Technologies Inc.
7 * Copyright 2002-2005 Jason Edmeades
8 * Copyright 2002-2003 Raphael Junqueira
9 * Copyright 2004 Christian Costa
10 * Copyright 2005 Oliver Stieber
11 * Copyright 2006-2008 Stefan Dösinger
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/port.h"
30 #include "wined3d_private.h"
35 /* Use the d3d_surface debug channel to have one channel for all surfaces */
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
38 /*****************************************************************************
39 * IWineD3DSurface::Release, GDI version
41 * In general a normal COM Release method, but the GDI version doesn't have
42 * to destroy all the GL things.
44 *****************************************************************************/
45 static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
46 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
47 ULONG ref = InterlockedDecrement(&This->resource.ref);
48 TRACE("(%p) : Releasing from %d\n", This, ref + 1);
50 TRACE("(%p) : cleaning up\n", This);
52 if(This->Flags & SFLAG_DIBSECTION) {
54 SelectObject(This->hDC, This->dib.holdbitmap);
56 /* Release the DIB section */
57 DeleteObject(This->dib.DIBsection);
58 This->dib.bitmap_data = NULL;
59 This->resource.allocatedMemory = NULL;
61 if(This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem(iface, NULL);
63 HeapFree(GetProcessHeap(), 0, This->palette9);
65 resource_cleanup((IWineD3DResource *)iface);
67 if(This->overlay_dest) {
68 list_remove(&This->overlay_entry);
71 TRACE("(%p) Released\n", This);
72 HeapFree(GetProcessHeap(), 0, This);
78 /*****************************************************************************
79 * IWineD3DSurface::PreLoad, GDI version
81 * This call is unsupported on GDI surfaces, if it's called something went
82 * wrong in the parent library. Write an informative warning
84 *****************************************************************************/
86 IWineGDISurfaceImpl_PreLoad(IWineD3DSurface *iface)
88 ERR("(%p): PreLoad is not supported on X11 surfaces!\n", iface);
89 ERR("(%p): Most likely the parent library did something wrong.\n", iface);
90 ERR("(%p): Please report to wine-devel\n", iface);
93 /*****************************************************************************
94 * IWineD3DSurface::UnLoad, GDI version
96 * This call is unsupported on GDI surfaces, if it's called something went
97 * wrong in the parent library. Write an informative warning.
99 *****************************************************************************/
100 static void WINAPI IWineGDISurfaceImpl_UnLoad(IWineD3DSurface *iface)
102 ERR("(%p): UnLoad is not supported on X11 surfaces!\n", iface);
103 ERR("(%p): Most likely the parent library did something wrong.\n", iface);
104 ERR("(%p): Please report to wine-devel\n", iface);
107 /*****************************************************************************
108 * IWineD3DSurface::LockRect, GDI version
110 * Locks the surface and returns a pointer to the surface memory
113 * pLockedRect: Address to return the locking info at
114 * pRect: Rectangle to lock
118 * WINED3D_OK on success
119 * WINED3DERR_INVALIDCALL on errors
121 *****************************************************************************/
122 static HRESULT WINAPI
123 IWineGDISurfaceImpl_LockRect(IWineD3DSurface *iface,
124 WINED3DLOCKED_RECT* pLockedRect,
128 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
130 /* Already locked? */
131 if(This->Flags & SFLAG_LOCKED)
133 WARN("(%p) Surface already locked\n", This);
134 /* What should I return here? */
135 return WINED3DERR_INVALIDCALL;
137 This->Flags |= SFLAG_LOCKED;
139 if(!This->resource.allocatedMemory) {
140 /* This happens on gdi surfaces if the application set a user pointer and resets it.
141 * Recreate the DIB section
143 IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
144 This->resource.allocatedMemory = This->dib.bitmap_data;
147 return IWineD3DBaseSurfaceImpl_LockRect(iface, pLockedRect, pRect, Flags);
150 /*****************************************************************************
151 * IWineD3DSurface::UnlockRect, GDI version
153 * Unlocks a surface. This implementation doesn't do much, except updating
154 * the window if the front buffer is unlocked
157 * WINED3D_OK on success
158 * WINED3DERR_INVALIDCALL on failure
160 *****************************************************************************/
161 static HRESULT WINAPI
162 IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
164 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
165 IWineD3DSwapChainImpl *swapchain = NULL;
166 TRACE("(%p)\n", This);
168 if (!(This->Flags & SFLAG_LOCKED))
170 WARN("trying to Unlock an unlocked surf@%p\n", This);
171 return WINEDDERR_NOTLOCKED;
174 /* Can be useful for debugging */
177 static unsigned int gen = 0;
180 if ((gen % 10) == 0) {
181 snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, This->glDescription.target, This->glDescription.level, gen);
182 IWineD3DSurfaceImpl_SaveSnapshot(iface, buffer);
185 * debugging crash code
194 /* Tell the swapchain to update the screen */
195 if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
197 x11_copy_to_screen(swapchain, &This->lockedRect);
198 IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
201 This->Flags &= ~SFLAG_LOCKED;
202 memset(&This->lockedRect, 0, sizeof(RECT));
206 /*****************************************************************************
207 * IWineD3DSurface::Flip, GDI version
209 * Flips 2 flipping enabled surfaces. Determining the 2 targets is done by
210 * the parent library. This implementation changes the data pointers of the
211 * surfaces and copies the new front buffer content to the screen
214 * override: Flipping target(e.g. back buffer)
217 * WINED3D_OK on success
219 *****************************************************************************/
220 static HRESULT WINAPI
221 IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface,
222 IWineD3DSurface *override,
225 IWineD3DSwapChainImpl *swapchain = NULL;
228 if(FAILED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
230 ERR("Flipped surface is not on a swapchain\n");
231 return WINEDDERR_NOTFLIPPABLE;
234 hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *) swapchain, NULL, NULL, 0, NULL, 0);
235 IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
239 /*****************************************************************************
240 * IWineD3DSurface::LoadTexture, GDI version
242 * This is mutually unsupported by GDI surfaces
247 *****************************************************************************/
248 static HRESULT WINAPI
249 IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode)
251 ERR("Unsupported on X11 surfaces\n");
252 return WINED3DERR_INVALIDCALL;
255 /*****************************************************************************
256 * IWineD3DSurface::SaveSnapshot, GDI version
258 * This method writes the surface's contents to the in tga format to the
259 * file specified in filename.
262 * filename: File to write to
265 * WINED3DERR_INVALIDCALL if the file couldn't be opened
266 * WINED3D_OK on success
268 *****************************************************************************/
269 static int get_shift(DWORD color_mask) {
271 while (color_mask > 0xFF) {
275 while ((color_mask & 0x80) == 0) {
283 static HRESULT WINAPI
284 IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface,
285 const char* filename)
289 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
290 static char *output = NULL;
291 static UINT size = 0;
292 const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
294 if (This->pow2Width > size) {
295 output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pow2Width * 3);
296 size = This->pow2Width;
300 f = fopen(filename, "w+");
302 ERR("opening of %s failed with\n", filename);
303 return WINED3DERR_INVALIDCALL;
305 fprintf(f, "P6\n%d %d\n255\n", This->pow2Width, This->pow2Height);
307 if (This->resource.format_desc->format == WINED3DFMT_P8)
309 unsigned char table[256][3];
312 if (This->palette == NULL) {
314 return WINED3DERR_INVALIDCALL;
316 for (i = 0; i < 256; i++) {
317 table[i][0] = This->palette->palents[i].peRed;
318 table[i][1] = This->palette->palents[i].peGreen;
319 table[i][2] = This->palette->palents[i].peBlue;
321 for (y = 0; y < This->pow2Height; y++) {
322 unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
323 for (x = 0; x < This->pow2Width; x++) {
324 unsigned char color = *src;
327 output[3 * x + 0] = table[color][0];
328 output[3 * x + 1] = table[color][1];
329 output[3 * x + 2] = table[color][2];
331 fwrite(output, 3 * This->pow2Width, 1, f);
334 int red_shift, green_shift, blue_shift, pix_width, alpha_shift;
336 pix_width = format_desc->byte_count;
338 red_shift = get_shift(format_desc->red_mask);
339 green_shift = get_shift(format_desc->green_mask);
340 blue_shift = get_shift(format_desc->blue_mask);
341 alpha_shift = get_shift(format_desc->alpha_mask);
343 for (y = 0; y < This->pow2Height; y++) {
344 const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
345 for (x = 0; x < This->pow2Width; x++) {
351 for (i = 0; i < pix_width; i++) {
352 color |= src[i] << (8 * i);
354 src += 1 * pix_width;
356 comp = color & format_desc->red_mask;
357 output[3 * x + 0] = red_shift > 0 ? comp >> red_shift : comp << -red_shift;
358 comp = color & format_desc->green_mask;
359 output[3 * x + 1] = green_shift > 0 ? comp >> green_shift : comp << -green_shift;
360 comp = color & format_desc->alpha_mask;
361 output[3 * x + 2] = alpha_shift > 0 ? comp >> alpha_shift : comp << -alpha_shift;
363 fwrite(output, 3 * This->pow2Width, 1, f);
370 static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
371 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
372 WINED3DLOCKED_RECT lock;
376 TRACE("(%p)->(%p)\n",This,pHDC);
378 if(This->Flags & SFLAG_USERPTR) {
379 ERR("Not supported on surfaces with an application-provided surfaces\n");
380 return WINEDDERR_NODC;
383 /* Give more detailed info for ddraw */
384 if (This->Flags & SFLAG_DCINUSE)
385 return WINEDDERR_DCALREADYCREATED;
387 /* Can't GetDC if the surface is locked */
388 if (This->Flags & SFLAG_LOCKED)
389 return WINED3DERR_INVALIDCALL;
391 memset(&lock, 0, sizeof(lock)); /* To be sure */
393 /* Should have a DIB section already */
395 /* Lock the surface */
396 hr = IWineD3DSurface_LockRect(iface,
401 ERR("IWineD3DSurface_LockRect failed with hr = %08x\n", hr);
402 /* keep the dib section */
406 if (This->resource.format_desc->format == WINED3DFMT_P8
407 || This->resource.format_desc->format == WINED3DFMT_A8P8)
410 const PALETTEENTRY *pal = NULL;
413 pal = This->palette->palents;
415 IWineD3DSurfaceImpl *dds_primary;
416 IWineD3DSwapChainImpl *swapchain;
417 swapchain = (IWineD3DSwapChainImpl *)This->resource.wineD3DDevice->swapchains[0];
418 dds_primary = (IWineD3DSurfaceImpl *)swapchain->frontBuffer;
419 if (dds_primary && dds_primary->palette)
420 pal = dds_primary->palette->palents;
424 for (n=0; n<256; n++) {
425 col[n].rgbRed = pal[n].peRed;
426 col[n].rgbGreen = pal[n].peGreen;
427 col[n].rgbBlue = pal[n].peBlue;
428 col[n].rgbReserved = 0;
430 SetDIBColorTable(This->hDC, 0, 256, col);
435 TRACE("returning %p\n",*pHDC);
436 This->Flags |= SFLAG_DCINUSE;
441 static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
442 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
444 TRACE("(%p)->(%p)\n",This,hDC);
446 if (!(This->Flags & SFLAG_DCINUSE))
447 return WINEDDERR_NODC;
449 if (This->hDC !=hDC) {
450 WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
451 return WINEDDERR_NODC;
454 /* we locked first, so unlock now */
455 IWineD3DSurface_UnlockRect(iface);
457 This->Flags &= ~SFLAG_DCINUSE;
462 static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
463 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
465 IWineD3DPaletteImpl *pal = This->palette;
467 IWineD3DSwapChainImpl *swapchain;
468 TRACE("(%p)\n", This);
470 if (!pal) return WINED3D_OK;
472 if(This->Flags & SFLAG_DIBSECTION) {
473 TRACE("(%p): Updating the hdc's palette\n", This);
474 for (n=0; n<256; n++) {
475 col[n].rgbRed = pal->palents[n].peRed;
476 col[n].rgbGreen = pal->palents[n].peGreen;
477 col[n].rgbBlue = pal->palents[n].peBlue;
478 col[n].rgbReserved = 0;
480 SetDIBColorTable(This->hDC, 0, 256, col);
483 /* Update the image because of the palette change. Some games like e.g Red Alert
484 call SetEntries a lot to implement fading. */
485 /* Tell the swapchain to update the screen */
486 if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
488 x11_copy_to_screen(swapchain, NULL);
489 IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
495 /*****************************************************************************
496 * IWineD3DSurface::PrivateSetup, GDI version
498 * Initializes the GDI surface, aka creates the DIB section we render to
499 * The DIB section creation is done by calling GetDC, which will create the
500 * section and releasing the dc to allow the app to use it. The dib section
501 * will stay until the surface is released
503 * GDI surfaces do not need to be a power of 2 in size, so the pow2 sizes
504 * are set to the real sizes to save memory. The NONPOW2 flag is unset to
505 * avoid confusion in the shared surface code.
508 * WINED3D_OK on success
509 * The return values of called methods on failure
511 *****************************************************************************/
512 static HRESULT WINAPI
513 IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
515 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
517 if(This->resource.usage & WINED3DUSAGE_OVERLAY)
519 ERR("(%p) Overlays not yet supported by GDI surfaces\n", This);
520 return WINED3DERR_INVALIDCALL;
522 /* Sysmem textures have memory already allocated -
523 * release it, this avoids an unnecessary memcpy
525 HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
526 This->resource.allocatedMemory = NULL;
527 This->resource.heapMemory = NULL;
529 /* We don't mind the nonpow2 stuff in GDI */
530 This->pow2Width = This->currentDesc.Width;
531 This->pow2Height = This->currentDesc.Height;
533 IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
534 This->resource.allocatedMemory = This->dib.bitmap_data;
539 static void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
540 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
541 FIXME("(%p) : Should not be called on a GDI surface\n", This);
542 *glDescription = NULL;
545 static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
546 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
548 /* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
549 if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
550 ERR("Not supported on render targets\n");
551 return WINED3DERR_INVALIDCALL;
554 if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) {
555 WARN("Surface is locked or the HDC is in use\n");
556 return WINED3DERR_INVALIDCALL;
559 if(Mem && Mem != This->resource.allocatedMemory) {
560 void *release = NULL;
562 /* Do I have to copy the old surface content? */
563 if(This->Flags & SFLAG_DIBSECTION) {
564 /* Release the DC. No need to hold the critical section for the update
565 * Thread because this thread runs only on front buffers, but this method
566 * fails for render targets in the check above.
568 SelectObject(This->hDC, This->dib.holdbitmap);
570 /* Release the DIB section */
571 DeleteObject(This->dib.DIBsection);
572 This->dib.bitmap_data = NULL;
573 This->resource.allocatedMemory = NULL;
575 This->Flags &= ~SFLAG_DIBSECTION;
576 } else if(!(This->Flags & SFLAG_USERPTR)) {
577 release = This->resource.allocatedMemory;
579 This->resource.allocatedMemory = Mem;
580 This->Flags |= SFLAG_USERPTR | SFLAG_INSYSMEM;
582 /* Now free the old memory if any */
583 HeapFree(GetProcessHeap(), 0, release);
584 } else if(This->Flags & SFLAG_USERPTR) {
585 /* LockRect and GetDC will re-create the dib section and allocated memory */
586 This->resource.allocatedMemory = NULL;
587 This->Flags &= ~SFLAG_USERPTR;
592 /***************************
594 ***************************/
595 static void WINAPI IWineGDISurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DWORD flag, BOOL persistent) {
596 TRACE("(%p)->(%s, %s)\n", iface,
597 flag == SFLAG_INSYSMEM ? "SFLAG_INSYSMEM" : flag == SFLAG_INDRAWABLE ? "SFLAG_INDRAWABLE" : "SFLAG_INTEXTURE",
598 persistent ? "TRUE" : "FALSE");
599 /* GDI surfaces can be in system memory only */
600 if(flag != SFLAG_INSYSMEM) {
601 ERR("GDI Surface requested in gl %s memory\n", flag == SFLAG_INDRAWABLE ? "drawable" : "texture");
605 static HRESULT WINAPI IWineGDISurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) {
606 if(flag != SFLAG_INSYSMEM) {
607 ERR("GDI Surface requested to be copied to gl %s\n", flag == SFLAG_INTEXTURE ? "texture" : "drawable");
609 TRACE("Surface requested in surface memory\n");
614 static WINED3DSURFTYPE WINAPI IWineGDISurfaceImpl_GetImplType(IWineD3DSurface *iface) {
618 static HRESULT WINAPI IWineGDISurfaceImpl_DrawOverlay(IWineD3DSurface *iface) {
619 FIXME("GDI surfaces can't draw overlays yet\n");
623 /* FIXME: This vtable should not use any IWineD3DSurface* implementation functions,
624 * only IWineD3DBaseSurface and IWineGDISurface ones.
626 const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
629 IWineD3DBaseSurfaceImpl_QueryInterface,
630 IWineD3DBaseSurfaceImpl_AddRef,
631 IWineGDISurfaceImpl_Release,
632 /* IWineD3DResource */
633 IWineD3DBaseSurfaceImpl_GetParent,
634 IWineD3DBaseSurfaceImpl_GetDevice,
635 IWineD3DBaseSurfaceImpl_SetPrivateData,
636 IWineD3DBaseSurfaceImpl_GetPrivateData,
637 IWineD3DBaseSurfaceImpl_FreePrivateData,
638 IWineD3DBaseSurfaceImpl_SetPriority,
639 IWineD3DBaseSurfaceImpl_GetPriority,
640 IWineGDISurfaceImpl_PreLoad,
641 IWineGDISurfaceImpl_UnLoad,
642 IWineD3DBaseSurfaceImpl_GetType,
643 /* IWineD3DSurface */
644 IWineD3DBaseSurfaceImpl_GetContainer,
645 IWineD3DBaseSurfaceImpl_GetDesc,
646 IWineGDISurfaceImpl_LockRect,
647 IWineGDISurfaceImpl_UnlockRect,
648 IWineGDISurfaceImpl_GetDC,
649 IWineGDISurfaceImpl_ReleaseDC,
650 IWineGDISurfaceImpl_Flip,
651 IWineD3DBaseSurfaceImpl_Blt,
652 IWineD3DBaseSurfaceImpl_GetBltStatus,
653 IWineD3DBaseSurfaceImpl_GetFlipStatus,
654 IWineD3DBaseSurfaceImpl_IsLost,
655 IWineD3DBaseSurfaceImpl_Restore,
656 IWineD3DBaseSurfaceImpl_BltFast,
657 IWineD3DBaseSurfaceImpl_GetPalette,
658 IWineD3DBaseSurfaceImpl_SetPalette,
659 IWineGDISurfaceImpl_RealizePalette,
660 IWineD3DBaseSurfaceImpl_SetColorKey,
661 IWineD3DBaseSurfaceImpl_GetPitch,
662 IWineGDISurfaceImpl_SetMem,
663 IWineD3DBaseSurfaceImpl_SetOverlayPosition,
664 IWineD3DBaseSurfaceImpl_GetOverlayPosition,
665 IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder,
666 IWineD3DBaseSurfaceImpl_UpdateOverlay,
667 IWineD3DBaseSurfaceImpl_SetClipper,
668 IWineD3DBaseSurfaceImpl_GetClipper,
670 IWineGDISurfaceImpl_LoadTexture,
671 IWineD3DBaseSurfaceImpl_BindTexture,
672 IWineGDISurfaceImpl_SaveSnapshot,
673 IWineD3DBaseSurfaceImpl_SetContainer,
674 IWineGDISurfaceImpl_GetGlDesc,
675 IWineD3DBaseSurfaceImpl_GetData,
676 IWineD3DBaseSurfaceImpl_SetFormat,
677 IWineGDISurfaceImpl_PrivateSetup,
678 IWineGDISurfaceImpl_ModifyLocation,
679 IWineGDISurfaceImpl_LoadLocation,
680 IWineGDISurfaceImpl_GetImplType,
681 IWineGDISurfaceImpl_DrawOverlay