Example #1
0
 public RenderThread(boolean isCasting) {
   this.isCasting = isCasting;
   surfaceHolder = null;
   screenBuffer = XTRS.getScreenBuffer();
   lastScreenBuffer = new short[0];
   clipRect = new Rect();
   adjustedClipRect = new Rect();
 }
Example #2
0
 public synchronized Bitmap takeScreenshot(Hardware hardware) {
   Bitmap screenshot =
       Bitmap.createBitmap(hardware.getScreenWidth(), hardware.getScreenHeight(), Config.RGB_565);
   boolean expandedMode = XTRS.isExpandedMode();
   int d = expandedMode ? 2 : 1;
   dirtyRectLeft = dirtyRectTop = 0;
   dirtyRectRight = trsScreenCols / d - 1;
   dirtyRectBottom = trsScreenRows - 1;
   Canvas c = new Canvas(screenshot);
   renderScreenToCanvas(c, expandedMode);
   return screenshot;
 }
Example #3
0
  @Override
  public synchronized void run() {
    while (run) {
      isRendering = false;
      try {
        this.wait();
      } catch (InterruptedException e) {
        return;
      }
      isRendering = true;

      boolean expandedMode = XTRS.isExpandedMode();
      int d = expandedMode ? 2 : 1;
      computeDirtyRect(d);
      if (dirtyRectBottom == -1) {
        // Nothing to update
        continue;
      }

      if (isCasting) {
        renderScreenToCast(RemoteCastScreen.get(), expandedMode);
        continue;
      }
      if (surfaceHolder != null) {
        /*
         * The Android documentation does not mention that lockCanvas()
         * may adjust the clip rect due to double buffering. Since the
         * dirty rect might differ from the one that was computed in
         * computeDirtyRect() we simply invalidate the whole TRS screen
         * when this happens.
         */
        Canvas canvas = surfaceHolder.lockCanvas(adjustedClipRect);
        if (canvas == null) {
          continue;
        }
        if (adjustedClipRect.left != clipRect.left
            || adjustedClipRect.top != clipRect.top
            || adjustedClipRect.right != clipRect.right
            || adjustedClipRect.bottom != clipRect.bottom) {
          dirtyRectLeft = dirtyRectTop = 0;
          dirtyRectRight = trsScreenCols / d - 1;
          dirtyRectBottom = trsScreenRows - 1;
        }
        renderScreenToCanvas(canvas, expandedMode);
        surfaceHolder.unlockCanvasAndPost(canvas);
      }
    }
  }