Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 =
26 image.makeShader(TileMode.REPEAT, TileMode.REPEAT,
27 new SamplingOptions(SamplingOptions.FilterMode.LINEAR));
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}
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
void render(Canvas canvas, long t, float left, float top, float right, float bottom)
sk_sp< SkImage > image
Definition examples.cpp:29