19fc12334a7d14347cd6951d0653264b2597bd3a0Sam Juddpackage com.bumptech.glide.load; 2c27229a159bfc992874609270ab8b57981fef339Sam Judd 3b7c7c2b2505f996dbda219faeb0d08dc1c9982d7Sam Juddimport com.bumptech.glide.load.engine.Resource; 4c27229a159bfc992874609270ab8b57981fef339Sam Judd 5c27229a159bfc992874609270ab8b57981fef339Sam Judd/** 65f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * A class for performing an arbitrary transformation on a resource. 7fe090f50f3040f4d478143a3e0ffa8cdf813fefcSam Judd * 831b60a4ba485dcc22e5edd19c6768e1141c32f4eSam Judd * @param <T> The type of the resource being transformed. 9c27229a159bfc992874609270ab8b57981fef339Sam Judd */ 1031b60a4ba485dcc22e5edd19c6768e1141c32f4eSam Juddpublic interface Transformation<T> { 11c27229a159bfc992874609270ab8b57981fef339Sam Judd 12c27229a159bfc992874609270ab8b57981fef339Sam Judd /** 135f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * Transforms the given resource and returns the transformed resource. 14c27229a159bfc992874609270ab8b57981fef339Sam Judd * 155f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * <p> 165f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * Note - If the original resource object is not returned, the original resource will be recycled and it's 175f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * internal resources may be reused. This means it is not safe to rely on the original resource or any internal 185f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * state of the original resource in any new resource that is created. Usually this shouldn't occur, but if 195f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * absolutely necessary either the original resource object can be returned with modified internal state, or 205f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * the data in the original resource can be copied into the transformed resource. 215f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * </p> 225f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * 235f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * @param resource The resource to transform. 245f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * @param outWidth The width of the view or target the resource will be displayed in. 255f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * @param outHeight The height of the view or target the resource will be displayed in. 265f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * @return The transformed resource. 27c27229a159bfc992874609270ab8b57981fef339Sam Judd */ 285ba19a0e69ad3a651b8f13ba45de48a56b56ce36Sam Judd Resource<T> transform(Resource<T> resource, int outWidth, int outHeight); 29c27229a159bfc992874609270ab8b57981fef339Sam Judd 30c27229a159bfc992874609270ab8b57981fef339Sam Judd /** 3131b60a4ba485dcc22e5edd19c6768e1141c32f4eSam Judd * A method to get a unique identifier for this particular transformation that can be used as part of a cache key. 3231b60a4ba485dcc22e5edd19c6768e1141c32f4eSam Judd * The fully qualified class name for this class is appropriate if written out, but getClass().getName() is not 3331b60a4ba485dcc22e5edd19c6768e1141c32f4eSam Judd * because the name may be changed by proguard. 34c27229a159bfc992874609270ab8b57981fef339Sam Judd * 355f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * <p> 365f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * If this transformation does not affect the data that will be stored in cache, returning an empty string here 375f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * is acceptable. 385f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * </p> 395f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * 405f4610b54d517be58105bcf73ce3291ba79f9f40Sam Judd * @return A string that uniquely identifies this transformation. 41c27229a159bfc992874609270ab8b57981fef339Sam Judd */ 425ba19a0e69ad3a651b8f13ba45de48a56b56ce36Sam Judd String getId(); 43c27229a159bfc992874609270ab8b57981fef339Sam Judd} 44