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_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_
6#define FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_
7
8#include "flutter/flow/embedded_views.h"
9#include "flutter/fml/macros.h"
10#include "flutter/shell/gpu/gpu_surface_delegate.h"
11#include "third_party/skia/include/core/SkSurface.h"
12
13namespace flutter {
14
15//------------------------------------------------------------------------------
16/// @brief Interface implemented by all platform surfaces that can present
17/// a software backing store to the "screen". The GPU surface
18/// abstraction (which abstracts the client rendering API) uses this
19/// delegation pattern to tell the platform surface (which abstracts
20/// how backing stores fulfilled by the selected client rendering
21/// API end up on the "screen" on a particular platform) when the
22/// rasterizer needs to allocate and present the software backing
23/// store.
24///
25/// @see |IOSurfaceSoftware|, |AndroidSurfaceSoftware|,
26/// |EmbedderSurfaceSoftware|.
27///
28class GPUSurfaceSoftwareDelegate : public GPUSurfaceDelegate {
29 public:
30 ~GPUSurfaceSoftwareDelegate() override;
31
32 // |GPUSurfaceDelegate|
33 ExternalViewEmbedder* GetExternalViewEmbedder() override;
34
35 //----------------------------------------------------------------------------
36 /// @brief Called when the GPU surface needs a new buffer to render a new
37 /// frame into.
38 ///
39 /// @param[in] size The size of the frame.
40 ///
41 /// @return A raster surface returned by the platform.
42 ///
43 virtual sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) = 0;
44
45 //----------------------------------------------------------------------------
46 /// @brief Called by the platform when a frame has been rendered into the
47 /// backing store and the platform must display it on-screen.
48 ///
49 /// @param[in] backing_store The software backing store to present.
50 ///
51 /// @return Returns if the platform could present the backing store onto
52 /// the screen.
53 ///
54 virtual bool PresentBackingStore(sk_sp<SkSurface> backing_store) = 0;
55};
56
57} // namespace flutter
58
59#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_
60