1 // 2 // Copyright 2014 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // SurfaceImpl.h: Implementation methods of egl::Surface 8 9 #ifndef LIBANGLE_RENDERER_SURFACEIMPL_H_ 10 #define LIBANGLE_RENDERER_SURFACEIMPL_H_ 11 12 #include <EGL/egl.h> 13 #include <EGL/eglext.h> 14 15 #include "common/angleutils.h" 16 #include "libANGLE/Error.h" 17 #include "libANGLE/FramebufferAttachment.h" 18 #include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h" 19 20 namespace angle 21 { 22 struct Format; 23 } 24 25 namespace gl 26 { 27 class Context; 28 class FramebufferState; 29 } // namespace gl 30 31 namespace egl 32 { 33 class Display; 34 struct Config; 35 struct SurfaceState; 36 class Thread; 37 38 using SupportedTimestamps = angle::PackedEnumBitSet<Timestamp>; 39 using SupportedCompositorTimings = angle::PackedEnumBitSet<CompositorTiming>; 40 } // namespace egl 41 42 namespace rx 43 { 44 class FramebufferImpl; 45 46 class SurfaceImpl : public FramebufferAttachmentObjectImpl 47 { 48 public: 49 SurfaceImpl(const egl::SurfaceState &surfaceState); 50 ~SurfaceImpl() override; destroy(const egl::Display * display)51 virtual void destroy(const egl::Display *display) {} 52 53 virtual egl::Error initialize(const egl::Display *display) = 0; 54 virtual FramebufferImpl *createDefaultFramebuffer(const gl::Context *context, 55 const gl::FramebufferState &state) = 0; 56 virtual egl::Error makeCurrent(const gl::Context *context); 57 virtual egl::Error unMakeCurrent(const gl::Context *context); 58 virtual egl::Error swap(const gl::Context *context) = 0; 59 virtual egl::Error swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects); 60 virtual egl::Error swapWithFrameToken(const gl::Context *context, 61 EGLFrameTokenANGLE frameToken); 62 virtual egl::Error postSubBuffer(const gl::Context *context, 63 EGLint x, 64 EGLint y, 65 EGLint width, 66 EGLint height) = 0; 67 virtual egl::Error setPresentationTime(EGLnsecsANDROID time); 68 virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0; 69 virtual egl::Error bindTexImage(const gl::Context *context, 70 gl::Texture *texture, 71 EGLint buffer) = 0; 72 virtual egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) = 0; 73 virtual egl::Error getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc) = 0; 74 virtual egl::Error getMscRate(EGLint *numerator, EGLint *denominator) = 0; 75 virtual void setSwapInterval(EGLint interval) = 0; 76 virtual void setFixedWidth(EGLint width); 77 virtual void setFixedHeight(EGLint height); 78 79 // width and height can change with client window resizing 80 virtual EGLint getWidth() const = 0; 81 virtual EGLint getHeight() const = 0; 82 // Note: windows cannot be resized on Android. The approach requires 83 // calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR. However, that is 84 // expensive; and there are troublesome timing issues for other parts of 85 // ANGLE (which cause test failures and crashes). Therefore, a 86 // special-Android-only path is created just for the querying of EGL_WIDTH 87 // and EGL_HEIGHT. 88 // https://issuetracker.google.com/issues/153329980 89 virtual egl::Error getUserWidth(const egl::Display *display, EGLint *value) const; 90 virtual egl::Error getUserHeight(const egl::Display *display, EGLint *value) const; 91 92 virtual EGLint isPostSubBufferSupported() const = 0; 93 virtual EGLint getSwapBehavior() const = 0; 94 95 // Used to query color format from pbuffers created from D3D textures. 96 virtual const angle::Format *getD3DTextureColorFormat() const; 97 98 // EGL_ANDROID_get_frame_timestamps 99 virtual void setTimestampsEnabled(bool enabled); 100 virtual egl::SupportedCompositorTimings getSupportedCompositorTimings() const; 101 virtual egl::Error getCompositorTiming(EGLint numTimestamps, 102 const EGLint *names, 103 EGLnsecsANDROID *values) const; 104 virtual egl::Error getNextFrameId(EGLuint64KHR *frameId) const; 105 virtual egl::SupportedTimestamps getSupportedTimestamps() const; 106 virtual egl::Error getFrameTimestamps(EGLuint64KHR frameId, 107 EGLint numTimestamps, 108 const EGLint *timestamps, 109 EGLnsecsANDROID *values) const; 110 111 protected: 112 const egl::SurfaceState &mState; 113 }; 114 115 } // namespace rx 116 117 #endif // LIBANGLE_RENDERER_SURFACEIMPL_H_ 118