Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
org.skia.jetskidemo.CubeRenderer Class Reference
Inheritance diagram for org.skia.jetskidemo.CubeRenderer:
org.skia.jetski.util.SurfaceRenderer

Public Member Functions

 CubeRenderer (Resources res)
 
boolean onFling (MotionEvent e1, MotionEvent e2, float dx, float dy)
 
boolean onDown (MotionEvent e)
 
boolean onScroll (MotionEvent e1, MotionEvent e2, float dx, float dy)
 
boolean onSingleTapUp (MotionEvent e)
 
void onLongPress (MotionEvent e)
 
void onShowPress (MotionEvent e)
 
boolean onScale (ScaleGestureDetector detector)
 
boolean onScaleBegin (ScaleGestureDetector detector)
 
void onScaleEnd (ScaleGestureDetector detector)
 
- Public Member Functions inherited from org.skia.jetski.util.SurfaceRenderer
void run ()
 
void surfaceCreated (SurfaceHolder holder)
 
void surfaceChanged (SurfaceHolder holder, int format, int width, int height)
 
void surfaceDestroyed (SurfaceHolder holder)
 
void setBaseTime (long millis)
 
void release ()
 

Protected Member Functions

void onSurfaceInitialized (Surface surface)
 
void onRenderFrame (Canvas canvas, long ms)
 
abstract void onSurfaceInitialized (Surface surface)
 
abstract void onRenderFrame (Canvas canvas, long ms)
 

Detailed Description

Definition at line 157 of file CubeActivity.java.

Constructor & Destructor Documentation

◆ CubeRenderer()

org.skia.jetskidemo.CubeRenderer.CubeRenderer ( Resources  res)
inline

Definition at line 166 of file CubeActivity.java.

166 {
167 final float rot = (float) Math.PI;
168 mFaces = new Face[] {
169 new Face(0, -rot/2, new ImageShaderSample(res, R.raw.brickwork_texture)),
170 new Face(0, 0 , new SkottieSample(res, R.raw.im_thirsty)),
171 new Face(0, rot , new RuntimeSample(res, R.raw.runtime_shader1)),
172 new Face(rot/2, 0 , new SkottieSample(res, R.raw.permission)),
173 new Face(0, rot/2 , new RuntimeSample(res, R.raw.runtime_shader2)),
174 };
175 }
#define R(r)

Member Function Documentation

◆ onDown()

boolean org.skia.jetskidemo.CubeRenderer.onDown ( MotionEvent  e)
inline

Definition at line 256 of file CubeActivity.java.

256 {
257 mVSphere.startDrag(e);
258 return true;
259 }

◆ onFling()

boolean org.skia.jetskidemo.CubeRenderer.onFling ( MotionEvent  e1,
MotionEvent  e2,
float  dx,
float  dy 
)
inline

Definition at line 250 of file CubeActivity.java.

250 {
251 mVSphere.fling(dx, dy);
252 return true;
253 }
void fling(float dx, float dy)
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208

◆ onLongPress()

void org.skia.jetskidemo.CubeRenderer.onLongPress ( MotionEvent  e)
inline

Definition at line 272 of file CubeActivity.java.

272{}

◆ onRenderFrame()

void org.skia.jetskidemo.CubeRenderer.onRenderFrame ( Canvas  canvas,
long  ms 
)
inlineprotected

Callback for frame content.

Invoked once per (vsync'ed) frame.

Reimplemented from org.skia.jetski.util.SurfaceRenderer.

Definition at line 204 of file CubeActivity.java.

204 {
205 if (mPrevMS == 0) {
206 mPrevMS = ms;
207 }
208
209 mVSphere.animate((ms - mPrevMS) / 1000.f);
210 mPrevMS = ms;
211
212
213 // clear canvas
214 canvas.drawColor(0xffffffff);
215
216 canvas.save();
217 canvas.concat(mViewMatrix);
218 canvas.scale(mZoom, mZoom);
219 canvas.concat(mVSphere.getMatrix());
220
221 drawFaces(canvas, ms, false);
222 drawFaces(canvas, ms, true);
223
224 canvas.restore();
225 }

◆ onScale()

boolean org.skia.jetskidemo.CubeRenderer.onScale ( ScaleGestureDetector  detector)
inline

Definition at line 289 of file CubeActivity.java.

289 {
290 zoom(detector.getScaleFactor());
291 return true;
292 }

◆ onScaleBegin()

boolean org.skia.jetskidemo.CubeRenderer.onScaleBegin ( ScaleGestureDetector  detector)
inline

Definition at line 295 of file CubeActivity.java.

295 {
296 zoom(detector.getScaleFactor());
297 return true;
298 }

◆ onScaleEnd()

void org.skia.jetskidemo.CubeRenderer.onScaleEnd ( ScaleGestureDetector  detector)
inline

Definition at line 301 of file CubeActivity.java.

301 {
302 zoom(detector.getScaleFactor());
303 }

◆ onScroll()

boolean org.skia.jetskidemo.CubeRenderer.onScroll ( MotionEvent  e1,
MotionEvent  e2,
float  dx,
float  dy 
)
inline

Definition at line 262 of file CubeActivity.java.

262 {
263 mVSphere.drag(e2);
264 return true;
265 }

◆ onShowPress()

void org.skia.jetskidemo.CubeRenderer.onShowPress ( MotionEvent  e)
inline

Definition at line 275 of file CubeActivity.java.

275{}

◆ onSingleTapUp()

boolean org.skia.jetskidemo.CubeRenderer.onSingleTapUp ( MotionEvent  e)
inline

Definition at line 269 of file CubeActivity.java.

269{ return false; }

◆ onSurfaceInitialized()

void org.skia.jetskidemo.CubeRenderer.onSurfaceInitialized ( Surface  surface)
inlineprotected

Initialization callback.

This can be invoked multiple times if the underlying surface changes.

Reimplemented from org.skia.jetski.util.SurfaceRenderer.

Definition at line 178 of file CubeActivity.java.

178 {
179 float cx = surface.getWidth() / 2,
180 cy = surface.getHeight() / 2,
181 r = Math.min(cx, cy);
182
183 mVSphere = new VSphereAnimator(cx, cy, r);
184
185 // square viewport size fitting the given surface
186 float vsz = r * 2;
187
188 mCubeSideLength = vsz * 0.5f;
189
190 float viewAngle = (float)Math.PI / 4f,
191 viewDistance = (float)(r / tan(viewAngle/2));
192
193 mViewMatrix = new Matrix()
194 // centered viewport
195 .translate(cx, cy)
196 // perspective
197 .scale(vsz/2, vsz/2, 1)
198 .preConcat(Matrix.makePerspective(0.05f, viewDistance, viewAngle))
199 // camera
200 .preConcat(Matrix.makeLookAt(0, 0, -viewDistance, 0, 0, 0, 0, 1, 0));
201 }
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< PrecompileColorFilter > Matrix()

The documentation for this class was generated from the following file: