• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <optional>
18 #include <string>
19 
20 #include "Handle.h"
21 #include "StalePtrRegistry.h"
22 #include "aemu/base/files/Stream.h"
23 #include "gl/EmulatedEglContext.h"
24 #include "gl/EmulatedEglWindowSurface.h"
25 #include "gl/gles1_dec/GLESv1Decoder.h"
26 #include "gl/gles2_dec/GLESv2Decoder.h"
27 
28 namespace gfxstream {
29 namespace gl {
30 
31 struct RenderThreadInfoGl {
32     // Create new instance. Only call this once per thread.
33     // Future calls to get() will return this instance until
34     // it is destroyed.
35     RenderThreadInfoGl();
36 
37     // Destructor.
38     ~RenderThreadInfoGl();
39 
40     // Return the current thread's instance, if any, or NULL.
41     static RenderThreadInfoGl* get();
42 
43     // Functions to save / load a snapshot
44     // They must be called after Framebuffer snapshot
45     void onSave(android::base::Stream* stream);
46     bool onLoad(android::base::Stream* stream);
47 
48     // Sometimes we can load render thread info before
49     // FrameBuffer repopulates the contexts.
50     void postLoadRefreshCurrentContextSurfacePtrs();
51 
52     // The unique id of owner guest process of this render thread
53     uint64_t m_puid = 0;
54 
55     // All the contexts that are created by this render thread.
56     // New emulator manages contexts in guest process level,
57     // m_contextSet should be deprecated. It is only kept for
58     // backward compatibility reason.
59     ThreadContextSet                m_contextSet;
60     // all the window surfaces that are created by this render thread
61     WindowSurfaceSet                m_windowSet;
62 
63     // Current EGL context, draw surface and read surface.
64     HandleType currContextHandleFromLoad;
65     HandleType currDrawSurfHandleFromLoad;
66     HandleType currReadSurfHandleFromLoad;
67 
68     EmulatedEglContextPtr currContext;
69     EmulatedEglWindowSurfacePtr currDrawSurf;
70     EmulatedEglWindowSurfacePtr currReadSurf;
71 
72     // Decoder states.
73     GLESv1Decoder                   m_glDec;
74     GLESv2Decoder                   m_gl2Dec;
75 };
76 
77 }  // namespace gl
78 }  // namespace gfxstream