本文整理汇总了Java中com.facebook.common.references.CloseableReference.cloneOrNull方法的典型用法代码示例。如果您正苦于以下问题:Java CloseableReference.cloneOrNull方法的具体用法?Java CloseableReference.cloneOrNull怎么用?Java CloseableReference.cloneOrNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.common.references.CloseableReference
的用法示例。
在下文中一共展示了CloseableReference.cloneOrNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {
float scale = 1.0f * width / sourceBitmap.getWidth();
Log.e("ReScalePostprocessor", "scale:" + scale);
scaledWidth = (int) (sourceBitmap.getWidth() * scale);
scaledHeight = (int) (sourceBitmap.getHeight() * scale);
listener.onProcessFinished(scaledWidth, scaledHeight);
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
Bitmap bitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(), matrix, true);
CloseableReference<Bitmap> bitmapRef = bitmapFactory.createBitmap(bitmap);
try {
return CloseableReference.cloneOrNull(bitmapRef);
} finally {
CloseableReference.closeSafely(bitmapRef);
}
}
示例2: onFrameRendered
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
public synchronized void onFrameRendered(
int frameNumber,
CloseableReference<Bitmap> bitmapReference,
@BitmapAnimationBackend.FrameType int frameType) {
if (bitmapReference != null
&& mLastBitmapReference != null
&& bitmapReference.get().equals(mLastBitmapReference.get())) {
return;
}
CloseableReference.closeSafely(mLastBitmapReference);
if (mFrameCacheListener != null && mLastFrameNumber != FRAME_NUMBER_UNSET) {
mFrameCacheListener.onFrameEvicted(this, mLastFrameNumber);
}
mLastBitmapReference = CloseableReference.cloneOrNull(bitmapReference);
if (mFrameCacheListener != null) {
mFrameCacheListener.onFrameCached(this, frameNumber);
}
mLastFrameNumber = frameNumber;
}
示例3: process
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {
CloseableReference<Bitmap> bitmapRef;
if (isFull) {
bitmapRef = bitmapFactory.createBitmap(
sourceBitmap.getWidth() / 2,
sourceBitmap.getHeight());
} else {
bitmapRef = bitmapFactory.createBitmap(
sourceBitmap.getWidth(),
sourceBitmap.getHeight());
}
try {
Bitmap destBitmap = bitmapRef.get();
Canvas canvas2d = new Canvas(destBitmap);
canvas2d.drawBitmap(sourceBitmap,
new Rect(0, 0, sourceBitmap.getWidth() / 2, sourceBitmap.getHeight()),
new Rect(0, 0, destBitmap.getWidth(), destBitmap.getHeight()), null);
return CloseableReference.cloneOrNull(bitmapRef);
} finally {
CloseableReference.closeSafely(bitmapRef);
}
}
示例4: getInputStream
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
/**
* Returns an InputStream from the internal InputStream Supplier if it's not null. Otherwise
* returns an InputStream for the internal buffer reference if valid and null otherwise.
*
* <p>The caller has to close the InputStream after using it.
*/
public InputStream getInputStream() {
if (mInputStreamSupplier != null) {
return mInputStreamSupplier.get();
}
CloseableReference<PooledByteBuffer> pooledByteBufferRef =
CloseableReference.cloneOrNull(mPooledByteBufferRef);
if (pooledByteBufferRef != null) {
try {
return new PooledByteBufferInputStream(pooledByteBufferRef.get());
} finally {
CloseableReference.closeSafely(pooledByteBufferRef);
}
}
return null;
}
示例5: updateSourceImageRef
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
private void updateSourceImageRef(
@Nullable CloseableReference<CloseableImage> sourceImageRef,
int status) {
CloseableReference<CloseableImage> oldSourceImageRef;
boolean shouldSubmit;
synchronized (PostprocessorConsumer.this) {
if (mIsClosed) {
return;
}
oldSourceImageRef = mSourceImageRef;
mSourceImageRef = CloseableReference.cloneOrNull(sourceImageRef);
mStatus = status;
mIsDirty = true;
shouldSubmit = setRunningIfDirtyAndNotRunning();
}
CloseableReference.closeSafely(oldSourceImageRef);
if (shouldSubmit) {
submitPostprocessing();
}
}
示例6: process
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
public CloseableReference<Bitmap> process(
Bitmap sourceBitmap,
PlatformBitmapFactory bitmapFactory) {
final CloseableReference<Bitmap> bitmapRef = bitmapFactory.createBitmap(
sourceBitmap.getWidth() / SCALE_RATIO,
sourceBitmap.getHeight() / SCALE_RATIO);
try {
final Bitmap destBitmap = bitmapRef.get();
final Canvas canvas = new Canvas(destBitmap);
canvas.drawBitmap(
sourceBitmap,
null,
new Rect(0, 0, destBitmap.getWidth(), destBitmap.getHeight()),
mPaint);
NativeBlurFilter.iterativeBoxBlur(destBitmap, mIterations, mBlurRadius / SCALE_RATIO);
return CloseableReference.cloneOrNull(bitmapRef);
} finally {
CloseableReference.closeSafely(bitmapRef);
}
}
示例7: getBitmapToReuseForFrame
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
public synchronized CloseableReference<Bitmap> getBitmapToReuseForFrame(
int frameNumber,
int width,
int height) {
try {
return CloseableReference.cloneOrNull(mLastBitmapReference);
} finally {
closeAndResetLastBitmapReference();
}
}
示例8: getCloseableImage
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
private CloseableImage getCloseableImage(
ImageDecodeOptions options,
AnimatedImage image,
Bitmap.Config bitmapConfig) {
List<CloseableReference<Bitmap>> decodedFrames = null;
CloseableReference<Bitmap> previewBitmap = null;
try {
final int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
if (options.forceStaticImage) {
return new CloseableStaticBitmap(
createPreviewBitmap(image, bitmapConfig, frameForPreview),
ImmutableQualityInfo.FULL_QUALITY,
0);
}
if (options.decodeAllFrames) {
decodedFrames = decodeAllFrames(image, bitmapConfig);
previewBitmap = CloseableReference.cloneOrNull(decodedFrames.get(frameForPreview));
}
if (options.decodePreviewFrame && previewBitmap == null) {
previewBitmap = createPreviewBitmap(image, bitmapConfig, frameForPreview);
}
AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
.setPreviewBitmap(previewBitmap)
.setFrameForPreview(frameForPreview)
.setDecodedFrames(decodedFrames)
.build();
return new CloseableAnimatedImage(animatedImageResult);
} finally {
CloseableReference.closeSafely(previewBitmap);
CloseableReference.closeSafely(decodedFrames);
}
}
示例9: setSourceImageRef
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
private void setSourceImageRef(CloseableReference<CloseableImage> sourceImageRef) {
CloseableReference<CloseableImage> oldSourceImageRef;
synchronized (RepeatedPostprocessorConsumer.this) {
if (mIsClosed) {
return;
}
oldSourceImageRef = mSourceImageRef;
mSourceImageRef = CloseableReference.cloneOrNull(sourceImageRef);
}
CloseableReference.closeSafely(oldSourceImageRef);
}
示例10: getFallbackFrame
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Nullable
@Override
public synchronized CloseableReference<Bitmap> getFallbackFrame(int frameNumber) {
return CloseableReference.cloneOrNull(mLastBitmapReference);
}
示例11: cloneOrNull
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
public CloseableReference<CloseableImage> cloneOrNull(
CloseableReference<CloseableImage> closeableImage) {
return CloseableReference.cloneOrNull(closeableImage);
}
示例12: DumpInfoEntry
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
public DumpInfoEntry(
final K key,
final CloseableReference<V> valueRef) {
this.key = Preconditions.checkNotNull(key);
this.value = CloseableReference.cloneOrNull(valueRef);
}
示例13: getResult
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
@Nullable
public CloseableReference<T> getResult() {
return CloseableReference.cloneOrNull(super.getResult());
}
示例14: getPreviewBitmap
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
/**
* Gets the preview bitmap. This method returns a new reference. The caller must close it.
*
* @return the reference to the preview bitmap or null if none was set. This returns a reference
* that must be released by the caller
*/
public CloseableReference<Bitmap> getPreviewBitmap() {
return CloseableReference.cloneOrNull(mPreviewBitmap);
}
示例15: setPreviewBitmap
import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
/**
* Sets a preview bitmap.
*
* @param previewBitmap the preview. The method clones the reference.
* @return this builder
*/
public AnimatedImageResultBuilder setPreviewBitmap(CloseableReference<Bitmap> previewBitmap) {
mPreviewBitmap = CloseableReference.cloneOrNull(previewBitmap);
return this;
}