public abstract class BaseShaderGraphics extends BaseGraphics implements ShaderGraphics, ReadbackGraphics, MaskTextureGraphics
Modifier and Type | Field and Description |
---|---|
private BaseShaderContext |
context |
private Shader |
externalShader |
private static float |
FRINGE_FACTOR |
private boolean |
isComplexPaint |
private boolean |
lcdSampleInvalid |
private NGLightBase[] |
lights |
private static double |
SQRT_2 |
private static Affine2D |
TEMP_TX2D |
private static Affine3D |
TEMP_TX3D |
private static RectBounds |
TMP_BOUNDS |
IDENT, isSimpleTranslate, nodeBounds, paint, scratchEllipse, scratchLine, scratchRRect, stroke, transX, transY
Modifier | Constructor and Description |
---|---|
protected |
BaseShaderGraphics(BaseShaderContext context,
RenderTarget renderTarget) |
Modifier and Type | Method and Description |
---|---|
void |
blit(RTTexture srcTex,
RTTexture dstTex,
int srcX0,
int srcY0,
int srcX1,
int srcY1,
int dstX0,
int dstY0,
int dstX1,
int dstY1) |
private static float |
calculateScaleFactor(float contentDim,
float physicalDim) |
boolean |
canReadBack() |
private static boolean |
canUseStrokeShader(BasicStroke bs) |
private boolean |
checkInnerCurvature(float arcw,
float arch) |
void |
drawEllipse(float x,
float y,
float w,
float h) |
private void |
drawLCDBuffer(float bx,
float by,
float bw,
float bh,
float tx1,
float ty1,
float tx2,
float ty2) |
void |
drawLine(float x1,
float y1,
float x2,
float y2) |
void |
drawMappedTextureRaw2(Texture src1,
Texture src2,
float dx1,
float dy1,
float dx2,
float dy2,
float t1x11,
float t1y11,
float t1x21,
float t1y21,
float t1x12,
float t1y12,
float t1x22,
float t1y22,
float t2x11,
float t2y11,
float t2x21,
float t2y21,
float t2x12,
float t2y12,
float t2x22,
float t2y22) |
protected void |
drawMultiTexture(MultiTexture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2) |
void |
drawPixelsMasked(RTTexture imgtex,
RTTexture masktex,
int dx,
int dy,
int dw,
int dh,
int ix,
int iy,
int mx,
int my)
Apply a mask to the pixels of an image and render the results onto
the destination in device space.
|
(package private) boolean |
drawPrimDiagonal(float x1,
float y1,
float x2,
float y2,
float lw,
int cap,
float bx,
float by,
float bw,
float bh) |
(package private) boolean |
drawPrimRect(float x,
float y,
float w,
float h) |
void |
drawRect(float x,
float y,
float w,
float h) |
void |
drawRoundRect(float x,
float y,
float w,
float h,
float arcw,
float arch) |
void |
drawString(GlyphList gl,
FontStrike strike,
float x,
float y,
Color selectColor,
int selectStart,
int selectEnd) |
void |
drawTexture(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2) |
void |
drawTexture3SliceH(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2,
float dh1,
float dh2,
float sh1,
float sh2) |
void |
drawTexture3SliceV(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2,
float dv1,
float dv2,
float sv1,
float sv2) |
void |
drawTexture9Slice(Texture tex,
float dx1,
float dy1,
float dx2,
float dy2,
float sx1,
float sy1,
float sx2,
float sy2,
float dh1,
float dv1,
float dh2,
float dv2,
float sh1,
float sv1,
float sh2,
float sv2) |
void |
drawTextureRaw2(Texture src1,
Texture src2,
float dx1,
float dy1,
float dx2,
float dy2,
float t1x1,
float t1y1,
float t1x2,
float t1y2,
float t2x1,
float t2y1,
float t2x2,
float t2y2) |
private BaseTransform |
extract3Dremainder(BaseTransform xform) |
void |
fillEllipse(float x,
float y,
float w,
float h) |
(package private) boolean |
fillPrimRect(float x,
float y,
float w,
float h,
Texture rectTex,
Texture wrapTex,
float bx,
float by,
float bw,
float bh) |
void |
fillQuad(float x1,
float y1,
float x2,
float y2) |
void |
fillRect(float x,
float y,
float w,
float h) |
void |
fillRoundRect(float x,
float y,
float w,
float h,
float arcw,
float arch) |
(package private) BaseShaderContext |
getContext() |
Shader |
getExternalShader() |
NGLightBase[] |
getLights() |
void |
getPaintShaderTransform(Affine3D ret) |
(package private) AffineBase |
getPaintTextureTx(BaseTransform renderTx,
Shader shader,
float rx,
float ry,
float rw,
float rh) |
private static float |
getStrokeExpansionFactor(BasicStroke stroke) |
private void |
initLCDSampleRT() |
(package private) boolean |
isComplexPaint() |
private static float |
len(float x,
float y) |
void |
maskInterpolatePixels(RTTexture imgtex,
RTTexture masktex,
int dx,
int dy,
int dw,
int dh,
int ix,
int iy,
int mx,
int my)
Use a mask to determine which pixels of an image are to be rendered
onto the destination in device space.
|
RTTexture |
readBack(Rectangle view) |
void |
releaseReadBackBuffer(RTTexture rtt) |
private void |
renderGeneralRoundedPgram(float ox,
float oy,
float wvecx,
float wvecy,
float hvecx,
float hvecy,
float arcfractw,
float arcfracth,
float ifractw,
float ifracth,
BaseTransform rendertx,
BaseShaderContext.MaskType type,
float rx,
float ry,
float rw,
float rh) |
private void |
renderGeneralRoundedRect(float rx,
float ry,
float rw,
float rh,
float arcw,
float arch,
BaseShaderContext.MaskType type,
BasicStroke stroke) |
protected void |
renderShape(Shape shape,
BasicStroke stroke,
float bx,
float by,
float bw,
float bh) |
private void |
renderWithComplexPaint(Shape shape,
BasicStroke stroke,
float bx,
float by,
float bw,
float bh) |
void |
setExternalShader(Shader shader) |
void |
setLights(NGLightBase[] lights) |
void |
setNodeBounds(RectBounds bounds)
Set the node bounds for any node that would like to render objects of a
different size to self.
|
void |
setPaint(Paint paint) |
void |
setup3DRendering() |
clear, draw, drawMappedTextureRaw, drawTexture, drawTextureRaw, drawTextureVO, fill, getAssociatedScreen, getCamera, getCameraNoClone, getClipRect, getClipRectIndex, getClipRectNoClone, getCompositeMode, getExtraAlpha, getFinalClipNoClone, getPaint, getPixelScaleFactor, getRenderRoot, getRenderTarget, getResourceFactory, getStroke, getTransformNoClone, hasPreCullingBits, isAlphaTestShader, isAntialiasedShape, isDepthBuffer, isDepthTest, isState3D, scale, scale, setAntialiasedShape, setCamera, setClipRect, setClipRectIndex, setCompositeMode, setDepthBuffer, setDepthTest, setExtraAlpha, setHasPreCullingBits, setPerspectiveTransform, setPixelScaleFactor, setRenderRoot, setState3D, setStroke, setTransform, setTransform, setTransform3D, transform, translate, translate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, clear, clearQuad, draw, drawMappedTextureRaw, drawTexture, drawTextureRaw, drawTextureVO, fill, getAssociatedScreen, getCameraNoClone, getClipRect, getClipRectIndex, getClipRectNoClone, getCompositeMode, getExtraAlpha, getFinalClipNoClone, getPaint, getPixelScaleFactor, getRenderRoot, getRenderTarget, getResourceFactory, getStroke, getTransformNoClone, hasPreCullingBits, isAlphaTestShader, isAntialiasedShape, isDepthBuffer, isDepthTest, isState3D, scale, scale, setAntialiasedShape, setCamera, setClipRect, setClipRectIndex, setCompositeMode, setDepthBuffer, setDepthTest, setExtraAlpha, setHasPreCullingBits, setPerspectiveTransform, setPixelScaleFactor, setRenderRoot, setState3D, setStroke, setTransform, setTransform, setTransform3D, sync, transform, translate, translate
private static Affine2D TEMP_TX2D
private static Affine3D TEMP_TX3D
private final BaseShaderContext context
private Shader externalShader
private boolean isComplexPaint
private NGLightBase[] lights
private static RectBounds TMP_BOUNDS
private static final float FRINGE_FACTOR
private static final double SQRT_2
private boolean lcdSampleInvalid
protected BaseShaderGraphics(BaseShaderContext context, RenderTarget renderTarget)
BaseShaderContext getContext()
boolean isComplexPaint()
public void getPaintShaderTransform(Affine3D ret)
getPaintShaderTransform
in interface ShaderGraphics
public Shader getExternalShader()
public void setExternalShader(Shader shader)
setExternalShader
in interface ShaderGraphics
public void setPaint(Paint paint)
setPaint
in interface Graphics
setPaint
in class BaseGraphics
public void setLights(NGLightBase[] lights)
public final NGLightBase[] getLights()
public void drawTexture(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2)
drawTexture
in interface Graphics
drawTexture
in class BaseGraphics
public void drawTexture3SliceH(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dh1, float dh2, float sh1, float sh2)
drawTexture3SliceH
in interface Graphics
drawTexture3SliceH
in class BaseGraphics
public void drawTexture3SliceV(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dv1, float dv2, float sv1, float sv2)
drawTexture3SliceV
in interface Graphics
drawTexture3SliceV
in class BaseGraphics
public void drawTexture9Slice(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dh1, float dv1, float dh2, float dv2, float sh1, float sv1, float sh2, float sv2)
drawTexture9Slice
in interface Graphics
drawTexture9Slice
in class BaseGraphics
private static float calculateScaleFactor(float contentDim, float physicalDim)
protected void drawMultiTexture(MultiTexture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2)
public void drawTextureRaw2(Texture src1, Texture src2, float dx1, float dy1, float dx2, float dy2, float t1x1, float t1y1, float t1x2, float t1y2, float t2x1, float t2y1, float t2x2, float t2y2)
drawTextureRaw2
in interface ShaderGraphics
public void drawMappedTextureRaw2(Texture src1, Texture src2, float dx1, float dy1, float dx2, float dy2, float t1x11, float t1y11, float t1x21, float t1y21, float t1x12, float t1y12, float t1x22, float t1y22, float t2x11, float t2y11, float t2x21, float t2y21, float t2x12, float t2y12, float t2x22, float t2y22)
drawMappedTextureRaw2
in interface ShaderGraphics
public void drawPixelsMasked(RTTexture imgtex, RTTexture masktex, int dx, int dy, int dw, int dh, int ix, int iy, int mx, int my)
MaskTextureGraphics
The image texture is combined with the mask texture by multiplying the pixels in the image texture by the alpha in the mask texture and then the result is applied to the destination using the current compositing rule (which should likely be SrcOver in most cases).
dst.argb = (img.argb * mask.a) Composite dst.argb
drawPixelsMasked
in interface MaskTextureGraphics
imgtex
- the texture containing the source image pixelsmasktex
- the texture containing the mask pixels, only the
alpha channel is used from this texturedx
- the X coordinate of the UL destination pixeldy
- the Y coordinate of the UL destination pixeldw
- the width of the pixel regions to be combineddh
- the height of the pixel regions to be combinedix
- the X coordinate of the UL pixel in the image textureiy
- the Y coordinate of the UL pixel in the image texturemx
- the X coordinate of the UL pixel in the mask texturemy
- the Y coordinate of the UL pixel in the mask texturepublic void maskInterpolatePixels(RTTexture imgtex, RTTexture masktex, int dx, int dy, int dw, int dh, int ix, int iy, int mx, int my)
MaskTextureGraphics
The mask texture controls the contribution of source and destination pixels in the resulting output. Note that a simple multiply of the source texture by the mask texture may not produce the correct masking operation for the case where a non-SrcOver blending mode is in use. In those conditions, it is more accurate to first compute the result of blending the source into the destination and to then use this method to choose how much of the result should be taken from the results of the blending and how much should remain the original destination pixel value. Mathematically, the mask alpha controls a linear interpolation between the image and destination pixels.
dst.argb = (mask.a * img.argb) + ((1 - mask.a) * dst.argb)Note that the current composite mode is ignored during this operation.
maskInterpolatePixels
in interface MaskTextureGraphics
imgtex
- the texture containing the source image pixelsmasktex
- the texture containing the mask pixels, only the
alpha channel is used from this texturedx
- the X coordinate of the UL destination pixeldy
- the Y coordinate of the UL destination pixeldw
- the width of the pixel regions to be combineddh
- the height of the pixel regions to be combinedix
- the X coordinate of the UL pixel in the image textureiy
- the Y coordinate of the UL pixel in the image texturemx
- the X coordinate of the UL pixel in the mask texturemy
- the Y coordinate of the UL pixel in the mask textureprivate void renderWithComplexPaint(Shape shape, BasicStroke stroke, float bx, float by, float bw, float bh)
protected void renderShape(Shape shape, BasicStroke stroke, float bx, float by, float bw, float bh)
renderShape
in class BaseGraphics
private static float getStrokeExpansionFactor(BasicStroke stroke)
private BaseTransform extract3Dremainder(BaseTransform xform)
private void renderGeneralRoundedRect(float rx, float ry, float rw, float rh, float arcw, float arch, BaseShaderContext.MaskType type, BasicStroke stroke)
private void renderGeneralRoundedPgram(float ox, float oy, float wvecx, float wvecy, float hvecx, float hvecy, float arcfractw, float arcfracth, float ifractw, float ifracth, BaseTransform rendertx, BaseShaderContext.MaskType type, float rx, float ry, float rw, float rh)
AffineBase getPaintTextureTx(BaseTransform renderTx, Shader shader, float rx, float ry, float rw, float rh)
boolean fillPrimRect(float x, float y, float w, float h, Texture rectTex, Texture wrapTex, float bx, float by, float bw, float bh)
boolean drawPrimRect(float x, float y, float w, float h)
boolean drawPrimDiagonal(float x1, float y1, float x2, float y2, float lw, int cap, float bx, float by, float bw, float bh)
public void fillRect(float x, float y, float w, float h)
public void fillEllipse(float x, float y, float w, float h)
fillEllipse
in interface Graphics
public void fillRoundRect(float x, float y, float w, float h, float arcw, float arch)
fillRoundRect
in interface Graphics
public void fillQuad(float x1, float y1, float x2, float y2)
private static boolean canUseStrokeShader(BasicStroke bs)
public void blit(RTTexture srcTex, RTTexture dstTex, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1)
public void drawRect(float x, float y, float w, float h)
private boolean checkInnerCurvature(float arcw, float arch)
public void drawEllipse(float x, float y, float w, float h)
drawEllipse
in interface Graphics
public void drawRoundRect(float x, float y, float w, float h, float arcw, float arch)
drawRoundRect
in interface Graphics
public void drawLine(float x1, float y1, float x2, float y2)
private static float len(float x, float y)
public void setNodeBounds(RectBounds bounds)
Graphics
setNodeBounds
in interface Graphics
bounds
- should not include node transformprivate void initLCDSampleRT()
public void drawString(GlyphList gl, FontStrike strike, float x, float y, Color selectColor, int selectStart, int selectEnd)
drawString
in interface Graphics
private void drawLCDBuffer(float bx, float by, float bw, float bh, float tx1, float ty1, float tx2, float ty2)
public boolean canReadBack()
canReadBack
in interface ReadbackGraphics
public RTTexture readBack(Rectangle view)
readBack
in interface ReadbackGraphics
public void releaseReadBackBuffer(RTTexture rtt)
releaseReadBackBuffer
in interface ReadbackGraphics
public void setup3DRendering()
setup3DRendering
in interface Graphics