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  GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override
52  __attribute__((cf_audited_transfer));
53 
54  // |GPUSurfaceMetalDelegate|
55  bool PresentTexture(GPUMTLTextureInfo texture) const override
56  __attribute__((cf_audited_transfer));
57 
58  // |GPUSurfaceMetalDelegate|
59  bool AllowsDrawingWhenGpuDisabled() const override;
60 
61  FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceMetalSkia);
62 };
63 
64 } // namespace flutter
65 
66 #endif // !SLIMPELLER
67 
68 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
flutter::IOSSurface
Definition: ios_surface.h:25
ios_surface.h
flutter::IOSSurfaceMetalSkia
Definition: ios_surface_metal_skia.h:19
flutter
Definition: accessibility_bridge.h:28