Skip to content

Commit

Permalink
Update pipeline code to use copyMetaDataFrom method
Browse files Browse the repository at this point in the history
  • Loading branch information
lukkm authored and tyronen committed Jul 20, 2015
1 parent aa8bd4f commit 3ce4e16
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ public class EncodedImage implements Closeable {
private final @Nullable CloseableReference<PooledByteBuffer> mPooledByteBufferRef;
private final @Nullable Supplier<FileInputStream> mInputStreamSupplier;

private int mStreamSize = -1;

private ImageFormat mImageFormat = ImageFormat.UNKNOWN;
private int mRotationAngle = UNKNOWN_ROTATION_ANGLE;
private int mWidth = UNKNOWN_WIDTH;
private int mHeight = UNKNOWN_HEIGHT;
private int mSampleSize = DEFAULT_SAMPLE_SIZE;
private int mStreamSize = UNKNOWN_STREAM_SIZE;

public EncodedImage(CloseableReference<PooledByteBuffer> pooledByteBufferRef) {
Preconditions.checkArgument(CloseableReference.isValid(pooledByteBufferRef));
Expand Down Expand Up @@ -105,11 +104,7 @@ public EncodedImage cloneOrNull() {
}
}
if (encodedImage != null) {
encodedImage.setImageFormat(mImageFormat);
encodedImage.setRotationAngle(mRotationAngle);
encodedImage.setWidth(mWidth);
encodedImage.setHeight(mHeight);
encodedImage.setSampleSize(mSampleSize);
encodedImage.copyMetaDataFrom(this);
}
return encodedImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void onNewResultImpl(EncodedImage newResult, boolean isLast) {
EncodedImage cachedEncodedImage;
try {
cachedEncodedImage = new EncodedImage(cachedResult);
cachedEncodedImage.copyMetaDataFrom(newResult);
} finally {
CloseableReference.closeSafely(cachedResult);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ protected EncodedImage getResult() throws Exception {
try {
encodedImage = getByteBufferBackedEncodedImage(
oldEncodedImage.getInputStream(), oldEncodedImage.getSize());
encodedImage.copyMetaDataFrom(oldEncodedImage);
} finally {
EncodedImage.closeSafely(oldEncodedImage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ protected EncodedImage getResult() throws Exception {
CloseableReference<PooledByteBuffer> ref =
CloseableReference.of(outputStream.toByteBuffer());
try {
return new EncodedImage(ref);
EncodedImage encodedImage = new EncodedImage(ref);
encodedImage.copyMetaDataFrom(encodedImageCopy);
return encodedImage;
} finally {
CloseableReference.closeSafely(ref);
}
Expand Down

0 comments on commit 3ce4e16

Please sign in to comment.