Flutter Engine
 
Loading...
Searching...
No Matches
gpu_surface_gl_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_GPU_GPU_SURFACE_GL_SKIA_H_
6#define FLUTTER_SHELL_GPU_GPU_SURFACE_GL_SKIA_H_
7
8#include <functional>
9#include <memory>
10
14#include "flutter/fml/macros.h"
17
18#include "third_party/skia/include/core/SkSurface.h"
19#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
20
21namespace flutter {
22
23class GPUSurfaceGLSkia : public Surface {
24 public:
25 static sk_sp<GrDirectContext> MakeGLContext(GPUSurfaceGLDelegate* delegate);
26
27 GPUSurfaceGLSkia(GPUSurfaceGLDelegate* delegate, bool render_to_surface);
28
29 // Creates a new GL surface reusing an existing GrDirectContext.
30 GPUSurfaceGLSkia(const sk_sp<GrDirectContext>& gr_context,
31 GPUSurfaceGLDelegate* delegate,
32 bool render_to_surface);
33
34 // |Surface|
35 ~GPUSurfaceGLSkia() override;
36
37 // |Surface|
38 bool IsValid() override;
39
40 // |Surface|
41 std::unique_ptr<SurfaceFrame> AcquireFrame(const DlISize& size) override;
42
43 // |Surface|
44 DlMatrix GetRootTransformation() const override;
45
46 // |Surface|
47 GrDirectContext* GetContext() override;
48
49 // |Surface|
50 std::unique_ptr<GLContextResult> MakeRenderContextCurrent() override;
51
52 // |Surface|
53 bool ClearRenderContext() override;
54
55 // |Surface|
56 bool AllowsDrawingWhenGpuDisabled() const override;
57
58 private:
59 bool CreateOrUpdateSurfaces(const DlISize& size);
60
61 sk_sp<SkSurface> AcquireRenderSurface(
62 const DlISize& untransformed_size,
63 const DlMatrix& root_surface_transformation);
64
65 bool PresentSurface(const SurfaceFrame& frame);
66
67 GPUSurfaceGLDelegate* delegate_;
68 sk_sp<GrDirectContext> context_;
69 sk_sp<SkSurface> onscreen_surface_;
70 /// FBO backing the current `onscreen_surface_`.
71 uint32_t fbo_id_ = 0;
72 // The current FBO's existing damage, as tracked by the GPU surface, delegates
73 // still have an option of overriding this damage with their own in
74 // `GLContextFrameBufferInfo`.
75 std::optional<DlIRect> existing_damage_ = std::nullopt;
76 bool context_owner_ = false;
77 // TODO(38466): Refactor GPU surface APIs take into account the fact that an
78 // external view embedder may want to render to the root surface. This is a
79 // hack to make avoid allocating resources for the root surface when an
80 // external view embedder is present.
81 const bool render_to_surface_ = true;
82 bool valid_ = false;
83
84 // WeakPtrFactory must be the last member.
87};
88
89} // namespace flutter
90
91#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_SKIA_H_
GrDirectContext * GetContext() override
DlMatrix GetRootTransformation() const override
bool AllowsDrawingWhenGpuDisabled() const override
static sk_sp< GrDirectContext > MakeGLContext(GPUSurfaceGLDelegate *delegate)
std::unique_ptr< GLContextResult > MakeRenderContextCurrent() override
std::unique_ptr< SurfaceFrame > AcquireFrame(const DlISize &size) override
Abstract Base Class that represents where we will be rendering content.
Definition surface.h:26
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
A 4x4 matrix using column-major storage.
Definition matrix.h:37