public class RenderLoop extends Object
This class provides methods to start, stop, pause, or resume rendering loops, and to add or cancel tasks in the rendering loops.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
RenderLoop.FrameListener |
Provides the listener for frame rendering events.
|
| 构造器 | 说明 |
|---|---|
RenderLoop(ViewHolder viewHolder,
Engine engine) |
Creates a rendering loop.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
cancelAllTasks() |
Cancels all tasks that are being executed.
|
boolean |
cancelTask(Task task) |
Cancels a task in the queue.
|
int |
getVsyncCount() |
Obtains the V-Sync based on rendering restrictions.
|
void |
pause() |
Pause rendering.
|
void |
release() |
Releases the rendering loop.
|
void |
requestRender() |
Requests rendering on a frame.
|
void |
resume() |
Resumes the rendering that has been paused.
|
void |
setFrameListener(RenderLoop.FrameListener frameListener) |
Sets the listener for frame events.
|
void |
setRenderNodeGraph(Engine.RenderNodeGraph renderNodeGraph) |
Sets the rendering node graph.
|
void |
setRenderNodeGraph(Engine.RenderNodeGraphType renderNodeGraphType) |
Sets the rendering node graph using a set of predefined options.
|
void |
setVsyncCount(int vsyncCount) |
Sets the vertical synchronization (VSync) based on the rendering frequency.
|
void |
startRendering() |
Starts the rendering loop.
|
void |
stopRendering() |
Stops the rendering loop.
|
void |
submitTask(Task task) |
Add a task that is to be executed in the rendering loop.
|
public RenderLoop(ViewHolder viewHolder, Engine engine)
viewHolder - Indicates the view holder used as the rendering target.engine - Indicates the rendering engine.public void setRenderNodeGraph(Engine.RenderNodeGraph renderNodeGraph)
This method is used to configure the rendering pipeline.
You can also use setRenderNodeGraph(ohos.agp.render.render3d.Engine.RenderNodeGraphType)
to apply the default configuration.
renderNodeGraph - Indicates the rendering node graph.NullPointerException - Throws this exception if the parameter is null.public void setRenderNodeGraph(Engine.RenderNodeGraphType renderNodeGraphType)
renderNodeGraphType - Indicates the rendering node graph used for rendering.NullPointerException - Throws this exception if the parameter is null.public void startRendering()
public void submitTask(Task task)
task - Indicates the task to execute.public boolean cancelTask(Task task)
task - Indicates the task to cancel.true if the task is cleared from the queue; returns false otherwise.public void cancelAllTasks()
public void requestRender()
public void stopRendering()
public void pause()
public void resume()
public void setFrameListener(RenderLoop.FrameListener frameListener)
frameListener - Indicates the listener for frame events.public void setVsyncCount(int vsyncCount)
The rendering frequency values 1, 2, and 3 indicate the rendering is performed
on every frame, every other frame, and every three frames respectively. For example, if the VSync is
60 Hz and the rendering frequency value is 2, the rendering frame rate is 30 fps.
vsyncCount - v-sync based rendering frequency.public int getVsyncCount()
setVsyncCount(int).public void release()