Flutter Engine
 
Loading...
Searching...
No Matches
gpu_surface_metal_impeller.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_IMPELLER_H_
6#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_IMPELLER_H_
7
8#include <Metal/Metal.h>
9
11#include "flutter/fml/macros.h"
16#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h"
17
18namespace flutter {
19
21 : public Surface {
22 public:
24 const std::shared_ptr<impeller::AiksContext>& context,
25 bool render_to_surface = true);
26
27 // |Surface|
29
30 // |Surface|
31 bool IsValid() override;
32
33 virtual Surface::SurfaceData GetSurfaceData() const override;
34
35 private:
37 const MTLRenderTargetType render_target_type_;
38 std::shared_ptr<impeller::AiksContext> aiks_context_;
39 id<MTLTexture> last_texture_;
40 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
41 // external view embedder may want to render to the root surface. This is a
42 // hack to make avoid allocating resources for the root surface when an
43 // external view embedder is present.
44 bool render_to_surface_ = true;
45 bool disable_partial_repaint_ = false;
46 // Accumulated damage for each framebuffer; Key is address of underlying
47 // MTLTexture for each drawable
48 std::shared_ptr<std::map<void*, DlIRect>> damage_ =
49 std::make_shared<std::map<void*, DlIRect>>();
50 std::shared_ptr<impeller::SwapchainTransientsMTL> swapchain_transients_;
51
52 // |Surface|
53 std::unique_ptr<SurfaceFrame> AcquireFrame(
54 const DlISize& frame_size) override;
55
56 std::unique_ptr<SurfaceFrame> AcquireFrameFromCAMetalLayer(
57 const DlISize& frame_size);
58
59 std::unique_ptr<SurfaceFrame> AcquireFrameFromMTLTexture(
60 const DlISize& frame_size);
61
62 // |Surface|
63 DlMatrix GetRootTransformation() const override;
64
65 // |Surface|
66 GrDirectContext* GetContext() override;
67
68 // |Surface|
69 std::unique_ptr<GLContextResult> MakeRenderContextCurrent() override;
70
71 // |Surface|
72 bool AllowsDrawingWhenGpuDisabled() const override;
73
74 // |Surface|
75 bool EnableRasterCache() const override;
76
77 // |Surface|
78 std::shared_ptr<impeller::AiksContext> GetAiksContext() const override;
79
81};
82
83} // namespace flutter
84
85#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_IMPELLER_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
#define IMPELLER_CA_METAL_LAYER_AVAILABLE
Definition context_mtl.h:30
A screenshot of the surface's raw data.
Definition surface.h:29
A 4x4 matrix using column-major storage.
Definition matrix.h:37