ui-desktop: get rid of android.graphics/android.text emulation
We don't need them anymore. We use real implementation (DesktopCanvas, DesktopParagraph, ...)
Test: ./gradlew :ui:ui-desktop:jvmTest
Change-Id: I3764dc40c95028ea32b2ad21d0f5e669a4b91e89
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/BoringLayout.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/BoringLayout.java
deleted file mode 100644
index dd442d5..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/BoringLayout.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * 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.text;
-
-import android.compat.annotation.UnsupportedAppUsage;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.text.style.ParagraphStyle;
-
-/**
- * A BoringLayout is a very simple Layout implementation for text that
- * fits on a single line and is all left-to-right characters.
- * You will probably never want to make one of these yourself;
- * if you do, be sure to call {@link #isBoring} first to make sure
- * the text meets the criteria.
- * <p>This class is used by widgets to control text layout. You should not need
- * to use this class directly unless you are implementing your own widget
- * or custom display object, in which case
- * you are encouraged to use a Layout instead of calling
- * {@link android.graphics.Canvas#drawText(
- * java.lang.CharSequence, int, int, float, float, android.graphics.Paint)
- * Canvas.drawText()} directly.</p>
- */
-public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback {
-
- /**
- * Utility function to construct a BoringLayout instance.
- *
- * @param source the text to render
- * @param paint the default paint for the layout
- * @param outerWidth the wrapping width for the text
- * @param align whether to left, right, or center the text
- * @param spacingMult this value is no longer used by BoringLayout
- * @param spacingAdd this value is no longer used by BoringLayout
- * @param metrics {@code #Metrics} instance that contains information about FontMetrics and
- * line width
- * @param includePad set whether to include extra space beyond font ascent and descent which is
- * needed to avoid clipping in some scripts
- */
- public static BoringLayout make(CharSequence source, TextPaint paint, int outerWidth,
- Alignment align, float spacingMult, float spacingAdd, BoringLayout.Metrics metrics,
- boolean includePad) {
- return new BoringLayout(source, paint, outerWidth, align, spacingMult, spacingAdd, metrics,
- includePad);
- }
-
- /**
- * Utility function to construct a BoringLayout instance.
- *
- * @param source the text to render
- * @param paint the default paint for the layout
- * @param outerWidth the wrapping width for the text
- * @param align whether to left, right, or center the text
- * @param spacingmult this value is no longer used by BoringLayout
- * @param spacingadd this value is no longer used by BoringLayout
- * @param metrics {@code #Metrics} instance that contains information about FontMetrics and
- * line width
- * @param includePad set whether to include extra space beyond font ascent and descent which is
- * needed to avoid clipping in some scripts
- * @param ellipsize whether to ellipsize the text if width of the text is longer than the
- * requested width
- * @param ellipsizedWidth the width to which this Layout is ellipsizing. If {@code ellipsize} is
- * {@code null}, or is {@link TextUtils.TruncateAt#MARQUEE} this value is
- * not used, {@code outerWidth} is used instead
- */
- public static BoringLayout make(CharSequence source, TextPaint paint, int outerWidth,
- Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics,
- boolean includePad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
- return new BoringLayout(source, paint, outerWidth, align, spacingmult, spacingadd, metrics,
- includePad, ellipsize, ellipsizedWidth);
- }
-
- /**
- * Returns a BoringLayout for the specified text, potentially reusing
- * this one if it is already suitable. The caller must make sure that
- * no one is still using this Layout.
- *
- * @param source the text to render
- * @param paint the default paint for the layout
- * @param outerwidth the wrapping width for the text
- * @param align whether to left, right, or center the text
- * @param spacingMult this value is no longer used by BoringLayout
- * @param spacingAdd this value is no longer used by BoringLayout
- * @param metrics {@code #Metrics} instance that contains information about FontMetrics and
- * line width
- * @param includePad set whether to include extra space beyond font ascent and descent which is
- * needed to avoid clipping in some scripts
- */
- public BoringLayout replaceOrMake(CharSequence source, TextPaint paint, int outerwidth,
- Alignment align, float spacingMult, float spacingAdd, BoringLayout.Metrics metrics,
- boolean includePad) {
- replaceWith(source, paint, outerwidth, align, spacingMult, spacingAdd);
-
- mEllipsizedWidth = outerwidth;
- mEllipsizedStart = 0;
- mEllipsizedCount = 0;
-
- init(source, paint, align, metrics, includePad, true);
- return this;
- }
-
- /**
- * Returns a BoringLayout for the specified text, potentially reusing
- * this one if it is already suitable. The caller must make sure that
- * no one is still using this Layout.
- *
- * @param source the text to render
- * @param paint the default paint for the layout
- * @param outerWidth the wrapping width for the text
- * @param align whether to left, right, or center the text
- * @param spacingMult this value is no longer used by BoringLayout
- * @param spacingAdd this value is no longer used by BoringLayout
- * @param metrics {@code #Metrics} instance that contains information about FontMetrics and
- * line width
- * @param includePad set whether to include extra space beyond font ascent and descent which is
- * needed to avoid clipping in some scripts
- * @param ellipsize whether to ellipsize the text if width of the text is longer than the
- * requested width
- * @param ellipsizedWidth the width to which this Layout is ellipsizing. If {@code ellipsize} is
- * {@code null}, or is {@link TextUtils.TruncateAt#MARQUEE} this value is
- * not used, {@code outerwidth} is used instead
- */
- public BoringLayout replaceOrMake(CharSequence source, TextPaint paint, int outerWidth,
- Alignment align, float spacingMult, float spacingAdd, BoringLayout.Metrics metrics,
- boolean includePad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
- boolean trust;
-
- if (ellipsize == null || ellipsize == TextUtils.TruncateAt.MARQUEE) {
- replaceWith(source, paint, outerWidth, align, spacingMult, spacingAdd);
-
- mEllipsizedWidth = outerWidth;
- mEllipsizedStart = 0;
- mEllipsizedCount = 0;
- trust = true;
- } else {
- replaceWith(TextUtils.ellipsize(source, paint, ellipsizedWidth, ellipsize, true, this),
- paint, outerWidth, align, spacingMult, spacingAdd);
-
- mEllipsizedWidth = ellipsizedWidth;
- trust = false;
- }
-
- init(getText(), paint, align, metrics, includePad, trust);
- return this;
- }
-
- /**
- * @param source the text to render
- * @param paint the default paint for the layout
- * @param outerwidth the wrapping width for the text
- * @param align whether to left, right, or center the text
- * @param spacingMult this value is no longer used by BoringLayout
- * @param spacingAdd this value is no longer used by BoringLayout
- * @param metrics {@code #Metrics} instance that contains information about FontMetrics and
- * line width
- * @param includePad set whether to include extra space beyond font ascent and descent which is
- * needed to avoid clipping in some scripts
- */
- public BoringLayout(CharSequence source, TextPaint paint, int outerwidth, Alignment align,
- float spacingMult, float spacingAdd, BoringLayout.Metrics metrics, boolean includePad) {
- super(source, paint, outerwidth, align, spacingMult, spacingAdd);
-
- mEllipsizedWidth = outerwidth;
- mEllipsizedStart = 0;
- mEllipsizedCount = 0;
-
- init(source, paint, align, metrics, includePad, true);
- }
-
- /**
- *
- * @param source the text to render
- * @param paint the default paint for the layout
- * @param outerWidth the wrapping width for the text
- * @param align whether to left, right, or center the text
- * @param spacingMult this value is no longer used by BoringLayout
- * @param spacingAdd this value is no longer used by BoringLayout
- * @param metrics {@code #Metrics} instance that contains information about FontMetrics and
- * line width
- * @param includePad set whether to include extra space beyond font ascent and descent which is
- * needed to avoid clipping in some scripts
- * @param ellipsize whether to ellipsize the text if width of the text is longer than the
- * requested {@code outerwidth}
- * @param ellipsizedWidth the width to which this Layout is ellipsizing. If {@code ellipsize} is
- * {@code null}, or is {@link TextUtils.TruncateAt#MARQUEE} this value is
- * not used, {@code outerwidth} is used instead
- */
- public BoringLayout(CharSequence source, TextPaint paint, int outerWidth, Alignment align,
- float spacingMult, float spacingAdd, BoringLayout.Metrics metrics, boolean includePad,
- TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
- /*
- * It is silly to have to call super() and then replaceWith(),
- * but we can't use "this" for the callback until the call to
- * super() finishes.
- */
- super(source, paint, outerWidth, align, spacingMult, spacingAdd);
-
- boolean trust;
-
- if (ellipsize == null || ellipsize == TextUtils.TruncateAt.MARQUEE) {
- mEllipsizedWidth = outerWidth;
- mEllipsizedStart = 0;
- mEllipsizedCount = 0;
- trust = true;
- } else {
- replaceWith(TextUtils.ellipsize(source, paint, ellipsizedWidth, ellipsize, true, this),
- paint, outerWidth, align, spacingMult, spacingAdd);
-
- mEllipsizedWidth = ellipsizedWidth;
- trust = false;
- }
-
- init(getText(), paint, align, metrics, includePad, trust);
- }
-
- /* package */ void init(CharSequence source, TextPaint paint, Alignment align,
- BoringLayout.Metrics metrics, boolean includePad, boolean trustWidth) {
- int spacing;
-
- if (source instanceof String && align == Layout.Alignment.ALIGN_NORMAL) {
- mDirect = source.toString();
- } else {
- mDirect = null;
- }
-
- mPaint = paint;
-
- if (includePad) {
- spacing = metrics.bottom - metrics.top;
- mDesc = metrics.bottom;
- } else {
- spacing = metrics.descent - metrics.ascent;
- mDesc = metrics.descent;
- }
-
- mBottom = spacing;
-
- if (trustWidth) {
- mMax = metrics.width;
- } else {
- /*
- * If we have ellipsized, we have to actually calculate the
- * width because the width that was passed in was for the
- * full text, not the ellipsized form.
- */
- TextLine line = TextLine.obtain();
- line.set(paint, source, 0, source.length(), Layout.DIR_LEFT_TO_RIGHT,
- Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null,
- mEllipsizedStart, mEllipsizedStart + mEllipsizedCount);
- mMax = (int) Math.ceil(line.metrics(null));
- TextLine.recycle(line);
- }
-
- if (includePad) {
- mTopPadding = metrics.top - metrics.ascent;
- mBottomPadding = metrics.bottom - metrics.descent;
- }
- }
-
- /**
- * Determine and compute metrics if given text can be handled by BoringLayout.
- *
- * @param text a text
- * @param paint a paint
- * @return layout metric for the given text. null if given text is unable to be handled by
- * BoringLayout.
- */
- public static Metrics isBoring(CharSequence text, TextPaint paint) {
- return isBoring(text, paint, TextDirectionHeuristics.FIRSTSTRONG_LTR, null);
- }
-
- /**
- * Determine and compute metrics if given text can be handled by BoringLayout.
- *
- * @param text a text
- * @param paint a paint
- * @param metrics a metrics object to be recycled. If null is passed, this function creat new
- * object.
- * @return layout metric for the given text. If metrics is not null, this method fills values
- * to given metrics object instead of allocating new metrics object. null if given text
- * is unable to be handled by BoringLayout.
- */
- public static Metrics isBoring(CharSequence text, TextPaint paint, Metrics metrics) {
- return isBoring(text, paint, TextDirectionHeuristics.FIRSTSTRONG_LTR, metrics);
- }
-
- /**
- * Returns true if the text contains any RTL characters, bidi format characters, or surrogate
- * code units.
- */
- private static boolean hasAnyInterestingChars(CharSequence text, int textLength) {
- final int maxBufLen = 500;
- final char[] buffer = TextUtils.obtain(maxBufLen);
- try {
- for (int start = 0; start < textLength; start += maxBufLen) {
- final int end = Math.min(start + maxBufLen, textLength);
-
- // No need to worry about getting half codepoints, since we consider surrogate code
- // units "interesting" as soon we see one.
- TextUtils.getChars(text, start, end, buffer, 0);
-
- final int len = end - start;
- for (int i = 0; i < len; i++) {
- final char c = buffer[i];
- if (c == '\n' || c == '\t' || TextUtils.couldAffectRtl(c)) {
- return true;
- }
- }
- }
- return false;
- } finally {
- TextUtils.recycle(buffer);
- }
- }
-
- /**
- * Returns null if not boring; the width, ascent, and descent in the
- * provided Metrics object (or a new one if the provided one was null)
- * if boring.
- */
- @UnsupportedAppUsage
- public static Metrics isBoring(CharSequence text, TextPaint paint,
- TextDirectionHeuristic textDir, Metrics metrics) {
- final int textLength = text.length();
- if (hasAnyInterestingChars(text, textLength)) {
- return null; // There are some interesting characters. Not boring.
- }
- if (textDir != null && textDir.isRtl(text, 0, textLength)) {
- return null; // The heuristic considers the whole text RTL. Not boring.
- }
- if (text instanceof Spanned) {
- Spanned sp = (Spanned) text;
- Object[] styles = sp.getSpans(0, textLength, ParagraphStyle.class);
- if (styles.length > 0) {
- return null; // There are some ParagraphStyle spans. Not boring.
- }
- }
-
- Metrics fm = metrics;
- if (fm == null) {
- fm = new Metrics();
- } else {
- fm.reset();
- }
-
- TextLine line = TextLine.obtain();
- line.set(paint, text, 0, textLength, Layout.DIR_LEFT_TO_RIGHT,
- Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null,
- 0 /* ellipsisStart, 0 since text has not been ellipsized at this point */,
- 0 /* ellipsisEnd, 0 since text has not been ellipsized at this point */);
- fm.width = (int) Math.ceil(line.metrics(fm));
- TextLine.recycle(line);
-
- return fm;
- }
-
- @Override
- public int getHeight() {
- return mBottom;
- }
-
- @Override
- public int getLineCount() {
- return 1;
- }
-
- @Override
- public int getLineTop(int line) {
- if (line == 0) {
- return 0;
- } else {
- return mBottom;
- }
- }
-
- @Override
- public int getLineDescent(int line) {
- return mDesc;
- }
-
- @Override
- public int getLineStart(int line) {
- if (line == 0) {
- return 0;
- } else {
- return getText().length();
- }
- }
-
- @Override
- public int getParagraphDirection(int line) {
- return DIR_LEFT_TO_RIGHT;
- }
-
- @Override
- public boolean getLineContainsTab(int line) {
- return false;
- }
-
- @Override
- public float getLineMax(int line) {
- return mMax;
- }
-
- @Override
- public float getLineWidth(int line) {
- return (line == 0 ? mMax : 0);
- }
-
- @Override
- public final Directions getLineDirections(int line) {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT;
- }
-
- @Override
- public int getTopPadding() {
- return mTopPadding;
- }
-
- @Override
- public int getBottomPadding() {
- return mBottomPadding;
- }
-
- @Override
- public int getEllipsisCount(int line) {
- return mEllipsizedCount;
- }
-
- @Override
- public int getEllipsisStart(int line) {
- return mEllipsizedStart;
- }
-
- @Override
- public int getEllipsizedWidth() {
- return mEllipsizedWidth;
- }
-
- // Override draw so it will be faster.
- @Override
- public void draw(Canvas c, Path highlight, Paint highlightpaint,
- int cursorOffset) {
- if (mDirect != null && highlight == null) {
- c.drawText(mDirect, 0, mBottom - mDesc, mPaint);
- } else {
- super.draw(c, highlight, highlightpaint, cursorOffset);
- }
- }
-
- /**
- * Callback for the ellipsizer to report what region it ellipsized.
- */
- public void ellipsized(int start, int end) {
- mEllipsizedStart = start;
- mEllipsizedCount = end - start;
- }
-
- private String mDirect;
- private Paint mPaint;
-
- /* package */ int mBottom, mDesc; // for Direct
- private int mTopPadding, mBottomPadding;
- private float mMax;
- private int mEllipsizedWidth, mEllipsizedStart, mEllipsizedCount;
-
- /**
- * Metrics.
- */
- public static class Metrics extends Paint.FontMetricsInt {
- public int width;
-
- @Override public String toString() {
- return super.toString() + " width=" + width;
- }
-
- private void reset() {
- top = 0;
- bottom = 0;
- ascent = 0;
- descent = 0;
- width = 0;
- leading = 0;
- }
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/GetChars.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/GetChars.java
deleted file mode 100644
index 7a7d5be..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/GetChars.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.text;
-
-/**
- * Please implement this interface if your CharSequence has a
- * getChars() method like the one in String that is faster than
- * calling charAt() multiple times.
- */
-public interface GetChars extends CharSequence {
- /**
- * Exactly like String.getChars(): copy chars <code>start</code>
- * through <code>end - 1</code> from this CharSequence into <code>dest</code>
- * beginning at offset <code>destoff</code>.
- */
- void getChars(int start, int end, char[] dest, int destoff);
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/NoCopySpan.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/NoCopySpan.java
deleted file mode 100644
index 4cbe062..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/NoCopySpan.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2009 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.text;
-
-/**
- * This interface should be added to a span object that should not be copied
- * into a new Spanned when performing a slice or copy operation on the original
- * Spanned it was placed in.
- */
-public interface NoCopySpan {
- /**
- * Convenience equivalent for when you would just want a new Object() for
- * a span but want it to be no-copy. Use this instead.
- */
- class Concrete implements NoCopySpan {
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpanWatcher.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpanWatcher.java
deleted file mode 100644
index e1eee36..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpanWatcher.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.text;
-
-/**
- * When an object of this type is attached to a Spannable, its methods
- * will be called to notify it that other markup objects have been
- * added, changed, or removed.
- */
-public interface SpanWatcher extends NoCopySpan {
- /**
- * This method is called to notify you that the specified object
- * has been attached to the specified range of the text.
- */
- void onSpanAdded(Spannable text, Object what, int start, int end);
- /**
- * This method is called to notify you that the specified object
- * has been detached from the specified range of the text.
- */
- void onSpanRemoved(Spannable text, Object what, int start, int end);
- /**
- * This method is called to notify you that the specified object
- * has been relocated from the range <code>ostart…oend</code>
- * to the new range <code>nstart…nend</code> of the text.
- */
- void onSpanChanged(Spannable text, Object what, int ostart, int oend,
- int nstart, int nend);
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/Spannable.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/Spannable.java
deleted file mode 100644
index e374fba..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/Spannable.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.text;
-
-/**
- * This is the interface for text to which markup objects can be
- * attached and detached. Not all Spannable classes have mutable text;
- * see {@link Editable} for that.
- */
-public interface Spannable extends Spanned {
- /**
- * Attach the specified markup object to the range <code>start…end</code>
- * of the text, or move the object to that range if it was already
- * attached elsewhere. See {@link Spanned} for an explanation of
- * what the flags mean. The object can be one that has meaning only
- * within your application, or it can be one that the text system will
- * use to affect text display or behavior. Some noteworthy ones are
- * the subclasses of {@link android.text.style.CharacterStyle} and
- * {@link android.text.style.ParagraphStyle}, and
- * {@link android.text.TextWatcher} and
- * {@link android.text.SpanWatcher}.
- */
- void setSpan(Object what, int start, int end, int flags);
-
- /**
- * Remove the specified object from the range of text to which it
- * was attached, if any. It is OK to remove an object that was never
- * attached in the first place.
- */
- void removeSpan(Object what);
-
- /**
- * Remove the specified object from the range of text to which it
- * was attached, if any. It is OK to remove an object tShat was never
- * attached in the first place.
- *
- * See {@link Spanned} for an explanation of what the flags mean.
- *
- */
- default void removeSpan(Object what, int flags) {
- removeSpan(what);
- }
-
- /**
- * Factory used by TextView to create new {@link Spannable Spannables}. You can subclass
- * it to provide something other than {@link SpannableString}.
- *
- * @see android.widget.TextView#setSpannableFactory(Factory)
- */
- class Factory {
- private static Spannable.Factory sInstance = new Spannable.Factory();
-
- /**
- * Returns the standard Spannable Factory.
- */
- public static Spannable.Factory getInstance() {
- return sInstance;
- }
-
- /**
- * Returns a new SpannableString from the specified CharSequence.
- * You can override this to provide a different kind of Spannable.
- */
- public Spannable newSpannable(CharSequence source) {
- return new SpannableString(source);
- }
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpannableString.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpannableString.java
deleted file mode 100644
index 49484e7..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpannableString.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.text;
-
-/**
- * This is the class for text whose content is immutable but to which
- * markup objects can be attached and detached.
- * For mutable text, see {@link SpannableStringBuilder}.
- */
-public class SpannableString
- extends SpannableStringInternal
- implements CharSequence, GetChars, Spannable {
-
- /**
- * @param source source object to copy from
- * @param ignoreNoCopySpan whether to copy NoCopySpans in the {@code source}
- */
- public SpannableString(CharSequence source, boolean ignoreNoCopySpan) {
- super(source, 0, source.length(), ignoreNoCopySpan);
- }
-
- /**
- * For the backward compatibility reasons, this constructor copies all spans including {@link
- * android.text.NoCopySpan}.
- *
- * @param source source text
- */
- public SpannableString(CharSequence source) {
- this(source, false /* ignoreNoCopySpan */); // preserve existing NoCopySpan behavior
- }
-
- /**
- * Ctor.
- */
- private SpannableString(CharSequence source, int start, int end) {
- // preserve existing NoCopySpan behavior
- super(source, start, end, false /* ignoreNoCopySpan */);
- }
-
- /**
- * valueOf.
- */
- public static SpannableString valueOf(CharSequence source) {
- if (source instanceof SpannableString) {
- return (SpannableString) source;
- } else {
- return new SpannableString(source);
- }
- }
-
- /**
- * setSpan.
- */
- public void setSpan(Object what, int start, int end, int flags) {
- super.setSpan(what, start, end, flags);
- }
-
- /**
- * removeSpan.
- */
- public void removeSpan(Object what) {
- super.removeSpan(what);
- }
-
- /**
- * subSequence.
- */
- public final CharSequence subSequence(int start, int end) {
- return new SpannableString(this, start, end);
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpannableStringInternal.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpannableStringInternal.java
deleted file mode 100644
index f327845..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/SpannableStringInternal.java
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * 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.text;
-
-import android.compat.annotation.UnsupportedAppUsage;
-
-import com.android.internal.util.ArrayUtils;
-import com.android.internal.util.GrowingArrayUtils;
-
-import libcore.util.EmptyArray;
-
-import java.lang.reflect.Array;
-
-/* package */ abstract class SpannableStringInternal {
- /* package */ SpannableStringInternal(CharSequence source,
- int start, int end, boolean ignoreNoCopySpan) {
- if (start == 0 && end == source.length()) {
- mText = source.toString();
- } else {
- mText = source.toString().substring(start, end);
- }
- mSpans = EmptyArray.OBJECT;
- // Invariant: mSpanData.length = mSpans.length * COLUMNS
- mSpanData = EmptyArray.INT;
-
- if (source instanceof Spanned) {
- if (source instanceof SpannableStringInternal) {
- copySpans((SpannableStringInternal) source, start, end, ignoreNoCopySpan);
- } else {
- copySpans((Spanned) source, start, end, ignoreNoCopySpan);
- }
- }
- }
-
- /**
- * This unused method is left since this is listed in hidden api list.
- *
- * Due to backward compatibility reasons, we copy even NoCopySpan by default
- */
- @UnsupportedAppUsage
- /* package */ SpannableStringInternal(CharSequence source, int start, int end) {
- this(source, start, end, false /* ignoreNoCopySpan */);
- }
-
- /**
- * Copies another {@link Spanned} object's spans between [start, end] into this object.
- *
- * @param src Source object to copy from.
- * @param start Start index in the source object.
- * @param end End index in the source object.
- * @param ignoreNoCopySpan whether to copy NoCopySpans in the {@code source}
- */
- private void copySpans(Spanned src, int start, int end, boolean ignoreNoCopySpan) {
- Object[] spans = src.getSpans(start, end, Object.class);
-
- for (int i = 0; i < spans.length; i++) {
- if (ignoreNoCopySpan && spans[i] instanceof NoCopySpan) {
- continue;
- }
- int st = src.getSpanStart(spans[i]);
- int en = src.getSpanEnd(spans[i]);
- int fl = src.getSpanFlags(spans[i]);
-
- if (st < start) st = start;
- if (en > end) en = end;
-
- setSpan(spans[i], st - start, en - start, fl, false/*enforceParagraph*/);
- }
- }
-
- /**
- * Copies a {@link SpannableStringInternal} object's spans between [start, end] into this
- * object.
- *
- * @param src Source object to copy from.
- * @param start Start index in the source object.
- * @param end End index in the source object.
- * @param ignoreNoCopySpan copy NoCopySpan for backward compatible reasons.
- */
- private void copySpans(SpannableStringInternal src, int start, int end,
- boolean ignoreNoCopySpan) {
- int count = 0;
- final int[] srcData = src.mSpanData;
- final Object[] srcSpans = src.mSpans;
- final int limit = src.mSpanCount;
- boolean hasNoCopySpan = false;
-
- for (int i = 0; i < limit; i++) {
- int spanStart = srcData[i * COLUMNS + START];
- int spanEnd = srcData[i * COLUMNS + END];
- if (isOutOfCopyRange(start, end, spanStart, spanEnd)) continue;
- if (srcSpans[i] instanceof NoCopySpan) {
- hasNoCopySpan = true;
- if (ignoreNoCopySpan) {
- continue;
- }
- }
- count++;
- }
-
- if (count == 0) return;
-
- if (!hasNoCopySpan && start == 0 && end == src.length()) {
- mSpans = ArrayUtils.newUnpaddedObjectArray(src.mSpans.length);
- mSpanData = new int[src.mSpanData.length];
- mSpanCount = src.mSpanCount;
- System.arraycopy(src.mSpans, 0, mSpans, 0, src.mSpans.length);
- System.arraycopy(src.mSpanData, 0, mSpanData, 0, mSpanData.length);
- } else {
- mSpanCount = count;
- mSpans = ArrayUtils.newUnpaddedObjectArray(mSpanCount);
- mSpanData = new int[mSpans.length * COLUMNS];
- for (int i = 0, j = 0; i < limit; i++) {
- int spanStart = srcData[i * COLUMNS + START];
- int spanEnd = srcData[i * COLUMNS + END];
- if (isOutOfCopyRange(start, end, spanStart, spanEnd)
- || (ignoreNoCopySpan && srcSpans[i] instanceof NoCopySpan)) {
- continue;
- }
- if (spanStart < start) spanStart = start;
- if (spanEnd > end) spanEnd = end;
-
- mSpans[j] = srcSpans[i];
- mSpanData[j * COLUMNS + START] = spanStart - start;
- mSpanData[j * COLUMNS + END] = spanEnd - start;
- mSpanData[j * COLUMNS + FLAGS] = srcData[i * COLUMNS + FLAGS];
- j++;
- }
- }
- }
-
- /**
- * Checks if [spanStart, spanEnd] interval is excluded from [start, end].
- *
- * @return True if excluded, false if included.
- */
- @UnsupportedAppUsage
- private boolean isOutOfCopyRange(int start, int end, int spanStart, int spanEnd) {
- if (spanStart > end || spanEnd < start) return true;
- if (spanStart != spanEnd && start != end) {
- if (spanStart == end || spanEnd == start) return true;
- }
- return false;
- }
-
- public final int length() {
- return mText.length();
- }
-
- public final char charAt(int i) {
- return mText.charAt(i);
- }
-
- public final String toString() {
- return mText;
- }
-
- /* subclasses must do subSequence() to preserve type */
-
- public final void getChars(int start, int end, char[] dest, int off) {
- mText.getChars(start, end, dest, off);
- }
-
- @UnsupportedAppUsage
- /* package */ void setSpan(Object what, int start, int end, int flags) {
- setSpan(what, start, end, flags, true/*enforceParagraph*/);
- }
-
- @UnsupportedAppUsage
- private boolean isIndexFollowsNextLine(int index) {
- return index != 0 && index != length() && charAt(index - 1) != '\n';
- }
-
- @UnsupportedAppUsage
- private void setSpan(Object what, int start, int end, int flags, boolean enforceParagraph) {
- int nstart = start;
- int nend = end;
-
- checkRange("setSpan", start, end);
-
- if ((flags & Spannable.SPAN_PARAGRAPH) == Spannable.SPAN_PARAGRAPH) {
- if (isIndexFollowsNextLine(start)) {
- if (!enforceParagraph) {
- // do not set the span
- return;
- }
- throw new RuntimeException("PARAGRAPH span must start at paragraph boundary"
- + " (" + start + " follows " + charAt(start - 1) + ")");
- }
-
- if (isIndexFollowsNextLine(end)) {
- if (!enforceParagraph) {
- // do not set the span
- return;
- }
- throw new RuntimeException("PARAGRAPH span must end at paragraph boundary"
- + " (" + end + " follows " + charAt(end - 1) + ")");
- }
- }
-
- int count = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
-
- for (int i = 0; i < count; i++) {
- if (spans[i] == what) {
- int ostart = data[i * COLUMNS + START];
- int oend = data[i * COLUMNS + END];
-
- data[i * COLUMNS + START] = start;
- data[i * COLUMNS + END] = end;
- data[i * COLUMNS + FLAGS] = flags;
-
- sendSpanChanged(what, ostart, oend, nstart, nend);
- return;
- }
- }
-
- if (mSpanCount + 1 >= mSpans.length) {
- Object[] newtags = ArrayUtils.newUnpaddedObjectArray(
- GrowingArrayUtils.growSize(mSpanCount));
- int[] newdata = new int[newtags.length * 3];
-
- System.arraycopy(mSpans, 0, newtags, 0, mSpanCount);
- System.arraycopy(mSpanData, 0, newdata, 0, mSpanCount * 3);
-
- mSpans = newtags;
- mSpanData = newdata;
- }
-
- mSpans[mSpanCount] = what;
- mSpanData[mSpanCount * COLUMNS + START] = start;
- mSpanData[mSpanCount * COLUMNS + END] = end;
- mSpanData[mSpanCount * COLUMNS + FLAGS] = flags;
- mSpanCount++;
-
- if (this instanceof Spannable) {
- sendSpanAdded(what, nstart, nend);
- }
- }
-
- @UnsupportedAppUsage
- /* package */ void removeSpan(Object what) {
- removeSpan(what, 0 /* flags */);
- }
-
- /**
- * removeSpan
- */
- public void removeSpan(Object what, int flags) {
- int count = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
-
- for (int i = count - 1; i >= 0; i--) {
- if (spans[i] == what) {
- int ostart = data[i * COLUMNS + START];
- int oend = data[i * COLUMNS + END];
-
- int c = count - (i + 1);
-
- System.arraycopy(spans, i + 1, spans, i, c);
- System.arraycopy(data, (i + 1) * COLUMNS,
- data, i * COLUMNS, c * COLUMNS);
-
- mSpanCount--;
-
- if ((flags & Spanned.SPAN_INTERMEDIATE) == 0) {
- sendSpanRemoved(what, ostart, oend);
- }
- return;
- }
- }
- }
-
- @UnsupportedAppUsage
- public int getSpanStart(Object what) {
- int count = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
-
- for (int i = count - 1; i >= 0; i--) {
- if (spans[i] == what) {
- return data[i * COLUMNS + START];
- }
- }
-
- return -1;
- }
-
- @UnsupportedAppUsage
- public int getSpanEnd(Object what) {
- int count = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
-
- for (int i = count - 1; i >= 0; i--) {
- if (spans[i] == what) {
- return data[i * COLUMNS + END];
- }
- }
-
- return -1;
- }
-
- @UnsupportedAppUsage
- public int getSpanFlags(Object what) {
- int count = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
-
- for (int i = count - 1; i >= 0; i--) {
- if (spans[i] == what) {
- return data[i * COLUMNS + FLAGS];
- }
- }
-
- return 0;
- }
-
- @UnsupportedAppUsage
- public <T> T[] getSpans(int queryStart, int queryEnd, Class<T> kind) {
- int count = 0;
-
- int spanCount = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
- Object[] ret = null;
- Object ret1 = null;
-
- for (int i = 0; i < spanCount; i++) {
- int spanStart = data[i * COLUMNS + START];
- int spanEnd = data[i * COLUMNS + END];
-
- if (spanStart > queryEnd) {
- continue;
- }
- if (spanEnd < queryStart) {
- continue;
- }
-
- if (spanStart != spanEnd && queryStart != queryEnd) {
- if (spanStart == queryEnd) {
- continue;
- }
- if (spanEnd == queryStart) {
- continue;
- }
- }
-
- // verify span class as late as possible, since it is expensive
- if (kind != null && kind != Object.class && !kind.isInstance(spans[i])) {
- continue;
- }
-
- if (count == 0) {
- ret1 = spans[i];
- count++;
- } else {
- if (count == 1) {
- ret = (Object[]) Array.newInstance(kind, spanCount - i + 1);
- ret[0] = ret1;
- }
-
- int prio = data[i * COLUMNS + FLAGS] & Spanned.SPAN_PRIORITY;
- if (prio != 0) {
- int j;
-
- for (j = 0; j < count; j++) {
- int p = getSpanFlags(ret[j]) & Spanned.SPAN_PRIORITY;
-
- if (prio > p) {
- break;
- }
- }
-
- System.arraycopy(ret, j, ret, j + 1, count - j);
- ret[j] = spans[i];
- count++;
- } else {
- ret[count++] = spans[i];
- }
- }
- }
-
- if (count == 0) {
- return (T[]) ArrayUtils.emptyArray(kind);
- }
- if (count == 1) {
- ret = (Object[]) Array.newInstance(kind, 1);
- ret[0] = ret1;
- return (T[]) ret;
- }
- if (count == ret.length) {
- return (T[]) ret;
- }
-
- Object[] nret = (Object[]) Array.newInstance(kind, count);
- System.arraycopy(ret, 0, nret, 0, count);
- return (T[]) nret;
- }
-
- @UnsupportedAppUsage
- public int nextSpanTransition(int start, int limit, Class kind) {
- int count = mSpanCount;
- Object[] spans = mSpans;
- int[] data = mSpanData;
-
- if (kind == null) {
- kind = Object.class;
- }
-
- for (int i = 0; i < count; i++) {
- int st = data[i * COLUMNS + START];
- int en = data[i * COLUMNS + END];
-
- if (st > start && st < limit && kind.isInstance(spans[i])) {
- limit = st;
- }
- if (en > start && en < limit && kind.isInstance(spans[i])) {
- limit = en;
- }
- }
-
- return limit;
- }
-
- @UnsupportedAppUsage
- private void sendSpanAdded(Object what, int start, int end) {
- SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
- int n = recip.length;
-
- for (int i = 0; i < n; i++) {
- recip[i].onSpanAdded((Spannable) this, what, start, end);
- }
- }
-
- @UnsupportedAppUsage
- private void sendSpanRemoved(Object what, int start, int end) {
- SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
- int n = recip.length;
-
- for (int i = 0; i < n; i++) {
- recip[i].onSpanRemoved((Spannable) this, what, start, end);
- }
- }
-
- @UnsupportedAppUsage
- private void sendSpanChanged(Object what, int s, int e, int st, int en) {
- SpanWatcher[] recip = getSpans(Math.min(s, st), Math.max(e, en),
- SpanWatcher.class);
- int n = recip.length;
-
- for (int i = 0; i < n; i++) {
- recip[i].onSpanChanged((Spannable) this, what, s, e, st, en);
- }
- }
-
- @UnsupportedAppUsage
- private static String region(int start, int end) {
- return "(" + start + " ... " + end + ")";
- }
-
- @UnsupportedAppUsage
- private void checkRange(final String operation, int start, int end) {
- if (end < start) {
- throw new IndexOutOfBoundsException(operation + " "
- + region(start, end)
- + " has end before start");
- }
-
- int len = length();
-
- if (start > len || end > len) {
- throw new IndexOutOfBoundsException(operation + " "
- + region(start, end)
- + " ends beyond length " + len);
- }
-
- if (start < 0 || end < 0) {
- throw new IndexOutOfBoundsException(operation + " "
- + region(start, end)
- + " starts before 0");
- }
- }
-
- // Same as SpannableStringBuilder
- @Override
- public boolean equals(Object o) {
- if (o instanceof Spanned
- && toString().equals(o.toString())) {
- final Spanned other = (Spanned) o;
- // Check span data
- final Object[] otherSpans = other.getSpans(0, other.length(), Object.class);
- final Object[] thisSpans = getSpans(0, length(), Object.class);
- if (mSpanCount == otherSpans.length) {
- for (int i = 0; i < mSpanCount; ++i) {
- final Object thisSpan = thisSpans[i];
- final Object otherSpan = otherSpans[i];
- if (thisSpan == this) {
- if (other != otherSpan
- || getSpanStart(thisSpan) != other.getSpanStart(otherSpan)
- || getSpanEnd(thisSpan) != other.getSpanEnd(otherSpan)
- || getSpanFlags(thisSpan) != other.getSpanFlags(otherSpan)) {
- return false;
- }
- } else if (!thisSpan.equals(otherSpan)
- || getSpanStart(thisSpan) != other.getSpanStart(otherSpan)
- || getSpanEnd(thisSpan) != other.getSpanEnd(otherSpan)
- || getSpanFlags(thisSpan) != other.getSpanFlags(otherSpan)) {
- return false;
- }
- }
- return true;
- }
- }
- return false;
- }
-
- // Same as SpannableStringBuilder
- @Override
- public int hashCode() {
- int hash = toString().hashCode();
- hash = hash * 31 + mSpanCount;
- for (int i = 0; i < mSpanCount; ++i) {
- Object span = mSpans[i];
- if (span != this) {
- hash = hash * 31 + span.hashCode();
- }
- hash = hash * 31 + getSpanStart(span);
- hash = hash * 31 + getSpanEnd(span);
- hash = hash * 31 + getSpanFlags(span);
- }
- return hash;
- }
-
- /**
- * Following two unused methods are left since these are listed in hidden api list.
- *
- * Due to backward compatibility reasons, we copy even NoCopySpan by default
- */
- @UnsupportedAppUsage
- private void copySpans(Spanned src, int start, int end) {
- copySpans(src, start, end, false);
- }
-
- @UnsupportedAppUsage
- private void copySpans(SpannableStringInternal src, int start, int end) {
- copySpans(src, start, end, false);
- }
-
-
-
- @UnsupportedAppUsage
- private String mText;
- @UnsupportedAppUsage
- private Object[] mSpans;
- @UnsupportedAppUsage
- private int[] mSpanData;
- @UnsupportedAppUsage
- private int mSpanCount;
-
- @UnsupportedAppUsage
- /* package */ static final Object[] EMPTY = new Object[0];
-
- @UnsupportedAppUsage
- private static final int START = 0;
- @UnsupportedAppUsage
- private static final int END = 1;
- @UnsupportedAppUsage
- private static final int FLAGS = 2;
- @UnsupportedAppUsage
- private static final int COLUMNS = 3;
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/Spanned.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/Spanned.java
deleted file mode 100644
index 998b8b0..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/Spanned.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.text;
-
-/**
- * This is the interface for text that has markup objects attached to
- * ranges of it. Not all text classes have mutable markup or text;
- * see {@link Spannable} for mutable markup and {@link Editable} for
- * mutable text.
- */
-public interface Spanned extends CharSequence {
- /**
- * Bitmask of bits that are relevant for controlling point/mark behavior
- * of spans.
- *
- * MARK and POINT are conceptually located <i>between</i> two adjacent characters.
- * A MARK is "attached" to the character before, while a POINT will stick to the character
- * after. The insertion cursor is conceptually located between the MARK and the POINT.
- *
- * As a result, inserting a new character between a MARK and a POINT will leave the MARK
- * unchanged, while the POINT will be shifted, now located after the inserted character and
- * still glued to the same character after it.
- *
- * Depending on whether the insertion happens at the beginning or the end of a span, the span
- * will hence be expanded to <i>include</i> the new character (when the span is using a MARK at
- * its beginning or a POINT at its end) or it will be <i>excluded</i>.
- *
- * Note that <i>before</i> and <i>after</i> here refer to offsets in the String, which are
- * independent from the visual representation of the text (left-to-right or right-to-left).
- */
- int SPAN_POINT_MARK_MASK = 0x33;
-
- /**
- * 0-length spans with type SPAN_MARK_MARK behave like text marks:
- * they remain at their original offset when text is inserted
- * at that offset. Conceptually, the text is added after the mark.
- */
- int SPAN_MARK_MARK = 0x11;
-
- /**
- * SPAN_MARK_POINT is a synonym for {@link #SPAN_INCLUSIVE_INCLUSIVE}.
- */
- int SPAN_MARK_POINT = 0x12;
-
- /**
- * SPAN_POINT_MARK is a synonym for {@link #SPAN_EXCLUSIVE_EXCLUSIVE}.
- */
- int SPAN_POINT_MARK = 0x21;
-
- /**
- * 0-length spans with type SPAN_POINT_POINT behave like cursors:
- * they are pushed forward by the length of the insertion when text
- * is inserted at their offset.
- * The text is conceptually inserted before the point.
- */
- int SPAN_POINT_POINT = 0x22;
-
- /**
- * SPAN_PARAGRAPH behaves like SPAN_INCLUSIVE_EXCLUSIVE
- * (SPAN_MARK_MARK), except that if either end of the span is
- * at the end of the buffer, that end behaves like _POINT
- * instead (so SPAN_INCLUSIVE_INCLUSIVE if it starts in the
- * middle and ends at the end, or SPAN_EXCLUSIVE_INCLUSIVE
- * if it both starts and ends at the end).
- * <p>
- * Its endpoints must be the start or end of the buffer or
- * immediately after a \n character, and if the \n
- * that anchors it is deleted, the endpoint is pulled to the
- * next \n that follows in the buffer (or to the end of
- * the buffer). If a span with SPAN_PARAGRAPH flag is pasted
- * into another text and the paragraph boundary constraint
- * is not satisfied, the span is discarded.
- */
- int SPAN_PARAGRAPH = 0x33;
-
- /**
- * Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
- * to include text inserted at their starting point but not at their
- * ending point. When 0-length, they behave like marks.
- */
- int SPAN_INCLUSIVE_EXCLUSIVE = SPAN_MARK_MARK;
-
- /**
- * Spans of type SPAN_INCLUSIVE_INCLUSIVE expand
- * to include text inserted at either their starting or ending point.
- */
- int SPAN_INCLUSIVE_INCLUSIVE = SPAN_MARK_POINT;
-
- /**
- * Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand
- * to include text inserted at either their starting or ending point.
- * They can never have a length of 0 and are automatically removed
- * from the buffer if all the text they cover is removed.
- */
- int SPAN_EXCLUSIVE_EXCLUSIVE = SPAN_POINT_MARK;
-
- /**
- * Non-0-length spans of type SPAN_EXCLUSIVE_INCLUSIVE expand
- * to include text inserted at their ending point but not at their
- * starting point. When 0-length, they behave like points.
- */
- int SPAN_EXCLUSIVE_INCLUSIVE = SPAN_POINT_POINT;
-
- /**
- * This flag is set on spans that are being used to apply temporary
- * styling information on the composing text of an input method, so that
- * they can be found and removed when the composing text is being
- * replaced.
- */
- int SPAN_COMPOSING = 0x100;
-
- /**
- * This flag will be set for intermediate span changes, meaning there
- * is guaranteed to be another change following it. Typically it is
- * used for {@link Selection} which automatically uses this with the first
- * offset it sets when updating the selection.
- */
- int SPAN_INTERMEDIATE = 0x200;
-
- /**
- * The bits numbered SPAN_USER_SHIFT and above are available
- * for callers to use to store scalar data associated with their
- * span object.
- */
- int SPAN_USER_SHIFT = 24;
-
- /**
- * The bits specified by the SPAN_USER bitfield are available
- * for callers to use to store scalar data associated with their
- * span object.
- */
- int SPAN_USER = 0xFFFFFFFF << SPAN_USER_SHIFT;
-
- /**
- * The bits numbered just above SPAN_PRIORITY_SHIFT determine the order
- * of change notifications -- higher numbers go first. You probably
- * don't need to set this; it is used so that when text changes, the
- * text layout gets the chance to update itself before any other
- * callbacks can inquire about the layout of the text.
- */
- int SPAN_PRIORITY_SHIFT = 16;
-
- /**
- * The bits specified by the SPAN_PRIORITY bitmap determine the order
- * of change notifications -- higher numbers go first. You probably
- * don't need to set this; it is used so that when text changes, the
- * text layout gets the chance to update itself before any other
- * callbacks can inquire about the layout of the text.
- */
- int SPAN_PRIORITY = 0xFF << SPAN_PRIORITY_SHIFT;
-
- /**
- * Return an array of the markup objects attached to the specified
- * slice of this CharSequence and whose type is the specified type
- * or a subclass of it. Specify Object.class for the type if you
- * want all the objects regardless of type.
- */
- <T> T[] getSpans(int start, int end, Class<T> type);
-
- /**
- * Return the beginning of the range of text to which the specified
- * markup object is attached, or -1 if the object is not attached.
- */
- int getSpanStart(Object tag);
-
- /**
- * Return the end of the range of text to which the specified
- * markup object is attached, or -1 if the object is not attached.
- */
- int getSpanEnd(Object tag);
-
- /**
- * Return the flags that were specified when {@link Spannable#setSpan} was
- * used to attach the specified markup object, or 0 if the specified
- * object has not been attached.
- */
- int getSpanFlags(Object tag);
-
- /**
- * Return the first offset greater than <code>start</code> where a markup
- * object of class <code>type</code> begins or ends, or <code>limit</code>
- * if there are no starts or ends greater than <code>start</code> but less
- * than <code>limit</code>. Specify <code>null</code> or Object.class for
- * the type if you want every transition regardless of type.
- */
- int nextSpanTransition(int start, int limit, Class type);
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextDirectionHeuristic.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextDirectionHeuristic.java
deleted file mode 100644
index 88a35c1..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextDirectionHeuristic.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 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.text;
-
-/**
- * Interface for objects that use a heuristic for guessing at the paragraph direction
- * by examining text.
- */
-public interface TextDirectionHeuristic {
- /**
- * Guess if a chars array is in the RTL direction or not.
- *
- * @param array the char array.
- * @param start start index, inclusive.
- * @param count the length to check, must not be negative and not greater than
- * {@code array.length - start}.
- * @return true if all chars in the range are to be considered in a RTL direction,
- * false otherwise.
- */
- boolean isRtl(char[] array, int start, int count);
-
- /**
- * Guess if a {@code CharSequence} is in the RTL direction or not.
- *
- * @param cs the CharSequence.
- * @param start start index, inclusive.
- * @param count the length to check, must not be negative and not greater than
- * {@code CharSequence.length() - start}.
- * @return true if all chars in the range are to be considered in a RTL direction,
- * false otherwise.
- */
- boolean isRtl(CharSequence cs, int start, int count);
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextDirectionHeuristics.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextDirectionHeuristics.java
deleted file mode 100644
index 4feab0d..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextDirectionHeuristics.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (C) 2011 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.text;
-
-
-import android.view.View;
-
-import java.nio.CharBuffer;
-
-/**
- * Some objects that implement {@link TextDirectionHeuristic}. Use these with
- * the {@link BidiFormatter#unicodeWrap unicodeWrap()} methods in {@link BidiFormatter}.
- * Also notice that these direction heuristics correspond to the same types of constants
- * provided in the {@link android.view.View} class for {@link android.view.View#setTextDirection
- * setTextDirection()}, such as {@link android.view.View#TEXT_DIRECTION_RTL}.
- * <p>To support versions lower than {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
- * you can use the support library's {@link android.support.v4.text.TextDirectionHeuristicsCompat}
- * class.
- */
-public class TextDirectionHeuristics {
-
- /**
- * Always decides that the direction is left to right.
- */
- public static final TextDirectionHeuristic LTR =
- new TextDirectionHeuristicInternal(null /* no algorithm */, false);
-
- /**
- * Always decides that the direction is right to left.
- */
- public static final TextDirectionHeuristic RTL =
- new TextDirectionHeuristicInternal(null /* no algorithm */, true);
-
- /**
- * Determines the direction based on the first strong directional character, including bidi
- * format chars, falling back to left to right if it finds none. This is the default behavior
- * of the Unicode Bidirectional Algorithm.
- */
- public static final TextDirectionHeuristic FIRSTSTRONG_LTR =
- new TextDirectionHeuristicInternal(FirstStrong.INSTANCE, false);
-
- /**
- * Determines the direction based on the first strong directional character, including bidi
- * format chars, falling back to right to left if it finds none. This is similar to the default
- * behavior of the Unicode Bidirectional Algorithm, just with different fallback behavior.
- */
- public static final TextDirectionHeuristic FIRSTSTRONG_RTL =
- new TextDirectionHeuristicInternal(FirstStrong.INSTANCE, true);
-
- /**
- * If the text contains any strong right to left non-format character, determines that the
- * direction is right to left, falling back to left to right if it finds none.
- */
- public static final TextDirectionHeuristic ANYRTL_LTR =
- new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_RTL, false);
-
- /**
- * Force the paragraph direction to the Locale direction. Falls back to left to right.
- */
- public static final TextDirectionHeuristic LOCALE = TextDirectionHeuristicLocale.INSTANCE;
-
- /**
- * State constants for taking care about true / false / unknown
- */
- private static final int STATE_TRUE = 0;
- private static final int STATE_FALSE = 1;
- private static final int STATE_UNKNOWN = 2;
-
- /* Returns STATE_TRUE for strong RTL characters, STATE_FALSE for strong LTR characters, and
- * STATE_UNKNOWN for everything else.
- */
- private static int isRtlCodePoint(int codePoint) {
- switch (Character.getDirectionality(codePoint)) {
- case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
- return STATE_FALSE;
- case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
- case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
- return STATE_TRUE;
- case Character.DIRECTIONALITY_UNDEFINED:
- // Unassigned characters still have bidi direction, defined at:
- // http://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedBidiClass.txt
-
- if ((0x0590 <= codePoint && codePoint <= 0x08FF)
- || (0xFB1D <= codePoint && codePoint <= 0xFDCF)
- || (0xFDF0 <= codePoint && codePoint <= 0xFDFF)
- || (0xFE70 <= codePoint && codePoint <= 0xFEFF)
- || (0x10800 <= codePoint && codePoint <= 0x10FFF)
- || (0x1E800 <= codePoint && codePoint <= 0x1EFFF)) {
- // Unassigned RTL character
- return STATE_TRUE;
- } else if (
- // Potentially-unassigned Default_Ignorable. Ranges are from unassigned
- // characters that have Unicode property Other_Default_Ignorable_Code_Point
- // plus some enlargening to cover bidi isolates and simplify checks.
- (0x2065 <= codePoint && codePoint <= 0x2069)
- || (0xFFF0 <= codePoint && codePoint <= 0xFFF8)
- || (0xE0000 <= codePoint && codePoint <= 0xE0FFF)
- // Non-character
- || (0xFDD0 <= codePoint && codePoint <= 0xFDEF)
- || ((codePoint & 0xFFFE) == 0xFFFE)
- // Currency symbol
- || (0x20A0 <= codePoint && codePoint <= 0x20CF)
- // Unpaired surrogate
- || (0xD800 <= codePoint && codePoint <= 0xDFFF)) {
- return STATE_UNKNOWN;
- } else {
- // Unassigned LTR character
- return STATE_FALSE;
- }
- default:
- return STATE_UNKNOWN;
- }
- }
-
- /**
- * Computes the text direction based on an algorithm. Subclasses implement
- * {@link #defaultIsRtl} to handle cases where the algorithm cannot determine the
- * direction from the text alone.
- */
- private abstract static class TextDirectionHeuristicImpl implements TextDirectionHeuristic {
- private final TextDirectionAlgorithm mAlgorithm;
-
- TextDirectionHeuristicImpl(TextDirectionAlgorithm algorithm) {
- mAlgorithm = algorithm;
- }
-
- /**
- * Return true if the default text direction is rtl.
- */
- protected abstract boolean defaultIsRtl();
-
- @Override
- public boolean isRtl(char[] array, int start, int count) {
- return isRtl(CharBuffer.wrap(array), start, count);
- }
-
- @Override
- public boolean isRtl(CharSequence cs, int start, int count) {
- if (cs == null || start < 0 || count < 0 || cs.length() - count < start) {
- throw new IllegalArgumentException();
- }
- if (mAlgorithm == null) {
- return defaultIsRtl();
- }
- return doCheck(cs, start, count);
- }
-
- private boolean doCheck(CharSequence cs, int start, int count) {
- switch (mAlgorithm.checkRtl(cs, start, count)) {
- case STATE_TRUE:
- return true;
- case STATE_FALSE:
- return false;
- default:
- return defaultIsRtl();
- }
- }
- }
-
- private static class TextDirectionHeuristicInternal extends TextDirectionHeuristicImpl {
- private final boolean mDefaultIsRtl;
-
- private TextDirectionHeuristicInternal(TextDirectionAlgorithm algorithm,
- boolean defaultIsRtl) {
- super(algorithm);
- mDefaultIsRtl = defaultIsRtl;
- }
-
- @Override
- protected boolean defaultIsRtl() {
- return mDefaultIsRtl;
- }
- }
-
- /**
- * Interface for an algorithm to guess the direction of a paragraph of text.
- */
- private interface TextDirectionAlgorithm {
- /**
- * Returns whether the range of text is RTL according to the algorithm.
- */
- int checkRtl(CharSequence cs, int start, int count);
- }
-
- /**
- * Algorithm that uses the first strong directional character to determine the paragraph
- * direction. This is the standard Unicode Bidirectional Algorithm (steps P2 and P3), with the
- * exception that if no strong character is found, UNKNOWN is returned.
- */
- private static class FirstStrong implements TextDirectionAlgorithm {
- @Override
- public int checkRtl(CharSequence cs, int start, int count) {
- int result = STATE_UNKNOWN;
- int openIsolateCount = 0;
- for (int cp, i = start, end = start + count;
- i < end && result == STATE_UNKNOWN;
- i += Character.charCount(cp)) {
- cp = Character.codePointAt(cs, i);
- if (0x2066 <= cp && cp <= 0x2068) { // Opening isolates
- openIsolateCount += 1;
- } else if (cp == 0x2069) { // POP DIRECTIONAL ISOLATE (PDI)
- if (openIsolateCount > 0) openIsolateCount -= 1;
- } else if (openIsolateCount == 0) {
- // Only consider the characters outside isolate pairs
- result = isRtlCodePoint(cp);
- }
- }
- return result;
- }
-
- private FirstStrong() {
- }
-
- public static final FirstStrong INSTANCE = new FirstStrong();
- }
-
- /**
- * Algorithm that uses the presence of any strong directional character of the type indicated
- * in the constructor parameter to determine the direction of text.
- *
- * Characters inside isolate pairs are skipped.
- */
- private static class AnyStrong implements TextDirectionAlgorithm {
- private final boolean mLookForRtl;
-
- @Override
- public int checkRtl(CharSequence cs, int start, int count) {
- boolean haveUnlookedFor = false;
- int openIsolateCount = 0;
- for (int cp, i = start, end = start + count; i < end; i += Character.charCount(cp)) {
- cp = Character.codePointAt(cs, i);
- if (0x2066 <= cp && cp <= 0x2068) { // Opening isolates
- openIsolateCount += 1;
- } else if (cp == 0x2069) { // POP DIRECTIONAL ISOLATE (PDI)
- if (openIsolateCount > 0) openIsolateCount -= 1;
- } else if (openIsolateCount == 0) {
- // Only consider the characters outside isolate pairs
- switch (isRtlCodePoint(cp)) {
- case STATE_TRUE:
- if (mLookForRtl) {
- return STATE_TRUE;
- }
- haveUnlookedFor = true;
- break;
- case STATE_FALSE:
- if (!mLookForRtl) {
- return STATE_FALSE;
- }
- haveUnlookedFor = true;
- break;
- default:
- break;
- }
- }
- }
- if (haveUnlookedFor) {
- return mLookForRtl ? STATE_FALSE : STATE_TRUE;
- }
- return STATE_UNKNOWN;
- }
-
- private AnyStrong(boolean lookForRtl) {
- this.mLookForRtl = lookForRtl;
- }
-
- public static final AnyStrong INSTANCE_RTL = new AnyStrong(true);
- public static final AnyStrong INSTANCE_LTR = new AnyStrong(false);
- }
-
- /**
- * Algorithm that uses the Locale direction to force the direction of a paragraph.
- */
- private static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl {
-
- TextDirectionHeuristicLocale() {
- super(null);
- }
-
- @Override
- protected boolean defaultIsRtl() {
- // TODO: fix me!
- final int dir =
- View.LAYOUT_DIRECTION_LTR; // TextUtils.getLayoutDirectionFromLocale(java
- // .util.Locale.getDefault());
- return (dir == View.LAYOUT_DIRECTION_RTL);
- }
-
- public static final TextDirectionHeuristicLocale INSTANCE =
- new TextDirectionHeuristicLocale();
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextUtils.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextUtils.java
deleted file mode 100644
index 33f69ba..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/TextUtils.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.text;
-
-import android.compat.annotation.UnsupportedAppUsage;
-
-import com.android.internal.util.ArrayUtils;
-
-/**
- * TextUtils.
- */
-public class TextUtils {
- private static final String ELLIPSIS_NORMAL = "\u2026"; // HORIZONTAL ELLIPSIS (…)
- private static final String ELLIPSIS_TWO_DOTS = "\u2025"; // TWO DOT LEADER (‥)
-
- /**
- * getChars
- */
- public static void getChars(CharSequence s, int start, int end,
- char[] dest, int destoff) {
- Class<? extends CharSequence> c = s.getClass();
- if (c == String.class) {
- ((String) s).getChars(start, end, dest, destoff);
- } else if (c == StringBuffer.class) {
- ((StringBuffer) s).getChars(start, end, dest, destoff);
- } else if (c == StringBuilder.class) {
- ((StringBuilder) s).getChars(start, end, dest, destoff);
- } else if (s instanceof GetChars) {
- ((GetChars) s).getChars(start, end, dest, destoff);
- } else {
- for (int i = start; i < end; i++) {
- dest[destoff++] = s.charAt(i);
- }
- }
- }
-
- /**
- * ellipsize.
- */
- public static CharSequence ellipsize(CharSequence text,
- TextPaint p,
- float avail, TruncateAt where) {
- return ellipsize(text, p, avail, where, false, null);
- }
-
- /**
- * ellipsize.
- */
- public static CharSequence ellipsize(CharSequence text,
- TextPaint paint,
- float avail, TruncateAt where,
- boolean preserveLength,
- EllipsizeCallback callback) {
- return ellipsize(text, paint, avail, where, preserveLength, callback,
- TextDirectionHeuristics.FIRSTSTRONG_LTR,
- getEllipsisString(where));
- }
-
- /**
- * ellipsize
- */
- public static CharSequence ellipsize(
- CharSequence text,
- TextPaint paint,
- float avail, TruncateAt where,
- boolean preserveLength,
- EllipsizeCallback callback,
- TextDirectionHeuristic textDir, String ellipsis) {
- // TODO: incorrect
- return text;
- }
-
- /**
- * getEllipsisString
- */
- public static String getEllipsisString(TextUtils.TruncateAt method) {
- return (method == TextUtils.TruncateAt.END_SMALL) ? ELLIPSIS_TWO_DOTS : ELLIPSIS_NORMAL;
- }
-
- /**
- * obtain
- */
- static char[] obtain(int len) {
- return ArrayUtils.newUnpaddedCharArray(len);
- }
-
- /**
- * recycle
- */
- static void recycle(char[] temp) {
- }
-
- /**
- * couldAffectRtl
- */
- static boolean couldAffectRtl(char c) {
- return (0x0590 <= c && c <= 0x08FF) || // RTL scripts
- c == 0x200E || // Bidi format character
- c == 0x200F || // Bidi format character
- (0x202A <= c && c <= 0x202E) || // Bidi format characters
- (0x2066 <= c && c <= 0x2069) || // Bidi format characters
- (0xD800 <= c && c <= 0xDFFF) || // Surrogate pairs
- (0xFB1D <= c && c <= 0xFDFF) || // Hebrew and Arabic presentation forms
- (0xFE70 <= c && c <= 0xFEFE); // Arabic presentation forms
- }
-
- /**
- * TruncateAt.
- */
- public enum TruncateAt {
- START,
- MIDDLE,
- END,
- MARQUEE,
- @UnsupportedAppUsage
- END_SMALL
- }
-
- /**
- * EllipsizeCallback
- */
- public interface EllipsizeCallback {
- /**
- * This method is called to report that the specified region of
- * text was ellipsized away by a call to {@link #ellipsize}.
- */
- void ellipsized(int start, int end);
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/CharacterStyle.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/CharacterStyle.java
deleted file mode 100644
index 19be4be8..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/CharacterStyle.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.text.style;
-
-import android.text.TextPaint;
-
-/**
- * The classes that affect character-level text formatting extend this
- * class. Most extend its subclass {@link MetricAffectingSpan}, but simple
- * ones may just implement {@link UpdateAppearance}.
- */
-public abstract class CharacterStyle {
- abstract void updateDrawState(TextPaint tp);
-
- /**
- * A given CharacterStyle can only applied to a single region of a given
- * Spanned. If you need to attach the same CharacterStyle to multiple
- * regions, you can use this method to wrap it with a new object that
- * will have the same effect but be a distinct object so that it can
- * also be attached without conflict.
- */
- public static CharacterStyle wrap(CharacterStyle cs) {
- if (cs instanceof MetricAffectingSpan) {
- return new MetricAffectingSpan.Passthrough((MetricAffectingSpan) cs);
- } else {
- return new Passthrough(cs);
- }
- }
-
- /**
- * Returns "this" for most CharacterStyles, but for CharacterStyles
- * that were generated by {@link #wrap}, returns the underlying
- * CharacterStyle.
- */
- public CharacterStyle getUnderlying() {
- return this;
- }
-
- /**
- * A Passthrough CharacterStyle is one that
- * passes {@link #updateDrawState} calls through to the
- * specified CharacterStyle while still being a distinct object,
- * and is therefore able to be attached to the same Spannable
- * to which the specified CharacterStyle is already attached.
- */
- private static class Passthrough extends CharacterStyle {
- private CharacterStyle mStyle;
-
- /**
- * Creates a new Passthrough of the specfied CharacterStyle.
- */
- Passthrough(CharacterStyle cs) {
- mStyle = cs;
- }
-
- /**
- * Passes updateDrawState through to the underlying CharacterStyle.
- */
- @Override
- public void updateDrawState(TextPaint tp) {
- mStyle.updateDrawState(tp);
- }
-
- /**
- * Returns the CharacterStyle underlying this one, or the one
- * underlying it if it too is a Passthrough.
- */
- @Override
- public CharacterStyle getUnderlying() {
- return mStyle.getUnderlying();
- }
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/MetricAffectingSpan.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/MetricAffectingSpan.java
deleted file mode 100644
index 61b7947..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/MetricAffectingSpan.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.text.style;
-
-import android.annotation.NonNull;
-import android.text.TextPaint;
-
-/**
- * The classes that affect character-level text formatting in a way that
- * changes the width or height of characters extend this class.
- */
-public abstract class MetricAffectingSpan
- extends CharacterStyle
- implements UpdateLayout {
-
- /**
- * Classes that extend MetricAffectingSpan implement this method to update the text formatting
- * in a way that can change the width or height of characters.
- *
- * @param textPaint the paint used for drawing the text
- */
- public abstract void updateMeasureState(@NonNull TextPaint textPaint);
-
- /**
- * Returns "this" for most MetricAffectingSpans, but for
- * MetricAffectingSpans that were generated by {@link #wrap},
- * returns the underlying MetricAffectingSpan.
- */
- @Override
- public MetricAffectingSpan getUnderlying() {
- return this;
- }
-
- /**
- * A Passthrough MetricAffectingSpan is one that
- * passes {@link #updateDrawState} and {@link #updateMeasureState}
- * calls through to the specified MetricAffectingSpan
- * while still being a distinct object,
- * and is therefore able to be attached to the same Spannable
- * to which the specified MetricAffectingSpan is already attached.
- */
- /* package */ static class Passthrough extends MetricAffectingSpan {
- private MetricAffectingSpan mStyle;
-
- /**
- * Creates a new Passthrough of the specfied MetricAffectingSpan.
- */
- Passthrough(@NonNull MetricAffectingSpan cs) {
- mStyle = cs;
- }
-
- /**
- * Passes updateDrawState through to the underlying MetricAffectingSpan.
- */
- @Override
- public void updateDrawState(@NonNull TextPaint tp) {
- mStyle.updateDrawState(tp);
- }
-
- /**
- * Passes updateMeasureState through to the underlying MetricAffectingSpan.
- */
- @Override
- public void updateMeasureState(@NonNull TextPaint tp) {
- mStyle.updateMeasureState(tp);
- }
-
- /**
- * Returns the MetricAffectingSpan underlying this one, or the one
- * underlying it if it too is a Passthrough.
- */
- @Override
- public MetricAffectingSpan getUnderlying() {
- return mStyle.getUnderlying();
- }
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/ParagraphStyle.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/ParagraphStyle.java
deleted file mode 100644
index c213f96..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/ParagraphStyle.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.text.style;
-
-/**
- * The classes that affect paragraph-level text formatting implement
- * this interface.
- */
-public interface ParagraphStyle {
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/ReplacementSpan.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/ReplacementSpan.java
deleted file mode 100644
index e1b9ee1..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/ReplacementSpan.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.text.style;
-
-import android.annotation.IntRange;
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.text.TextPaint;
-
-/**
- * Replacement span.
- */
-public abstract class ReplacementSpan extends MetricAffectingSpan {
-
- /**
- * Returns the width of the span. Extending classes can set the height of the span by updating
- * attributes of {@link android.graphics.Paint.FontMetricsInt}. If the span covers the whole
- * text, and the height is not set,
- * {@link #draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)} will not be
- * called for the span.
- *
- * @param paint Paint instance.
- * @param text Current text.
- * @param start Start character index for span.
- * @param end End character index for span.
- * @param fm Font metrics, can be null.
- * @return Width of the span.
- */
- public abstract int getSize(@NonNull Paint paint, CharSequence text,
- @IntRange(from = 0) int start, @IntRange(from = 0) int end,
- @Nullable Paint.FontMetricsInt fm);
-
- /**
- * Draws the span into the canvas.
- *
- * @param canvas Canvas into which the span should be rendered.
- * @param text Current text.
- * @param start Start character index for span.
- * @param end End character index for span.
- * @param x Edge of the replacement closest to the leading margin.
- * @param top Top of the line.
- * @param y Baseline.
- * @param bottom Bottom of the line.
- * @param paint Paint instance.
- */
- public abstract void draw(@NonNull Canvas canvas, CharSequence text,
- @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x,
- int top, int y, int bottom, @NonNull Paint paint);
-
- /**
- * This method does nothing, since ReplacementSpans are measured
- * explicitly instead of affecting Paint properties.
- */
- public void updateMeasureState(TextPaint p) { }
-
- /**
- * This method does nothing, since ReplacementSpans are drawn
- * explicitly instead of affecting Paint properties.
- */
- public void updateDrawState(TextPaint ds) { }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UnderlineSpan.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UnderlineSpan.java
deleted file mode 100644
index 461028c..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UnderlineSpan.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.text.style;
-
-import android.annotation.NonNull;
-import android.text.TextPaint;
-
-/**
- * A span that underlines the text it's attached to.
- * <p>
- * The span can be used like this:
- * <pre>{@code
- * SpannableString string = new SpannableString("Text with underline span");
- *string.setSpan(new UnderlineSpan(), 10, 19, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);}</pre>
- * <img src="{@docRoot}reference/android/images/text/style/underlinespan.png" />
- * <figcaption>Underlined text.</figcaption>
- */
-public class UnderlineSpan extends CharacterStyle
- implements UpdateAppearance {
-
- /**
- * Creates an {@link UnderlineSpan}.
- */
- public UnderlineSpan() {
- }
-
-
- /**
- * Describes content.
- */
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- ds.setUnderlineText(true);
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UpdateAppearance.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UpdateAppearance.java
deleted file mode 100644
index 7112347..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UpdateAppearance.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2008 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.text.style;
-
-/**
- * The classes that affect character-level text in a way that modifies their
- * appearance when one is added or removed must implement this interface. Note
- * that if the class also impacts size or other metrics, it should instead
- * implement {@link UpdateLayout}.
- */
-public interface UpdateAppearance {
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UpdateLayout.java b/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UpdateLayout.java
deleted file mode 100644
index 591075e..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/java/android/text/style/UpdateLayout.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.text.style;
-
-/**
- * The classes that affect character-level text formatting in a way that
- * triggers a text layout update when one is added or removed must implement
- * this interface. This interface also includes {@link UpdateAppearance}
- * since such a change implicitly also impacts the appearance.
- */
-public interface UpdateLayout extends UpdateAppearance { }
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/BlurMaskFilter.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/BlurMaskFilter.kt
deleted file mode 100644
index fc5393f..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/BlurMaskFilter.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2020 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
-
-class BlurMaskFilter {
- enum class Blur {
- INNER,
- NORMAL,
- OUTER,
- SOLID
- }
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Canvas.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Canvas.kt
index fc1843e..bdcb8c59 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Canvas.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Canvas.kt
@@ -16,378 +16,6 @@
package android.graphics
-@Suppress("unused", "MemberVisibilityCanBePrivate")
-public class Canvas(private val _skijaCanvas: org.jetbrains.skija.Canvas? = null) {
- enum class VertexMode {
- TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN
- }
-
+class Canvas(private val _skijaCanvas: org.jetbrains.skija.Canvas? = null) {
val skijaCanvas: org.jetbrains.skija.Canvas get() = requireNotNull(_skijaCanvas)
-
- var skijaFont = org.jetbrains.skija.Font(Typeface.DEFAULT.skijaTypeface, 30f)
-
- fun translate(x: Float, y: Float) {
- skijaCanvas.translate(x, y)
- }
-
- fun scale(sx: Float, sy: Float) {
- skijaCanvas.scale(sx, sy)
- }
-
- fun scale(sx: Float, sy: Float, px: Float, py: Float) {
- translate(px, py)
- skijaCanvas.scale(sx, sy)
- translate(-px, -py)
- }
-
- fun rotate(degrees: Float) {
- skijaCanvas.rotate(degrees)
- }
-
- fun rotate(degrees: Float, px: Float, py: Float) {
- translate(px, py)
- skijaCanvas.rotate(degrees)
- translate(-px, -py)
- }
-
- fun skew(sx: Float, sy: Float) {
- skijaCanvas.skew(sx, sy)
- }
-
- fun concat(matrix: Matrix) {
- skijaCanvas.concat(matrix.skija)
- }
-
- fun drawLine(
- startX: Float,
- startY: Float,
- stopX: Float,
- stopY: Float,
- paint: Paint
- ) {
- skijaCanvas.drawLine(
- startX,
- startY,
- stopX,
- stopY,
- paint.skijaPaint
- )
- }
-
- fun drawBitmap(
- bitmap: Bitmap,
- left: Float,
- top: Float,
- paint: Paint
- ) {
- skijaCanvas.drawImage(bitmap.skiaImage, left, top, paint.skijaPaint)
- }
-
- fun drawBitmap(
- bitmap: Bitmap,
- src: Rect?,
- dst: RectF,
- paint: Paint
- ) {
- val skijaDst = dst.toSkia()
- val skijaSrc = src?.toSkia()
- skijaCanvas.drawImageRect(bitmap.skiaImage, skijaSrc, skijaDst, paint.skijaPaint)
- }
-
- fun drawBitmap(
- bitmap: Bitmap,
- src: Rect?,
- dst: Rect,
- paint: Paint
- ) {
- val skijaDst = dst.toSkia()
- val skijaSrc = src?.toSkia()
- skijaCanvas.drawImageRect(bitmap.skiaImage, skijaSrc, skijaDst, paint.skijaPaint)
- }
-
- fun drawBitmap(
- bitmap: Bitmap,
- matrix: Matrix,
- paint: Paint
- ) {
- save()
- concat(matrix)
- skijaCanvas.drawImage(bitmap.skiaImage, 0f, 0f, paint.skijaPaint)
- restore()
- }
-
- fun drawRect(rect: RectF, paint: Paint) {
- val skijaRect = rect.toSkia()
- skijaCanvas.drawRect(skijaRect, paint.skijaPaint)
- }
-
- fun drawRect(r: Rect, paint: Paint) {
- drawRect(r.left.toFloat(), r.top.toFloat(), r.right.toFloat(), r.bottom.toFloat(), paint)
- }
-
- fun drawRect(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- paint: Paint
- ) {
- val skijaRect = org.jetbrains.skija.Rect.makeLTRB(left, top, right, bottom)
- skijaCanvas.drawRect(skijaRect, paint.skijaPaint)
- }
-
- fun drawArc(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- startAngle: Float,
- sweepAngle: Float,
- useCenter: Boolean,
- paint: Paint
- ) {
- skijaCanvas.drawArc(
- left,
- top,
- right,
- bottom,
- startAngle,
- sweepAngle,
- useCenter,
- paint.skijaPaint
- )
- }
-
- fun drawArc(
- oval: RectF,
- startAngle: Float,
- sweepAngle: Float,
- useCenter: Boolean,
- paint: Paint
- ) {
- skijaCanvas.drawArc(
- oval.left,
- oval.top,
- oval.right,
- oval.bottom,
- startAngle,
- sweepAngle,
- useCenter,
- paint.skijaPaint
- )
- }
-
- fun drawText(
- text: CharArray,
- index: Int,
- count: Int,
- x: Float,
- y: Float,
- paint: Paint
- ) {
- drawText(String(text, index, count), x, y, paint)
- }
-
- fun drawText(
- text: String,
- x: Float,
- y: Float,
- paint: Paint
- ) {
- drawText(text, 0, text.length, x, y, paint)
- }
-
- fun drawText(
- text: String,
- start: Int,
- end: Int,
- x: Float,
- y: Float,
- paint: Paint
- ) {
- drawText(text, start, end, x, y, paint)
- }
-
- fun drawText(
- text: CharSequence,
- start: Int,
- end: Int,
- x: Float,
- y: Float,
- paint: Paint
- ) {
- val typeface = paint.getTypeface() ?: Typeface.DEFAULT
- val skijaFont = org.jetbrains.skija.Font(typeface.skijaTypeface, paint.textSize)
- skijaCanvas.drawString(text.substring(start, end), x, y, skijaFont, paint.skijaPaint)
- }
-
- fun drawRoundRect(
- rect: RectF,
- rx: Float,
- ry: Float,
- paint: Paint
- ) {
- drawRoundRect(rect.left, rect.top, rect.right, rect.bottom, rx, ry, paint)
- }
-
- fun drawRoundRect(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- rx: Float,
- ry: Float,
- paint: Paint
- ) {
- val skijaRoundedRect = org.jetbrains.skija.RRect.makeLTRB(left, top, right, bottom, rx, ry)
- skijaCanvas.drawRRect(skijaRoundedRect, paint.skijaPaint)
- }
-
- fun drawPath(path: Path, paint: Paint) {
- skijaCanvas.drawPath(path.skijaPath, paint.skijaPaint)
- }
-
- fun drawCircle(
- cx: Float,
- cy: Float,
- radius: Float,
- paint: Paint
- ) {
- skijaCanvas.drawCircle(cx, cy, radius, paint.skijaPaint)
- }
-
- fun clipRect(rect: Rect, op: Region.Op): Boolean {
- val skijaRect = rect.toSkia()
- skijaCanvas.clipRect(skijaRect, op.skija)
- return true
- }
-
- fun clipRect(rect: RectF): Boolean {
- val skijaRect = rect.toSkia()
- skijaCanvas.clipRect(skijaRect)
- return true
- }
-
- fun clipRect(rect: Rect): Boolean {
- val skijaRect = rect.toSkia()
- skijaCanvas.clipRect(skijaRect)
- return true
- }
-
- fun clipRect(left: Float, top: Float, right: Float, bottom: Float, op: Region.Op): Boolean {
- val skijaRect = org.jetbrains.skija.Rect.makeLTRB(left, top, right, bottom)
- skijaCanvas.clipRect(skijaRect, op.skija)
- return true
- }
-
- fun clipRect(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float
- ): Boolean {
- val skijaRect = org.jetbrains.skija.Rect.makeLTRB(left, top, right, bottom)
- skijaCanvas.clipRect(skijaRect)
- return true
- }
-
- fun clipRect(
- left: Int,
- top: Int,
- right: Int,
- bottom: Int
- ): Boolean {
- return clipRect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
- }
-
- fun clipPath(path: Path, op: Region.Op): Boolean {
- skijaCanvas.clipPath(path.skijaPath, op.skija)
- return true
- }
-
- fun clipPath(path: Path) {
- skijaCanvas.clipPath(path.skijaPath)
- }
-
- fun drawColor(color: Int) {
- skijaCanvas.drawPaint(org.jetbrains.skija.Paint().apply {
- setColor(color)
- })
- }
-
- fun drawOval(oval: RectF, paint: Paint) {
- drawOval(oval.left, oval.top, oval.right, oval.bottom, paint)
- }
-
- fun drawOval(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- paint: Paint
- ) {
- skijaCanvas.drawOval(
- org.jetbrains.skija.Rect.makeLTRB(left, top, right, bottom),
- paint.skijaPaint
- )
- }
-
- fun drawPaint(paint: Paint) {
- skijaCanvas.drawPaint(paint.skijaPaint)
- }
-
- fun drawPoint(
- x: Float,
- y: Float,
- paint: Paint
- ) {
- skijaCanvas.drawPoint(x, y, paint.skijaPaint)
- }
-
- fun drawVertices(
- mode: VertexMode,
- vertexCount: Int,
- verts: FloatArray,
- vertOffset: Int,
- texs: FloatArray,
- texOffset: Int,
- colors: IntArray,
- colorOffset: Int,
- indices: ShortArray,
- indexOffset: Int,
- indexCount: Int,
- paint: Paint
- ) {
- println("Canvas.drawVertices not implemented yet")
- }
-
- fun save(): Int {
- return skijaCanvas.save()
- }
-
- fun restore() {
- skijaCanvas.restore()
- }
-
- @Suppress("UNUSED_PARAMETER")
- fun saveLayer(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- paint: Paint,
- saveFlags: Int
- ): Int {
- return skijaCanvas.saveLayer(left, top, right, bottom, paint.skijaPaint)
- }
-
- fun saveLayer(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- paint: Paint
- ): Int {
- return skijaCanvas.saveLayer(left, top, right, bottom, paint.skijaPaint)
- }
-}
+}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/ColorFilter.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/ColorFilter.kt
deleted file mode 100644
index 33d4f64..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/ColorFilter.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2020 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
-
-open class ColorFilter
-
-data class PorterDuffColorFilter(val color: Int, val mode: PorterDuff.Mode) : ColorFilter()
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Paint.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Paint.kt
index 4ea8cf2..9a05c59 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Paint.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Paint.kt
@@ -16,204 +16,6 @@
package android.graphics
-import org.jetbrains.skija.FilterQuality
-
-@Suppress("unused")
-open class Paint {
- enum class Style(val skija: org.jetbrains.skija.PaintMode) {
- FILL(org.jetbrains.skija.PaintMode.FILL),
- FILL_AND_STROKE(org.jetbrains.skija.PaintMode.STROKE_AND_FILL),
- STROKE(org.jetbrains.skija.PaintMode.STROKE)
- }
-
- enum class Cap(val skija: org.jetbrains.skija.PaintStrokeCap) {
- BUTT(org.jetbrains.skija.PaintStrokeCap.BUTT),
- ROUND(org.jetbrains.skija.PaintStrokeCap.ROUND),
- SQUARE(org.jetbrains.skija.PaintStrokeCap.SQUARE)
- }
-
- enum class Join(val skija: org.jetbrains.skija.PaintStrokeJoin) {
- BEVEL(org.jetbrains.skija.PaintStrokeJoin.BEVEL),
- MITER(org.jetbrains.skija.PaintStrokeJoin.MITER),
- ROUND((org.jetbrains.skija.PaintStrokeJoin.ROUND))
- }
-
- open class FontMetricsInt {
- @JvmField
- var top: Int = 0
- @JvmField
- var ascent: Int = 0
- @JvmField
- var descent: Int = 0
- @JvmField
- var bottom: Int = 0
- @JvmField
- var leading: Int = 0
-
- override fun toString(): String {
- return "FontMetricsInt: top=" + top + " ascent=" + ascent +
- " descent=" + descent + " bottom=" + bottom +
- " leading=" + leading
- }
- }
-
- companion object {
- const val ANTI_ALIAS_FLAG = 1
- const val FILTER_BITMAP_FLAG = 2
- }
-
+class Paint {
val skijaPaint = org.jetbrains.skija.Paint()
-
- constructor()
-
- constructor(flags: Int) {
- if (flags and ANTI_ALIAS_FLAG == ANTI_ALIAS_FLAG) {
- isAntiAlias = true
- }
- if (flags and FILTER_BITMAP_FLAG == FILTER_BITMAP_FLAG) {
- isFilterBitmap = true
- }
- }
-
- var color: Int
- get() = skijaPaint.getColor()
- set(value) {
- skijaPaint.setColor(value)
- }
- var strokeWidth: Float
- get() = skijaPaint.getStrokeWidth()
- set(value) {
- skijaPaint.setStrokeWidth(value)
- }
- var style: Style
- get() = Style.values().first { it.skija == skijaPaint.getMode() }
- set(value) {
- skijaPaint.setMode(value.skija)
- }
- var strokeCap: Cap
- get() = Cap.values().first { it.skija == skijaPaint.getStrokeCap() }
- set(value) {
- skijaPaint.setStrokeCap(value.skija)
- }
- var strokeMiter: Float
- get() = skijaPaint.getStrokeMiter().toFloat()
- set(value) {
- skijaPaint.setStrokeMiter(value)
- }
- var strokeJoin: Join
- get() = Join.values().first { it.skija == skijaPaint.getStrokeJoin() }
- set(value) {
- skijaPaint.setStrokeJoin(value.skija)
- }
- var isAntiAlias: Boolean
- get() = skijaPaint.isAntiAlias()
- set(value) {
- skijaPaint.setAntiAlias(value)
- }
- var isFilterBitmap: Boolean
- get() = skijaPaint.filterQuality != FilterQuality.NONE
- set(value) {
- skijaPaint.filterQuality = if (value) {
- FilterQuality.LOW
- } else {
- FilterQuality.NONE
- }
- }
-
- var alpha: Int
- get() = (color shr 24) and 0xff
- set(value) {
- color = (value shl 24) or (color and 0x00ffffff)
- }
-
- var textSize: Float = 20f
-
- private var typeface: Typeface? = null
- fun getTypeface(): Typeface? = typeface
- fun setTypeface(typeface: Typeface?): Typeface? {
- this.typeface = typeface
- return typeface
- }
-
- private var xfermode: Xfermode? = null
- fun getXfermode(): Xfermode? = xfermode
- fun setXfermode(xfermode: Xfermode?): Xfermode? {
- xfermode as PorterDuffXfermode?
- this.xfermode = xfermode
- skijaPaint.blendMode = xfermode?.mode?.toSkia()
- return xfermode
- }
-
- private var colorFilter: ColorFilter? = null
- fun getColorFilter(): ColorFilter? = colorFilter
- fun setColorFilter(colorFilter: ColorFilter?): ColorFilter? {
- colorFilter as PorterDuffColorFilter?
- this.colorFilter = colorFilter
- if (colorFilter != null) {
- skijaPaint.colorFilter = org.jetbrains.skija.ColorFilter.makeBlend(
- colorFilter.color, colorFilter.mode.toSkia()
- )
- } else {
- skijaPaint.colorFilter = null
- }
- return colorFilter
- }
-
- private var shader: Shader? = null
- fun getShader(): Shader? = shader
- fun setShader(shader: Shader?): Shader? {
- this.shader = shader
- skijaPaint.shader = shader?.skija
- return shader
- }
-
- private var pathEffect: PathEffect? = null
- fun getPathEffect(): PathEffect? = pathEffect
- fun setPathEffect(pathEffect: PathEffect?): PathEffect? {
- this.pathEffect = pathEffect
- skijaPaint.pathEffect = pathEffect?.skija
- return pathEffect
- }
-
- var textLocale: java.util.Locale = java.util.Locale.getDefault()
- set(value) {
- field = value
- println("Paint.textLocale not implemented yet")
- }
-
- var fontFeatureSettings: String? = null
- set(value) {
- field = value
- println("Paint.fontFeatureSettings not implemented yet")
- }
-
- var textScaleX: Float = 1f
- set(value) {
- field = value
- println("Paint.textScaleX not implemented yet")
- }
- var textSkewX: Float = 1f
- set(value) {
- field = value
- println("Paint.textSkewX not implemented yet")
- }
- var letterSpacing: Float = 0f
- set(value) {
- field = value
- println("Paint.letterSpacing not implemented yet")
- }
- var underlineText: Boolean = false
- set(value) {
- field = value
- println("Paint.underlineText not implemented yet")
- }
- var strikeThruText: Boolean = false
- set(value) {
- field = value
- println("Paint.strikeThruText not implemented yet")
- }
-
- fun setShadowLayer(radius: Float, dx: Float, dy: Float, shadowColor: Int) {
- println("Paint.setShadowLayer not implemented yet")
- }
-}
+}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Path.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Path.kt
index 90f3c59..61cdafe 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Path.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Path.kt
@@ -16,212 +16,6 @@
package android.graphics
-@Suppress("unused", "MemberVisibilityCanBePrivate")
class Path {
- enum class Op {
- DIFFERENCE, INTERSECT, UNION, XOR, REVERSE_DIFFERENCE
- }
-
- enum class FillType {
- WINDING, EVEN_ODD, INVERSE_WINDING, INVERSE_EVEN_ODD
- }
-
- enum class Direction(val skija: org.jetbrains.skija.PathDirection) {
- @JvmStatic
- CW(org.jetbrains.skija.PathDirection.CLOCKWISE),
- @JvmStatic
- CCW(org.jetbrains.skija.PathDirection.COUNTER_CLOCKWISE)
- }
-
val skijaPath = org.jetbrains.skija.Path()
-
- var fillType: FillType = FillType.WINDING
- set(value) {
- field = value
- skijaPath.fillMode = value.toSkia()
- }
-
- fun moveTo(x: Float, y: Float) {
- skijaPath.moveTo(x, y)
- }
-
- fun rMoveTo(dx: Float, dy: Float) {
- skijaPath.rMoveTo(dx, dy)
- }
-
- fun lineTo(x: Float, y: Float) {
- skijaPath.lineTo(x, y)
- }
-
- fun rLineTo(dx: Float, dy: Float) {
- skijaPath.rLineTo(dx, dy)
- }
-
- fun quadTo(x1: Float, y1: Float, x2: Float, y2: Float) {
- skijaPath.quadTo(x1, y1, x2, y2)
- }
-
- fun rQuadTo(dx1: Float, dy1: Float, dx2: Float, dy2: Float) {
- skijaPath.rQuadTo(dx1, dy1, dx2, dy2)
- }
-
- fun cubicTo(x1: Float, y1: Float, x2: Float, y2: Float, x3: Float, y3: Float) {
- skijaPath.cubicTo(x1, y1, x2, y2, x3, y3)
- }
-
- fun rCubicTo(dx1: Float, dy1: Float, dx2: Float, dy2: Float, dx3: Float, dy3: Float) {
- skijaPath.rCubicTo(dx1, dy1, dx2, dy2, dx3, dy3)
- }
-
- fun arcTo(
- oval: RectF,
- startAngle: Float,
- sweepAngle: Float,
- forceMoveTo: Boolean
- ) {
- skijaPath.arcTo(oval.toSkia(), startAngle, sweepAngle, forceMoveTo)
- }
-
- fun arcTo(
- oval: RectF,
- startAngle: Float,
- sweepAngle: Float
- ) {
- arcTo(oval, startAngle, sweepAngle, forceMoveTo = false)
- }
-
- fun arcTo(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- startAngle: Float,
- sweepAngle: Float,
- forceMoveTo: Boolean
- ) {
- arcTo(RectF(left, top, right, bottom), startAngle, sweepAngle, forceMoveTo)
- }
-
- fun addRect(rect: RectF, dir: Direction) {
- skijaPath.addRect(rect.toSkia(), dir.skija)
- }
-
- fun addRect(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- dir: Direction
- ) {
- addRect(RectF(left, top, right, bottom), dir)
- }
-
- fun addOval(oval: RectF, dir: Direction) {
- skijaPath.addOval(oval.toSkia(), dir.skija)
- }
-
- fun addOval(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- dir: Direction
- ) {
- addOval(RectF(left, top, right, bottom), dir)
- }
-
- fun addArc(oval: RectF, startAngle: Float, sweepAngle: Float) {
- skijaPath.addArc(oval.toSkia(), startAngle, sweepAngle)
- }
-
- fun addArc(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- startAngle: Float,
- sweepAngle: Float
- ) {
- addArc(RectF(left, top, right, bottom), startAngle, sweepAngle)
- }
-
- fun addRoundRect(
- left: Float,
- top: Float,
- right: Float,
- bottom: Float,
- rx: Float,
- ry: Float,
- dir: Direction
- ) {
- skijaPath.addRRect(org.jetbrains.skija.RRect.makeLTRB(
- left, top, right, bottom, rx, ry), dir.skija)
- }
-
- fun addRoundRect(
- rect: RectF,
- radii: FloatArray,
- dir: Direction
- ) {
- skijaPath.addRRect(org.jetbrains.skija.RRect.makeComplexLTRB(
- rect.left, rect.top, rect.right, rect.bottom, radii), dir.skija)
- }
-
- fun addPath(src: Path, dx: Float, dy: Float) {
- skijaPath.addPath(src.skijaPath, dx, dy)
- }
-
- fun addPath(src: Path) {
- skijaPath.addPath(src.skijaPath)
- }
-
- fun addPath(src: Path, matrix: Matrix) {
- skijaPath.addPath(src.skijaPath, matrix.skija)
- }
-
- fun close() {
- skijaPath.closePath()
- }
-
- fun reset() {
- skijaPath.reset()
- }
-
- fun transform(matrix: Matrix, dst: Path?) {
- skijaPath.transform(matrix.skija, dst?.skijaPath)
- }
-
- fun transform(matrix: Matrix) {
- skijaPath.transform(matrix.skija)
- }
-
- @Suppress("UNUSED_PARAMETER")
- fun computeBounds(bounds: RectF, exact: Boolean) {
- val skijaBounds = skijaPath.bounds
- bounds.left = skijaBounds.left
- bounds.top = skijaBounds.top
- bounds.right = skijaBounds.right
- bounds.bottom = skijaBounds.bottom
- }
-
- fun op(path: Path, op: Op): Boolean {
- println("Canvas.op not implemented yet")
- return false
- }
-
- fun op(path1: Path, path2: Path, op: Op): Boolean {
- println("Canvas.op not implemented yet")
- return false
- }
-
- fun isConvex(): Boolean = skijaPath.isConvex
-
- fun isEmpty(): Boolean = skijaPath.isEmpty
-}
-
-internal fun Path.FillType.toSkia() = when (this) {
- Path.FillType.WINDING -> org.jetbrains.skija.PathFillMode.WINDING
- Path.FillType.EVEN_ODD -> org.jetbrains.skija.PathFillMode.EVEN_ODD
- Path.FillType.INVERSE_WINDING -> org.jetbrains.skija.PathFillMode.INVERSE_WINDING
- Path.FillType.INVERSE_EVEN_ODD -> org.jetbrains.skija.PathFillMode.INVERSE_EVEN_ODD
-}
+}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/PorterDuff.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/PorterDuff.kt
deleted file mode 100644
index 0cf5816..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/PorterDuff.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2020 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 org.jetbrains.skija.BlendMode
-
-@Suppress("unused")
-class PorterDuff {
- enum class Mode {
- ADD,
- CLEAR,
- DARKEN,
- DST,
- DST_ATOP,
- DST_IN,
- DST_OUT,
- DST_OVER,
- LIGHTEN,
- MULTIPLY,
- OVERLAY,
- SCREEN,
- SRC,
- SRC_ATOP,
- SRC_IN,
- SRC_OUT,
- SRC_OVER,
- XOR
- }
-}
-
-internal fun PorterDuff.Mode.toSkia() = when (this) {
- PorterDuff.Mode.ADD -> BlendMode.PLUS
- PorterDuff.Mode.CLEAR -> BlendMode.CLEAR
- PorterDuff.Mode.DARKEN -> BlendMode.DARKEN
- PorterDuff.Mode.DST -> BlendMode.DST
- PorterDuff.Mode.DST_ATOP -> BlendMode.DST_ATOP
- PorterDuff.Mode.DST_IN -> BlendMode.DST_IN
- PorterDuff.Mode.DST_OUT -> BlendMode.DST_OUT
- PorterDuff.Mode.DST_OVER -> BlendMode.DST_OVER
- PorterDuff.Mode.LIGHTEN -> BlendMode.LIGHTEN
- PorterDuff.Mode.MULTIPLY -> BlendMode.MULTIPLY
- PorterDuff.Mode.OVERLAY -> BlendMode.OVERLAY
- PorterDuff.Mode.SCREEN -> BlendMode.SCREEN
- PorterDuff.Mode.SRC -> BlendMode.SRC
- PorterDuff.Mode.SRC_ATOP -> BlendMode.SRC_ATOP
- PorterDuff.Mode.SRC_IN -> BlendMode.SRC_IN
- PorterDuff.Mode.SRC_OUT -> BlendMode.SRC_OUT
- PorterDuff.Mode.SRC_OVER -> BlendMode.SRC_OVER
- PorterDuff.Mode.XOR -> BlendMode.XOR
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Rect.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Rect.kt
index 0cae1f2..cf4f260 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Rect.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Rect.kt
@@ -16,8 +16,6 @@
package android.graphics
-import org.jetbrains.skija.Rect as SkRect
-
class Rect(
@kotlin.jvm.JvmField
var left: Int,
@@ -36,7 +34,4 @@
this.right = right
this.bottom = bottom
}
-}
-
-internal fun Rect.toSkia() =
- SkRect.makeLTRB(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
+}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/RectF.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/RectF.kt
index 2849bea..16d220f 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/RectF.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/RectF.kt
@@ -16,8 +16,6 @@
package android.graphics
-import org.jetbrains.skija.Rect as SkRect
-
class RectF(
@kotlin.jvm.JvmField
var left: Float,
@@ -50,7 +48,4 @@
this.right = src.right.toFloat()
this.bottom = src.bottom.toFloat()
}
-}
-
-internal fun RectF.toSkia() =
- SkRect.makeLTRB(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Region.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Region.kt
deleted file mode 100644
index 2c703d8..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Region.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2020 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
-
-class Region {
- enum class Op(internal val skija: org.jetbrains.skija.ClipMode) {
- DIFFERENCE(org.jetbrains.skija.ClipMode.DIFFERENCE),
- INTERSECT(org.jetbrains.skija.ClipMode.INTERSECT)
- }
-}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Shader.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Shader.kt
index c4a6510..27208a0 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Shader.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Shader.kt
@@ -15,105 +15,5 @@
*/
package android.graphics
-import org.jetbrains.skija.FilterTileMode
-import org.jetbrains.skija.GradientStyle
-
@Suppress("unused")
-open class Shader(val skija: org.jetbrains.skija.Shader? = null) {
- enum class TileMode(val skija: FilterTileMode) {
- CLAMP(FilterTileMode.CLAMP),
- REPEAT(FilterTileMode.REPEAT),
- MIRROR(FilterTileMode.MIRROR)
- }
-}
-
-@Suppress("unused")
-class LinearGradient(skija: org.jetbrains.skija.Shader) : Shader(skija) {
- constructor(
- x0: Float,
- y0: Float,
- x1: Float,
- y1: Float,
- colors: IntArray,
- positions: FloatArray?,
- tile: TileMode
- ) : this(
- org.jetbrains.skija.Shader.makeLinearGradient(
- x0, y0, x1, y1, colors, positions,
- GradientStyle(tile.skija, true, Matrix().skija)
- )
- )
-
- constructor(
- x0: Float,
- y0: Float,
- x1: Float,
- y1: Float,
- color0: Int,
- color1: Int,
- tile: TileMode
- ) : this(
- org.jetbrains.skija.Shader.makeLinearGradient(
- x0, y0, x1, y1, intArrayOf(color0, color1), null,
- GradientStyle(tile.skija, true, Matrix().skija)
- )
- )
-}
-
-@Suppress("unused")
-class SweepGradient(skija: org.jetbrains.skija.Shader) : Shader(skija) {
- constructor(
- cx: Float,
- cy: Float,
- colors: IntArray,
- positions: FloatArray?
- ) : this(
- org.jetbrains.skija.Shader.makeSweepGradient(cx, cy, colors, positions)
- )
-
- constructor(cx: Float, cy: Float, color0: Int, color1: Int) : this(
- org.jetbrains.skija.Shader.makeSweepGradient(cx, cy, intArrayOf(color0, color1), null)
- )
-}
-
-@Suppress("unused")
-class RadialGradient(skija: org.jetbrains.skija.Shader) : Shader(skija) {
- constructor(
- centerX: Float,
- centerY: Float,
- radius: Float,
- colors: IntArray,
- stops: FloatArray?,
- tileMode: TileMode
- ) : this(
- org.jetbrains.skija.Shader.makeRadialGradient(
- centerX, centerY, radius, colors, stops,
- GradientStyle(tileMode.skija, true, Matrix().skija)
- )
- )
-
- constructor(
- centerX: Float,
- centerY: Float,
- radius: Float,
- centerColor: Int,
- edgeColor: Int,
- tileMode: TileMode
- ) : this(
- org.jetbrains.skija.Shader.makeRadialGradient(
- centerX, centerY, radius, intArrayOf(centerColor, edgeColor), null,
- GradientStyle(tileMode.skija, true, Matrix().skija)
- )
- )
-}
-
-@Suppress("unused")
-class BitmapShader(
- bitmap: Bitmap,
- tileX: TileMode,
- tileY: TileMode
-) : Shader(null) {
- init {
- println("BitmapShader not implemented yet")
- }
-}
\ No newline at end of file
+class Shader(val skija: org.jetbrains.skija.Shader? = null)
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Typeface.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Typeface.kt
deleted file mode 100644
index 09cb6dc..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Typeface.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2020 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 java.io.File
-import java.nio.file.Files
-import java.nio.file.StandardCopyOption
-
-private const val NORMAL_FONT_NAME = "NotoSans-Regular"
-private const val BOLD_FONT_NAME = "NotoSans-Bold"
-private const val ITALIC_FONT_NAME = "NotoSans-Italic"
-private const val BOLD_ITALIC_FONT_NAME = "NotoSans-BoldItalic"
-
-class Typeface(internal val skijaTypeface: org.jetbrains.skija.Typeface) {
- companion object {
- // TODO: Skija should make it possible to make fonts from non-file in-memory source
- val NORMAL_TYPEFACE = Typeface(org.jetbrains.skija.Typeface.makeFromFile(
- getFontPathAsString(NORMAL_FONT_NAME)))
- val BOLD_TYPEFACE = Typeface(org.jetbrains.skija.Typeface.makeFromFile(
- getFontPathAsString(BOLD_FONT_NAME)))
- val ITALIC_TYPEFACE = Typeface(org.jetbrains.skija.Typeface.makeFromFile(
- getFontPathAsString(ITALIC_FONT_NAME)))
- val BOLD_ITALIC_TYPEFACE = Typeface(org.jetbrains.skija.Typeface.makeFromFile(
- getFontPathAsString(BOLD_ITALIC_FONT_NAME)))
-
- @JvmField
- val DEFAULT = NORMAL_TYPEFACE
-
- @JvmField
- val NORMAL = 0x0
-
- @JvmField
- val BOLD = 0x1
-
- @JvmField
- val ITALIC = 0x2
-
- @JvmField
- val BOLD_ITALIC = 0x3
-
- @JvmStatic
- fun defaultFromStyle(style: Int): Typeface = when (style) {
- BOLD -> BOLD_TYPEFACE
- ITALIC -> ITALIC_TYPEFACE
- BOLD_ITALIC -> BOLD_ITALIC_TYPEFACE
- else -> DEFAULT
- }
- }
-}
-
-fun getFontPathAsString(font: String): String {
- val tempDir = File(System.getProperty("java.io.tmpdir"), "compose").apply {
- mkdirs()
- deleteOnExit()
- }
- val tempFile = File(tempDir, "$font.ttf").apply {
- deleteOnExit()
- }
- val stream = Typeface::class.java.getClassLoader().getResourceAsStream("$font.ttf")
- if (stream == null) throw Error("Cannoty find font $font")
- Files.copy(stream, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
- return tempFile.absolutePath
-}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Xfermode.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Xfermode.kt
deleted file mode 100644
index 5b6ce3a..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/graphics/Xfermode.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2020 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
-
-open class Xfermode
-
-class PorterDuffXfermode(val mode: PorterDuff.Mode) : Xfermode()
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/Layout.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/Layout.kt
deleted file mode 100644
index 6b02cc2..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/Layout.kt
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2020 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.text
-
-import android.graphics.Canvas
-import android.graphics.Paint
-import android.graphics.Path
-import android.compat.annotation.UnsupportedAppUsage
-
-open class Layout(
- var mText: CharSequence,
- paint: TextPaint,
- width: Int,
- align: Alignment,
- spacingmult: Float,
- spacingadd: Float
-) {
- enum class Alignment {
- ALIGN_NORMAL,
- ALIGN_OPPOSITE,
- ALIGN_CENTER,
- /** @hide */
- @UnsupportedAppUsage
- ALIGN_LEFT,
- /** @hide */
- @UnsupportedAppUsage
- ALIGN_RIGHT,
- }
-
- class Directions(val mDirections: IntArray)
-
- class TabStops(val increment: Float, val spans: Array<Any>)
-
- companion object {
- @JvmStatic
- fun getDesiredWidth(source: CharSequence, start: Int, end: Int, paint: TextPaint): Float {
- return minOf(end - start + 1, source.length) * 1f
- }
-
- @JvmField
- val DIR_LEFT_TO_RIGHT = 1
-
- @JvmField
- val DIR_RIGHT_TO_LEFT = -1
-
- @JvmField
- val RUN_LENGTH_MASK = 0x03ffffff
-
- @JvmField
- val RUN_LEVEL_SHIFT = 26
-
- @JvmField
- val RUN_RTL_FLAG = 1 shl RUN_LEVEL_SHIFT
-
- @JvmField
- val DIRS_ALL_LEFT_TO_RIGHT = Directions(intArrayOf(0, RUN_LENGTH_MASK))
-
- @JvmField
- val DIRS_ALL_RIGHT_TO_LEFT = Directions(intArrayOf(0, RUN_LENGTH_MASK or RUN_RTL_FLAG))
- }
-
- fun replaceWith(
- text: CharSequence,
- paint: TextPaint,
- width: Int,
- align: Alignment,
- spacingmult: Float,
- spacingadd: Float
- ) {
- println("Layout.replaceWith")
- mText = text
- }
-
- fun getText(): CharSequence = mText
-
- open fun getHeight(): Int {
- return 0
- }
-
- open fun getLineCount(): Int {
- return 1
- }
-
- open fun getLineTop(line: Int): Int {
- return 0
- }
-
- open fun getLineBottom(line: Int): Int {
- return 0
- }
- open fun getLineDescent(line: Int): Int {
- return 0
- }
-
- open fun getLineStart(line: Int): Int {
- return 0
- }
-
- open fun getLineEnd(line: Int): Int {
- return mText.length
- }
-
- open fun getParagraphDirection(line: Int): Int {
- return DIR_LEFT_TO_RIGHT
- }
-
- open fun getLineContainsTab(line: Int): Boolean {
- return false
- }
-
- open fun getLineMax(line: Int): Float {
- return 0f
- }
-
- open fun getLineForOffset(offset: Int): Int {
- return 0
- }
-
- open fun getLineWidth(line: Int): Float {
- return 0f
- }
-
- open fun getLineDirections(line: Int): Directions {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT
- }
-
- open fun getTopPadding(): Int {
- return 0
- }
-
- open fun getBottomPadding(): Int {
- return 0
- }
-
- open fun getEllipsisCount(line: Int): Int {
- return 0
- }
-
- open fun getEllipsisStart(line: Int): Int {
- return 0
- }
-
- open fun getEllipsizedWidth(): Int {
- return 0
- }
-
- open fun getPrimaryHorizontal(offset: Int): Float {
- return 0f
- }
-
- open fun draw(c: Canvas) {
- // println("Layout.draw1: $mText")
- draw(c, null, null, 0)
- }
-
- open fun draw(canvas: Canvas, highlight: Path?, highlightpaint: Paint?, cursorOffset: Int) {
- // println("Layout.draw2")
- drawText(canvas, 0, 1)
- }
-
- fun drawText(canvas: Canvas, firstLine: Int, lastLine: Int) {
- // println("Layout.drawText: $firstLine .. $lastLine")
- canvas.drawText(mText, 0, mText.length, 0.5f, 0.5f, mWorkPaint)
- }
-
- fun getLineBaseline(line: Int): Int {
- return getLineTop(line + 1) - getLineDescent(line)
- }
-
- val mWorkPaint = TextPaint(0)
-}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/StaticLayout.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/StaticLayout.kt
deleted file mode 100644
index 2e5cfeb..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/StaticLayout.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2020 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.text
-
-class StaticLayout(
- text: CharSequence,
- paint: TextPaint,
- width: Int,
- align: Alignment,
- spacingmult: Float,
- spacingadd: Float
-) : Layout(text, paint, width, align, spacingmult, spacingadd) {
-
- constructor(
- source: CharSequence,
- bufstart: Int,
- bufend: Int,
- paint: TextPaint,
- outerwidth: Int,
- align: Alignment,
- spacingmult: Float,
- spacingadd: Float,
- includepad: Boolean,
- ellipsize: TextUtils.TruncateAt?,
- ellipsizedWidth: Int
- ) : this(source, paint, bufend - bufstart, align, spacingmult, spacingadd)
-}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/TextLine.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/TextLine.kt
deleted file mode 100644
index 127a50c..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/TextLine.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2020 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.text
-
-import android.graphics.Paint.FontMetricsInt
-import android.text.Layout.Directions
-import android.text.Layout.TabStops
-
-class TextLine() {
- var mText: CharSequence = ""
- var mLen = 0
-
- companion object {
- @JvmStatic
- fun obtain(): TextLine = TextLine()
-
- @JvmStatic
- fun recycle(line: TextLine) {
- }
- }
-
- fun metrics(fmi: FontMetricsInt): Float {
- println("TextLine.metrics")
- return mLen * 1f
- }
-
- fun set(
- paint: TextPaint,
- text: CharSequence,
- start: Int,
- limit: Int,
- dir: Int,
- directions: Directions,
- hasTabs: Boolean,
- tabStops: TabStops?,
- ellipsisStart: Int,
- ellipsisEnd: Int
- ) {
- println("TextLine.set")
- mText = text
- mLen = limit - start
- }
-}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/TextPaint.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/TextPaint.kt
deleted file mode 100644
index 7560a27..0000000
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/text/TextPaint.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2020 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.text
-
-import android.graphics.Paint
-
-class TextPaint(flags: Int) : Paint(flags)
\ No newline at end of file
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/TestResources.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/TestResources.kt
similarity index 88%
rename from ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/TestResources.kt
rename to ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/TestResources.kt
index c8c3732..53d9a07 100644
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/TestResources.kt
+++ b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/TestResources.kt
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package androidx.ui.desktop
+package androidx.ui
import android.graphics.Bitmap
import androidx.ui.graphics.ImageAsset
import androidx.ui.graphics.asImageAsset
internal object TestResources {
- fun testImageAsset(path: String = "androidx/ui/desktop/test.png"): ImageAsset {
+ fun testImageAsset(path: String): ImageAsset {
return Bitmap(
javaClass.classLoader.getResource(path)!!
.openStream().buffered().readBytes()
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuCanvasTest.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuCanvasTest.kt
deleted file mode 100644
index 82149ca..0000000
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuCanvasTest.kt
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright 2020 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 androidx.ui.desktop.emu
-
-import androidx.ui.desktop.TestResources.testImageAsset
-import androidx.ui.geometry.Offset
-import androidx.ui.geometry.Rect
-import androidx.ui.graphics.BlendMode
-import androidx.ui.graphics.Canvas
-import androidx.ui.graphics.ClipOp
-import androidx.ui.graphics.Color
-import androidx.ui.graphics.Paint
-import androidx.ui.graphics.Path
-import androidx.ui.graphics.PathFillType
-import androidx.ui.graphics.PointMode
-import androidx.ui.graphics.StrokeCap
-import androidx.ui.graphics.StrokeJoin
-import androidx.ui.graphics.VertexMode
-import androidx.ui.graphics.Vertices
-import androidx.ui.graphics.vectormath.Matrix4
-import androidx.ui.unit.IntOffset
-import androidx.ui.unit.IntSize
-import org.junit.Test
-
-class AndroidEmuCanvasTest : AndroidEmuTest() {
- private val canvas: Canvas = initCanvas(width = 100, height = 100)
-
- @Test
- fun `save, restore without crash`() {
- canvas.save()
- canvas.restore()
- canvas.save()
- canvas.save()
- canvas.restore()
- canvas.restore()
- }
-
- @Test
- fun `save, restore layer without crash`() {
- canvas.saveLayer(
- Rect(
- left = 0f,
- top = 0f,
- right = 50f,
- bottom = 50f
- ),
- Paint()
- )
- canvas.restore()
- }
-
- @Test
- fun `transform operations without crash`() {
- canvas.translate(10f, 20f)
- canvas.scale(1.1f, 1.2f)
- canvas.rotate(30f)
- canvas.skew(1f, 2f)
- canvas.concat(
- Matrix4.identity().apply {
- translate(0.9f, 0.5f)
- }
- )
- }
-
- @Test
- fun `clipRect without crash`() {
- canvas.clipRect(
- left = 0f,
- top = 10f,
- right = 100f,
- bottom = 70f,
- clipOp = ClipOp.intersect
- )
- canvas.clipRect(
- left = 50f,
- top = 30f,
- right = 70f,
- bottom = 100f,
- clipOp = ClipOp.difference
- )
- }
-
- @Test
- fun `clipPath without crash`() {
- val path = Path().apply {
- fillType = PathFillType.nonZero
- lineTo(20f, 40f)
- addArc(
- oval = Rect(left = 0f, top = 0f, right = 20f, bottom = 20f),
- startAngleDegrees = 30f,
- sweepAngleDegrees = 10f
- )
- }
- canvas.clipPath(path, ClipOp.intersect)
- }
-
- @Test
- fun `drawLine without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- strokeWidth = 2f
- strokeCap = StrokeCap.butt
- }
- canvas.drawLine(Offset(10f, 10f), Offset(40f, 50f), paint)
- }
-
- @Test
- fun `drawRect without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawRect(left = 0f, top = 10f, right = 10f, bottom = 20f, paint = paint)
- }
-
- @Test
- fun `drawRoundRect without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawRoundRect(
- left = 0f,
- top = 10f,
- right = 10f,
- bottom = 20f,
- radiusX = 4f,
- radiusY = 2f,
- paint = paint
- )
- }
-
- @Test
- fun `drawOval without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawOval(
- left = 0f,
- top = 10f,
- right = 10f,
- bottom = 20f,
- paint = paint
- )
- }
-
- @Test
- fun `drawCircle without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawCircle(
- Offset(20f, 30f),
- radius = 25f,
- paint = paint
- )
- }
-
- @Test
- fun `drawArc without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawArc(
- left = 0f,
- top = 0f,
- right = 20f,
- bottom = 20f,
- startAngle = 30f,
- sweepAngle = 10f,
- useCenter = true,
- paint = paint
- )
- }
-
- @Test
- fun `drawPath without crash`() {
- val path = Path().apply {
- fillType = PathFillType.nonZero
- moveTo(25f, 10f)
- lineTo(30f, 20f)
- lineTo(20f, 20f)
- }
-
- val paint = Paint().apply {
- color = Color.Red
- strokeWidth = 2f
- strokeCap = StrokeCap.butt
- strokeJoin = StrokeJoin.round
- }
- canvas.drawPath(
- path = path,
- paint = paint
- )
- }
-
- @Test
- fun `drawImage without crash`() {
- val image = testImageAsset()
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawImage(image, Offset(30f, 40f), paint)
- }
-
- @Test
- fun `drawImageRect without crash`() {
- val image = testImageAsset()
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawImageRect(
- image,
- srcOffset = IntOffset(30, 40),
- srcSize = IntSize(20, 30),
- dstOffset = IntOffset(30, 40),
- dstSize = IntSize(20, 30),
- paint = paint
- )
- }
-
- @Test
- fun `drawPoints without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- strokeWidth = 2f
- strokeCap = StrokeCap.butt
- strokeJoin = StrokeJoin.round
- }
- canvas.drawPoints(
- pointMode = PointMode.points,
- points = listOf(
- Offset(20f, 30f),
- Offset(50f, 30f),
- Offset(30f, 50f)
- ),
- paint = paint
- )
- canvas.drawPoints(
- pointMode = PointMode.lines,
- points = listOf(
- Offset(20f, 30f),
- Offset(50f, 30f),
- Offset(30f, 50f)
- ),
- paint = paint
- )
- canvas.drawPoints(
- pointMode = PointMode.polygon,
- points = listOf(
- Offset(20f, 30f),
- Offset(50f, 30f),
- Offset(30f, 50f)
- ),
- paint = paint
- )
- }
-
- @Test
- fun `drawRawPoints without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- strokeWidth = 2f
- strokeCap = StrokeCap.butt
- strokeJoin = StrokeJoin.round
- }
- canvas.drawRawPoints(
- pointMode = PointMode.points,
- points = floatArrayOf(
- 20f, 30f,
- 50f, 30f,
- 30f, 50f
- ),
- paint = paint
- )
- canvas.drawRawPoints(
- pointMode = PointMode.lines,
- points = floatArrayOf(
- 20f, 30f,
- 50f, 30f,
- 30f, 50f
- ),
- paint = paint
- )
- canvas.drawRawPoints(
- pointMode = PointMode.polygon,
- points = floatArrayOf(
- 20f, 30f,
- 50f, 30f,
- 30f, 50f
- ),
- paint = paint
- )
- }
-
- @Test
- fun `drawVertices without crash`() {
- val paint = Paint().apply {
- color = Color.Red
- }
- canvas.drawVertices(
- Vertices(
- vertexMode = VertexMode.triangleStrip,
- positions = listOf(
- Offset(20f, 10f),
- Offset(25f, 30f),
- Offset(40f, 15f)
- ),
- textureCoordinates = listOf(
- Offset(0f, 0f),
- Offset(0.5f, 1f),
- Offset(1f, 0.5f)
- ),
- colors = listOf(
- Color.Red,
- Color.Green,
- Color.Blue
- ),
- indices = listOf(
- 0, 1, 2
- )
- ),
- blendMode = BlendMode.plus,
- paint = paint
- )
- }
-
- @Test
- fun `enableZ, disableZ without crash`() {
- canvas.enableZ()
- canvas.disableZ()
- }
-}
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuPaintTest.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuPaintTest.kt
deleted file mode 100644
index 4b7daf3..0000000
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuPaintTest.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2020 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 androidx.ui.desktop.emu
-
-import androidx.ui.desktop.TestResources.testImageAsset
-import androidx.ui.geometry.Offset
-import androidx.ui.graphics.BlendMode
-import androidx.ui.graphics.Canvas
-import androidx.ui.graphics.Color
-import androidx.ui.graphics.ColorFilter
-import androidx.ui.graphics.FilterQuality
-import androidx.ui.graphics.ImageShader
-import androidx.ui.graphics.LinearGradientShader
-import androidx.ui.graphics.Paint
-import androidx.ui.graphics.PaintingStyle
-import androidx.ui.graphics.RadialGradientShader
-import androidx.ui.graphics.StrokeCap
-import androidx.ui.graphics.StrokeJoin
-import androidx.ui.graphics.TileMode
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
-class AndroidEmuPaintTest : AndroidEmuTest() {
- private val canvas: Canvas = initCanvas(width = 100, height = 100)
-
- @Test
- fun `call paint methods`() {
- val linearGradientShader = LinearGradientShader(
- from = Offset(0f, 0f),
- to = Offset(100f, 20f),
- colors = listOf(Color.Red, Color.Blue, Color.Green),
- colorStops = listOf(0f, 0.5f, 1f),
- tileMode = TileMode.Mirror
- )
-
- val paint = Paint().apply {
- color = Color.Red
- style = PaintingStyle.stroke
- strokeWidth = 2f
- strokeCap = StrokeCap.butt
- strokeMiterLimit = 3f
- strokeJoin = StrokeJoin.round
- isAntiAlias = true
- filterQuality = FilterQuality.low
- alpha = 0.3f
- blendMode = BlendMode.plus
- colorFilter = ColorFilter(Color.Red, BlendMode.multiply)
- shader = ImageShader(
- testImageAsset(),
- tileModeX = TileMode.Mirror
- )
- shader = RadialGradientShader(
- center = Offset(5f, 0f),
- radius = 10f,
- colors = listOf(Color.Red, Color.Blue, Color.Green),
- colorStops = listOf(0f, 0.5f, 1f),
- tileMode = TileMode.Mirror
- )
- shader = linearGradientShader
- }
-
- assertEquals(Color.Red, paint.color.copy(alpha = 1f))
- assertEquals(0.3f, paint.color.alpha, 0.1f)
- assertEquals(PaintingStyle.stroke, paint.style)
- assertEquals(2f, paint.strokeWidth)
- assertEquals(StrokeCap.butt, paint.strokeCap)
- assertEquals(3f, paint.strokeMiterLimit)
- assertEquals(StrokeJoin.round, paint.strokeJoin)
- assertEquals(true, paint.isAntiAlias)
- assertEquals(FilterQuality.low, paint.filterQuality)
- assertEquals(0.3f, paint.alpha, 0.1f)
- assertEquals(BlendMode.plus, paint.blendMode)
- assertEquals(ColorFilter(Color.Red, BlendMode.multiply), paint.colorFilter)
- assertEquals(linearGradientShader, paint.shader)
-
- canvas.drawLine(Offset(10f, 10f), Offset(40f, 50f), paint)
- }
-}
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuPathTest.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuPathTest.kt
deleted file mode 100644
index 631dada..0000000
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuPathTest.kt
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2020 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 androidx.ui.desktop.emu
-
-import androidx.ui.geometry.Offset
-import androidx.ui.geometry.RRect
-import androidx.ui.geometry.Rect
-import androidx.ui.graphics.Canvas
-import androidx.ui.graphics.Color
-import androidx.ui.graphics.Paint
-import androidx.ui.graphics.Path
-import androidx.ui.graphics.PathFillType
-import androidx.ui.graphics.PathOperation
-import androidx.ui.graphics.StrokeCap
-import androidx.ui.graphics.StrokeJoin
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
-class AndroidEmuPathTest : AndroidEmuTest() {
- private val canvas: Canvas = initCanvas(width = 100, height = 100)
-
- @Test
- fun `draw complex path without crash`() {
- val path = Path().apply {
- moveTo(20f, 30f)
- reset()
-
- fillType = PathFillType.nonZero
- moveTo(250f, 100f)
- lineTo(300f, 200f)
- lineTo(200f, 200f)
- close()
-
- relativeMoveTo(10f, 20f)
- lineTo(20f, 40f)
- relativeLineTo(30f, 40f)
- quadraticBezierTo(x1 = 10f, x2 = 20f, y1 = 40f, y2 = 60f)
- relativeQuadraticBezierTo(dx1 = 10f, dx2 = 20f, dy1 = 40f, dy2 = 60f)
- cubicTo(x1 = 10f, y1 = 40f, x2 = 20f, y2 = 60f, x3 = 30f, y3 = 70f)
- relativeCubicTo(dx1 = 10f, dy1 = 40f, dx2 = 20f, dy2 = 60f, dx3 = 30f, dy3 = 70f)
- arcTo(
- rect = Rect(left = 0f, top = 0f, right = 20f, bottom = 20f),
- startAngleDegrees = 30f,
- sweepAngleDegrees = 10f,
- forceMoveTo = true
- )
- addRect(Rect(left = 0f, top = 0f, right = 20f, bottom = 20f))
- addOval(Rect(left = 0f, top = 0f, right = 20f, bottom = 20f))
- addArc(
- oval = Rect(left = 0f, top = 0f, right = 20f, bottom = 20f),
- startAngleDegrees = 30f,
- sweepAngleDegrees = 10f
- )
- addRRect(
- RRect(left = 0f, top = 0f, right = 20f, bottom = 20f, radiusX = 2f, radiusY = 2f)
- )
- addPath(
- Path().apply {
- lineTo(20f, 40f)
- lineTo(30f, 50f)
- },
- Offset(20f, 30f)
- )
- op(
- Path().apply {
- lineTo(20f, 40f)
- lineTo(30f, 50f)
- },
- Path().apply {
- lineTo(30f, 40f)
- lineTo(40f, 50f)
- },
- PathOperation.intersect
- )
- shift(Offset(10f, 20f))
- }
-
- assertEquals(Rect.fromLTRB(10f, 20f, 310f, 240f), path.getBounds())
- assertEquals(false, path.isConvex)
- assertEquals(false, path.isEmpty)
-
- val paint = Paint().apply {
- color = Color.Red
- strokeWidth = 2f
- strokeCap = StrokeCap.butt
- strokeJoin = StrokeJoin.round
- }
-
- canvas.drawPath(
- path = path,
- paint = paint
- )
- }
-
- @Test
- fun `check parameters of initial path`() {
- val path = Path()
- assertEquals(Rect.fromLTRB(0f, 0f, 0f, 0f), path.getBounds())
- assertEquals(true, path.isConvex)
- assertEquals(true, path.isEmpty)
- }
-}
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuTest.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuTest.kt
deleted file mode 100644
index 103e602..0000000
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/desktop/emu/AndroidEmuTest.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2020 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 androidx.ui.desktop.emu
-
-import androidx.ui.graphics.Canvas
-import org.jetbrains.skija.Library
-import org.jetbrains.skija.Surface
-import org.junit.After
-
-abstract class AndroidEmuTest {
- private var surface: Surface? = null
-
- @Suppress("SameParameterValue")
- protected fun initCanvas(width: Int, height: Int): Canvas {
- require(surface == null)
- surface = Surface.makeRasterN32Premul(width, height)
- return Canvas(android.graphics.Canvas(surface!!.canvas))
- }
-
- @After
- fun teardown() {
- surface?.close()
- }
-
- private companion object {
- init {
- Library.load("/", "skija")
- }
- }
-}
\ No newline at end of file
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/DesktopPaintTest.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/DesktopPaintTest.kt
index 475101d..71edc91 100644
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/DesktopPaintTest.kt
+++ b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/DesktopPaintTest.kt
@@ -16,7 +16,7 @@
package androidx.ui.graphics
-import androidx.ui.desktop.TestResources.testImageAsset
+import androidx.ui.TestResources.testImageAsset
import androidx.ui.geometry.Offset
import androidx.ui.unit.IntOffset
import androidx.ui.unit.IntSize
diff --git a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/canvas/DesktopCanvasTest.kt b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/canvas/DesktopCanvasTest.kt
index 9b9a20d..35f0708 100644
--- a/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/canvas/DesktopCanvasTest.kt
+++ b/ui/ui-desktop/src/jvmTest/kotlin/androidx/ui/graphics/canvas/DesktopCanvasTest.kt
@@ -16,7 +16,7 @@
package androidx.ui.graphics.canvas
-import androidx.ui.desktop.TestResources.testImageAsset
+import androidx.ui.TestResources.testImageAsset
import androidx.ui.geometry.Offset
import androidx.ui.geometry.Rect
import androidx.ui.graphics.BlendMode