/** * @param pTextureManager * @param pPVRTextureFormat * @param pPVRTexturePixelBufferStrategy * @param pTextureOptions * @param pTextureStateListener * @throws IllegalArgumentException * @throws IOException */ public PVRTexture( final TextureManager pTextureManager, final PVRTextureFormat pPVRTextureFormat, final IPVRTexturePixelBufferStrategy pPVRTexturePixelBufferStrategy, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) throws IllegalArgumentException, IOException { super( pTextureManager, pPVRTextureFormat.getPixelFormat(), pTextureOptions, pTextureStateListener); this.mPVRTexturePixelBufferStrategy = pPVRTexturePixelBufferStrategy; InputStream inputStream = null; try { inputStream = this.getInputStream(); this.mPVRTextureHeader = new PVRTextureHeader(StreamUtils.streamToBytes(inputStream, PVRTextureHeader.SIZE)); } finally { StreamUtils.close(inputStream); } if (this.mPVRTextureHeader.getPVRTextureFormat().getPixelFormat() != pPVRTextureFormat.getPixelFormat()) { throw new IllegalArgumentException( "Other PVRTextureFormat: '" + this.mPVRTextureHeader.getPVRTextureFormat().getPixelFormat() + "' found than expected: '" + pPVRTextureFormat.getPixelFormat() + "'."); } if (this.mPVRTextureHeader .getPVRTextureFormat() .isCompressed()) { // TODO && ! GLHELPER_EXTENSION_PVRTC] ) { throw new IllegalArgumentException( "Invalid PVRTextureFormat: '" + this.mPVRTextureHeader.getPVRTextureFormat() + "'."); } this.mUpdateOnHardwareNeeded = true; }
/** * @param pID * @return */ public static PVRTextureFormat fromID(final int pID) { final PVRTextureFormat[] pvrTextureFormats = PVRTextureFormat.values(); final int pvrTextureFormatCount = pvrTextureFormats.length; for (int i = 0; i < pvrTextureFormatCount; i++) { final PVRTextureFormat pvrTextureFormat = pvrTextureFormats[i]; if (pvrTextureFormat.mID == pID) { return pvrTextureFormat; } } throw new IllegalArgumentException( "Unexpected " + PVRTextureFormat.class.getSimpleName() + "-ID: '" + pID + "'."); }
/** @param pData */ public PVRTextureHeader(final byte[] pData) { this.mDataByteBuffer = ByteBuffer.wrap(pData); this.mDataByteBuffer.rewind(); this.mDataByteBuffer.order(ByteOrder.LITTLE_ENDIAN); /* Check magic bytes. */ if (!ArrayUtils.equals( pData, 11 * DataConstants.BYTES_PER_INT, PVRTextureHeader.MAGIC_IDENTIFIER, 0, PVRTextureHeader.MAGIC_IDENTIFIER.length)) { throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!"); } this.mPVRTextureFormat = PVRTextureFormat.fromID(this.getFlags() & PVRTextureHeader.FORMAT_FLAG_MASK); }