当前位置: 首页>>代码示例>>Java>>正文


Java CloseableReference.cloneOrNull方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Bleoo,项目名称:WindowImageView,代码行数:21,代码来源:ReScalePostprocessor.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:KeepLastFrameCache.java

示例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);
    }
}
 
开发者ID:senierr,项目名称:ModuleFrame,代码行数:26,代码来源:SBSPostProcessor.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:EncodedImage.java

示例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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:PostprocessorProducer.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ScalingBlurPostprocessor.java

示例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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:KeepLastFrameCache.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:AnimatedImageFactoryImpl.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:PostprocessorProducer.java

示例10: getFallbackFrame

import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Nullable
@Override
public synchronized CloseableReference<Bitmap> getFallbackFrame(int frameNumber) {
  return CloseableReference.cloneOrNull(mLastBitmapReference);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:KeepLastFrameCache.java

示例11: cloneOrNull

import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
public CloseableReference<CloseableImage> cloneOrNull(
    CloseableReference<CloseableImage> closeableImage) {
  return CloseableReference.cloneOrNull(closeableImage);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:BitmapMemoryCacheKeyMultiplexProducer.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:CountingMemoryCacheInspector.java

示例13: getResult

import com.facebook.common.references.CloseableReference; //导入方法依赖的package包/类
@Override
@Nullable
public CloseableReference<T> getResult() {
  return CloseableReference.cloneOrNull(super.getResult());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:CloseableProducerToDataSourceAdapter.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:AnimatedImageResultBuilder.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:AnimatedImageResultBuilder.java


注:本文中的com.facebook.common.references.CloseableReference.cloneOrNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。