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_SOFTWARE_H_
6#define FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_H_
7
8#include "flutter/flow/surface.h"
9#include "flutter/fml/macros.h"
10#include "flutter/fml/memory/weak_ptr.h"
11#include "flutter/shell/gpu/gpu_surface_software_delegate.h"
12
13namespace flutter {
14
15class GPUSurfaceSoftware : public Surface {
16 public:
17 GPUSurfaceSoftware(GPUSurfaceSoftwareDelegate* delegate,
18 bool render_to_surface);
19
20 ~GPUSurfaceSoftware() override;
21
22 // |Surface|
23 bool IsValid() override;
24
25 // |Surface|
26 std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
27
28 // |Surface|
29 SkMatrix GetRootTransformation() const override;
30
31 // |Surface|
32 GrDirectContext* GetContext() override;
33
34 // |Surface|
35 flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;
36
37 private:
38 GPUSurfaceSoftwareDelegate* delegate_;
39 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
40 // external view embedder may want to render to the root surface. This is a
41 // hack to make avoid allocating resources for the root surface when an
42 // external view embedder is present.
43 const bool render_to_surface_;
44 fml::TaskRunnerAffineWeakPtrFactory<GPUSurfaceSoftware> weak_factory_;
45
46 FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceSoftware);
47};
48
49} // namespace flutter
50
51#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_H_
52