예제 #1
0
 /**
  * Creates a SurfaceData object representing an off-screen buffer (either a plain surface or
  * Texture).
  */
 public static D3DSurfaceData createData(
     D3DGraphicsConfig gc, int width, int height, ColorModel cm, Image image, int type) {
   if (type == RT_TEXTURE) {
     boolean isOpaque = cm.getTransparency() == Transparency.OPAQUE;
     int cap = isOpaque ? CAPS_RT_TEXTURE_OPAQUE : CAPS_RT_TEXTURE_ALPHA;
     if (!gc.getD3DDevice().isCapPresent(cap)) {
       type = RT_PLAIN;
     }
   }
   D3DSurfaceData ret = null;
   try {
     ret =
         new D3DSurfaceData(
             null, gc, width, height, image, cm, 0, SWAP_DISCARD, VSYNC_DEFAULT, type);
   } catch (InvalidPipeException ipe) {
     // try again - we might have ran out of vram, and rt textures
     // could take up more than a plain surface, so it might succeed
     if (type == RT_TEXTURE) {
       // If a RT_TEXTURE was requested do not attempt to create a
       // plain surface. (note that RT_TEXTURE can only be requested
       // from a VI so the cast is safe)
       if (((SunVolatileImage) image).getForcedAccelSurfaceType() != RT_TEXTURE) {
         type = RT_PLAIN;
         ret =
             new D3DSurfaceData(
                 null, gc, width, height, image, cm, 0, SWAP_DISCARD, VSYNC_DEFAULT, type);
       }
     }
   }
   return ret;
 }
예제 #2
0
  protected D3DSurfaceData(
      WComponentPeer peer,
      D3DGraphicsConfig gc,
      int width,
      int height,
      Image image,
      ColorModel cm,
      int numBackBuffers,
      int swapEffect,
      VSyncType vSyncType,
      int type) {
    super(getCustomSurfaceType(type), cm);
    this.graphicsDevice = gc.getD3DDevice();
    this.peer = peer;
    this.type = type;
    this.width = width;
    this.height = height;
    this.offscreenImage = image;
    this.backBuffersNum = numBackBuffers;
    this.swapEffect = swapEffect;
    this.syncType = vSyncType;

    initOps(graphicsDevice.getScreen(), width, height);
    if (type == WINDOW) {
      // we put the surface into the "lost"
      // state; it will be restored by the D3DScreenUpdateManager
      // prior to rendering to it for the first time. This is done
      // so that vram is not wasted for surfaces never rendered to
      setSurfaceLost(true);
    } else {
      initSurface();
    }
    setBlitProxyKey(gc.getProxyKey());
  }