Search in sources :

Example 21 with ColorFilter

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);
}
Also used : ColorFilter(android.graphics.ColorFilter) Test(org.junit.Test)

Example 22 with 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());
}
Also used : ColorFilter(android.graphics.ColorFilter) Paint(android.graphics.Paint) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Test(org.junit.Test)

Example 23 with ColorFilter

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);
}
Also used : ColorFilter(android.graphics.ColorFilter) Drawable(android.graphics.drawable.Drawable) Test(org.junit.Test)

Example 24 with ColorFilter

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;
}
Also used : ColorFilter(android.graphics.ColorFilter) Shader(android.graphics.Shader) Paint(android.graphics.Paint)

Example 25 with ColorFilter

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);
    }
}
Also used : ColorFilter(android.graphics.ColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter)

Aggregations

ColorFilter (android.graphics.ColorFilter)50 LightingColorFilter (android.graphics.LightingColorFilter)21 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)17 Drawable (android.graphics.drawable.Drawable)17 FilterableStateListDrawable (com.simplecity.amp_library.ui.views.FilterableStateListDrawable)16 Paint (android.graphics.Paint)14 LayerDrawable (android.graphics.drawable.LayerDrawable)14 Path (android.graphics.Path)5 RectF (android.graphics.RectF)5 Test (org.junit.Test)5 Bitmap (android.graphics.Bitmap)4 Canvas (android.graphics.Canvas)4 Rect (android.graphics.Rect)3 Shader (android.graphics.Shader)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 StateListDrawable (android.graphics.drawable.StateListDrawable)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 FilterableStateListDrawable (com.bilibili.magicasakura.drawables.FilterableStateListDrawable)2