• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.bumptech.glide.load;
2 
3 import com.bumptech.glide.load.engine.Resource;
4 
5 /**
6  * A class for performing an arbitrary transformation on a resource.
7  *
8  * @param <T> The type of the resource being transformed.
9  */
10 public interface Transformation<T> {
11 
12     /**
13      * Transforms the given resource and returns the transformed resource.
14      *
15      * <p>
16      *     Note - If the original resource object is not returned, the original resource will be recycled and it's
17      *     internal resources may be reused. This means it is not safe to rely on the original resource or any internal
18      *     state of the original resource in any new resource that is created. Usually this shouldn't occur, but if
19      *     absolutely necessary either the original resource object can be returned with modified internal state, or
20      *     the data in the original resource can be copied into the transformed resource.
21      * </p>
22      *
23      * @param resource The resource to transform.
24      * @param outWidth The width of the view or target the resource will be displayed in.
25      * @param outHeight The height of the view or target the resource will be displayed in.
26      * @return The transformed resource.
27      */
transform(Resource<T> resource, int outWidth, int outHeight)28     Resource<T> transform(Resource<T> resource, int outWidth, int outHeight);
29 
30     /**
31      * A method to get a unique identifier for this particular transformation that can be used as part of a cache key.
32      * The fully qualified class name for this class is appropriate if written out, but getClass().getName() is not
33      * because the name may be changed by proguard.
34      *
35      * <p>
36      *     If this transformation does not affect the data that will be stored in cache, returning an empty string here
37      *     is acceptable.
38      * </p>
39      *
40      * @return A string that uniquely identifies this transformation.
41      */
getId()42     String getId();
43 }
44