use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class GradientDrawable_Delegate method buildRing.
/**
* The ring can be built either by drawing full circles, or by drawing arcs in case the
* circle isn't complete. LayoutLib cannot handle drawing full circles (requires path
* subtraction). So, if we need to draw full circles, we switch to drawing 99% circle.
*/
@LayoutlibDelegate
static /*package*/
Path buildRing(GradientDrawable thisDrawable, GradientState st) {
boolean useLevel = st.mUseLevelForShape;
int level = thisDrawable.getLevel();
// 10000 is the max level. See android.graphics.drawable.Drawable#getLevel()
float sweep = useLevel ? (360.0f * level / 10000.0f) : 360f;
Field mLevel = null;
if (sweep >= 360 || sweep <= -360) {
st.mUseLevelForShape = true;
// dirty again.
try {
mLevel = Drawable.class.getDeclaredField("mLevel");
mLevel.setAccessible(true);
// set to one less than max.
mLevel.setInt(thisDrawable, 9999);
} catch (NoSuchFieldException e) {
// The field has been removed in a recent framework change. Fall back to old
// buggy behaviour.
} catch (IllegalAccessException e) {
// We've already set the field to be accessible.
assert false;
}
}
Path path = thisDrawable.buildRing_Original(st);
st.mUseLevelForShape = useLevel;
if (mLevel != null) {
try {
mLevel.setInt(thisDrawable, level);
} catch (IllegalAccessException e) {
assert false;
}
}
return path;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class VectorDrawable_Delegate method nGetFullPathProperties.
@LayoutlibDelegate
static boolean nGetFullPathProperties(long pathPtr, byte[] propertiesData, int length) {
VFullPath_Delegate path = VNativeObject.getDelegate(pathPtr);
ByteBuffer properties = ByteBuffer.wrap(propertiesData);
properties.order(ByteOrder.nativeOrder());
properties.putFloat(VFullPath_Delegate.STROKE_WIDTH_INDEX * 4, path.getStrokeWidth());
properties.putInt(VFullPath_Delegate.STROKE_COLOR_INDEX * 4, path.getStrokeColor());
properties.putFloat(VFullPath_Delegate.STROKE_ALPHA_INDEX * 4, path.getStrokeAlpha());
properties.putInt(VFullPath_Delegate.FILL_COLOR_INDEX * 4, path.getFillColor());
properties.putFloat(VFullPath_Delegate.FILL_ALPHA_INDEX * 4, path.getStrokeAlpha());
properties.putFloat(VFullPath_Delegate.TRIM_PATH_START_INDEX * 4, path.getTrimPathStart());
properties.putFloat(VFullPath_Delegate.TRIM_PATH_END_INDEX * 4, path.getTrimPathEnd());
properties.putFloat(VFullPath_Delegate.TRIM_PATH_OFFSET_INDEX * 4, path.getTrimPathOffset());
properties.putInt(VFullPath_Delegate.STROKE_LINE_CAP_INDEX * 4, path.getStrokeLineCap());
properties.putInt(VFullPath_Delegate.STROKE_LINE_JOIN_INDEX * 4, path.getStrokeLineJoin());
properties.putFloat(VFullPath_Delegate.STROKE_MITER_LIMIT_INDEX * 4, path.getStrokeMiterlimit());
properties.putInt(VFullPath_Delegate.FILL_TYPE_INDEX * 4, path.getFillType());
return true;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class VectorDrawable_Delegate method nGetGroupProperties.
@LayoutlibDelegate
static boolean nGetGroupProperties(long groupPtr, float[] propertiesData, int length) {
VGroup_Delegate group = VNativeObject.getDelegate(groupPtr);
FloatBuffer properties = FloatBuffer.wrap(propertiesData);
properties.put(VGroup_Delegate.ROTATE_INDEX, group.getRotation());
properties.put(VGroup_Delegate.PIVOT_X_INDEX, group.getPivotX());
properties.put(VGroup_Delegate.PIVOT_Y_INDEX, group.getPivotY());
properties.put(VGroup_Delegate.SCALE_X_INDEX, group.getScaleX());
properties.put(VGroup_Delegate.SCALE_Y_INDEX, group.getScaleY());
properties.put(VGroup_Delegate.TRANSLATE_X_INDEX, group.getTranslateX());
properties.put(VGroup_Delegate.TRANSLATE_Y_INDEX, group.getTranslateY());
return true;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class Matrix_Delegate method native_invert.
@LayoutlibDelegate
static /*package*/
boolean native_invert(long native_object, long inverse) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
}
Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
if (inv_mtx == null) {
return false;
}
try {
AffineTransform affineTransform = d.getAffineTransform();
AffineTransform inverseTransform = affineTransform.createInverse();
inv_mtx.mValues[0] = (float) inverseTransform.getScaleX();
inv_mtx.mValues[1] = (float) inverseTransform.getShearX();
inv_mtx.mValues[2] = (float) inverseTransform.getTranslateX();
inv_mtx.mValues[3] = (float) inverseTransform.getScaleX();
inv_mtx.mValues[4] = (float) inverseTransform.getShearY();
inv_mtx.mValues[5] = (float) inverseTransform.getTranslateY();
return true;
} catch (NoninvertibleTransformException e) {
return false;
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class Paint_Delegate method nGetFillPath.
@LayoutlibDelegate
static /*package*/
boolean nGetFillPath(long native_object, long src, long dst) {
Paint_Delegate paint = sManager.getDelegate(native_object);
if (paint == null) {
return false;
}
Path_Delegate srcPath = Path_Delegate.getDelegate(src);
if (srcPath == null) {
return true;
}
Path_Delegate dstPath = Path_Delegate.getDelegate(dst);
if (dstPath == null) {
return true;
}
Stroke stroke = paint.getJavaStroke();
Shape strokeShape = stroke.createStrokedShape(srcPath.getJavaShape());
dstPath.setJavaShape(strokeShape);
// FIXME figure out the return value?
return true;
}
Aggregations