You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
refactor source tree organization, switch to meson
This commit is contained in:
1617
src/api-impl/android/graphics/Bitmap.java
Normal file
1617
src/api-impl/android/graphics/Bitmap.java
Normal file
File diff suppressed because it is too large
Load Diff
677
src/api-impl/android/graphics/BitmapFactory.java
Normal file
677
src/api-impl/android/graphics/BitmapFactory.java
Normal file
File diff suppressed because it is too large
Load Diff
372
src/api-impl/android/graphics/Canvas.java
Normal file
372
src/api-impl/android/graphics/Canvas.java
Normal file
@@ -0,0 +1,372 @@
|
||||
package android.graphics;
|
||||
|
||||
public class Canvas {
|
||||
public long cairo_context;
|
||||
public long widget;
|
||||
|
||||
public Canvas() {}
|
||||
|
||||
public Canvas(long cairo_context, long widget) {
|
||||
this.cairo_context = cairo_context;
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
// FIXME: are these _needed_ ?
|
||||
|
||||
public int save() {
|
||||
native_save(cairo_context, widget);
|
||||
return -1; // FIXME: wtf should we return
|
||||
}
|
||||
public void restore() {
|
||||
native_restore(cairo_context, widget);
|
||||
}
|
||||
|
||||
private static native void native_save(long cairo_context, long widget);
|
||||
private static native void native_restore(long cairo_context, long widget);
|
||||
|
||||
// ---
|
||||
|
||||
/**
|
||||
* Draw the specified Rect using the specified paint. The rectangle will
|
||||
* be filled or framed based on the Style in the paint.
|
||||
*
|
||||
* @param rect The rect to be drawn
|
||||
* @param paint The paint used to draw the rect
|
||||
*/
|
||||
public void drawRect(RectF rect, Paint paint) {
|
||||
// native_drawRect(mNativeCanvas, rect, paint.mNativePaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the specified Rect using the specified Paint. The rectangle
|
||||
* will be filled or framed based on the Style in the paint.
|
||||
*
|
||||
* @param r The rectangle to be drawn.
|
||||
* @param paint The paint used to draw the rectangle
|
||||
*/
|
||||
public void drawRect(Rect r, Paint paint) {
|
||||
drawRect(r.left, r.top, r.right, r.bottom, paint);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw the specified Rect using the specified paint. The rectangle will
|
||||
* be filled or framed based on the Style in the paint.
|
||||
*
|
||||
* @param left The left side of the rectangle to be drawn
|
||||
* @param top The top side of the rectangle to be drawn
|
||||
* @param right The right side of the rectangle to be drawn
|
||||
* @param bottom The bottom side of the rectangle to be drawn
|
||||
* @param paint The paint used to draw the rect
|
||||
*/
|
||||
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
|
||||
// native_drawRect(mNativeCanvas, left, top, right, bottom, paint.mNativePaint);
|
||||
}
|
||||
|
||||
// ---
|
||||
/**
|
||||
* Preconcat the current matrix with the specified rotation.
|
||||
*
|
||||
* @param degrees The amount to rotate, in degrees
|
||||
*/
|
||||
public void rotate(float degrees) {
|
||||
native_rotate(cairo_context, widget, degrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preconcat the current matrix with the specified rotation.
|
||||
*
|
||||
* @param degrees The amount to rotate, in degrees
|
||||
* @param px The x-coord for the pivot point (unchanged by the rotation)
|
||||
* @param py The y-coord for the pivot point (unchanged by the rotation)
|
||||
*/
|
||||
public final void rotate(float degrees, float px, float py) {
|
||||
native_rotate_and_translate(cairo_context, widget, degrees, px, py);
|
||||
}
|
||||
// ---
|
||||
/**
|
||||
* Draw the text, with origin at (x,y), using the specified paint. The
|
||||
* origin is interpreted based on the Align setting in the paint.
|
||||
*
|
||||
* @param text The text to be drawn
|
||||
* @param x The x-coordinate of the origin of the text being drawn
|
||||
* @param y The y-coordinate of the origin of the text being drawn
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
public void drawText(String text, float x, float y, Paint paint) {
|
||||
/* native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags,
|
||||
paint.mNativePaint);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the text, with origin at (x,y), using the specified paint.
|
||||
* The origin is interpreted based on the Align setting in the paint.
|
||||
*
|
||||
* @param text The text to be drawn
|
||||
* @param start The index of the first character in text to draw
|
||||
* @param end (end - 1) is the index of the last character in text to draw
|
||||
* @param x The x-coordinate of the origin of the text being drawn
|
||||
* @param y The y-coordinate of the origin of the text being drawn
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
public void drawText(String text, int start, int end, float x, float y, Paint paint) {
|
||||
/* if ((start | end | (end - start) | (text.length() - end)) < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
native_drawText(mNativeCanvas, text, start, end, x, y, paint.mBidiFlags,
|
||||
paint.mNativePaint);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the specified range of text, specified by start/end, with its
|
||||
* origin at (x,y), in the specified Paint. The origin is interpreted
|
||||
* based on the Align setting in the Paint.
|
||||
*
|
||||
* @param text The text to be drawn
|
||||
* @param start The index of the first character in text to draw
|
||||
* @param end (end - 1) is the index of the last character in text
|
||||
* to draw
|
||||
* @param x The x-coordinate of origin for where to draw the text
|
||||
* @param y The y-coordinate of origin for where to draw the text
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
|
||||
/*if (text instanceof String || text instanceof SpannedString ||
|
||||
text instanceof SpannableString) {
|
||||
native_drawText(mNativeCanvas, text.toString(), start, end, x, y,
|
||||
paint.mBidiFlags, paint.mNativePaint);
|
||||
} else if (text instanceof GraphicsOperations) {
|
||||
((GraphicsOperations) text).drawText(this, start, end, x, y,
|
||||
paint);
|
||||
} else {
|
||||
char[] buf = TemporaryBuffer.obtain(end - start);
|
||||
TextUtils.getChars(text, start, end, buf, 0);
|
||||
native_drawText(mNativeCanvas, buf, 0, end - start, x, y,
|
||||
paint.mBidiFlags, paint.mNativePaint);
|
||||
TemporaryBuffer.recycle(buf);
|
||||
}*/
|
||||
}
|
||||
// ---
|
||||
/**
|
||||
* <p>Draw the specified arc, which will be scaled to fit inside the
|
||||
* specified oval.</p>
|
||||
*
|
||||
* <p>If the start angle is negative or >= 360, the start angle is treated
|
||||
* as start angle modulo 360.</p>
|
||||
*
|
||||
* <p>If the sweep angle is >= 360, then the oval is drawn
|
||||
* completely. Note that this differs slightly from SkPath::arcTo, which
|
||||
* treats the sweep angle modulo 360. If the sweep angle is negative,
|
||||
* the sweep angle is treated as sweep angle modulo 360</p>
|
||||
*
|
||||
* <p>The arc is drawn clockwise. An angle of 0 degrees correspond to the
|
||||
* geometric angle of 0 degrees (3 o'clock on a watch.)</p>
|
||||
*
|
||||
* @param oval The bounds of oval used to define the shape and size
|
||||
* of the arc
|
||||
* @param startAngle Starting angle (in degrees) where the arc begins
|
||||
* @param sweepAngle Sweep angle (in degrees) measured clockwise
|
||||
* @param useCenter If true, include the center of the oval in the arc, and
|
||||
close it if it is being stroked. This will draw a wedge
|
||||
* @param paint The paint used to draw the arc
|
||||
*/
|
||||
public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
|
||||
Paint paint) {
|
||||
if (oval == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
/*native_drawArc(mNativeCanvas, oval, startAngle, sweepAngle,
|
||||
useCenter, paint.mNativePaint);*/
|
||||
}
|
||||
// ---
|
||||
/**
|
||||
* Preconcat the current matrix with the specified scale.
|
||||
*
|
||||
* @param sx The amount to scale in X
|
||||
* @param sy The amount to scale in Y
|
||||
*/
|
||||
public /*native*/ void scale(float sx, float sy) {}
|
||||
|
||||
/**
|
||||
* Preconcat the current matrix with the specified scale.
|
||||
*
|
||||
* @param sx The amount to scale in X
|
||||
* @param sy The amount to scale in Y
|
||||
* @param px The x-coord for the pivot point (unchanged by the scale)
|
||||
* @param py The y-coord for the pivot point (unchanged by the scale)
|
||||
*/
|
||||
public final void scale(float sx, float sy, float px, float py) {
|
||||
/*translate(px, py);
|
||||
scale(sx, sy);
|
||||
translate(-px, -py);*/
|
||||
}
|
||||
// ---
|
||||
/**
|
||||
* Draw the specified bitmap, with its top/left corner at (x,y), using
|
||||
* the specified paint, transformed by the current matrix.
|
||||
*
|
||||
* <p>Note: if the paint contains a maskfilter that generates a mask which
|
||||
* extends beyond the bitmap's original width/height (e.g. BlurMaskFilter),
|
||||
* then the bitmap will be drawn as if it were in a Shader with CLAMP mode.
|
||||
* Thus the color outside of the original width/height will be the edge
|
||||
* color replicated.
|
||||
*
|
||||
* <p>If the bitmap and canvas have different densities, this function
|
||||
* will take care of automatically scaling the bitmap to draw at the
|
||||
* same density as the canvas.
|
||||
*
|
||||
* @param bitmap The bitmap to be drawn
|
||||
* @param left The position of the left side of the bitmap being drawn
|
||||
* @param top The position of the top side of the bitmap being drawn
|
||||
* @param paint The paint used to draw the bitmap (may be null)
|
||||
*/
|
||||
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {/*
|
||||
native_drawBitmap(mNativeCanvas, bitmap.ni(), left, top, paint != null ? paint.mNativePaint : 0, mDensity, mScreenDensity, bitmap.mDensity);
|
||||
*/}
|
||||
|
||||
/**
|
||||
* Draw the specified bitmap, scaling/translating automatically to fill
|
||||
* the destination rectangle. If the source rectangle is not null, it
|
||||
* specifies the subset of the bitmap to draw.
|
||||
*
|
||||
* <p>Note: if the paint contains a maskfilter that generates a mask which
|
||||
* extends beyond the bitmap's original width/height (e.g. BlurMaskFilter),
|
||||
* then the bitmap will be drawn as if it were in a Shader with CLAMP mode.
|
||||
* Thus the color outside of the original width/height will be the edge
|
||||
* color replicated.
|
||||
*
|
||||
* <p>This function <em>ignores the density associated with the bitmap</em>.
|
||||
* This is because the source and destination rectangle coordinate
|
||||
* spaces are in their respective densities, so must already have the
|
||||
* appropriate scaling factor applied.
|
||||
*
|
||||
* @param bitmap The bitmap to be drawn
|
||||
* @param src May be null. The subset of the bitmap to be drawn
|
||||
* @param dst The rectangle that the bitmap will be scaled/translated
|
||||
* to fit into
|
||||
* @param paint May be null. The paint used to draw the bitmap
|
||||
*/
|
||||
public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) {
|
||||
if (dst == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
native_drawBitmap(cairo_context, widget, bitmap.pixbuf, src.left, src.top, dst.left, dst.top, paint); // FIXME - ignores width/height
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the specified bitmap, scaling/translating automatically to fill
|
||||
* the destination rectangle. If the source rectangle is not null, it
|
||||
* specifies the subset of the bitmap to draw.
|
||||
*
|
||||
* <p>Note: if the paint contains a maskfilter that generates a mask which
|
||||
* extends beyond the bitmap's original width/height (e.g. BlurMaskFilter),
|
||||
* then the bitmap will be drawn as if it were in a Shader with CLAMP mode.
|
||||
* Thus the color outside of the original width/height will be the edge
|
||||
* color replicated.
|
||||
*
|
||||
* <p>This function <em>ignores the density associated with the bitmap</em>.
|
||||
* This is because the source and destination rectangle coordinate
|
||||
* spaces are in their respective densities, so must already have the
|
||||
* appropriate scaling factor applied.
|
||||
*
|
||||
* @param bitmap The bitmap to be drawn
|
||||
* @param src May be null. The subset of the bitmap to be drawn
|
||||
* @param dst The rectangle that the bitmap will be scaled/translated
|
||||
* to fit into
|
||||
* @param paint May be null. The paint used to draw the bitmap
|
||||
*/
|
||||
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {/*
|
||||
if (dst == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
native_drawBitmap(mNativeCanvas, bitmap.ni(), src, dst, paint != null ? paint.mNativePaint : 0, mScreenDensity, bitmap.mDensity);
|
||||
*/}
|
||||
|
||||
/**
|
||||
* Treat the specified array of colors as a bitmap, and draw it. This gives
|
||||
* the same result as first creating a bitmap from the array, and then
|
||||
* drawing it, but this method avoids explicitly creating a bitmap object
|
||||
* which can be more efficient if the colors are changing often.
|
||||
*
|
||||
* @param colors Array of colors representing the pixels of the bitmap
|
||||
* @param offset Offset into the array of colors for the first pixel
|
||||
* @param stride The number of colors in the array between rows (must be
|
||||
* >= width or <= -width).
|
||||
* @param x The X coordinate for where to draw the bitmap
|
||||
* @param y The Y coordinate for where to draw the bitmap
|
||||
* @param width The width of the bitmap
|
||||
* @param height The height of the bitmap
|
||||
* @param hasAlpha True if the alpha channel of the colors contains valid
|
||||
* values. If false, the alpha byte is ignored (assumed to
|
||||
* be 0xFF for every pixel).
|
||||
* @param paint May be null. The paint used to draw the bitmap
|
||||
*/
|
||||
public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
|
||||
int width, int height, boolean hasAlpha, Paint paint) {
|
||||
/* // check for valid input
|
||||
if (width < 0) {
|
||||
throw new IllegalArgumentException("width must be >= 0");
|
||||
}
|
||||
if (height < 0) {
|
||||
throw new IllegalArgumentException("height must be >= 0");
|
||||
}
|
||||
if (Math.abs(stride) < width) {
|
||||
throw new IllegalArgumentException("abs(stride) must be >= width");
|
||||
}
|
||||
int lastScanline = offset + (height - 1) * stride;
|
||||
int length = colors.length;
|
||||
if (offset < 0 || (offset + width > length) || lastScanline < 0
|
||||
|| (lastScanline + width > length)) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
// quick escape if there's nothing to draw
|
||||
if (width == 0 || height == 0) {
|
||||
return;
|
||||
}
|
||||
// punch down to native for the actual draw
|
||||
native_drawBitmap(mNativeCanvas, colors, offset, stride, x, y, width, height, hasAlpha,
|
||||
paint != null ? paint.mNativePaint : 0);*/
|
||||
}
|
||||
|
||||
/** Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
|
||||
*/
|
||||
public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
|
||||
int width, int height, boolean hasAlpha, Paint paint) {
|
||||
// call through to the common float version
|
||||
drawBitmap(colors, offset, stride, (float)x, (float)y, width, height,
|
||||
hasAlpha, paint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the bitmap using the specified matrix.
|
||||
*
|
||||
* @param bitmap The bitmap to draw
|
||||
* @param matrix The matrix used to transform the bitmap when it is drawn
|
||||
* @param paint May be null. The paint used to draw the bitmap
|
||||
*/
|
||||
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
|
||||
/* nativeDrawBitmapMatrix(mNativeCanvas, bitmap.ni(), matrix.ni(),
|
||||
paint != null ? paint.mNativePaint : 0);*/
|
||||
}
|
||||
// ---
|
||||
/**
|
||||
* Draw a line segment with the specified start and stop x,y coordinates,
|
||||
* using the specified paint.
|
||||
*
|
||||
* <p>Note that since a line is always "framed", the Style is ignored in the paint.</p>
|
||||
*
|
||||
* <p>Degenerate lines (length is 0) will not be drawn.</p>
|
||||
*
|
||||
* @param startX The x-coordinate of the start point of the line
|
||||
* @param startY The y-coordinate of the start point of the line
|
||||
* @param paint The paint used to draw the line
|
||||
*/
|
||||
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
||||
native_drawLine(cairo_context, widget, startX, startY, stopX, stopY, paint.getColor());
|
||||
}
|
||||
|
||||
private static native void native_drawLine(long cairo_context, long widget, float startX, float startY, float stopX, float stopY, int paint_color); // TODO: pass all the other relevant parameters extracted from paint
|
||||
private static native void native_drawBitmap(long cairo_context, long widget, long pixbuf, float src_x, float src_y, float dest_x, float dest_y, Paint paint); // TODO: make use of "paint"?
|
||||
private static native void native_rotate(long cairo_context, long widget, float angle);
|
||||
private static native void native_rotate_and_translate(long cairo_context, long widget, float angle, float tx, float ty);
|
||||
}
|
||||
784
src/api-impl/android/graphics/Matrix.java
Normal file
784
src/api-impl/android/graphics/Matrix.java
Normal file
File diff suppressed because it is too large
Load Diff
58
src/api-impl/android/graphics/Paint.java
Normal file
58
src/api-impl/android/graphics/Paint.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package android.graphics;
|
||||
|
||||
public class Paint {
|
||||
private int color = 0xFF000000;
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean aa) {}
|
||||
public void setStrokeWidth(float width) {}
|
||||
public void setTextSize(float textSize) {}
|
||||
|
||||
public Typeface setTypeface(Typeface typeface) {
|
||||
return null;
|
||||
}
|
||||
public void getTextBounds(String text, int start, int end, Rect bounds) {}
|
||||
public void getTextBounds(char[] text, int index, int count, Rect bounds) {}
|
||||
public void setFlags(int flags) {}
|
||||
public void setFilterBitmap(boolean filter) {}
|
||||
public void setStyle(Style style) {}
|
||||
public float ascent() { return 0; }
|
||||
|
||||
public float measureText(char[] text, int index, int count) { return 10; }
|
||||
public float measureText(String text, int start, int end) { return 10; }
|
||||
public float measureText(String text) { return 10; }
|
||||
public float measureText(CharSequence text, int start, int end) { return 10; }
|
||||
|
||||
public enum Style {
|
||||
/**
|
||||
* Geometry and text drawn with this style will be filled, ignoring all
|
||||
* stroke-related settings in the paint.
|
||||
*/
|
||||
FILL (0),
|
||||
/**
|
||||
* Geometry and text drawn with this style will be stroked, respecting
|
||||
* the stroke-related fields on the paint.
|
||||
*/
|
||||
STROKE (1),
|
||||
/**
|
||||
* Geometry and text drawn with this style will be both filled and
|
||||
* stroked at the same time, respecting the stroke-related fields on
|
||||
* the paint. This mode can give unexpected results if the geometry
|
||||
* is oriented counter-clockwise. This restriction does not apply to
|
||||
* either FILL or STROKE.
|
||||
*/
|
||||
FILL_AND_STROKE (2);
|
||||
|
||||
Style(int nativeInt) {
|
||||
this.nativeInt = nativeInt;
|
||||
}
|
||||
final int nativeInt;
|
||||
}
|
||||
}
|
||||
707
src/api-impl/android/graphics/Path.java
Normal file
707
src/api-impl/android/graphics/Path.java
Normal file
File diff suppressed because it is too large
Load Diff
515
src/api-impl/android/graphics/Rect.java
Normal file
515
src/api-impl/android/graphics/Rect.java
Normal file
File diff suppressed because it is too large
Load Diff
513
src/api-impl/android/graphics/RectF.java
Normal file
513
src/api-impl/android/graphics/RectF.java
Normal file
File diff suppressed because it is too large
Load Diff
342
src/api-impl/android/graphics/Region.java
Normal file
342
src/api-impl/android/graphics/Region.java
Normal file
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.graphics;
|
||||
//import android.util.Pools.SynchronizedPool;
|
||||
public class Region {
|
||||
private static final int MAX_POOL_SIZE = 10;
|
||||
/* private static final SynchronizedPool<Region> sPool =
|
||||
new SynchronizedPool<Region>(MAX_POOL_SIZE);*/
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public final int mNativeRegion;
|
||||
// the native values for these must match up with the enum in SkRegion.h
|
||||
public enum Op {
|
||||
DIFFERENCE(0),
|
||||
INTERSECT(1),
|
||||
UNION(2),
|
||||
XOR(3),
|
||||
REVERSE_DIFFERENCE(4),
|
||||
REPLACE(5);
|
||||
Op(int nativeInt) {
|
||||
this.nativeInt = nativeInt;
|
||||
}
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public final int nativeInt;
|
||||
}
|
||||
/** Create an empty region
|
||||
*/
|
||||
public Region() {
|
||||
this(nativeConstructor());
|
||||
}
|
||||
/** Return a copy of the specified region
|
||||
*/
|
||||
public Region(Region region) {
|
||||
this(nativeConstructor());
|
||||
nativeSetRegion(mNativeRegion, region.mNativeRegion);
|
||||
}
|
||||
/** Return a region set to the specified rectangle
|
||||
*/
|
||||
public Region(Rect r) {
|
||||
mNativeRegion = nativeConstructor();
|
||||
nativeSetRect(mNativeRegion, r.left, r.top, r.right, r.bottom);
|
||||
}
|
||||
/** Return a region set to the specified rectangle
|
||||
*/
|
||||
public Region(int left, int top, int right, int bottom) {
|
||||
mNativeRegion = nativeConstructor();
|
||||
nativeSetRect(mNativeRegion, left, top, right, bottom);
|
||||
}
|
||||
/** Set the region to the empty region
|
||||
*/
|
||||
public void setEmpty() {
|
||||
nativeSetRect(mNativeRegion, 0, 0, 0, 0);
|
||||
}
|
||||
/** Set the region to the specified region.
|
||||
*/
|
||||
public boolean set(Region region) {
|
||||
nativeSetRegion(mNativeRegion, region.mNativeRegion);
|
||||
return true;
|
||||
}
|
||||
/** Set the region to the specified rectangle
|
||||
*/
|
||||
public boolean set(Rect r) {
|
||||
return nativeSetRect(mNativeRegion, r.left, r.top, r.right, r.bottom);
|
||||
}
|
||||
|
||||
/** Set the region to the specified rectangle
|
||||
*/
|
||||
public boolean set(int left, int top, int right, int bottom) {
|
||||
return nativeSetRect(mNativeRegion, left, top, right, bottom);
|
||||
}
|
||||
/**
|
||||
* Set the region to the area described by the path and clip.
|
||||
* Return true if the resulting region is non-empty. This produces a region
|
||||
* that is identical to the pixels that would be drawn by the path
|
||||
* (with no antialiasing).
|
||||
*/
|
||||
public boolean setPath(Path path, Region clip) {
|
||||
return nativeSetPath(mNativeRegion, path.ni(), clip.mNativeRegion);
|
||||
}
|
||||
/**
|
||||
* Return true if this region is empty
|
||||
*/
|
||||
public native boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Return true if the region contains a single rectangle
|
||||
*/
|
||||
public native boolean isRect();
|
||||
|
||||
/**
|
||||
* Return true if the region contains more than one rectangle
|
||||
*/
|
||||
public native boolean isComplex();
|
||||
/**
|
||||
* Return a new Rect set to the bounds of the region. If the region is
|
||||
* empty, the Rect will be set to [0, 0, 0, 0]
|
||||
*/
|
||||
public Rect getBounds() {
|
||||
Rect r = new Rect();
|
||||
nativeGetBounds(mNativeRegion, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Rect to the bounds of the region. If the region is empty, the
|
||||
* Rect will be set to [0, 0, 0, 0]
|
||||
*/
|
||||
public boolean getBounds(Rect r) {
|
||||
if (r == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return nativeGetBounds(mNativeRegion, r);
|
||||
}
|
||||
/**
|
||||
* Return the boundary of the region as a new Path. If the region is empty,
|
||||
* the path will also be empty.
|
||||
*/
|
||||
public Path getBoundaryPath() {
|
||||
Path path = new Path();
|
||||
nativeGetBoundaryPath(mNativeRegion, path.ni());
|
||||
return path;
|
||||
}
|
||||
/**
|
||||
* Set the path to the boundary of the region. If the region is empty, the
|
||||
* path will also be empty.
|
||||
*/
|
||||
public boolean getBoundaryPath(Path path) {
|
||||
return nativeGetBoundaryPath(mNativeRegion, path.ni());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the region contains the specified point
|
||||
*/
|
||||
public native boolean contains(int x, int y);
|
||||
/**
|
||||
* Return true if the region is a single rectangle (not complex) and it
|
||||
* contains the specified rectangle. Returning false is not a guarantee
|
||||
* that the rectangle is not contained by this region, but return true is a
|
||||
* guarantee that the rectangle is contained by this region.
|
||||
*/
|
||||
public boolean quickContains(Rect r) {
|
||||
return quickContains(r.left, r.top, r.right, r.bottom);
|
||||
}
|
||||
/**
|
||||
* Return true if the region is a single rectangle (not complex) and it
|
||||
* contains the specified rectangle. Returning false is not a guarantee
|
||||
* that the rectangle is not contained by this region, but return true is a
|
||||
* guarantee that the rectangle is contained by this region.
|
||||
*/
|
||||
public native boolean quickContains(int left, int top, int right,
|
||||
int bottom);
|
||||
/**
|
||||
* Return true if the region is empty, or if the specified rectangle does
|
||||
* not intersect the region. Returning false is not a guarantee that they
|
||||
* intersect, but returning true is a guarantee that they do not.
|
||||
*/
|
||||
public boolean quickReject(Rect r) {
|
||||
return quickReject(r.left, r.top, r.right, r.bottom);
|
||||
}
|
||||
/**
|
||||
* Return true if the region is empty, or if the specified rectangle does
|
||||
* not intersect the region. Returning false is not a guarantee that they
|
||||
* intersect, but returning true is a guarantee that they do not.
|
||||
*/
|
||||
public native boolean quickReject(int left, int top, int right, int bottom);
|
||||
/**
|
||||
* Return true if the region is empty, or if the specified region does not
|
||||
* intersect the region. Returning false is not a guarantee that they
|
||||
* intersect, but returning true is a guarantee that they do not.
|
||||
*/
|
||||
public native boolean quickReject(Region rgn);
|
||||
/**
|
||||
* Translate the region by [dx, dy]. If the region is empty, do nothing.
|
||||
*/
|
||||
public void translate(int dx, int dy) {
|
||||
translate(dx, dy, null);
|
||||
}
|
||||
/**
|
||||
* Set the dst region to the result of translating this region by [dx, dy].
|
||||
* If this region is empty, then dst will be set to empty.
|
||||
*/
|
||||
public native void translate(int dx, int dy, Region dst);
|
||||
/**
|
||||
* Scale the region by the given scale amount. This re-constructs new region by
|
||||
* scaling the rects that this region consists of. New rectis are computed by scaling
|
||||
* coordinates by float, then rounded by roundf() function to integers. This may results
|
||||
* in less internal rects if 0 < scale < 1. Zero and Negative scale result in
|
||||
* an empty region. If this region is empty, do nothing.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void scale(float scale) {
|
||||
scale(scale, null);
|
||||
}
|
||||
/**
|
||||
* Set the dst region to the result of scaling this region by the given scale amount.
|
||||
* If this region is empty, then dst will be set to empty.
|
||||
* @hide
|
||||
*/
|
||||
public native void scale(float scale, Region dst);
|
||||
public final boolean union(Rect r) {
|
||||
return op(r, Op.UNION);
|
||||
}
|
||||
/**
|
||||
* Perform the specified Op on this region and the specified rect. Return
|
||||
* true if the result of the op is not empty.
|
||||
*/
|
||||
public boolean op(Rect r, Op op) {
|
||||
return nativeOp(mNativeRegion, r.left, r.top, r.right, r.bottom,
|
||||
op.nativeInt);
|
||||
}
|
||||
/**
|
||||
* Perform the specified Op on this region and the specified rect. Return
|
||||
* true if the result of the op is not empty.
|
||||
*/
|
||||
public boolean op(int left, int top, int right, int bottom, Op op) {
|
||||
return nativeOp(mNativeRegion, left, top, right, bottom,
|
||||
op.nativeInt);
|
||||
}
|
||||
/**
|
||||
* Perform the specified Op on this region and the specified region. Return
|
||||
* true if the result of the op is not empty.
|
||||
*/
|
||||
public boolean op(Region region, Op op) {
|
||||
return op(this, region, op);
|
||||
}
|
||||
/**
|
||||
* Set this region to the result of performing the Op on the specified rect
|
||||
* and region. Return true if the result is not empty.
|
||||
*/
|
||||
public boolean op(Rect rect, Region region, Op op) {
|
||||
return nativeOp(mNativeRegion, rect, region.mNativeRegion,
|
||||
op.nativeInt);
|
||||
}
|
||||
/**
|
||||
* Set this region to the result of performing the Op on the specified
|
||||
* regions. Return true if the result is not empty.
|
||||
*/
|
||||
public boolean op(Region region1, Region region2, Op op) {
|
||||
return nativeOp(mNativeRegion, region1.mNativeRegion,
|
||||
region2.mNativeRegion, op.nativeInt);
|
||||
}
|
||||
public String toString() {
|
||||
return nativeToString(mNativeRegion);
|
||||
}
|
||||
/**
|
||||
* @return An instance from a pool if such or a new one.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static Region obtain() {
|
||||
//Region region = sPool.acquire();
|
||||
return /*(region != null) ? region : */new Region();
|
||||
}
|
||||
/**
|
||||
* @return An instance from a pool if such or a new one.
|
||||
*
|
||||
* @param other Region to copy values from for initialization.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static Region obtain(Region other) {
|
||||
Region region = obtain();
|
||||
region.set(other);
|
||||
return region;
|
||||
}
|
||||
/**
|
||||
* Recycles an instance.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void recycle() {
|
||||
setEmpty();
|
||||
// sPool.release(this);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof Region)) {
|
||||
return false;
|
||||
}
|
||||
Region peer = (Region) obj;
|
||||
return nativeEquals(mNativeRegion, peer.mNativeRegion);
|
||||
}
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
nativeDestructor(mNativeRegion);
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
Region(int ni) {
|
||||
if (ni == 0) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
mNativeRegion = ni;
|
||||
}
|
||||
/* add dummy parameter so constructor can be called from jni without
|
||||
triggering 'not cloneable' exception */
|
||||
private Region(int ni, int dummy) {
|
||||
this(ni);
|
||||
}
|
||||
final int ni() {
|
||||
return mNativeRegion;
|
||||
}
|
||||
private static native boolean nativeEquals(int native_r1, int native_r2);
|
||||
private static native int nativeConstructor();
|
||||
private static native void nativeDestructor(int native_region);
|
||||
private static native void nativeSetRegion(int native_dst, int native_src);
|
||||
private static native boolean nativeSetRect(int native_dst, int left,
|
||||
int top, int right, int bottom);
|
||||
private static native boolean nativeSetPath(int native_dst, int native_path,
|
||||
int native_clip);
|
||||
private static native boolean nativeGetBounds(int native_region, Rect rect);
|
||||
private static native boolean nativeGetBoundaryPath(int native_region,
|
||||
int native_path);
|
||||
private static native boolean nativeOp(int native_dst, int left, int top,
|
||||
int right, int bottom, int op);
|
||||
private static native boolean nativeOp(int native_dst, Rect rect,
|
||||
int native_region, int op);
|
||||
private static native boolean nativeOp(int native_dst, int native_region1,
|
||||
int native_region2, int op);
|
||||
private static native String nativeToString(int native_region);
|
||||
}
|
||||
11
src/api-impl/android/graphics/Typeface.java
Normal file
11
src/api-impl/android/graphics/Typeface.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package android.graphics;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
public class Typeface {
|
||||
|
||||
public static Typeface createFromAsset(AssetManager mgr, String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user