use of java.awt.geom.AffineTransform in project android_frameworks_base by ParanoidAndroid.
the class Path_Delegate method offset.
/**
* Offset the path by (dx,dy), returning true on success
*
* @param dx The amount in the X direction to offset the entire path
* @param dy The amount in the Y direction to offset the entire path
* @param dst The translated path is written here. If this is null, then
* the original path is modified.
*/
public void offset(float dx, float dy, Path_Delegate dst) {
GeneralPath newPath = new GeneralPath();
PathIterator iterator = mPath.getPathIterator(new AffineTransform(0, 0, dx, 0, 0, dy));
newPath.append(iterator, false);
if (dst != null) {
dst.mPath = newPath;
} else {
mPath = newPath;
}
}
use of java.awt.geom.AffineTransform in project android_frameworks_base by ParanoidAndroid.
the class Region_Delegate method scale.
@LayoutlibDelegate
static /*package*/
void scale(Region thisRegion, float scale, Region dst) {
Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
if (regionDelegate == null) {
return;
}
Region_Delegate targetRegionDelegate = sManager.getDelegate(dst.mNativeRegion);
if (targetRegionDelegate == null) {
return;
}
if (regionDelegate.mArea.isEmpty()) {
targetRegionDelegate.mArea = new Area();
} else {
targetRegionDelegate.mArea = new Area(regionDelegate.mArea);
AffineTransform mtx = new AffineTransform();
mtx.scale(scale, scale);
targetRegionDelegate.mArea.transform(mtx);
}
}
use of java.awt.geom.AffineTransform in project android_frameworks_base by ParanoidAndroid.
the class Canvas_Delegate method nativeDrawBitmapMatrix.
@LayoutlibDelegate
static /*package*/
void nativeDrawBitmapMatrix(int nCanvas, int nBitmap, int nMatrix, int nPaint) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
return;
}
// get the delegate from the native int, which can be null
Paint_Delegate paintDelegate = Paint_Delegate.getDelegate(nPaint);
// get the delegate from the native int.
Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(nBitmap);
if (bitmapDelegate == null) {
return;
}
final BufferedImage image = getImageToDraw(bitmapDelegate, paintDelegate, sBoolOut);
Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
if (matrixDelegate == null) {
return;
}
final AffineTransform mtx = matrixDelegate.getAffineTransform();
canvasDelegate.getSnapshot().draw(new GcSnapshot.Drawable() {
@Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
if (paint != null && paint.isFilterBitmap()) {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
}
//FIXME add support for canvas, screen and bitmap densities.
graphics.drawImage(image, mtx, null);
}
}, paintDelegate, true, /*compositeOnly*/
false);
}
use of java.awt.geom.AffineTransform in project android_frameworks_base by ParanoidAndroid.
the class Matrix_Delegate method native_invert.
@LayoutlibDelegate
static /*package*/
boolean native_invert(int native_object, int 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 java.awt.geom.AffineTransform in project android_frameworks_base by ParanoidAndroid.
the class GcSnapshot method doRestore.
private GcSnapshot doRestore() {
if (mPrevious != null) {
if (mLocalLayer != null) {
// prepare to blit the layers in which we have draw, in the layer beneath
// them, starting with the top one (which is the current local layer).
int i = mLayers.size() - 1;
int flags;
do {
Layer dstLayer = mLayers.get(i - 1);
restoreLayer(dstLayer);
flags = dstLayer.getFlags();
i--;
} while (i > 0 && (flags & Canvas.CLIP_TO_LAYER_SAVE_FLAG) == 0);
}
// didn't save the matrix? set the current matrix on the previous snapshot
if ((mFlags & Canvas.MATRIX_SAVE_FLAG) == 0) {
AffineTransform mtx = getTransform();
for (Layer layer : mPrevious.mLayers) {
layer.getGraphics().setTransform(mtx);
}
}
// didn't save the clip? set the current clip on the previous snapshot
if ((mFlags & Canvas.CLIP_SAVE_FLAG) == 0) {
Shape clip = getClip();
for (Layer layer : mPrevious.mLayers) {
layer.setClip(clip);
}
}
}
for (Layer layer : mLayers) {
layer.getGraphics().dispose();
}
return mPrevious;
}
Aggregations