diff options
author | John Reck <jreck@google.com> | 2015-08-10 09:52:29 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2015-08-12 14:26:05 -0700 |
commit | 149173d28c0843aba86b0810ce75b34be6a0d08f (patch) | |
tree | b602af79dc1bb677a6fc504960cd27d4ac09ff6b /libs/hwui/renderthread/EglManager.h | |
parent | fb3a57d0c1044dedacabfaaa722f5ed4409067b9 (diff) |
Support new EGL extensions
Bug: 21753739
Includes a revert of 13d1b4ab10fbee5e81a2ba1ac59cfae1e51d3ef0
as that only supported EGL_EXT_buffer_age
Change-Id: Ia86a47d19e3355c067934d7764c330b640c6958d
Diffstat (limited to 'libs/hwui/renderthread/EglManager.h')
-rw-r--r-- | libs/hwui/renderthread/EglManager.h | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h index bb5d24b0557f..62b5b99a6e30 100644 --- a/libs/hwui/renderthread/EglManager.h +++ b/libs/hwui/renderthread/EglManager.h @@ -21,13 +21,35 @@ #include <SkRect.h> #include <ui/GraphicBuffer.h> #include <utils/StrongPointer.h> -#include <set> namespace android { namespace uirenderer { namespace renderthread { class RenderThread; +class EglManager; + +class Frame { +public: + EGLint width() const { return mWidth; } + EGLint height() const { return mHeight; } + + // See: https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_buffer_age.txt + // for what this means + EGLint bufferAge() const { return mBufferAge; } + +private: + friend class EglManager; + + EGLSurface mSurface; + EGLint mWidth; + EGLint mHeight; + EGLint mBufferAge; + + // Maps from 0,0 in top-left to 0,0 in bottom-left + // If out is not an EGLint[4] you're going to have a bad time + void map(const SkRect& in, EGLint* out) const; +}; // This class contains the shared global EGL objects, such as EGLDisplay // and EGLConfig, which are re-used by CanvasContext @@ -38,8 +60,6 @@ public: bool hasEglContext(); - bool hasEglExtension(const char* extension) const; - EGLSurface createSurface(EGLNativeWindowType window); void destroySurface(EGLSurface surface); @@ -48,14 +68,13 @@ public: bool isCurrent(EGLSurface surface) { return mCurrentSurface == surface; } // Returns true if the current surface changed, false if it was already current bool makeCurrent(EGLSurface surface, EGLint* errOut = nullptr); - void beginFrame(EGLSurface surface, EGLint* width, EGLint* height, EGLint* framebufferAge); - bool swapBuffers(EGLSurface surface, const SkRect& dirty, EGLint width, EGLint height); + Frame beginFrame(EGLSurface surface); + void damageFrame(const Frame& frame, const SkRect& dirty); + bool swapBuffers(const Frame& frame, const SkRect& screenDirty); // Returns true iff the surface is now preserving buffers. bool setPreserveBuffer(EGLSurface surface, bool preserve); - bool useBufferAgeExt(); - void setTextureAtlas(const sp<GraphicBuffer>& buffer, int64_t* map, size_t mapSize); void fence(); @@ -67,12 +86,12 @@ private: // EglContext is never destroyed, method is purposely not implemented ~EglManager(); + void initExtensions(); void createPBufferSurface(); - void loadConfig(bool useBufferAgeExt); + void loadConfig(); void createContext(); void initAtlas(); - - void findExtensions(const char* extensions, std::set<std::string>& list) const; + EGLint queryBufferAge(EGLSurface surface); RenderThread& mRenderThread; @@ -81,18 +100,18 @@ private: EGLContext mEglContext; EGLSurface mPBufferSurface; - const bool mAllowPreserveBuffer; - bool mCanSetPreserveBuffer; - - bool mHasBufferAgeExt; - EGLSurface mCurrentSurface; sp<GraphicBuffer> mAtlasBuffer; int64_t* mAtlasMap; size_t mAtlasMapSize; - std::set<std::string> mEglExtensionList; + enum class SwapBehavior { + Discard, + Preserved, + BufferAge, + }; + SwapBehavior mSwapBehavior = SwapBehavior::Discard; }; } /* namespace renderthread */ |