Flutter Engine
 
Loading...
Searching...
No Matches
gpu_surface_metal_skia.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_GPU_GPU_SURFACE_METAL_SKIA_H_
6#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_
7
8#if !SLIMPELLER
9
11#include "flutter/fml/macros.h"
13#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
14
15namespace flutter {
16
17class SK_API_AVAILABLE_CA_METAL_LAYER GPUSurfaceMetalSkia : public Surface {
18 public:
20 sk_sp<GrDirectContext> context,
21 bool render_to_surface = true);
22
23 // |Surface|
25
26 // |Surface|
27 bool IsValid() override;
28
29 private:
31 const MTLRenderTargetType render_target_type_;
32 sk_sp<GrDirectContext> context_;
33 GrDirectContext* precompiled_sksl_context_ = nullptr;
34 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
35 // external view embedder may want to render to the root surface. This is a
36 // hack to make avoid allocating resources for the root surface when an
37 // external view embedder is present.
38 bool render_to_surface_ = true;
39 bool disable_partial_repaint_ = false;
40
41 // Accumulated damage for each framebuffer; Key is address of underlying
42 // MTLTexture for each drawable
43 std::map<void*, DlIRect> damage_;
44
45 // |Surface|
46 std::unique_ptr<SurfaceFrame> AcquireFrame(const DlISize& size) override;
47
48 // |Surface|
49 DlMatrix GetRootTransformation() const override;
50
51 // |Surface|
52 GrDirectContext* GetContext() override;
53
54 // |Surface|
55 std::unique_ptr<GLContextResult> MakeRenderContextCurrent() override;
56
57 // |Surface|
58 bool AllowsDrawingWhenGpuDisabled() const override;
59
60 std::unique_ptr<SurfaceFrame> AcquireFrameFromCAMetalLayer(
61 const DlISize& frame_info);
62
63 std::unique_ptr<SurfaceFrame> AcquireFrameFromMTLTexture(
64 const DlISize& frame_info);
65
66 void PrecompileKnownSkSLsIfNecessary();
67
69};
70
71} // namespace flutter
72
73#endif // !SLIMPELLER
74
75#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_
Interface implemented by all platform surfaces that can present a metal backing store to the "screen"...
Abstract Base Class that represents where we will be rendering content.
Definition surface.h:26
MockDelegate delegate_
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
A 4x4 matrix using column-major storage.
Definition matrix.h:37