17 explicit DlImpellerPixelData(
18 std::unique_ptr<impeller::testing::Screenshot> screenshot)
19 : screenshot_(
std::move(screenshot)) {}
20 ~DlImpellerPixelData()
override =
default;
22 virtual const uint32_t*
addr32(uint32_t
x, uint32_t
y)
const override {
27 size_t offset = safe_math.
mul(screenshot_->GetBytesPerRow(),
y);
28 offset += safe_math.
mul(
x, 4u);
32 return reinterpret_cast<const uint32_t*
>(screenshot_->GetBytes() + offset);
35 virtual size_t width()
const override {
return screenshot_->GetWidth(); }
36 virtual size_t height()
const override {
return screenshot_->GetHeight(); }
38 virtual bool write(
const std::string& path)
const override {
39 return screenshot_->WriteToPNG(path);
43 std::unique_ptr<impeller::testing::Screenshot> screenshot_;
52 std::shared_ptr<impeller::Context> context,
53 std::shared_ptr<impeller::Surface> surface)
54 : context_(
std::move(context)),
56 aiks_context_(context_, typographer_context_) {}
59 std::shared_ptr<impeller::Context> context,
60 std::shared_ptr<impeller::RenderTarget>
target)
61 : context_(
std::move(context)),
63 aiks_context_(context_, typographer_context_) {}
68DlSurfaceInstanceImpeller::GetRenderTarget()
const {
70 return surface_->GetRenderTarget();
73 return *target_holder_;
83 std::ignore = builder_.
Build();
85 builder_.
Clear(color);
86 DoRenderDisplayList(builder_.
Build());
94 const sk_sp<DisplayList>& display_list) {
96 DoRenderDisplayList(display_list);
101 if (!context_->FinishQueue()) {
102 FML_LOG(ERROR) <<
"Impeller backend did not implement FinishQueue";
107inline void DlSurfaceInstanceImpeller::Flush() {
110 DoRenderDisplayList(builder_.
Build());
114void DlSurfaceInstanceImpeller::DoRenderDisplayList(
115 const sk_sp<DisplayList>& display_list) {
119 DlRect cull_rect = display_list->GetBounds().
Expand(1.0f);
121 display_list, cull_rect,
false,
false);
126 std::unique_ptr<impeller::testing::Screenshot> snapshot =
128 GetRenderTarget().GetRenderTargetTexture());
129 return snapshot ? std::make_unique<DlImpellerPixelData>(std::move(snapshot))
142 context_, temp_image->width(), temp_image->height(),
143 DlSurfaceProvider::PixelFormat::kN32Premul);
146 image_surface->GetCanvas()->DrawImage(temp_image,
DlPoint(0, 0),
148 image_surface->FlushSubmitCpuSync();
153 image_surface->GetRenderTarget().GetRenderTargetTexture());
168std::shared_ptr<impeller::TypographerContext>
169 DlSurfaceInstanceImpeller::typographer_context_ =
bool IsEmpty() const
Return true if the builder has not yet recorded any commands.
sk_sp< DisplayList > Build()
Developer-facing API for rendering anything within the engine.
void Clear(DlColor color)
virtual size_t height() const =0
virtual const uint32_t * addr32(uint32_t x, uint32_t y) const =0
virtual bool write(const std::string &path) const =0
virtual size_t width() const =0
void RenderDisplayList(const sk_sp< DisplayList > &display_list) override
DlSurfaceInstanceImpeller(std::shared_ptr< impeller::Context > context, std::shared_ptr< impeller::Surface > surface)
int height() const override
The height of the underlying surface.
bool SnapshotToFile(std::string &filename) const override
Store a snapshot of this Surface to the file indicated by the filename.
virtual ~DlSurfaceInstanceImpeller()
std::unique_ptr< DlPixelData > SnapshotToPixelData() const override
sk_sp< DlImage > SnapshotToImage() const override
void Clear(const DlColor &color) override
Clear the entire surface to the indicated color.
void FlushSubmitCpuSync() override
int width() const override
The width of the underlying surface.
DlCanvas * GetCanvas() override
std::unique_ptr< DlSurfaceInstance > MakeOffscreenSurface(size_t width, size_t height, PixelFormat format) const override
size_t mul(size_t x, size_t y)
bool overflow_detected() const
ContentContext & GetContentContext() const
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
std::shared_ptr< Texture > GetRenderTargetTexture() const
ISize GetRenderTargetSize() const
static std::shared_ptr< TypographerContext > Make()
#define FML_LOG(severity)
#define FML_UNREACHABLE()
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, Rect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.