1 #pragma once 2 3 #include <GLES2/gl2.h> 4 5 #include <functional> 6 #include <future> 7 #include <memory> 8 #include <vector> 9 10 #include "Handle.h" 11 #include "render-utils/Renderer.h" 12 13 namespace gfxstream { 14 15 class ColorBuffer; 16 17 // Posting 18 enum class PostCmd { 19 Post = 0, 20 Viewport = 1, 21 Compose = 2, 22 Clear = 3, 23 Screenshot = 4, 24 Exit = 5, 25 Block = 6, 26 }; 27 28 struct Post { 29 struct Block { 30 // schduledSignal will be set when the block task is scheduled. 31 std::promise<void> scheduledSignal; 32 // The block task won't stop until continueSignal is ready. 33 std::future<void> continueSignal; 34 }; 35 using CompletionCallback = 36 std::function<void(std::shared_future<void> waitForGpu)>; 37 PostCmd cmd; 38 int composeVersion; 39 std::vector<char> composeBuffer; 40 std::unique_ptr<CompletionCallback> completionCallback = nullptr; 41 std::unique_ptr<Block> block = nullptr; 42 HandleType cbHandle = 0; 43 union { 44 ColorBuffer* cb; 45 struct { 46 int width; 47 int height; 48 } viewport; 49 struct { 50 ColorBuffer* cb; 51 int screenwidth; 52 int screenheight; 53 GLenum format; 54 GLenum type; 55 int rotation; 56 void* pixels; 57 Rect rect; 58 } screenshot; 59 }; 60 }; 61 62 } // namespace gfxstream