Hash :
3625b749
Author :
Date :
2023-04-27T08:19:05
[ContextEGL] Synchronize state only when first making current ContextEGL::onMakeCurrent() can be called when this context is already current, which introduces complexities for the case where this context is wrapping an external context. This CL ensures that in this case we save state from the native context only when first transitioning this context to be current. To test: Exercise the repro steps in crbug.com/1434657: No assert should go off. Bug: chromium:1434657 Change-Id: I9690a76917fcb6d0fa31361bfbd3766bb6074d41 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4483695 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Auto-Submit: Colin Blundell <blundell@chromium.org>
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
//
// Copyright 2018 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.
//
// ContextEGL.h: Context class for GL on Android/ChromeOS. Wraps a RendererEGL.
#ifndef LIBANGLE_RENDERER_GL_EGL_CONTEXTEGL_H_
#define LIBANGLE_RENDERER_GL_EGL_CONTEXTEGL_H_
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/egl/RendererEGL.h"
namespace rx
{
struct ExternalContextState;
class ContextEGL : public ContextGL
{
public:
ContextEGL(const gl::State &state,
gl::ErrorSet *errorSet,
const std::shared_ptr<RendererEGL> &renderer,
RobustnessVideoMemoryPurgeStatus robustnessVideoMemoryPurgeStatus);
~ContextEGL() override;
angle::Result onMakeCurrent(const gl::Context *context) override;
angle::Result onUnMakeCurrent(const gl::Context *context) override;
EGLContext getContext() const;
private:
std::shared_ptr<RendererEGL> mRendererEGL;
std::unique_ptr<ExternalContextState> mExtState;
// Used to restore the default FBO's ID on unmaking an external context
// current, as when making an external context current ANGLE sets the
// default FBO's ID to that bound in the external context.
GLuint mPrevDefaultFramebufferID = 0;
// onMakeCurrent() can be called when this context is already current, which
// introduces complexities for the case where this context is wrapping an
// external context. This variable is used to ensure that in this case we
// save state from the native context only when first transitioning this
// context to be current. It is true for the duration of time between an
// onMakeCurrent() call and an onUnMakeCurrent() call (note: there is no
// "nesting" of onUnMakeCurrent() calls, i.e., no matter how many
// onMakeCurrent() calls have occurred consecutively, an onUnMakeCurrent()
// call transitions this context away from being current).
bool mIsCurrent = false;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EGL_RENDEREREGL_H_