Flutter Engine
The Flutter Engine
third_party
skia
platform_tools
android
apps
jetskidemo
src
main
java
org
skia
jetskidemo
samples
SkottieSample.java
Go to the documentation of this file.
1
/*
2
* Copyright 2021 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
package
org.skia.jetskidemo.samples;
9
10
import
android
.content.res.Resources;
11
12
import
java.io.InputStream;
13
14
import
org.
skia
.jetski.Canvas;
15
import
org.skia.jetski.Matrix;
16
import
org.skia.jetski.Paint;
17
import
org.skia.jetski.SkottieAnimation;
18
19
public
class
SkottieSample
implements
Sample
{
20
private
Paint
mClearPaint =
new
Paint
().
setColor
(0.8
f
, 0.8
f
, 0.8
f
, 1);
21
private
SkottieAnimation
mAnimation;
22
23
public
SkottieSample
(Resources res,
int
resId) {
24
String json =
""
;
25
26
try
{
27
InputStream is = res.openRawResource(resId);
28
byte
[]
data
=
new
byte
[is.available()];
29
is.read(
data
);
30
json =
new
String(
data
);
31
}
catch
(Exception
e
) {}
32
33
mAnimation =
new
SkottieAnimation
(json);
34
}
35
36
public
void
render
(
Canvas
canvas,
long
ms,
float
left,
float
top,
float
right,
float
bottom) {
37
canvas.
drawRect
(left, top, right, bottom, mClearPaint);
38
39
double
t = (double)ms / 1000 % mAnimation.
getDuration
();
40
mAnimation.
seekTime
(t);
41
42
float
w
= right - left,
43
h
= bottom - top,
44
s
= Math.min(
w
/ mAnimation.
getWidth
(),
45
h
/ mAnimation.
getHeight
());
46
47
canvas.
save
();
48
canvas.
concat
(
new
Matrix
().translate(left + (
w
-
s
*mAnimation.
getWidth
() )/2,
49
top + (
h
-
s
*mAnimation.
getHeight
())/2)
50
.scale(
s
,
s
));
51
52
mAnimation.
render
(canvas);
53
canvas.
restore
();
54
}
55
}
org.skia.jetski.Canvas
Definition:
Canvas.java:12
org.skia.jetski.Canvas.drawRect
void drawRect(float left, float top, float right, float bottom, Paint paint)
Definition:
Canvas.java:95
org.skia.jetski.Canvas.restore
void restore()
Definition:
Canvas.java:28
org.skia.jetski.Canvas.concat
void concat(Matrix m)
Definition:
Canvas.java:49
org.skia.jetski.Canvas.save
int save()
Definition:
Canvas.java:24
org.skia.jetski.Paint
Definition:
Paint.java:12
org.skia.jetski.Paint.setColor
Paint setColor(Color c)
Definition:
Paint.java:19
org.skia.jetski.SkottieAnimation
Definition:
SkottieAnimation.java:10
org.skia.jetski.SkottieAnimation.getDuration
double getDuration()
Definition:
SkottieAnimation.java:23
org.skia.jetski.SkottieAnimation.render
void render(Canvas canvas)
Definition:
SkottieAnimation.java:74
org.skia.jetski.SkottieAnimation.getWidth
float getWidth()
Definition:
SkottieAnimation.java:38
org.skia.jetski.SkottieAnimation.getHeight
float getHeight()
Definition:
SkottieAnimation.java:45
org.skia.jetski.SkottieAnimation.seekTime
void seekTime(double t)
Definition:
SkottieAnimation.java:53
org.skia.jetskidemo.samples.SkottieSample
Definition:
SkottieSample.java:19
org.skia.jetskidemo.samples.SkottieSample.render
void render(Canvas canvas, long ms, float left, float top, float right, float bottom)
Definition:
SkottieSample.java:36
org.skia.jetskidemo.samples.SkottieSample.SkottieSample
SkottieSample(Resources res, int resId)
Definition:
SkottieSample.java:23
s
struct MyStruct s
org.skia.jetskidemo.samples.Sample
Definition:
Sample.java:12
android::skia
Definition:
BitmapRegionDecoder.cpp:15
android
Definition:
BitmapRegionDecoder.cpp:14
protoc_wrapper.e
e
Definition:
protoc_wrapper.py:226
skcms_private::f
float f
Definition:
skcms_Transform.h:121
skgpu::graphite::PrecompileColorFilters::Matrix
SK_API sk_sp< PrecompileColorFilter > Matrix()
Definition:
PrecompileColorFilter.cpp:178
w
SkScalar w
Definition:
pictureshadertile.cpp:30
h
SkScalar h
Definition:
pictureshadertile.cpp:30
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:08 for Flutter Engine by
1.9.4