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_SOFTWARE_H_ 6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_ 7 8 #include "flutter/flow/embedded_views.h" 9 #include "flutter/fml/macros.h" 10 #include "flutter/fml/platform/darwin/scoped_nsobject.h" 11 #include "flutter/shell/gpu/gpu_surface_software.h" 12 #include "flutter/shell/platform/darwin/ios/ios_surface.h" 13 14 @class CALayer; 15 16 namespace flutter { 17 18 class IOSSurfaceSoftware final : public IOSSurface, 19 public GPUSurfaceSoftwareDelegate, 20 public ExternalViewEmbedder { 21 public: 22 IOSSurfaceSoftware(fml::scoped_nsobject<CALayer> layer, 23 FlutterPlatformViewsController* platform_views_controller); 24 25 ~IOSSurfaceSoftware() override; 26 27 // |IOSSurface| 28 bool IsValid() const override; 29 30 // |IOSSurface| 31 bool ResourceContextMakeCurrent() override; 32 33 // |IOSSurface| 34 void UpdateStorageSizeIfNecessary() override; 35 36 // |IOSSurface| 37 std::unique_ptr<Surface> CreateGPUSurface() override; 38 39 // |GPUSurfaceSoftwareDelegate| 40 sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override; 41 42 // |GPUSurfaceSoftwareDelegate| 43 bool PresentBackingStore(sk_sp<SkSurface> backing_store) override; 44 45 // |GPUSurfaceSoftwareDelegate| 46 ExternalViewEmbedder* GetExternalViewEmbedder() override; 47 48 // |ExternalViewEmbedder| 49 sk_sp<SkSurface> GetRootSurface() override; 50 51 // |ExternalViewEmbedder| 52 void CancelFrame() override; 53 54 // |ExternalViewEmbedder| 55 void BeginFrame(SkISize frame_size, GrContext* context) override; 56 57 // |ExternalViewEmbedder| 58 void PrerollCompositeEmbeddedView(int view_id, 59 std::unique_ptr<EmbeddedViewParams> params) override; 60 61 // |ExternalViewEmbedder| 62 std::vector<SkCanvas*> GetCurrentCanvases() override; 63 64 // |ExternalViewEmbedder| 65 SkCanvas* CompositeEmbeddedView(int view_id) override; 66 67 // |ExternalViewEmbedder| 68 bool SubmitFrame(GrContext* context) override; 69 70 private: 71 fml::scoped_nsobject<CALayer> layer_; 72 sk_sp<SkSurface> sk_surface_; 73 74 FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceSoftware); 75 }; 76 77 } // namespace flutter 78 79 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_ 80