Flutter Engine
The 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
11#include "flutter/common/graphics/gl_context_switch.h"
12#include "flutter/flow/embedded_views.h"
13#include "flutter/flow/surface.h"
14#include "flutter/fml/macros.h"
15#include "flutter/fml/memory/weak_ptr.h"
16#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
17
20
21namespace flutter {
22
23class GPUSurfaceGLSkia : public Surface {
24 public:
26
27 GPUSurfaceGLSkia(GPUSurfaceGLDelegate* delegate, bool render_to_surface);
28
29 // Creates a new GL surface reusing an existing GrDirectContext.
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 SkISize& size) override;
42
43 // |Surface|
44 SkMatrix 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 SkISize& size);
60
61 sk_sp<SkSurface> AcquireRenderSurface(
62 const SkISize& untransformed_size,
63 const SkMatrix& root_surface_transformation);
64
65 bool PresentSurface(const SurfaceFrame& frame, DlCanvas* canvas);
66
67 GPUSurfaceGLDelegate* delegate_;
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<SkIRect> 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_
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
GrDirectContext * GetContext() override
bool AllowsDrawingWhenGpuDisabled() const override
SkMatrix GetRootTransformation() const override
static sk_sp< GrDirectContext > MakeGLContext(GPUSurfaceGLDelegate *delegate)
std::unique_ptr< GLContextResult > MakeRenderContextCurrent() override
std::unique_ptr< SurfaceFrame > AcquireFrame(const SkISize &size) override
Abstract Base Class that represents where we will be rendering content.
Definition surface.h:24
double frame
Definition examples.cpp:31
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
it will be possible to load the file into Perfetto s trace viewer 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
Definition switches.h:259