This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Use new SurfaceProducer external texture class for rendering platform views #49201
Merged
johnmccutchan
merged 1 commit into
flutter:main
from
johnmccutchan:surface_producer_platform_views
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
.../platform/android/io/flutter/plugin/platform/SurfaceProducerPlatformViewRenderTarget.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package io.flutter.plugin.platform; | ||
|
|
||
| import android.annotation.TargetApi; | ||
| import android.graphics.Canvas; | ||
| import android.view.Surface; | ||
| import io.flutter.view.TextureRegistry.SurfaceProducer; | ||
|
|
||
| @TargetApi(29) | ||
| public class SurfaceProducerPlatformViewRenderTarget implements PlatformViewRenderTarget { | ||
| private static final String TAG = "SurfaceProducerRenderTarget"; | ||
| private SurfaceProducer producer; | ||
|
|
||
| public SurfaceProducerPlatformViewRenderTarget(SurfaceProducer producer) { | ||
| this.producer = producer; | ||
| } | ||
|
|
||
| // Called when the render target should be resized. | ||
| public void resize(int width, int height) { | ||
| this.producer.setSize(width, height); | ||
| } | ||
|
|
||
| // Returns the currently specified width. | ||
| public int getWidth() { | ||
| return this.producer.getWidth(); | ||
| } | ||
|
|
||
| // Returns the currently specified height. | ||
| public int getHeight() { | ||
| return this.producer.getHeight(); | ||
| } | ||
|
|
||
| // Forwards call to Surface returned by getSurface. | ||
| // NOTE: If this returns null the RenderTarget is "full" and has no room for a | ||
| // new frame. | ||
| public Canvas lockHardwareCanvas() { | ||
| Surface surface = this.producer.getSurface(); | ||
| return surface.lockHardwareCanvas(); | ||
| } | ||
|
|
||
| // Forwards call to Surface returned by getSurface. | ||
| // NOTE: Must be called if lockHardwareCanvas returns a non-null Canvas. | ||
| public void unlockCanvasAndPost(Canvas canvas) { | ||
| Surface surface = this.producer.getSurface(); | ||
| surface.unlockCanvasAndPost(canvas); | ||
| } | ||
|
|
||
| // The id of this render target. | ||
| public long getId() { | ||
| return this.producer.id(); | ||
| } | ||
|
|
||
| // Releases backing resources. | ||
| public void release() { | ||
| this.producer.release(); | ||
| this.producer = null; | ||
| } | ||
|
|
||
| // Returns true in the case that backing resource have been released. | ||
| public boolean isReleased() { | ||
| return this.producer == null; | ||
| } | ||
|
|
||
| // Returns the Surface to be rendered on to. | ||
| public Surface getSurface() { | ||
| return this.producer.getSurface(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.