Flutter Engine
 
Loading...
Searching...
No Matches
surface_producer.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_SURFACE_PRODUCER_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_SURFACE_PRODUCER_H_
7
8#include <fuchsia/sysmem2/cpp/fidl.h>
9#include <fuchsia/ui/composition/cpp/fidl.h>
10#include <lib/zx/event.h>
11
12#include <functional>
13#include <memory>
14#include <vector>
15
16#include "third_party/skia/include/core/SkSize.h"
17#include "third_party/skia/include/core/SkSurface.h"
18#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
19
20namespace flutter_runner {
21
22using ReleaseImageCallback = std::function<void()>;
23
24// This represents an abstract notion of a "rendering surface", which is a
25// destination for pixels drawn by some rendering engine. In this case, the
26// rendering engine is Skia combined with one of its rendering backends.
27//
28// In addition to allowing Skia-based drawing via `GetSkiaSurface`, this
29// rendering surface can be shared with Scenic via `SetImageId`,
30// `GetBufferCollectionImportToken`, `GetAcquireFene`, and `GetReleaseFence`.
32 public:
33 virtual ~SurfaceProducerSurface() = default;
34
35 virtual bool IsValid() const = 0;
36
37 virtual SkISize GetSize() const = 0;
38
39 virtual void SetImageId(uint32_t image_id) = 0;
40
41 virtual uint32_t GetImageId() = 0;
42
43 virtual sk_sp<SkSurface> GetSkiaSurface() const = 0;
44
45 virtual fuchsia::ui::composition::BufferCollectionImportToken
47
48 virtual zx::event GetAcquireFence() = 0;
49
50 virtual zx::event GetReleaseFence() = 0;
51
53 ReleaseImageCallback release_image_callback) = 0;
54
55 virtual size_t AdvanceAndGetAge() = 0;
56
58
60 const std::function<void(void)>& on_writes_committed) = 0;
61};
62
63// This represents an abstract notion of "surface producer", which serves as a
64// source for `SurfaceProducerSurface`s. Produces surfaces should be returned
65// to this `SurfaceProducer` via `SubmitSurfaces`, at which point they will be
66// shared with Scenic.
68 public:
69 virtual ~SurfaceProducer() = default;
70
71 virtual GrDirectContext* gr_context() const = 0;
72
73 virtual std::unique_ptr<SurfaceProducerSurface> ProduceOffscreenSurface(
74 const SkISize& size) = 0;
75 virtual std::unique_ptr<SurfaceProducerSurface> ProduceSurface(
76 const SkISize& size) = 0;
77
78 virtual void SubmitSurfaces(
79 std::vector<std::unique_ptr<SurfaceProducerSurface>> surfaces) = 0;
80};
81
82} // namespace flutter_runner
83
84#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_SURFACE_PRODUCER_H_
virtual ~SurfaceProducer()=default
virtual void SubmitSurfaces(std::vector< std::unique_ptr< SurfaceProducerSurface > > surfaces)=0
virtual GrDirectContext * gr_context() const =0
virtual std::unique_ptr< SurfaceProducerSurface > ProduceSurface(const SkISize &size)=0
virtual std::unique_ptr< SurfaceProducerSurface > ProduceOffscreenSurface(const SkISize &size)=0
virtual fuchsia::ui::composition::BufferCollectionImportToken GetBufferCollectionImportToken()=0
virtual sk_sp< SkSurface > GetSkiaSurface() const =0
virtual zx::event GetReleaseFence()=0
virtual zx::event GetAcquireFence()=0
virtual SkISize GetSize() const =0
virtual void SignalWritesFinished(const std::function< void(void)> &on_writes_committed)=0
virtual void SetImageId(uint32_t image_id)=0
virtual bool FlushSessionAcquireAndReleaseEvents()=0
virtual void SetReleaseImageCallback(ReleaseImageCallback release_image_callback)=0
std::function< void()> ReleaseImageCallback