use of android.graphics.ColorFilter in project fresco by facebook.
the class ArrayDrawableTest method testSetColorFilter.
@Test
public void testSetColorFilter() {
ColorFilter colorFilter = mock(ColorFilter.class);
mArrayDrawable.setColorFilter(colorFilter);
verify(mUnderlyingDrawable0).setColorFilter(colorFilter);
verify(mUnderlyingDrawable1).setColorFilter(colorFilter);
verify(mUnderlyingDrawable2).setColorFilter(colorFilter);
}
use of android.graphics.ColorFilter in project fresco by facebook.
the class RoundedBitmapDrawableTest method testPreservePaintOnDrawableCopy.
@Test
public void testPreservePaintOnDrawableCopy() {
ColorFilter colorFilter = mock(ColorFilter.class);
Paint originalPaint = mock(Paint.class);
BitmapDrawable originalVersion = mock(BitmapDrawable.class);
originalPaint.setColorFilter(colorFilter);
when(originalVersion.getPaint()).thenReturn(originalPaint);
RoundedBitmapDrawable roundedVersion = RoundedBitmapDrawable.fromBitmapDrawable(mResources, originalVersion);
assertEquals(originalVersion.getPaint().getColorFilter(), roundedVersion.getPaint().getColorFilter());
}
use of android.graphics.ColorFilter in project fresco by facebook.
the class DrawableUtilsTest method testSetDrawableProperties.
@Test
public void testSetDrawableProperties() {
DrawableProperties properties = new DrawableProperties();
ColorFilter colorFilter = mock(ColorFilter.class);
properties.setAlpha(42);
properties.setColorFilter(colorFilter);
properties.setDither(true);
properties.setFilterBitmap(true);
Drawable drawableTo = mock(Drawable.class);
DrawableUtils.setDrawableProperties(drawableTo, properties);
verify(drawableTo).setAlpha(42);
verify(drawableTo).setColorFilter(colorFilter);
verify(drawableTo).setDither(true);
verify(drawableTo).setFilterBitmap(true);
}
use of android.graphics.ColorFilter in project XobotOS by xamarin.
the class GLES20Canvas method setupModifiers.
private int setupModifiers(Paint paint) {
int modifiers = MODIFIER_NONE;
if (paint.hasShadow) {
nSetupShadow(mRenderer, paint.shadowRadius, paint.shadowDx, paint.shadowDy, paint.shadowColor);
modifiers |= MODIFIER_SHADOW;
}
final Shader shader = paint.getShader();
if (shader != null) {
nSetupShader(mRenderer, shader.native_shader);
modifiers |= MODIFIER_SHADER;
}
final ColorFilter filter = paint.getColorFilter();
if (filter != null) {
nSetupColorFilter(mRenderer, filter.nativeColorFilter);
modifiers |= MODIFIER_COLOR_FILTER;
}
return modifiers;
}
use of android.graphics.ColorFilter in project android_frameworks_base by DirtyUnicorns.
the class VectorDrawable method draw.
@Override
public void draw(Canvas canvas) {
// We will offset the bounds for drawBitmap, so copyBounds() here instead
// of getBounds().
copyBounds(mTmpBounds);
if (mTmpBounds.width() <= 0 || mTmpBounds.height() <= 0) {
// Nothing to draw
return;
}
// Color filters always override tint filters.
final ColorFilter colorFilter = (mColorFilter == null ? mTintFilter : mColorFilter);
final long colorFilterNativeInstance = colorFilter == null ? 0 : colorFilter.native_instance;
boolean canReuseCache = mVectorState.canReuseCache();
int pixelCount = nDraw(mVectorState.getNativeRenderer(), canvas.getNativeCanvasWrapper(), colorFilterNativeInstance, mTmpBounds, needMirroring(), canReuseCache);
if (pixelCount == 0) {
// cache, if any.
return;
}
int deltaInBytes;
// type, only one bitmap cache is allocated.
if (canvas.isHardwareAccelerated()) {
// Each pixel takes 4 bytes.
deltaInBytes = (pixelCount - mVectorState.mLastHWCachePixelCount) * 4;
mVectorState.mLastHWCachePixelCount = pixelCount;
} else {
// Each pixel takes 4 bytes.
deltaInBytes = (pixelCount - mVectorState.mLastSWCachePixelCount) * 4;
mVectorState.mLastSWCachePixelCount = pixelCount;
}
if (deltaInBytes > 0) {
VMRuntime.getRuntime().registerNativeAllocation(deltaInBytes);
} else if (deltaInBytes < 0) {
VMRuntime.getRuntime().registerNativeFree(-deltaInBytes);
}
}
Aggregations