1 // Copyright (C) 2020 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 express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 struct QAndroidEmulatorWindowAgent; 18 struct QAndroidDisplayAgent; 19 struct QAndroidRecordScreenAgent; 20 struct QAndroidMultiDisplayAgent; 21 struct QAndroidVmOperations; 22 typedef int (*LineConsumerCallback)(void* opaque, const char* buff, int len); 23 24 #define GRAPHICS_AGENTS_LIST(X) \ 25 X(QAndroidEmulatorWindowAgent, emu) \ 26 X(QAndroidDisplayAgent, display) \ 27 X(QAndroidRecordScreenAgent, record) \ 28 X(QAndroidMultiDisplayAgent, multi_display) \ 29 X(QAndroidVmOperations, vm) \ 30 31 namespace android { 32 namespace emulation { 33 #define DEFINE_GRAPHICS_AGENT_GETTER(typ, name) \ 34 virtual const typ* const android_get_##typ() const; 35 36 // The default graphics agent factory will not do anything, it will 37 // leave the graphics agents intact. 38 // 39 // You an call injectGraphicsAgents multiple times with this factory. 40 // 41 // If you want to override existing agents you can subclass this factory, 42 // override the method of interest and call injectGraphicsAgents, it will replace 43 // the existing agents with the one your factory provides. 44 class GraphicsAgentFactory { 45 public: 46 virtual ~GraphicsAgentFactory() = default; 47 GRAPHICS_AGENTS_LIST(DEFINE_GRAPHICS_AGENT_GETTER) 48 }; 49 50 51 // Call this method to inject the graphics agents into the emulator. You usually 52 // want to call this function *BEFORE* any calls to getGraphicsAgents are made. 53 // 54 // You can provide a factory that will be used to construct all the individual 55 // agents. 56 // 57 // Note: It is currently not safe to inject agents after the first injection has 58 // taken place. 59 void injectGraphicsAgents( 60 const GraphicsAgentFactory& factory); 61 62 } // namespace emulation 63 } // namespace android 64 65 extern "C" { 66 67 #define GRAPHICS_AGENTS_DEFINE_POINTER(type, name) const type* name; 68 typedef struct GraphicsAgents { 69 GRAPHICS_AGENTS_LIST(GRAPHICS_AGENTS_DEFINE_POINTER) 70 } GraphicsAgents; 71 72 const GraphicsAgents* getGraphicsAgents(); 73 74 } // extern "C" 75