ScenicFramework / scenic

Core Scenic library
Apache License 2.0
1.97k stars 137 forks source link

Add screenshot callback #265

Open crertel opened 2 years ago

crertel commented 2 years ago

Description

This adds an optional take_screenshot callback to the Scenic.Driver callback list.

This would be a way forward for screenshots that would allow pulling framebuffers from both a local driver (say, OpenGL-backed) or a web driver (say, HTML5 canvas). If a driver doesn't support a screenshot for whatever reason, this should still return a useful value of {:ok, :not_supported, driver}.

Motivation and Context

We currently don't have an easy way of grabbing the framebuffer from a driver.

This starts putting into place an interface that drivers can implement that does so.

The next step, if this is the direction we want to go, is getting this merged and updating scenic_driver_local and other drivers to support this.

Types of changes

Checklist

crertel commented 2 years ago

@boydm as per our convo, we want to update this to use a streaming bitmap instead of the type I added.

boydm commented 2 years ago

I think the returned result should be of type Scenic.Assets.Stream.Bitmap.t()

We don't need to define a new type here, when the existing stream-able bitmap format already has all the same fields.

Additionally, if it is a Bitmap.t(), then it can be passed directly into the streaming bitmap functions.