summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/EglManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/renderthread/EglManager.h')
-rw-r--r--libs/hwui/renderthread/EglManager.h40
1 files changed, 35 insertions, 5 deletions
diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h
index 0a8cfd30df71..62b5b99a6e30 100644
--- a/libs/hwui/renderthread/EglManager.h
+++ b/libs/hwui/renderthread/EglManager.h
@@ -27,6 +27,29 @@ 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
@@ -45,8 +68,9 @@ 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);
- 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);
@@ -62,10 +86,12 @@ private:
// EglContext is never destroyed, method is purposely not implemented
~EglManager();
+ void initExtensions();
void createPBufferSurface();
void loadConfig();
void createContext();
void initAtlas();
+ EGLint queryBufferAge(EGLSurface surface);
RenderThread& mRenderThread;
@@ -74,14 +100,18 @@ private:
EGLContext mEglContext;
EGLSurface mPBufferSurface;
- const bool mAllowPreserveBuffer;
- bool mCanSetPreserveBuffer;
-
EGLSurface mCurrentSurface;
sp<GraphicBuffer> mAtlasBuffer;
int64_t* mAtlasMap;
size_t mAtlasMapSize;
+
+ enum class SwapBehavior {
+ Discard,
+ Preserved,
+ BufferAge,
+ };
+ SwapBehavior mSwapBehavior = SwapBehavior::Discard;
};
} /* namespace renderthread */