Flutter Engine
The 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
10#include "flutter/flow/surface.h"
11#include "flutter/fml/macros.h"
12#include "flutter/fml/platform/darwin/scoped_nsobject.h"
13#include "flutter/impeller/aiks/aiks_context.h"
14#include "flutter/impeller/renderer/backend/metal/context_mtl.h"
15#include "flutter/impeller/renderer/renderer.h"
16#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
18
19namespace flutter {
20
22 : public Surface {
23 public:
25 const std::shared_ptr<impeller::Context>& context,
26 bool render_to_surface = true);
27
28 // |Surface|
30
31 // |Surface|
32 bool IsValid() override;
33
34 virtual Surface::SurfaceData GetSurfaceData() const override;
35
36 private:
38 const MTLRenderTargetType render_target_type_;
39 std::shared_ptr<impeller::Renderer> impeller_renderer_;
40 std::shared_ptr<impeller::AiksContext> aiks_context_;
42 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
43 // external view embedder may want to render to the root surface. This is a
44 // hack to make avoid allocating resources for the root surface when an
45 // external view embedder is present.
46 bool render_to_surface_ = true;
47 bool disable_partial_repaint_ = false;
48 // Accumulated damage for each framebuffer; Key is address of underlying
49 // MTLTexture for each drawable
50 std::shared_ptr<std::map<uintptr_t, SkIRect>> damage_ =
51 std::make_shared<std::map<uintptr_t, SkIRect>>();
52
53 // |Surface|
54 std::unique_ptr<SurfaceFrame> AcquireFrame(
55 const SkISize& frame_size) override;
56
57 std::unique_ptr<SurfaceFrame> AcquireFrameFromCAMetalLayer(
58 const SkISize& frame_size);
59
60 std::unique_ptr<SurfaceFrame> AcquireFrameFromMTLTexture(
61 const SkISize& frame_size);
62
63 // |Surface|
64 SkMatrix GetRootTransformation() const override;
65
66 // |Surface|
67 GrDirectContext* GetContext() override;
68
69 // |Surface|
70 std::unique_ptr<GLContextResult> MakeRenderContextCurrent() override;
71
72 // |Surface|
73 bool AllowsDrawingWhenGpuDisabled() const override;
74
75 // |Surface|
76 bool EnableRasterCache() const override;
77
78 // |Surface|
79 std::shared_ptr<impeller::AiksContext> GetAiksContext() const override;
80
82};
83
84} // namespace flutter
85
86#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:24
#define IMPELLER_CA_METAL_LAYER_AVAILABLE
Definition context_mtl.h:30
MockDelegate delegate_
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
A screenshot of the surface's raw data.
Definition surface.h:27