tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DisplayImpl.h (6071B)


      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 // DisplayImpl.h: Implementation methods of egl::Display
      8 
      9 #ifndef LIBANGLE_RENDERER_DISPLAYIMPL_H_
     10 #define LIBANGLE_RENDERER_DISPLAYIMPL_H_
     11 
     12 #include "common/Optional.h"
     13 #include "common/angleutils.h"
     14 #include "libANGLE/Caps.h"
     15 #include "libANGLE/Config.h"
     16 #include "libANGLE/Error.h"
     17 #include "libANGLE/Observer.h"
     18 #include "libANGLE/Stream.h"
     19 #include "libANGLE/Version.h"
     20 #include "libANGLE/renderer/EGLImplFactory.h"
     21 #include "platform/Feature.h"
     22 
     23 #include <set>
     24 #include <vector>
     25 
     26 namespace angle
     27 {
     28 struct FrontendFeatures;
     29 }  // namespace angle
     30 
     31 namespace egl
     32 {
     33 class AttributeMap;
     34 class BlobCache;
     35 class Display;
     36 struct DisplayState;
     37 struct Config;
     38 class Surface;
     39 class ImageSibling;
     40 class Thread;
     41 }  // namespace egl
     42 
     43 namespace gl
     44 {
     45 class Context;
     46 }  // namespace gl
     47 
     48 namespace rx
     49 {
     50 class SurfaceImpl;
     51 class ImageImpl;
     52 struct ConfigDesc;
     53 class DeviceImpl;
     54 class StreamProducerImpl;
     55 
     56 class ShareGroupImpl : angle::NonCopyable
     57 {
     58  public:
     59    ShareGroupImpl() : mAnyContextWithRobustness(false) {}
     60    virtual ~ShareGroupImpl() {}
     61    virtual void onDestroy(const egl::Display *display) {}
     62 
     63    void onRobustContextAdd() { mAnyContextWithRobustness = true; }
     64    bool hasAnyContextWithRobustness() const { return mAnyContextWithRobustness; }
     65 
     66  private:
     67    // Whether any context in the share group has robustness enabled.  If any context in the share
     68    // group is robust, any program created in any context of the share group must have robustness
     69    // enabled.  This is because programs are shared between the share group contexts.
     70    bool mAnyContextWithRobustness;
     71 };
     72 
     73 class DisplayImpl : public EGLImplFactory, public angle::Subject
     74 {
     75  public:
     76    DisplayImpl(const egl::DisplayState &state);
     77    ~DisplayImpl() override;
     78 
     79    virtual egl::Error initialize(egl::Display *display) = 0;
     80    virtual void terminate()                             = 0;
     81    virtual egl::Error prepareForCall();
     82    virtual egl::Error releaseThread();
     83 
     84    virtual egl::Error makeCurrent(egl::Display *display,
     85                                   egl::Surface *drawSurface,
     86                                   egl::Surface *readSurface,
     87                                   gl::Context *context) = 0;
     88 
     89    virtual egl::ConfigSet generateConfigs() = 0;
     90 
     91    virtual bool testDeviceLost()                                     = 0;
     92    virtual egl::Error restoreLostDevice(const egl::Display *display) = 0;
     93 
     94    virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0;
     95    virtual egl::Error validateClientBuffer(const egl::Config *configuration,
     96                                            EGLenum buftype,
     97                                            EGLClientBuffer clientBuffer,
     98                                            const egl::AttributeMap &attribs) const;
     99    virtual egl::Error validateImageClientBuffer(const gl::Context *context,
    100                                                 EGLenum target,
    101                                                 EGLClientBuffer clientBuffer,
    102                                                 const egl::AttributeMap &attribs) const;
    103    virtual egl::Error validatePixmap(const egl::Config *config,
    104                                      EGLNativePixmapType pixmap,
    105                                      const egl::AttributeMap &attributes) const;
    106 
    107    virtual std::string getRendererDescription()                  = 0;
    108    virtual std::string getVendorString()                         = 0;
    109    virtual std::string getVersionString(bool includeFullVersion) = 0;
    110 
    111    virtual DeviceImpl *createDevice();
    112 
    113    virtual egl::Error waitClient(const gl::Context *context)                = 0;
    114    virtual egl::Error waitNative(const gl::Context *context, EGLint engine) = 0;
    115    virtual gl::Version getMaxSupportedESVersion() const                     = 0;
    116    virtual gl::Version getMaxConformantESVersion() const                    = 0;
    117    // If desktop GL is not supported in any capacity for a given backend, this returns None.
    118    virtual Optional<gl::Version> getMaxSupportedDesktopVersion() const = 0;
    119    const egl::Caps &getCaps() const;
    120 
    121    virtual void setBlobCacheFuncs(EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get) {}
    122 
    123    const egl::DisplayExtensions &getExtensions() const;
    124 
    125    void setBlobCache(egl::BlobCache *blobCache) { mBlobCache = blobCache; }
    126    egl::BlobCache *getBlobCache() const { return mBlobCache; }
    127 
    128    virtual void initializeFrontendFeatures(angle::FrontendFeatures *features) const {}
    129 
    130    virtual void populateFeatureList(angle::FeatureList *features) = 0;
    131 
    132    const egl::DisplayState &getState() const { return mState; }
    133 
    134    virtual egl::Error handleGPUSwitch();
    135    virtual egl::Error forceGPUSwitch(EGLint gpuIDHigh, EGLint gpuIDLow);
    136 
    137    virtual bool isX11() const;
    138    virtual bool isWayland() const;
    139    virtual bool isGBM() const;
    140 
    141    virtual bool supportsDmaBufFormat(EGLint format) const;
    142    virtual egl::Error queryDmaBufFormats(EGLint max_formats, EGLint *formats, EGLint *num_formats);
    143    virtual egl::Error queryDmaBufModifiers(EGLint format,
    144                                            EGLint max_modifiers,
    145                                            EGLuint64KHR *modifiers,
    146                                            EGLBoolean *external_only,
    147                                            EGLint *num_modifiers);
    148    GLuint getNextSurfaceID() override;
    149 
    150  protected:
    151    const egl::DisplayState &mState;
    152 
    153  private:
    154    virtual void generateExtensions(egl::DisplayExtensions *outExtensions) const = 0;
    155    virtual void generateCaps(egl::Caps *outCaps) const                          = 0;
    156 
    157    mutable bool mExtensionsInitialized;
    158    mutable egl::DisplayExtensions mExtensions;
    159 
    160    mutable bool mCapsInitialized;
    161    mutable egl::Caps mCaps;
    162 
    163    egl::BlobCache *mBlobCache;
    164    rx::AtomicSerialFactory mNextSurfaceID;
    165 };
    166 
    167 }  // namespace rx
    168 
    169 #endif  // LIBANGLE_RENDERER_DISPLAYIMPL_H_