Flutter Engine
The Flutter Engine
Surface.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef JetSki_Surface_DEFINED
9#define JetSki_Surface_DEFINED
10
13
14#include <jni.h>
15#include <android/native_window_jni.h>
17
19
25
26class SurfaceThread;
28
29class Surface : public SkRefCnt {
30public:
31 virtual void release(JNIEnv*) = 0;
32 virtual void flushAndSubmit() = 0;
33 virtual SkCanvas* getCanvas() = 0;
34
35 int width() const { return fSurface ? fSurface->width() : 0; }
36 int height() const { return fSurface ? fSurface->height() : 0; }
37
39 return fSurface ? fSurface->makeImageSnapshot() : nullptr;
40 }
41
42protected:
44};
45
46class WindowSurface final : public Surface {
47public:
48 WindowSurface(ANativeWindow* win, std::unique_ptr<skwindow::WindowContext> wctx);
49
50private:
51 void release(JNIEnv* env) override;
52 SkCanvas* getCanvas() override;
53 void flushAndSubmit() override;
54
55 ANativeWindow* fWindow;
56 std::unique_ptr<skwindow::WindowContext> fWindowContext;
57};
58
59class ThreadedSurface final : public Surface {
60public:
61 ThreadedSurface(JNIEnv* env, jobject surface);
62
63private:
64 void release(JNIEnv* env) override;
65 SkCanvas* getCanvas() override;
66 void flushAndSubmit() override;
67
68 WindowSurface* fWindowSurface = nullptr;
69 SkPictureRecorder fRecorder;
70 std::unique_ptr<SurfaceThread> fThread;
71 int fWidth;
72 int fHeight;
73};
74
75#endif
int width() const
Definition: SkSurface.h:178
sk_sp< SkImage > makeImageSnapshot()
Definition: SkSurface.cpp:90
int height() const
Definition: SkSurface.h:184
int height() const
Definition: Surface.h:36
virtual SkCanvas * getCanvas()=0
virtual void release(JNIEnv *)=0
sk_sp< SkSurface > fSurface
Definition: Surface.h:43
int width() const
Definition: Surface.h:35
virtual void flushAndSubmit()=0
sk_sp< SkImage > makeImageSnapshot() const
Definition: Surface.h:38
ThreadedSurface(JNIEnv *env, jobject surface)
Definition: Surface.cpp:48
WindowSurface(ANativeWindow *win, std::unique_ptr< skwindow::WindowContext > wctx)
Definition: Surface.cpp:17
VkSurfaceKHR surface
Definition: main.cc:49
Definition: __init__.py:1
struct ANativeWindow ANativeWindow