Hash :
043fcf18
Author :
Date :
2021-01-07T13:23:57
Support create ANGLE EGLContext from an external EGLContext For Android WebView, Android creates an EGLContext, EGLSurface and FBO, and makeCurrent on them, and then calls WebView draw function to draw the WebView content on the current EGLSurface or binded FBO. So to use ANGLE in WebView, this CL adds a way to create ANGLE EGLContext from an external EGLContext, and save and restore GL state in eglMakeCurrent(). Bug: angleproject:5509 Change-Id: I874986813117f125e23e975ea1adc51ac5b3a631 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2615239 Commit-Queue: Peng Huang <penghuang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SurfaceEGL.h: common interface for EGL surfaces
#ifndef LIBANGLE_RENDERER_GL_EGL_SURFACEEGL_H_
#define LIBANGLE_RENDERER_GL_EGL_SURFACEEGL_H_
#include <EGL/egl.h>
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGL.h"
namespace rx
{
class SurfaceEGL : public SurfaceGL
{
public:
SurfaceEGL(const egl::SurfaceState &state, const FunctionsEGL *egl, EGLConfig config);
~SurfaceEGL() override;
egl::Error makeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override;
egl::Error swapWithDamage(const gl::Context *context,
const EGLint *rects,
EGLint n_rects) override;
egl::Error postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height) override;
egl::Error setPresentationTime(EGLnsecsANDROID time) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer) override;
egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override;
void setTimestampsEnabled(bool enabled) override;
egl::SupportedCompositorTimings getSupportedCompositorTimings() const override;
egl::Error getCompositorTiming(EGLint numTimestamps,
const EGLint *names,
EGLnsecsANDROID *values) const override;
egl::Error getNextFrameId(EGLuint64KHR *frameId) const override;
egl::SupportedTimestamps getSupportedTimestamps() const override;
egl::Error getFrameTimestamps(EGLuint64KHR frameId,
EGLint numTimestamps,
const EGLint *timestamps,
EGLnsecsANDROID *values) const override;
EGLSurface getSurface() const;
virtual bool isExternal() const;
protected:
const FunctionsEGL *mEGL;
EGLConfig mConfig;
EGLSurface mSurface;
private:
bool mHasSwapBuffersWithDamage;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_SURFACEEGL_H_