Flutter Engine
The Flutter Engine
Classes | Protected Member Functions | Static Package Functions | List of all members
org.skia.jetskidemo.MainActivity Class Reference
Inheritance diagram for org.skia.jetskidemo.MainActivity:

Classes

class  DemoRuntimeShaderRenderer
 

Protected Member Functions

void onCreate (Bundle savedInstanceState)
 

Static Package Functions

 [static initializer]
 

Detailed Description

Definition at line 27 of file MainActivity.java.

Member Function Documentation

◆ [static initializer]()

org.skia.jetskidemo.MainActivity.[static initializer]
inlinestaticpackage

◆ onCreate()

void org.skia.jetskidemo.MainActivity.onCreate ( Bundle  savedInstanceState)
inlineprotected

Definition at line 36 of file MainActivity.java.

36 {
37 super.onCreate(savedInstanceState);
38 setContentView(R.layout.activity_main);
39
40 Paint p = new Paint();
41 p.setColor(new Color(0, 1, 0, 1));
42
43 /*
44 * Draw into a Java Bitmap through software using Skia's native API.
45 * Load the Bitmap into an ImageView.
46 * Applies Matrix transformations to canvas
47 */
48 Bitmap.Config conf = Bitmap.Config.ARGB_8888;
49 Bitmap bmp = Bitmap.createBitmap(400, 400, conf);
50 Surface bitmapSurface = new Surface(bmp);
51 Canvas canvas = bitmapSurface.getCanvas();
52
53 canvas.drawRect(0, 0, 100, 100, p);
54
55 float[] m = {1, 0, 0, 100,
56 0, 1, 0, 100,
57 0, 0, 1, 0,
58 0, 0, 0, 1};
59 p.setColor(new Color(0, 0, 1, 1));
60 canvas.save();
61 canvas.concat(m);
62 canvas.drawRect(0, 0, 100, 100, p);
63 canvas.restore();
64
65 Image snapshot = bitmapSurface.makeImageSnapshot();
66 canvas.drawImage(snapshot, 0, 200);
67
68 try {
69 Image image = Image.fromStream(getResources().openRawResource(R.raw.brickwork_texture));
70 // TODO: Canvas.scale
71 canvas.concat(new Matrix().scale(10, 10));
72 canvas.drawImage(image, 20, 0, SamplingOptions.CATMULLROM());
73 } catch (Exception e) {
74 Log.e("JetSki Demo", "Could not load Image resource: " + R.raw.brickwork_texture);
75 }
76 bitmapImage = findViewById(R.id.bitmapImage);
77 bitmapImage.setImageBitmap(bmp);
78
79 /*
80 * Draw into a SurfaceView's surface with GL
81 * The ThreadedSurface is handled by JetSki through native code
82 */
83 SurfaceView surfaceView = findViewById(R.id.threadedSurface);
84 surfaceView.getHolder().addCallback(new ThreadedSurfaceHandler());
85
86 /*
87 * Draw into a SurfaceView's surface with GL
88 * The thread is handled using a util RenderThread provided by JetSki
89 */
90 SurfaceView runtimeEffectView = findViewById(R.id.runtimeEffect);
91 runtimeEffectView.getHolder().addCallback(new DemoRuntimeShaderRenderer());
92
93 /*
94 * SkottieView added programmatically to view hierarchy
95 */
96 SkottieView skottieView = new SkottieView(this, R.raw.im_thirsty, new Color(1, 1, 1, 1));
97 skottieView.setLayoutParams(new ViewGroup.LayoutParams(400, 400));
98 skottieView.setOnClickListener((View v) -> {
99 SkottieView s = (SkottieView)v;
100 s.pause();
101 });
102 LinearLayout skottieContainer = findViewById(R.id.skottie_container);
103 skottieContainer.addView(skottieView);
104 }
void drawImage(Image image, float x, float y)
Definition: Canvas.java:116
void drawRect(float left, float top, float right, float bottom, Paint paint)
Definition: Canvas.java:95
void concat(Matrix m)
Definition: Canvas.java:49
static Image fromStream(InputStream encodedStream)
Definition: Image.java:33
static SamplingOptions CATMULLROM()
struct MyStruct s
#define R(r)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API sk_sp< SkShader > Color(SkColor)
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137
SK_API sk_sp< PrecompileColorFilter > Matrix()
const Scalar scale

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