/**
  * Initializes the appropriate D3D offscreen surface based on the value of the type parameter. If
  * the surface creation fails for any reason, an OutOfMemoryError will be thrown.
  */
 protected void initSurface() {
   // any time we create or restore the surface, recreate the raster
   synchronized (this) {
     wrn = null;
   }
   // REMIND: somewhere a puppy died
   class Status {
     boolean success = false;
   };
   final Status status = new Status();
   D3DRenderQueue rq = D3DRenderQueue.getInstance();
   rq.lock();
   try {
     rq.flushAndInvokeNow(
         new Runnable() {
           public void run() {
             status.success = initSurfaceNow();
           }
         });
     if (!status.success) {
       throw new InvalidPipeException("Error creating D3DSurface");
     }
   } finally {
     rq.unlock();
   }
 }
    protected void setElem(final int x, final int y, final int pixel, final SurfaceData sData) {
      if (sData.isSurfaceLost()) {
        return;
      }

      D3DRenderQueue rq = D3DRenderQueue.getInstance();
      rq.lock();
      try {
        rq.flushAndInvokeNow(
            new Runnable() {
              public void run() {
                dbSetPixelNative(sData.getNativeOps(), x, y, pixel);
              }
            });
        sData.markDirty();
      } finally {
        rq.unlock();
      }
    }
    protected int getElem(final int x, final int y, final SurfaceData sData) {
      if (sData.isSurfaceLost()) {
        return 0;
      }

      int retPixel;
      D3DRenderQueue rq = D3DRenderQueue.getInstance();
      rq.lock();
      try {
        rq.flushAndInvokeNow(
            new Runnable() {
              public void run() {
                pixel = dbGetPixelNative(sData.getNativeOps(), x, y);
              }
            });
      } finally {
        retPixel = pixel;
        rq.unlock();
      }
      return retPixel;
    }