// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SHELL_GPU_GPU_SURFACE_GL_H_ #define SHELL_GPU_GPU_SURFACE_GL_H_ #include #include #include "flutter/flow/embedded_views.h" #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/shell/common/surface.h" #include "flutter/shell/gpu/gpu_surface_gl_delegate.h" #include "third_party/skia/include/gpu/GrContext.h" namespace shell { class GPUSurfaceGL : public Surface { public: GPUSurfaceGL(GPUSurfaceGLDelegate* delegate); // Creates a new GL surface reusing an existing GrContext. GPUSurfaceGL(sk_sp gr_context, GPUSurfaceGLDelegate* delegate); ~GPUSurfaceGL() override; // |shell::Surface| bool IsValid() override; // |shell::Surface| std::unique_ptr AcquireFrame(const SkISize& size) override; // |shell::Surface| SkMatrix GetRootTransformation() const override; // |shell::Surface| GrContext* GetContext() override; // |shell::Surface| flow::ExternalViewEmbedder* GetExternalViewEmbedder() override; // |shell::Surface| bool MakeRenderContextCurrent() override; private: GPUSurfaceGLDelegate* delegate_; sk_sp context_; sk_sp onscreen_surface_; sk_sp offscreen_surface_; bool valid_ = false; fml::WeakPtrFactory weak_factory_; bool context_owner_; bool CreateOrUpdateSurfaces(const SkISize& size); sk_sp AcquireRenderSurface( const SkISize& untransformed_size, const SkMatrix& root_surface_transformation); bool PresentSurface(SkCanvas* canvas); FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGL); }; } // namespace shell #endif // SHELL_GPU_GPU_SURFACE_GL_H_