Android skia浅析

来源:互联网 发布:painter for mac 编辑:程序博客网 时间:2024/06/05 14:44

skia.org
android graphics

canvas

  • Android Graphics Canvase
返回 Public Methods void drawARGB(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. void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint) Draw the specified arc, which will be scaled to fit inside the specified oval. void drawArc(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. void drawBitmap(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. void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) Draw the bitmap using the specified matrix. void drawBitmap(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. void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. void drawBitmap(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. void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. void drawBitmapMesh(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. void drawCircle(float cx, float cy, float radius, Paint paint) Draw the specified circle using the specified paint. void drawColor(int color) Fill the entire canvas’ bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode. void drawColor(int color, PorterDuff.Mode mode) Fill the entire canvas’ bitmap (restricted to the current clip) with the specified color and porter-duff xfermode. void drawLine(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. void drawLines(float[] pts, Paint paint) void drawLines(float[] pts, int offset, int count, Paint paint) Draw a series of lines. void drawOval(float left, float top, float right, float bottom, Paint paint) Draw the specified oval using the specified paint. void drawOval(RectF oval, Paint paint) Draw the specified oval using the specified paint. void drawPaint(Paint paint) Fill the entire canvas’ bitmap (restricted to the current clip) with the specified paint. void drawPath(Path path, Paint paint) Draw the specified path using the specified paint. void drawPicture(Picture picture, RectF dst) Draw the picture, stretched to fit into the dst rectangle. void drawPicture(Picture picture) Save the canvas state, draw the picture, and restore the canvas state. void drawPicture(Picture picture, Rect dst) Draw the picture, stretched to fit into the dst rectangle. void drawPoint(float x, float y, Paint paint) Helper for drawPoints() for drawing a single point. void drawPoints(float[] pts, int offset, int count, Paint paint) Draw a series of points. void drawPoints(float[] pts, Paint paint) Helper for drawPoints() that assumes you want to draw the entire array void drawPosText(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. void drawPosText(String text, float[] pos, Paint paint) Draw the text in the array, with each character’s origin specified by the pos array. void drawRGB(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. void drawRect(float left, float top, float right, float bottom, Paint paint) Draw the specified Rect using the specified paint. void drawRect(RectF rect, Paint paint) Draw the specified Rect using the specified paint. void drawRect(Rect r, Paint paint) Draw the specified Rect using the specified Paint. void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint) Draw the specified round-rect using the specified paint. void drawRoundRect(RectF rect, float rx, float ry, Paint paint) Draw the specified round-rect using the specified paint. void drawText(String text, float x, float y, Paint paint) Draw the text, with origin at (x,y), using the specified paint. void drawText(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. void drawText(char[] text, int index, int count, float x, float y, Paint paint) Draw the text, with origin at (x,y), using the specified paint. void drawText(String text, int start, int end, float x, float y, Paint paint) Draw the text, with origin at (x,y), using the specified paint. void drawTextOnPath(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. void drawTextOnPath(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. void drawTextRun(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. void drawTextRun(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. void drawVertices(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 void drawPaint (const SkPaint &paint) Fill the entire canvas (restricted to the current clip) with the specified paint. More… void drawPoints (PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint) Draw a series of points, interpreted based on the PointMode mode. More… void drawPoint (SkScalar x, SkScalar y, const SkPaint &paint) Helper method for drawing a single point. More… void drawPoint (SkScalar x, SkScalar y, SkColor color) Draws a single pixel in the specified color. More… void drawLine (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… void drawRect (const SkRect &rect, const SkPaint &paint) Draw the specified rectangle using the specified paint. More… void drawIRect (const SkIRect &rect, const SkPaint &paint) Draw the specified rectangle using the specified paint. More… void drawRectCoords (SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, const SkPaint &paint) Draw the specified rectangle using the specified paint. More… void drawOval (const SkRect &oval, const SkPaint &) Draw the specified oval using the specified paint. More… void drawRRect (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… void drawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &) Draw the annulus formed by the outer and inner rrects. More… void drawImageRect (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… void drawImageRect (const SkImage *image, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint) void drawImageRect (const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint) void drawImageRect (const sk_sp< SkImage > &image, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint cons=kStrict_SrcRectConstraint) void drawImageRect (const sk_sp< SkImage > &image, const SkRect &dst, const SkPaint *paint, SrcRectConstraint cons=kStrict_SrcRectConstraint) void drawImageNine (const SkImage *, const SkIRect &center, const SkRect &dst, const SkPaint *paint=nullptr) Draw the image stretched differentially to fit into dst. More… void drawImageNine (const sk_sp< SkImage > &image, const SkIRect &center, const SkRect &dst, const SkPaint *paint=nullptr) void drawBitmap (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… void drawBitmapRect (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… void drawBitmapRect (const SkBitmap &bitmap, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint) void drawBitmapRect (const SkBitmap &bitmap, const SkRect &dst, const SkPaint *paint, SrcRectConstraint=kStrict_SrcRectConstraint) void drawBitmapNine (const SkBitmap &bitmap, const SkIRect &center, const SkRect &dst, const SkPaint *paint=NULL) Draw the bitmap stretched differentially to fit into dst. More… void drawText (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… void drawPosText (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… void drawPosTextH (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… void drawTextOnPathHV (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… void drawTextOnPath (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… void drawTextBlob (const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) Draw the text blob, offset by (x,y), using the specified paint. More… void drawPicture (const SkPicture *picture) Draw the picture into this canvas. More… void drawPicture (const sk_sp< SkPicture > &picture) void drawPicture (const SkPicture *, const SkMatrix *matrix, const SkPaint *paint) Draw the picture into this canvas. More… void drawPicture (const sk_sp< SkPicture > &picture, const SkMatrix *matrix, const SkPaint *paint) void drawVertices (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… void drawVertices (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) void drawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkXfermode *xmode, const SkPaint &paint) Draw a cubic coons patch. More… void drawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], const sk_sp< SkXfermode > &xmode, const SkPaint &paint) void drawAtlas (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… void drawAtlas (const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], int count, const SkRect *cullRect, const SkPaint *paint) void drawAtlas (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) void drawAtlas (const sk_sp< SkImage > &atlas, const SkRSXform xform[], const SkRect tex[], int count, const SkRect *cullRect, const SkPaint *paint) void drawDrawable (SkDrawable drawable, const SkMatrix =NULL) Draw the contents of this drawable into the canvas. More… void drawDrawable (SkDrawable *, SkScalar x, SkScalar y) void drawAnnotation (const SkRect &, const char key[], SkData *value) Send an “annotation” to the canvas. More… void drawAnnotation (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

0 0
原创粉丝点击