(Gsk)Canvas: add debug prints, and a hack

This commit is contained in:
Mis012 2025-03-26 21:17:13 +01:00
parent 23078bfb06
commit 0a0e476883
2 changed files with 44 additions and 11 deletions

View file

@ -1,5 +1,8 @@
package android.graphics; package android.graphics;
import android.content.res.Resources;
import android.util.Log;
public class Canvas { public class Canvas {
public static final int HAS_ALPHA_LAYER_SAVE_FLAG = (1 << 2); public static final int HAS_ALPHA_LAYER_SAVE_FLAG = (1 << 2);
@ -136,6 +139,7 @@ public class Canvas {
* @param paint The paint used for the text (e.g. color, size, style) * @param paint The paint used for the text (e.g. color, size, style)
*/ */
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) { public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
drawText(text.toString(), start, end, x, y, paint);
/*if (text instanceof String || text instanceof SpannedString || /*if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) { text instanceof SpannableString) {
native_drawText(mNativeCanvas, text.toString(), start, end, x, y, native_drawText(mNativeCanvas, text.toString(), start, end, x, y,
@ -151,6 +155,11 @@ public class Canvas {
TemporaryBuffer.recycle(buf); TemporaryBuffer.recycle(buf);
}*/ }*/
} }
public void drawTextOnPath(String text, Path path, float x_offset, float y_offset, Paint paint) {
Log.w("Canvas", "STUB: drawTextOnPath");
}
// --- // ---
/** /**
* <p>Draw the specified arc, which will be scaled to fit inside the * <p>Draw the specified arc, which will be scaled to fit inside the
@ -180,6 +189,7 @@ public class Canvas {
if (oval == null) { if (oval == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
Log.w("Canvas", "STUB: drawArc");
/*native_drawArc(mNativeCanvas, oval, startAngle, sweepAngle, /*native_drawArc(mNativeCanvas, oval, startAngle, sweepAngle,
useCenter, paint.mNativePaint);*/ useCenter, paint.mNativePaint);*/
} }
@ -308,7 +318,7 @@ public class Canvas {
*/ */
public void drawBitmap(int[] colors, int offset, int stride, float x, float y, public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
int width, int height, boolean hasAlpha, Paint paint) { int width, int height, boolean hasAlpha, Paint paint) {
System.out.println("XXXXXXX bitmap(colors, offset, ...)"); Log.w("Canvas", "STUB: drawBitmap(colors, offset, ...)");
/* // check for valid input /* // check for valid input
if (width < 0) { if (width < 0) {
throw new IllegalArgumentException("width must be >= 0"); throw new IllegalArgumentException("width must be >= 0");
@ -417,7 +427,9 @@ public class Canvas {
matrix.reset(); matrix.reset();
} }
public void translate(float dx, float dy) {} public void translate(float dx, float dy) {
Log.w("Canvas", "STUB: translate");
}
public void drawCircle(float cx, float cy, float radius, Paint paint) { public void drawCircle(float cx, float cy, float radius, Paint paint) {
gsk_canvas.snapshot = bitmap.getSnapshot(); gsk_canvas.snapshot = bitmap.getSnapshot();
@ -425,14 +437,18 @@ public class Canvas {
} }
public Rect getClipBounds() { public Rect getClipBounds() {
return new Rect(0, 0, 10, 10); Rect rect = new Rect();
getClipBounds(rect);
return rect;
} }
public boolean clipRect(Rect rect, Region.Op op) { public boolean clipRect(Rect rect, Region.Op op) {
return false; return false;
} }
public void concat(Matrix matrix) {} public void concat(Matrix matrix) {
Log.w("Canvas", "STUB: concat");
}
public boolean clipPath(Path path, Region.Op op) { public boolean clipPath(Path path, Region.Op op) {
return false; return false;
@ -446,21 +462,29 @@ public class Canvas {
return (bitmap == null) ? 0 : bitmap.getHeight(); return (bitmap == null) ? 0 : bitmap.getHeight();
} }
public void drawColor(int dummy) {} public void drawColor(int color) {
Log.w("Canvas", "STUB: drawColor("+String.format("0x%08x", color)+")");
}
public void drawARGB(int a, int r, int g, int b) {} public void drawARGB(int a, int r, int g, int b) {
Log.w("Canvas", "STUB: drawARGB("+a+", "+r+", "+g+", "+b+")");
}
public int saveLayer(RectF bounds, Paint paint, int flags) { public int saveLayer(RectF bounds, Paint paint, int flags) {
return save(); return save();
} }
public void drawOval(RectF oval, Paint paint) {} public void drawOval(RectF oval, Paint paint) {
Log.w("Canvas", "STUB: drawOval");
}
public boolean clipRect(int left, int top, int right, int bottom) { public boolean clipRect(int left, int top, int right, int bottom) {
return false; return false;
} }
public void drawColor(int color, PorterDuff.Mode mode) {} public void drawColor(int color, PorterDuff.Mode mode) {
Log.w("Canvas", "STUB: drawColor("+String.format("0x%08x", color)+", "+mode+")");
}
public boolean clipRect(Rect rect) { public boolean clipRect(Rect rect) {
return false; return false;
@ -486,12 +510,17 @@ public class Canvas {
return false; return false;
} }
public void drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean includeCenter, Paint paint) {} public void drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean includeCenter, Paint paint) {
Log.w("Canvas", "STUB: drawArc");
}
public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint) {} public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint) {
Log.w("Canvas", "STUB: drawRoundRect");
}
public boolean getClipBounds(Rect outRect) { public boolean getClipBounds(Rect outRect) {
outRect.set(0, 0, 100, 100); /* UGLY HACK */
outRect.set(0, 0, Resources.getSystem().getDisplayMetrics().widthPixels, Resources.getSystem().getDisplayMetrics().heightPixels);
return true; return true;
} }

View file

@ -71,6 +71,10 @@ public class GskCanvas extends Canvas {
@Override @Override
public void drawText(String text, float x, float y, Paint paint) { public void drawText(String text, float x, float y, Paint paint) {
if(text == null) {
new Exception("drawText: text is null; stack trace:").printStackTrace();
return;
}
native_drawText(snapshot, text, x, y, paint != null ? paint.paint : default_paint.paint); native_drawText(snapshot, text, x, y, paint != null ? paint.paint : default_paint.paint);
} }