Skip to content

Commit

Permalink
Update ktfmt component on FBS:master
Browse files Browse the repository at this point in the history
Differential Revision: D46802820

fbshipit-source-id: a2737658576bf86f431a7b355d853a529f6a2c34
  • Loading branch information
cgrushko authored and facebook-github-bot committed Jun 19, 2023
1 parent 4e964d5 commit cc4ff60
Show file tree
Hide file tree
Showing 38 changed files with 113 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class BalancedAnimationStrategy(
private val fetchingOnDemand = AtomicBoolean(false)
private val framesCached: Boolean
get() = bitmapCache.isAnimationReady()

private val onDemandFrames: SortedSet<Int> = sortedSetOf()
private var nextPrepareFrames = SystemClock.uptimeMillis()

Expand Down Expand Up @@ -114,6 +115,7 @@ class BalancedAnimationStrategy(

AnimationLoaderExecutor.execute(task)
}

private fun loadAllFrames(frameSize: Size, notifyOnLoad: (() -> Unit)?): LoadFrameTask {
return loadFrameTaskFactory.createLoadFullAnimationTask(
frameSize.width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ class LoadFrameTaskFactory(

interface LoadFrameOutput {
fun onSuccess(frames: Map<Int, CloseableReference<Bitmap>>)

fun onFail()
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ object Deps {
private const val version = "0.183.0"
const val flipper = "com.facebook.flipper:flipper:$version"
}

object Stetho {
private const val version = "1.6.0"
const val stetho = "com.facebook.stetho:stetho:$version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CountingMemoryCacheInspector<K, V>(

// The value
@JvmField val value: CloseableReference<V>?

fun release() {
CloseableReference.closeSafely(value)
}
Expand Down Expand Up @@ -52,6 +53,7 @@ class CountingMemoryCacheInspector<K, V>(
@JvmField val sharedEntries: MutableList<DumpInfoEntry<K, V>>

@JvmField val otherEntries: MutableMap<Bitmap, Any>

fun release() {
for (entry in lruEntries) {
entry.release()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ data class BytesRange(
companion object {
const val TO_END_OF_CONTENT = Int.MAX_VALUE
private val headerParsingRegEx: Pattern by lazy { Pattern.compile("[-/ ]") }

private fun valueOrEmpty(n: Int): String {
return if (n == TO_END_OF_CONTENT) "" else n.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ object FrescoSystrace {

interface Systrace {
fun beginSection(name: String)

fun beginSectionWithArgs(name: String): ArgsBuilder

fun endSection()

fun isTracing(): Boolean
}

Expand Down Expand Up @@ -97,9 +100,13 @@ object FrescoSystrace {

private class NoOpArgsBuilder : ArgsBuilder {
override fun flush() = Unit

override fun arg(key: String, value: Any): ArgsBuilder = this

override fun arg(key: String, value: Int): ArgsBuilder = this

override fun arg(key: String, value: Long): ArgsBuilder = this

override fun arg(key: String, value: Double): ArgsBuilder = this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,79 +205,111 @@ class ImagePipelineConfig private constructor(builder: Builder) : ImagePipelineC
class Builder(context: Context) {
var bitmapConfig: Bitmap.Config? = null
private set

var bitmapMemoryCacheParamsSupplier: Supplier<MemoryCacheParams>? = null
private set

var bitmapMemoryCacheEntryStateObserver: EntryStateObserver<CacheKey>? = null
private set

var bitmapMemoryCacheTrimStrategy: CacheTrimStrategy? = null
private set

var encodedMemoryCacheTrimStrategy: CacheTrimStrategy? = null
private set

var cacheKeyFactory: CacheKeyFactory? = null
private set

val context: Context
var downsampleEnabled = false
private set

var encodedMemoryCacheParamsSupplier: Supplier<MemoryCacheParams>? = null
private set

var executorSupplier: ExecutorSupplier? = null
private set

var imageCacheStatsTracker: ImageCacheStatsTracker? = null
private set

var imageDecoder: ImageDecoder? = null
private set

var imageTranscoderFactory: ImageTranscoderFactory? = null
private set

@ImageTranscoderType var imageTranscoderType: Int? = null
var isPrefetchEnabledSupplier: Supplier<Boolean>? = null
private set

var mainDiskCacheConfig: DiskCacheConfig? = null
private set

var memoryTrimmableRegistry: MemoryTrimmableRegistry? = null
private set

@MemoryChunkType var memoryChunkType: Int? = null
var networkFetcher: NetworkFetcher<*>? = null
private set

var platformBitmapFactory: PlatformBitmapFactory? = null
private set

var poolFactory: PoolFactory? = null
private set

var progressiveJpegConfig: ProgressiveJpegConfig? = null
private set

var requestListeners: Set<RequestListener>? = null
private set

var requestListener2s: Set<RequestListener2>? = null
private set

var customProducerSequenceFactories: Set<CustomProducerSequenceFactory>? = null
private set

var resizeAndRotateEnabledForNetwork = true
private set

var smallImageDiskCacheConfig: DiskCacheConfig? = null
private set

var fileCacheFactory: FileCacheFactory? = null
private set

var imageDecoderConfig: ImageDecoderConfig? = null
private set

var httpConnectionTimeout = -1
private set

val experimentsBuilder = ImagePipelineExperiments.Builder(this)
var diskCacheEnabled = true
private set

var callerContextVerifier: CallerContextVerifier? = null
private set

var closeableReferenceLeakTracker: CloseableReferenceLeakTracker =
NoOpCloseableReferenceLeakTracker()
private set

var bitmapMemoryCache: MemoryCache<CacheKey, CloseableImage>? = null
private set

var encodedMemoryCache: MemoryCache<CacheKey, PooledByteBuffer>? = null
private set

var serialExecutorServiceForAnimatedImages: SerialExecutorService? = null
private set

var bitmapMemoryCacheFactory: BitmapMemoryCacheFactory? = null
private set

fun setBitmapsConfig(config: Bitmap.Config?): Builder = apply { this.bitmapConfig = config }

fun setBitmapMemoryCacheParamsSupplier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class RequestLoggingListener : RequestListener {

companion object {
private const val TAG = "RequestLoggingListener"

private fun getElapsedTime(startTime: Long?, endTime: Long): Long =
if (startTime != null) {
endTime - startTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ constructor(val blurRadius: Int, val context: Context, val iterations: Int = DEF
blurRadius > 0 && blurRadius <= RenderScriptBlurFilter.BLUR_MAX_RADIUS)
Preconditions.checkArgument(iterations > 0)
}

private val cacheKey: CacheKey =
SimpleCacheKey(
if (canUseRenderScript) {
String.format(null as Locale?, "IntrinsicBlur;%d", blurRadius)
} else {
String.format(null as Locale?, "IterativeBoxBlur;%d;%d", iterations, blurRadius)
})

override fun getPostprocessorCacheKey(): CacheKey = cacheKey

override fun process(destBitmap: Bitmap, sourceBitmap: Bitmap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RoundPostprocessor @JvmOverloads constructor(private val enableAntiAliasin
BasePostprocessor() {

private val cacheKey: CacheKey = SimpleCacheKey("XferRoundFilter")

override fun getPostprocessorCacheKey(): CacheKey = cacheKey

override fun process(destBitmap: Bitmap, sourceBitmap: Bitmap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class DecodeProducer(
@get:Synchronized @GuardedBy("this") private var isFinished: Boolean = false
private val jobScheduler: JobScheduler
protected var lastScheduledScanNumber = 0

private fun maybeIncreaseSampleSize(encodedImage: EncodedImage) {
if (encodedImage.imageFormat !== DefaultImageFormats.JPEG) {
return
Expand Down Expand Up @@ -388,6 +389,7 @@ class DecodeProducer(
}

protected abstract fun getIntermediateImageEndOffset(encodedImage: EncodedImage): Int

protected abstract val qualityInfo: QualityInfo

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class LocalAssetFetchProducer(

companion object {
const val PRODUCER_NAME = "LocalAssetFetchProducer"

private fun getAssetName(imageRequest: ImageRequest): String =
imageRequest.sourceUri.path!!.substring(1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class LocalResourceFetchProducer(

companion object {
const val PRODUCER_NAME = "LocalResourceFetchProducer"

private fun getResourceId(imageRequest: ImageRequest): Int {
val path = imageRequest.sourceUri.path
checkNotNull(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ThreadHandoffProducer<T>(
}

override fun disposeResult(ignored: T?) = Unit

@Throws(Exception::class)
override fun getResult(): T? {
return null
Expand All @@ -54,6 +55,7 @@ class ThreadHandoffProducer<T>(

companion object {
const val PRODUCER_NAME = "BackgroundThreadHandoffProducer"

private fun getInstrumentationTag(context: ProducerContext): String? {
return if (FrescoInstrumenter.isTracing) "ThreadHandoffProducer_produceResults_" + context.id
else null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ data class ExampleItem(
helpText: String? = null,
backstackTag: String? = null
) : this(title, helpText, backstackTag, { LithoSampleHostFragment(lithoSample, helpText) })

val itemId = title.hashCode()
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ class ShowcaseApplication : Application() {
private val sFlipperImageTracker = FlipperImageTracker()
lateinit var imageTracker: ImageTracker
private set

lateinit var imageUriProvider: ImageUriProvider
private set

lateinit var imageSelector: ImageSelector
private set
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ class MultiUriFragment : BaseShowcaseFragment() {
private var _binding: FragmentDraweeMultiUriBinding? = null
private val binding
get() = _binding!!

private val draweeView: SimpleDraweeView
get() = binding.draweeView

private val switchUseVito: SwitchMaterial
get() = binding.switchUseVito

private val btnFirstAvailable: Button
get() = binding.btnFirstAvailable

private val btnIncreasingQuality
get() = binding.btnIncreasingQuality

private val btnBoth
get() = binding.btnBoth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,55 @@ class FrescoVitoLithoImageOptionsConfigFragment : BaseShowcaseFragment() {
private var _binding: FragmentVitoImageOptionsConfigBinding? = null
private val binding
get() = _binding!!

private val container
get() = binding.container

private val spinnerRounding
get() = binding.spinnerRounding

private val spinnerBorder
get() = binding.spinnerBorder

private val spinnerScaleType
get() = binding.spinnerScaleType

private val spinnerImageSource
get() = binding.spinnerImageSource

private val spinnerImageFormat
get() = binding.spinnerImageFormat

private val spinnerColorFilter
get() = binding.spinnerColorFilter

private val spinnerPlaceholder
get() = binding.spinnerPlaceholder

private val spinnerError
get() = binding.spinnerError

private val spinnerOverlay
get() = binding.spinnerOverlay

private val spinnerFading
get() = binding.spinnerFading

private val spinnerProgress
get() = binding.spinnerProgress

private val spinnerPostprocessor
get() = binding.spinnerPostprocessor

private val spinnerRotation
get() = binding.spinnerRotation

private val spinnerResize
get() = binding.spinnerResize

private val spinnerCustomDrawableFactory
get() = binding.spinnerCustomDrawableFactory

private val switchAutoPlayAnimations
get() = binding.switchAutoPlayAnimations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class LithoSlideshowSample : LithoSample {
.round(RoundingOptions.asCircle())
.fadeDurationMs(0)
.build()

override fun createLithoComponent(
c: ComponentContext,
uris: ImageUriProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ class VitoViewPrefetchFragment : BaseShowcaseFragment() {
private var _binding: FragmentVitoViewPrefetchBinding? = null
private val binding
get() = _binding!!

private val buttonPrefetchBitmap
get() = binding.buttonPrefetchBitmap

private val buttonPrefetchEncoded
get() = binding.buttonPrefetchEncoded

private val buttonPrefetchDisk
get() = binding.buttonPrefetchDisk

private val buttonToggleImages
get() = binding.buttonToggleImages

private val buttonClearCache
get() = binding.buttonClearCache

Expand Down
Loading

0 comments on commit cc4ff60

Please sign in to comment.