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_H_ 6 #define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_H_ 7 8 #include <Metal/Metal.h> 9 10 #include "flutter/fml/macros.h" 11 #include "flutter/fml/platform/darwin/scoped_nsobject.h" 12 #include "flutter/shell/common/surface.h" 13 #include "third_party/skia/include/gpu/GrContext.h" 14 15 @class CAMetalLayer; 16 17 namespace flutter { 18 19 class GPUSurfaceMetal : public Surface { 20 public: 21 GPUSurfaceMetal(fml::scoped_nsobject<CAMetalLayer> layer); 22 23 ~GPUSurfaceMetal() override; 24 25 private: 26 fml::scoped_nsobject<CAMetalLayer> layer_; 27 sk_sp<GrContext> context_; 28 fml::scoped_nsprotocol<id<MTLCommandQueue>> command_queue_; 29 30 // |Surface| 31 bool IsValid() override; 32 33 // |Surface| 34 std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override; 35 36 // |Surface| 37 SkMatrix GetRootTransformation() const override; 38 39 // |Surface| 40 GrContext* GetContext() override; 41 42 // |Surface| 43 bool MakeRenderContextCurrent() override; 44 45 FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceMetal); 46 }; 47 48 } // namespace flutter 49 50 #endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_H_ 51