示例#1
0
  public void updateTextureFromRegion(Region region, int x, int z, int w, int h) {
    int tx = (x >> region.zoomLevel) & (this.w - 1);
    int ty = (z >> region.zoomLevel) & (this.h - 1);
    int tw = (w >> region.zoomLevel);
    int th = (h >> region.zoomLevel);

    // make sure we don't write outside texture
    tw = Math.min(tw, this.w - tx);
    th = Math.min(th, this.h - th);

    // MwUtil.log("updateTextureFromRegion: region %s, %d %d %d %d -> %d %d %d %d", region, x, z, w,
    // h, tx, ty, tw, th);

    int[] pixels = region.getPixels();
    if (pixels != null) {
      this.setRGBOpaque(tx, ty, tw, th, pixels, region.getPixelOffset(x, z), Region.SIZE);
    } else {
      this.fillRect(tx, ty, tw, th, 0xff000000);
    }
  }