use of android.graphics.Shader 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.Shader in project XobotOS by xamarin.
the class BitmapDrawable method draw.
@Override
public void draw(Canvas canvas) {
Bitmap bitmap = mBitmap;
if (bitmap != null) {
final BitmapState state = mBitmapState;
if (state.mRebuildShader) {
Shader.TileMode tmx = state.mTileModeX;
Shader.TileMode tmy = state.mTileModeY;
if (tmx == null && tmy == null) {
state.mPaint.setShader(null);
} else {
state.mPaint.setShader(new BitmapShader(bitmap, tmx == null ? Shader.TileMode.CLAMP : tmx, tmy == null ? Shader.TileMode.CLAMP : tmy));
}
state.mRebuildShader = false;
copyBounds(mDstRect);
}
Shader shader = state.mPaint.getShader();
if (shader == null) {
if (mApplyGravity) {
final int layoutDirection = getResolvedLayoutDirectionSelf();
Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight, getBounds(), mDstRect, layoutDirection);
mApplyGravity = false;
}
canvas.drawBitmap(bitmap, null, mDstRect, state.mPaint);
} else {
if (mApplyGravity) {
copyBounds(mDstRect);
mApplyGravity = false;
}
canvas.drawRect(mDstRect, state.mPaint);
}
}
}
use of android.graphics.Shader in project android_frameworks_base by AOSPA.
the class BitmapDrawable method onBoundsChange.
@Override
protected void onBoundsChange(Rect bounds) {
mDstRectAndInsetsDirty = true;
final Bitmap bitmap = mBitmapState.mBitmap;
final Shader shader = mBitmapState.mPaint.getShader();
if (bitmap != null && shader != null) {
updateShaderMatrix(bitmap, mBitmapState.mPaint, shader, needMirroring());
}
}
use of android.graphics.Shader in project weex-example by KalicyZhou.
the class BorderDrawable method preparePaint.
private void preparePaint(@BorderWidthStyleColorType int side) {
float borderWidth = getBorderWidth(side);
int color = WXViewUtils.multiplyColorAlpha(getBorderColor(side), mAlpha);
BorderStyle borderStyle = BorderStyle.values()[getBorderStyle(side)];
Shader shader = borderStyle.getLineShader(borderWidth, color, side);
mPaint.setShader(shader);
mPaint.setColor(color);
mPaint.setStrokeWidth(borderWidth);
mPaint.setStrokeCap(Paint.Cap.ROUND);
}
use of android.graphics.Shader in project weex-example by KalicyZhou.
the class WXResourceUtils method getShader.
/**
* Assembly gradients
* @param image gradient values contains direction、colors
* @param width component width
* @param height component height
* @return gradient shader
*/
public static Shader getShader(String image, float width, float height) {
List<String> valueList = parseGradientValues(image);
if (valueList != null && valueList.size() == 3) {
float[] points = parseGradientDirection(valueList.get(0), width, height);
Shader shader = new LinearGradient(points[0], points[1], points[2], points[3], getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE), Shader.TileMode.REPEAT);
return shader;
}
return null;
}
Aggregations