Flutter iOS Embedder
ios_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_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
7 
8 #if !SLIMPELLER
9 
10 #include "flutter/fml/macros.h"
11 #include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
13 #include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h"
14 
15 @class CAMetalLayer;
16 
17 namespace flutter {
18 
19 class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalSkia final : public IOSSurface,
20  public GPUSurfaceMetalDelegate {
21  public:
22  IOSSurfaceMetalSkia(const fml::scoped_nsobject<CAMetalLayer>& layer,
23  std::shared_ptr<IOSContext> context);
24 
25  // |IOSSurface|
27 
28  private:
29  fml::scoped_nsobject<CAMetalLayer> layer_;
30  id<MTLDevice> device_;
31  id<MTLCommandQueue> command_queue_;
32  bool is_valid_ = false;
33 
34  // |IOSSurface|
35  bool IsValid() const override;
36 
37  // |IOSSurface|
38  void UpdateStorageSizeIfNecessary() override;
39 
40  // |IOSSurface|
41  std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context) override;
42 
43  // |GPUSurfaceMetalDelegate|
44  GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
45  __attribute__((cf_audited_transfer));
46 
47  // |GPUSurfaceMetalDelegate|
48  bool PresentDrawable(GrMTLHandle drawable) const override __attribute__((cf_audited_transfer));
49 
50  // |GPUSurfaceMetalDelegate|
51  bool PreparePresent(GrMTLHandle drawable) const override;
52 
53  // |GPUSurfaceMetalDelegate|
54  GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override
55  __attribute__((cf_audited_transfer));
56 
57  // |GPUSurfaceMetalDelegate|
58  bool PresentTexture(GPUMTLTextureInfo texture) const override
59  __attribute__((cf_audited_transfer));
60 
61  // |GPUSurfaceMetalDelegate|
62  bool AllowsDrawingWhenGpuDisabled() const override;
63 
64  FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceMetalSkia);
65 };
66 
67 } // namespace flutter
68 
69 #endif // !SLIMPELLER
70 
71 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
flutter::IOSSurface
Definition: ios_surface.h:21
ios_surface.h
flutter::IOSSurfaceMetalSkia
Definition: ios_surface_metal_skia.h:19
flutter
Definition: accessibility_bridge.h:28