Пример #1
0
  public synchronized void update() {
    final BaseTextureRegion textureRegion = this.mTextureRegion;
    final Texture texture = textureRegion.getTexture();

    if (texture == null) { // TODO Check really needed?
      return;
    }

    final int x1 = Float.floatToRawIntBits(textureRegion.getTextureCoordinateX1());
    final int y1 = Float.floatToRawIntBits(textureRegion.getTextureCoordinateY1());
    final int x2 = Float.floatToRawIntBits(textureRegion.getTextureCoordinateX2());
    final int y2 = Float.floatToRawIntBits(textureRegion.getTextureCoordinateY2());

    final int[] bufferData = this.mBufferData;

    if (this.mFlippedVertical) {
      if (this.mFlippedHorizontal) {
        bufferData[0] = x2;
        bufferData[1] = y2;

        bufferData[2] = x2;
        bufferData[3] = y1;

        bufferData[4] = x1;
        bufferData[5] = y2;

        bufferData[6] = x1;
        bufferData[7] = y1;
      } else {
        bufferData[0] = x1;
        bufferData[1] = y2;

        bufferData[2] = x1;
        bufferData[3] = y1;

        bufferData[4] = x2;
        bufferData[5] = y2;

        bufferData[6] = x2;
        bufferData[7] = y1;
      }
    } else {
      if (this.mFlippedHorizontal) {
        bufferData[0] = x2;
        bufferData[1] = y1;

        bufferData[2] = x2;
        bufferData[3] = y2;

        bufferData[4] = x1;
        bufferData[5] = y1;

        bufferData[6] = x1;
        bufferData[7] = y2;
      } else {
        bufferData[0] = x1;
        bufferData[1] = y1;

        bufferData[2] = x1;
        bufferData[3] = y2;

        bufferData[4] = x2;
        bufferData[5] = y1;

        bufferData[6] = x2;
        bufferData[7] = y2;
      }
    }

    final FastFloatBuffer buffer = this.mFloatBuffer;
    buffer.position(0);
    buffer.put(bufferData);
    buffer.position(0);

    super.setHardwareBufferNeedsUpdate();
  }