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_FLOW_SURFACE_H_
6#define FLUTTER_FLOW_SURFACE_H_
7
8#include <memory>
9
10#include "flutter/common/graphics/gl_context_switch.h"
11#include "flutter/flow/embedded_views.h"
12#include "flutter/flow/surface_frame.h"
13#include "flutter/fml/macros.h"
14
15class GrDirectContext;
16
17namespace impeller {
18class AiksContext;
19} // namespace impeller
20
21namespace flutter {
22
23/// Abstract Base Class that represents where we will be rendering content.
24class Surface {
25 public:
26 /// A screenshot of the surface's raw data.
27 struct SurfaceData {
28 std::string pixel_format;
29 sk_sp<SkData> data;
30 };
31
32 Surface();
33
34 virtual ~Surface();
35
36 virtual bool IsValid() = 0;
37
38 virtual std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) = 0;
39
40 virtual SkMatrix GetRootTransformation() const = 0;
41
42 virtual GrDirectContext* GetContext() = 0;
43
44 virtual std::unique_ptr<GLContextResult> MakeRenderContextCurrent();
45
46 virtual bool ClearRenderContext();
47
48 virtual bool AllowsDrawingWhenGpuDisabled() const;
49
50 virtual bool EnableRasterCache() const;
51
52 virtual std::shared_ptr<impeller::AiksContext> GetAiksContext() const;
53
54 /// Capture the `SurfaceData` currently present in the surface.
55 ///
56 /// Not guaranteed to work on all setups and not intended to be used in
57 /// production. The data field will be null if it was unable to work.
58 virtual SurfaceData GetSurfaceData() const;
59
60 private:
61 FML_DISALLOW_COPY_AND_ASSIGN(Surface);
62};
63
64} // namespace flutter
65
66#endif // FLUTTER_FLOW_SURFACE_H_
67

source code of flutter_engine/flutter/flow/surface.h

Morty Proxy This is a proxified and sanitized view of the page, visit original site.