Flutter Engine
The Flutter Engine
third_party
skia
platform_tools
android
apps
jetskidemo
src
main
java
org
skia
jetskidemo
samples
RuntimeSample.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.RuntimeShaderBuilder;
18
19
public
class
RuntimeSample
implements
Sample
{
20
private
RuntimeShaderBuilder
mShaderBuilder;
21
22
public
RuntimeSample
(Resources res,
int
resId) {
23
String sksl =
""
;
24
try
{
25
InputStream is = res.openRawResource(resId);
26
byte
[]
data
=
new
byte
[is.available()];
27
is.read(
data
);
28
29
sksl =
new
String(
data
);
30
}
catch
(Exception
e
) {}
31
32
mShaderBuilder =
new
RuntimeShaderBuilder
(sksl);
33
}
34
35
public
void
render
(
Canvas
canvas,
long
ms,
float
left,
float
top,
float
right,
float
bottom) {
36
mShaderBuilder.
setUniform
(
"u_time"
, ms / 1000.0
f
)
37
.
setUniform
(
"u_w"
, right - left)
38
.
setUniform
(
"u_h"
, bottom - top);
39
40
Paint
paint
=
new
Paint
().
setShader
(mShaderBuilder.
makeShader
());
41
42
canvas.
save
();
43
canvas.
concat
(
new
Matrix
().translate(left, top));
44
canvas.
drawRect
(0, 0, right - left, bottom - top,
paint
);
45
canvas.
restore
();
46
}
47
}
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.setShader
Paint setShader(@Nullable Shader shader)
Definition:
Paint.java:34
org.skia.jetski.RuntimeShaderBuilder
Definition:
RuntimeShaderBuilder.java:12
org.skia.jetski.RuntimeShaderBuilder.makeShader
Shader makeShader()
Definition:
RuntimeShaderBuilder.java:32
org.skia.jetski.RuntimeShaderBuilder.setUniform
RuntimeShaderBuilder setUniform(String name, float val)
Definition:
RuntimeShaderBuilder.java:19
org.skia.jetskidemo.samples.RuntimeSample
Definition:
RuntimeSample.java:19
org.skia.jetskidemo.samples.RuntimeSample.render
void render(Canvas canvas, long ms, float left, float top, float right, float bottom)
Definition:
RuntimeSample.java:35
org.skia.jetskidemo.samples.RuntimeSample.RuntimeSample
RuntimeSample(Resources res, int resId)
Definition:
RuntimeSample.java:22
paint
const Paint & paint
Definition:
color_source.cc:38
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
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