Flutter Engine
The Flutter Engine
Protected Member Functions | List of all members
org.skia.jetskidemo.AnimationRenderer Class Reference
Inheritance diagram for org.skia.jetskidemo.AnimationRenderer:
org.skia.jetski.util.SurfaceRenderer

Protected Member Functions

void onSurfaceInitialized (Surface surface)
 
void onRenderFrame (Canvas canvas, long ms)
 
abstract void onSurfaceInitialized (Surface surface)
 
abstract void onRenderFrame (Canvas canvas, long ms)
 

Additional Inherited Members

- Public Member Functions inherited from org.skia.jetski.util.SurfaceRenderer
void run ()
 
void surfaceCreated (SurfaceHolder holder)
 
void surfaceChanged (SurfaceHolder holder, int format, int width, int height)
 
void surfaceDestroyed (SurfaceHolder holder)
 
void setBaseTime (long millis)
 
void release ()
 

Detailed Description

Definition at line 16 of file AnimationActivity.java.

Member Function Documentation

◆ onRenderFrame()

void org.skia.jetskidemo.AnimationRenderer.onRenderFrame ( Canvas  canvas,
long  ms 
)
inlineprotected

Callback for frame content.

Invoked once per (vsync'ed) frame.

Reimplemented from org.skia.jetski.util.SurfaceRenderer.

Definition at line 57 of file AnimationActivity.java.

57 {
58 final float kWidth = 400,
59 kHeight = 200,
60 kSpeed = 4;
61
62 canvas.drawColor(0xffffffe0);
63
64 float cw = canvas.getWidth(),
65 ch = canvas.getHeight(),
66 osc1 = (float)(java.lang.Math.cos(ms * kSpeed / 1000)),
67 osc2 = (float)(java.lang.Math.sin(ms * kSpeed / 1000));
68
69 drawRect(canvas, (1 + osc1)*cw/2, ch/2, mLinearGradient);
70 drawRect(canvas, (1 - osc1)*cw/2, ch/2, mConicalGradient);
71 drawRect(canvas, cw/2, (1 + osc2)*ch/2, mRadialGradient);
72 drawRect(canvas, cw/2, (1 - osc2)*ch/2, mSweepGradient);
73 }
void drawColor(Color c)
Definition: Canvas.java:99
constexpr size_t kHeight
constexpr size_t kWidth

◆ onSurfaceInitialized()

void org.skia.jetskidemo.AnimationRenderer.onSurfaceInitialized ( Surface  surface)
inlineprotected

Initialization callback.

This can be invoked multiple times if the underlying surface changes.

Reimplemented from org.skia.jetski.util.SurfaceRenderer.

Definition at line 29 of file AnimationActivity.java.

29 {
30 float sw = surface.getWidth(),
31 sh = surface.getHeight();
32
33 float[] colors1 = {
34 1,0,0,1,
35 0,1,0,1,
36 0,0,1,1
37 };
38 int[] colors2 = {
39 0xffffff00,
40 0xff00ffff,
41 0xffff00ff
42 };
43
44 float[] pos = {0, 0.5f, 1};
45
46 mLinearGradient = new LinearGradient(0, 0, sw/4, 0,
47 colors1, pos, TileMode.REPEAT);
48 mRadialGradient = new RadialGradient(sw/2, sh/4, Math.min(sw, sh)/2,
49 colors2, pos, TileMode.REPEAT);
50 mConicalGradient = new TwoPointConicalGradient(sw/4, sh/2, sw/4,
51 sw/2, sh/2, sw/2,
52 colors1, pos, TileMode.MIRROR);
53 mSweepGradient = new SweepGradient(sw/2, sh/4, 0, 90, colors2, pos, TileMode.REPEAT);
54 }
SkPoint pos
VkSurfaceKHR surface
Definition: main.cc:49
sh
Definition: run_sh.py:10
SK_API sk_sp< PrecompileShader > LinearGradient()
SK_API sk_sp< PrecompileShader > RadialGradient()
SK_API sk_sp< PrecompileShader > SweepGradient()
SK_API sk_sp< PrecompileShader > TwoPointConicalGradient()

The documentation for this class was generated from the following file: