Flutter Engine
The Flutter Engine
ImageShaderSample.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
8package org.skia.jetskidemo.samples;
9
10import android.content.res.Resources;
11
12import org.skia.jetski.Canvas;
13import org.skia.jetski.Image;
14import org.skia.jetski.Paint;
15import org.skia.jetski.SamplingOptions;
16import org.skia.jetski.Shader;
17import org.skia.jetski.TileMode;
18
19public class ImageShaderSample implements Sample {
20 private Paint mPaint = new Paint();
21
22 public ImageShaderSample(Resources res, int resId) {
23 try {
24 Image image = Image.fromStream(res.openRawResource(resId));
25 Shader shader =
28 mPaint.setShader(shader);
29 } catch (Exception e) {}
30 }
31
32 public void render(Canvas canvas, long t, float left, float top, float right, float bottom) {
33 canvas.drawRect(left, top, right, bottom, mPaint);
34 }
35}
void drawRect(float left, float top, float right, float bottom, Paint paint)
Definition: Canvas.java:95
static Image fromStream(InputStream encodedStream)
Definition: Image.java:33
Paint setShader(@Nullable Shader shader)
Definition: Paint.java:34
void render(Canvas canvas, long t, float left, float top, float right, float bottom)
sk_sp< const SkImage > image
Definition: SkRecords.h:269