1*8975f5c5SAndroid Build Coastguard Worker // 2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2019 The ANGLE Project Authors. All rights reserved. 3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file. 5*8975f5c5SAndroid Build Coastguard Worker // 6*8975f5c5SAndroid Build Coastguard Worker // ScenicWindow.h: 7*8975f5c5SAndroid Build Coastguard Worker // Subclasses OSWindow for Fuchsia's Scenic compositor. 8*8975f5c5SAndroid Build Coastguard Worker // 9*8975f5c5SAndroid Build Coastguard Worker 10*8975f5c5SAndroid Build Coastguard Worker #ifndef UTIL_FUCHSIA_SCENIC_WINDOW_H 11*8975f5c5SAndroid Build Coastguard Worker #define UTIL_FUCHSIA_SCENIC_WINDOW_H 12*8975f5c5SAndroid Build Coastguard Worker 13*8975f5c5SAndroid Build Coastguard Worker #include "common/debug.h" 14*8975f5c5SAndroid Build Coastguard Worker #include "util/OSWindow.h" 15*8975f5c5SAndroid Build Coastguard Worker #include "util/util_export.h" 16*8975f5c5SAndroid Build Coastguard Worker 17*8975f5c5SAndroid Build Coastguard Worker // Disable ANGLE-specific warnings that pop up in fuchsia headers. 18*8975f5c5SAndroid Build Coastguard Worker ANGLE_DISABLE_DESTRUCTOR_OVERRIDE_WARNING 19*8975f5c5SAndroid Build Coastguard Worker ANGLE_DISABLE_SUGGEST_OVERRIDE_WARNINGS 20*8975f5c5SAndroid Build Coastguard Worker 21*8975f5c5SAndroid Build Coastguard Worker #include <fuchsia/element/cpp/fidl.h> 22*8975f5c5SAndroid Build Coastguard Worker #include <fuchsia_egl.h> 23*8975f5c5SAndroid Build Coastguard Worker #include <lib/async-loop/cpp/loop.h> 24*8975f5c5SAndroid Build Coastguard Worker #include <zircon/types.h> 25*8975f5c5SAndroid Build Coastguard Worker #include <string> 26*8975f5c5SAndroid Build Coastguard Worker 27*8975f5c5SAndroid Build Coastguard Worker ANGLE_REENABLE_SUGGEST_OVERRIDE_WARNINGS 28*8975f5c5SAndroid Build Coastguard Worker ANGLE_REENABLE_DESTRUCTOR_OVERRIDE_WARNING 29*8975f5c5SAndroid Build Coastguard Worker 30*8975f5c5SAndroid Build Coastguard Worker struct FuchsiaEGLWindowDeleter 31*8975f5c5SAndroid Build Coastguard Worker { operatorFuchsiaEGLWindowDeleter32*8975f5c5SAndroid Build Coastguard Worker void operator()(fuchsia_egl_window *eglWindow) { fuchsia_egl_window_destroy(eglWindow); } 33*8975f5c5SAndroid Build Coastguard Worker }; 34*8975f5c5SAndroid Build Coastguard Worker 35*8975f5c5SAndroid Build Coastguard Worker class ANGLE_UTIL_EXPORT ScenicWindow : public OSWindow 36*8975f5c5SAndroid Build Coastguard Worker { 37*8975f5c5SAndroid Build Coastguard Worker public: 38*8975f5c5SAndroid Build Coastguard Worker ScenicWindow(); 39*8975f5c5SAndroid Build Coastguard Worker ~ScenicWindow() override; 40*8975f5c5SAndroid Build Coastguard Worker 41*8975f5c5SAndroid Build Coastguard Worker // OSWindow: 42*8975f5c5SAndroid Build Coastguard Worker void disableErrorMessageDialog() override; 43*8975f5c5SAndroid Build Coastguard Worker void destroy() override; 44*8975f5c5SAndroid Build Coastguard Worker void resetNativeWindow() override; 45*8975f5c5SAndroid Build Coastguard Worker EGLNativeWindowType getNativeWindow() const override; 46*8975f5c5SAndroid Build Coastguard Worker EGLNativeDisplayType getNativeDisplay() const override; 47*8975f5c5SAndroid Build Coastguard Worker void messageLoop() override; 48*8975f5c5SAndroid Build Coastguard Worker void setMousePosition(int x, int y) override; 49*8975f5c5SAndroid Build Coastguard Worker bool setOrientation(int width, int height) override; 50*8975f5c5SAndroid Build Coastguard Worker bool setPosition(int x, int y) override; 51*8975f5c5SAndroid Build Coastguard Worker bool resize(int width, int height) override; 52*8975f5c5SAndroid Build Coastguard Worker void setVisible(bool isVisible) override; 53*8975f5c5SAndroid Build Coastguard Worker void signalTestEvent() override; 54*8975f5c5SAndroid Build Coastguard Worker 55*8975f5c5SAndroid Build Coastguard Worker // Presents the window to Scenic. 56*8975f5c5SAndroid Build Coastguard Worker // 57*8975f5c5SAndroid Build Coastguard Worker // We need to do this once per EGL window surface after adding the 58*8975f5c5SAndroid Build Coastguard Worker // surface's image pipe as a child of our window. 59*8975f5c5SAndroid Build Coastguard Worker void present(); 60*8975f5c5SAndroid Build Coastguard Worker 61*8975f5c5SAndroid Build Coastguard Worker private: 62*8975f5c5SAndroid Build Coastguard Worker bool initializeImpl(const std::string &name, int width, int height) override; 63*8975f5c5SAndroid Build Coastguard Worker void updateViewSize(); 64*8975f5c5SAndroid Build Coastguard Worker 65*8975f5c5SAndroid Build Coastguard Worker // ScenicWindow async loop. 66*8975f5c5SAndroid Build Coastguard Worker async::Loop *const mLoop; 67*8975f5c5SAndroid Build Coastguard Worker 68*8975f5c5SAndroid Build Coastguard Worker // System services. 69*8975f5c5SAndroid Build Coastguard Worker zx::channel mServiceRoot; 70*8975f5c5SAndroid Build Coastguard Worker fuchsia::element::GraphicalPresenterPtr mPresenter; 71*8975f5c5SAndroid Build Coastguard Worker 72*8975f5c5SAndroid Build Coastguard Worker // EGL native window. 73*8975f5c5SAndroid Build Coastguard Worker std::unique_ptr<fuchsia_egl_window, FuchsiaEGLWindowDeleter> mFuchsiaEGLWindow; 74*8975f5c5SAndroid Build Coastguard Worker }; 75*8975f5c5SAndroid Build Coastguard Worker 76*8975f5c5SAndroid Build Coastguard Worker #endif // UTIL_FUCHSIA_SCENIC_WINDOW_H 77