-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new SurfaceProducer external texture class for rendering platform…
… views (#49201) - Fix lots of bugs in the implementation of ImageReaderSurfaceProducer - Add test that we drop frames produced from the wrong size - Hookup platform views to use new external texture class Related: [#139230](flutter/flutter#139230) Related: [#139702](flutter/flutter#139702)
- Loading branch information
1 parent
187334c
commit e70d1ad
Showing
6 changed files
with
202 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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