use of com.bumptech.glide.load.Options in project Rocket by mozilla-tw.
the class DecodeJob method getOptionsWithHardwareConfig.
private Options getOptionsWithHardwareConfig(DataSource dataSource) {
Options options = this.options;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return options;
}
if (options.get(Downsampler.ALLOW_HARDWARE_CONFIG) != null) {
return options;
}
if (dataSource == DataSource.RESOURCE_DISK_CACHE || decodeHelper.isScaleOnlyOrNoTransform()) {
options = new Options();
options.putAll(this.options);
options.set(Downsampler.ALLOW_HARDWARE_CONFIG, true);
}
return options;
}
use of com.bumptech.glide.load.Options in project Rocket by mozilla-tw.
the class RequestOptions method clone.
/**
* Returns a copy of this request builder with all of the options put so far on this builder.
*
* <p> This method returns a "deep" copy in that all non-immutable arguments are copied such that
* changes to one builder will not affect the other builder. However, in addition to immutable
* arguments, the current model is not copied copied so changes to the model will affect both
* builders. </p>
*
* <p> Even if this object was locked, the cloned object returned from this method will not be
* locked. </p>
*/
@SuppressWarnings("unchecked")
@CheckResult
@Override
public RequestOptions clone() {
try {
RequestOptions result = (RequestOptions) super.clone();
result.options = new Options();
result.options.putAll(options);
result.transformations = new HashMap<>();
result.transformations.putAll(transformations);
result.isLocked = false;
result.isAutoCloneEnabled = false;
return result;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
use of com.bumptech.glide.load.Options in project glide by bumptech.
the class DownsamplerEmulatorTest method runScaleTest.
/**
* Returns an error string if the test failed, and {@code null} otherwise.
*/
@Nullable
private static String runScaleTest(CompressFormat format, int initialWidth, int initialHeight, int targetWidth, int targetHeight, DownsampleStrategy strategy, int expectedWidth, int expectedHeight) throws IOException {
Downsampler downsampler = buildDownsampler();
InputStream is = openBitmapStream(format, initialWidth, initialHeight);
Options options = new Options().set(DownsampleStrategy.OPTION, strategy);
Bitmap bitmap = downsampler.decode(is, targetWidth, targetHeight, options).get();
try {
if (bitmap.getWidth() != expectedWidth || bitmap.getHeight() != expectedHeight) {
return "API: " + Build.VERSION.SDK_INT + ", os: " + Build.VERSION.RELEASE + ", format: " + format + ", strategy: " + strategy + " -" + " Initial " + readableDimens(initialWidth, initialHeight) + " Target " + readableDimens(targetWidth, targetHeight) + " Expected " + readableDimens(expectedWidth, expectedHeight) + ", but Received " + readableDimens(bitmap.getWidth(), bitmap.getHeight());
}
} finally {
bitmap.recycle();
}
return null;
}
use of com.bumptech.glide.load.Options in project glide by bumptech.
the class ReEncodingGifResourceEncoderTest method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Application context = RuntimeEnvironment.application;
ReEncodingGifResourceEncoder.Factory factory = mock(ReEncodingGifResourceEncoder.Factory.class);
when(decoder.getNextFrame()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));
when(factory.buildDecoder(any(GifDecoder.BitmapProvider.class))).thenReturn(decoder);
when(factory.buildParser()).thenReturn(parser);
when(factory.buildEncoder()).thenReturn(gifEncoder);
when(factory.buildFrameResource(any(Bitmap.class), any(BitmapPool.class))).thenReturn(frameResource);
// TODO Util.anyResource once Util is moved to testutil module (remove unchecked above!)
when(frameTransformation.transform(anyContext(), any(Resource.class), anyInt(), anyInt())).thenReturn(frameResource);
when(gifDrawable.getFrameTransformation()).thenReturn(frameTransformation);
when(gifDrawable.getBuffer()).thenReturn(ByteBuffer.allocate(0));
when(resource.get()).thenReturn(gifDrawable);
encoder = new ReEncodingGifResourceEncoder(context, mock(BitmapPool.class), factory);
options = new Options();
options.set(ReEncodingGifResourceEncoder.ENCODE_TRANSFORMATION, true);
file = new File(context.getCacheDir(), "test");
}
use of com.bumptech.glide.load.Options in project glide by bumptech.
the class UriLoaderTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
options = new Options();
loader = new UriLoader<>(factory);
}
Aggregations