[androidkit] Add an extra Skottie sample to CubeActivity

Also update SkottieSample to always clear its dest rect (for animations
which are not opaque).

Change-Id: I36c6172d468567ee8e03d97dd707e03ca968aa26
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414898
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
This commit is contained in:
Florin Malita 2021-06-02 11:49:48 -04:00 committed by Skia Commit-Bot
parent 0844cfa839
commit c27e0dc64f
3 changed files with 7 additions and 1 deletions

View File

@ -188,7 +188,7 @@ class CubeRenderer extends SurfaceRenderer implements GestureDetector.OnGestureL
new Face(0, -rot/2, new ImageShaderSample(res, R.raw.brickwork_texture)),
new Face(0, 0 , new SkottieSample(res, R.raw.im_thirsty)),
new Face(0, rot , new RuntimeSample(res, R.raw.runtime_shader1)),
new Face(rot/2, 0 , new SolidColorSample(0, 0, 1, 1)),
new Face(rot/2, 0 , new SkottieSample(res, R.raw.permission)),
new Face(-rot/2, 0, new SolidColorSample(1, 1, 0, 1)),
new Face(0, rot/2 , new RuntimeSample(res, R.raw.runtime_shader2)),
};

View File

@ -13,11 +13,13 @@ import java.io.InputStream;
import org.skia.androidkit.Canvas;
import org.skia.androidkit.Matrix;
import org.skia.androidkit.Paint;
import org.skia.androidkit.SkottieAnimation;
import org.skia.androidkitdemo1.samples.Sample;
public class SkottieSample implements Sample {
private Paint mClearPaint = new Paint().setColor(0.8f, 0.8f, 0.8f, 1);
private SkottieAnimation mAnimation;
public SkottieSample(Resources res, int resId) {
@ -34,6 +36,8 @@ public class SkottieSample implements Sample {
}
public void render(Canvas canvas, long ms, float left, float top, float right, float bottom) {
canvas.drawRect(left, top, right, bottom, mClearPaint);
double t = (double)ms / 1000 % mAnimation.getDuration();
mAnimation.seekTime(t);
@ -41,6 +45,7 @@ public class SkottieSample implements Sample {
h = bottom - top,
s = Math.min(w / mAnimation.getWidth(),
h / mAnimation.getHeight());
canvas.save();
canvas.concat(new Matrix().translate(left + (w - s*mAnimation.getWidth() )/2,
top + (h - s*mAnimation.getHeight())/2)

File diff suppressed because one or more lines are too long