예제 #1
0
void DDSetSurfacePalette( LPDIRECTDRAWSURFACE2 pSurface, LPDIRECTDRAWPALETTE pDDPalette )
{
	Assert( pDDPalette != NULL  );
	Assert( pSurface != NULL );

	ATTEMPT( IDirectDrawSurface2_SetPalette( pSurface, pDDPalette ) );

}
예제 #2
0
파일: winshaddd.c 프로젝트: L3oV1nc3/VMGL
static Bool
winDestroyColormapShadowDD (ColormapPtr pColormap)
{
  winScreenPriv(pColormap->pScreen);
  winCmapPriv(pColormap);
  HRESULT		ddrval = DD_OK;

  /*
   * Is colormap to be destroyed the default?
   *
   * Non-default colormaps should have had winUninstallColormap
   * called on them before we get here.  The default colormap
   * will not have had winUninstallColormap called on it.  Thus,
   * we need to handle the default colormap in a special way.
   */
  if (pColormap->flags & IsDefault)
    {
#if CYGDEBUG
      winDebug ("winDestroyColormapShadowDD - Destroying default "
	      "colormap\n");
#endif
      
      /*
       * FIXME: Walk the list of all screens, popping the default
       * palette out of each screen device context.
       */
      
      /* Pop the palette out of the primary surface */
      ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
					       NULL);
      if (FAILED (ddrval))
	{
	  ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
		  "default colormap DirectDraw palette.\n");
	  return FALSE;
	}

      /* Clear our private installed colormap pointer */
      pScreenPriv->pcmapInstalled = NULL;
    }
  
  /* Release the palette */
  IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
 
  /* Invalidate the colormap privates */
  pCmapPriv->lpDDPalette = NULL;

  return TRUE;
}
예제 #3
0
파일: winshaddd.c 프로젝트: L3oV1nc3/VMGL
static Bool
winInstallColormapShadowDD (ColormapPtr pColormap)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winCmapPriv(pColormap);
  HRESULT		ddrval = DD_OK;

  /* Install the DirectDraw palette on the primary surface */
  ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
					   pCmapPriv->lpDDPalette);
  if (FAILED (ddrval))
    {
      ErrorF ("winInstallColormapShadowDD - Failed installing the "
	      "DirectDraw palette.\n");
      return FALSE;
    }

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;

  return TRUE;
}
예제 #4
0
파일: wddbmp.c 프로젝트: Skiles/aseprite
/* recreate_flipping_chain:
 *  Destroys the previous flipping chain and creates a new one.
 */
static int recreate_flipping_chain(int n_pages)
{
   int w, h, type, n_backbuffers;
   DDSCAPS ddscaps;
   HRESULT hr;

   ASSERT(n_pages > 0);

   /* set flipping chain characteristics */
   w = gfx_directx_forefront_bitmap->w;
   h = gfx_directx_forefront_bitmap->h;
   type = flipping_page[0]->flags & DDRAW_SURFACE_TYPE_MASK;
   n_backbuffers = n_pages - 1;

   /* release existing flipping chain */
   if (flipping_page[0]->id) {
      hr = IDirectDrawSurface2_Release(flipping_page[0]->id);
      if (FAILED(hr)) {
         _TRACE(PREFIX_E "Unable to release the primary surface (%s)", dd_err(hr));
         return -1;
      }
   }

   /* create the new flipping chain with the specified characteristics */
   flipping_page[0]->id = create_directdraw2_surface(w, h, ddpixel_format, type, n_backbuffers);
   if (!flipping_page[0]->id) 
      return -1;

   /* retrieve the backbuffers */
   if (n_backbuffers > 0) {
      memset(&ddscaps, 0, sizeof(DDSCAPS));

      /* first backbuffer */
      ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
      hr = IDirectDrawSurface2_GetAttachedSurface(flipping_page[0]->id, &ddscaps, &flipping_page[1]->id);
      if (FAILED(hr)) {
         _TRACE(PREFIX_E "Unable to retrieve the first backbuffer (%s)", dd_err(hr));
         return -1;
      }

      flipping_page[1]->flags = flipping_page[0]->flags;
      flipping_page[1]->lock_nesting = 0;

      if (n_backbuffers > 1) {
         /* second backbuffer */
         ddscaps.dwCaps = DDSCAPS_FLIP;
         hr = IDirectDrawSurface2_GetAttachedSurface(flipping_page[1]->id, &ddscaps, &flipping_page[2]->id);
         if (FAILED(hr)) {
            _TRACE(PREFIX_E "Unable to retrieve the second backbuffer (%s)", dd_err(hr));
            return -1;
         }

         flipping_page[2]->flags = flipping_page[0]->flags;
         flipping_page[2]->lock_nesting = 0;
      }
   }

   /* attach the global palette if needed */
   if (flipping_page[0]->flags & DDRAW_SURFACE_INDEXED) {
      hr = IDirectDrawSurface2_SetPalette(flipping_page[0]->id, ddpalette);
      if (FAILED(hr)) {
         _TRACE(PREFIX_E "Unable to attach the global palette (%s)", dd_err(hr));
         return -1;
      }
   }

   return 0;
}