Android skia浅析

skia.org
android graphics

canvas

  • Android Graphics Canvase
返回Public Methods
voiddrawARGB(int a, int r, int g, int b)Fill the entire canvas’ bitmap (restricted to the current clip) with the specified ARGB color, using srcover porterduff mode.
voiddrawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)Draw the specified arc, which will be scaled to fit inside the specified oval.
voiddrawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean useCenter, Paint paint)Draw the specified arc, which will be scaled to fit inside the specified oval.
voiddrawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, Paint paint)This method was deprecated in API level 21. Usage with a hardware accelerated canvas requires an internal copy of color buffer contents every time this method is called. Using a Bitmap avoids this copy, and allows the application to more explicitly control the lifetime and copies of pixel data.
voiddrawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)Draw the bitmap using the specified matrix.
voiddrawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)This method was deprecated in API level 21. Usage with a hardware accelerated canvas requires an internal copy of color buffer contents every time this method is called. Using a Bitmap avoids this copy, and allows the application to more explicitly control the lifetime and copies of pixel data.
voiddrawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
voiddrawBitmap(Bitmap bitmap, float left, float top, Paint paint)Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.
voiddrawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
voiddrawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint)Draw the bitmap through the mesh, where mesh vertices are evenly distributed across the bitmap.
voiddrawCircle(float cx, float cy, float radius, Paint paint)Draw the specified circle using the specified paint.
voiddrawColor(int color)Fill the entire canvas’ bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode.
voiddrawColor(int color, PorterDuff.Mode mode)Fill the entire canvas’ bitmap (restricted to the current clip) with the specified color and porter-duff xfermode.
voiddrawLine(float startX, float startY, float stopX, float stopY, Paint paint)Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.
voiddrawLines(float[] pts, Paint paint)
voiddrawLines(float[] pts, int offset, int count, Paint paint)Draw a series of lines.
voiddrawOval(float left, float top, float right, float bottom, Paint paint)Draw the specified oval using the specified paint.
voiddrawOval(RectF oval, Paint paint)Draw the specified oval using the specified paint.
voiddrawPaint(Paint paint)Fill the entire canvas’ bitmap (restricted to the current clip) with the specified paint.
voiddrawPath(Path path, Paint paint)Draw the specified path using the specified paint.
voiddrawPicture(Picture picture, RectF dst)Draw the picture, stretched to fit into the dst rectangle.
voiddrawPicture(Picture picture)Save the canvas state, draw the picture, and restore the canvas state.
voiddrawPicture(Picture picture, Rect dst)Draw the picture, stretched to fit into the dst rectangle.
voiddrawPoint(float x, float y, Paint paint)Helper for drawPoints() for drawing a single point.
voiddrawPoints(float[] pts, int offset, int count, Paint paint)Draw a series of points.
voiddrawPoints(float[] pts, Paint paint)Helper for drawPoints() that assumes you want to draw the entire array
voiddrawPosText(char[] text, int index, int count, float[] pos, Paint paint)Draw the text in the array, with each character’s origin specified by the pos array.
voiddrawPosText(String text, float[] pos, Paint paint)Draw the text in the array, with each character’s origin specified by the pos array.
voiddrawRGB(int r, int g, int b)Fill the entire canvas’ bitmap (restricted to the current clip) with the specified RGB color, using srcover porterduff mode.
voiddrawRect(float left, float top, float right, float bottom, Paint paint)Draw the specified Rect using the specified paint.
voiddrawRect(RectF rect, Paint paint)Draw the specified Rect using the specified paint.
voiddrawRect(Rect r, Paint paint)Draw the specified Rect using the specified Paint.
voiddrawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)Draw the specified round-rect using the specified paint.
voiddrawRoundRect(RectF rect, float rx, float ry, Paint paint)Draw the specified round-rect using the specified paint.
voiddrawText(String text, float x, float y, Paint paint)Draw the text, with origin at (x,y), using the specified paint.
voiddrawText(CharSequence text, int start, int end, float x, float y, Paint paint)Draw the specified range of text, specified by start/end, with its origin at (x,y), in the specified Paint.
voiddrawText(char[] text, int index, int count, float x, float y, Paint paint)Draw the text, with origin at (x,y), using the specified paint.
voiddrawText(String text, int start, int end, float x, float y, Paint paint)Draw the text, with origin at (x,y), using the specified paint.
voiddrawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)Draw the text, with origin at (x,y), using the specified paint, along the specified path.
voiddrawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)Draw the text, with origin at (x,y), using the specified paint, along the specified path.
voiddrawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, float x, float y, boolean isRtl, Paint paint)Draw a run of text, all in a single direction, with optional context for complex text shaping.
voiddrawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, float x, float y, boolean isRtl, Paint paint)Draw a run of text, all in a single direction, with optional context for complex text shaping.
voiddrawVertices(Canvas.VertexMode mode, int vertexCount, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, int indexOffset, int indexCount, Paint paint)Draw the array of vertices, interpreted as triangles (based on mode).

skia SKCanvas

.Public Methods
voiddrawPaint (const SkPaint &paint)Fill the entire canvas (restricted to the current clip) with the specified paint. More…
voiddrawPoints (PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)Draw a series of points, interpreted based on the PointMode mode. More…
voiddrawPoint (SkScalar x, SkScalar y, const SkPaint &paint)Helper method for drawing a single point. More…
voiddrawPoint (SkScalar x, SkScalar y, SkColor color)Draws a single pixel in the specified color. More…
voiddrawLine (SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)Draw a line segment with the specified start and stop x,y coordinates, using the specified paint. More…
voiddrawRect (const SkRect &rect, const SkPaint &paint)Draw the specified rectangle using the specified paint. More…
voiddrawIRect (const SkIRect &rect, const SkPaint &paint)Draw the specified rectangle using the specified paint. More…
voiddrawRectCoords (SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, const SkPaint &paint)Draw the specified rectangle using the specified paint. More…
voiddrawOval (const SkRect &oval, const SkPaint &)Draw the specified oval using the specified paint. More…
voiddrawRRect (const SkRRect &rrect, const SkPaint &paint)Draw the specified RRect using the specified paint The rrect will be filled or stroked based on the Style in the paint. More…
voiddrawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &)Draw the annulus formed by the outer and inner rrects. More…
voiddrawImageRect (const SkImage *image, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)Draw the specified image, scaling and translating so that it fills the specified dst rect. More…
voiddrawImageRect (const SkImage *image, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint)
voiddrawImageRect (const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
voiddrawImageRect (const sk_sp< SkImage > &image, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint cons=kStrict_SrcRectConstraint)
voiddrawImageRect (const sk_sp< SkImage > &image, const SkRect &dst, const SkPaint *paint, SrcRectConstraint cons=kStrict_SrcRectConstraint)
voiddrawImageNine (const SkImage *, const SkIRect &center, const SkRect &dst, const SkPaint *paint=nullptr)Draw the image stretched differentially to fit into dst. More…
voiddrawImageNine (const sk_sp< SkImage > &image, const SkIRect &center, const SkRect &dst, const SkPaint *paint=nullptr)
voiddrawBitmap (const SkBitmap &bitmap, SkScalar left, SkScalar top, const SkPaint *paint=NULL)Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix. More…
voiddrawBitmapRect (const SkBitmap &bitmap, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint)Draw the specified bitmap, scaling and translating so that it fills the specified dst rect. More…
voiddrawBitmapRect (const SkBitmap &bitmap, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint)
voiddrawBitmapRect (const SkBitmap &bitmap, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint)
voiddrawBitmapNine (const SkBitmap &bitmap, const SkIRect &center, const SkRect &dst, const SkPaint *paint=NULL)Draw the bitmap stretched differentially to fit into dst. More…
voiddrawText (const void *text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint &paint)Draw the text, with origin at (x,y), using the specified paint. More…
voiddrawPosText (const void *text, size_t byteLength, const SkPoint pos[], const SkPaint &paint)Draw the text, with each character/glyph origin specified by the pos[] array. More…
voiddrawPosTextH (const void *text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint &paint)Draw the text, with each character/glyph origin specified by the x coordinate taken from the xpos[] array, and the y from the constY param. More…
voiddrawTextOnPathHV (const void *text, size_t byteLength, const SkPath &path, SkScalar hOffset, SkScalar vOffset, const SkPaint &paint)Draw the text, with origin at (x,y), using the specified paint, along the specified path. More…
voiddrawTextOnPath (const void *text, size_t byteLength, const SkPath &path, const SkMatrix *matrix, const SkPaint &paint)Draw the text, with origin at (x,y), using the specified paint, along the specified path. More…
voiddrawTextBlob (const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)Draw the text blob, offset by (x,y), using the specified paint. More…
voiddrawPicture (const SkPicture *picture)Draw the picture into this canvas. More…
voiddrawPicture (const sk_sp< SkPicture > &picture)
voiddrawPicture (const SkPicture *, const SkMatrix *matrix, const SkPaint *paint)Draw the picture into this canvas. More…
voiddrawPicture (const sk_sp< SkPicture > &picture, const SkMatrix *matrix, const SkPaint *paint)
voiddrawVertices (VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], SkXfermode *xmode, const uint16_t indices[], int indexCount, const SkPaint &paint)Draw the array of vertices, interpreted as triangles (based on mode). More…
voiddrawVertices (VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], const sk_sp< SkXfermode > &xmode, const uint16_t indices[], int indexCount, const SkPaint &paint)
voiddrawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkXfermode *xmode, const SkPaint &paint)Draw a cubic coons patch. More…
voiddrawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], const sk_sp< SkXfermode > &xmode, const SkPaint &paint)
voiddrawAtlas (const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkXfermode::Mode, const SkRect *cullRect, const SkPaint *paint)Draw a set of sprites from the atlas. More…
voiddrawAtlas (const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], int count, const SkRect *cullRect, const SkPaint *paint)
voiddrawAtlas (const sk_sp< SkImage > &atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkXfermode::Mode mode, const SkRect *cull, const SkPaint *paint)
voiddrawAtlas (const sk_sp< SkImage > &atlas, const SkRSXform xform[], const SkRect tex[], int count, const SkRect *cullRect, const SkPaint *paint)
voiddrawDrawable (SkDrawable drawable, const SkMatrix =NULL)Draw the contents of this drawable into the canvas. More…
voiddrawDrawable (SkDrawable *, SkScalar x, SkScalar y)
voiddrawAnnotation (const SkRect &, const char key[], SkData *value)Send an “annotation” to the canvas. More…
voiddrawAnnotation (const SkRect &rect, const char key[], const sk_sp< SkData > &value)

SkPaint

SkXfermode

skia SkXfermode

android Xfermode
android Xfermode

android PorterDeff
PorterDeff

ShShader

  • Bitmap Shader
  • Radial Gradient Shader
  • Two-Point Conical Gradient Shader
  • Sweep Gradient Shader
  • Fractal Perlin Noise Shader
  • Turbulence Perlin Noise Shader
  • Compose Shader

android

  • android.graphics.SweepGradient
  • android.graphics.BitmapShader
  • android.graphics.RadialGradient
  • android.graphics.LinearGradient
  • android.graphics.ComposeShader

这里写图片描述

SkMaskFilter

  • Blur Mask Filter
  • Emboss Mask Filter

android
- android.graphics.EmbossMaskFilter
- android.graphics.BlurMaskFilter

SkColorFilter

  • Color Matrix Color Filter
  • Color Table Color Filter

android
- android.graphics.ColorMatrixColorFilter
- android.graphics.LightingColorFilter
- android.graphics.PorterDuffColorFilter

SkPathEffect

  • SkPath2DPathEffect
  • SkLine2DPathEffect
  • SkPath1DPathEffect
  • SkArcToPathEffect
  • SkCornerPathEffect
  • SkDashPathEffect
  • SkDiscretePathEffect
  • SkComposePathEffect
  • SkSumPathEffect

android

  • android.graphics.DiscretePathEffect
  • android.graphics.DashPathEffect
  • android.graphics.CornerPathEffect
  • android.graphics.ComposePathEffect
  • android.graphics.SumPathEffect
  • android.graphics.PathDashPathEffect

SkRect

android

  • android.graphics.Rect
  • android.graphics.RectF

SkRegion

android对应类 android.graphics.Region

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值