Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: gpu/gles2_conform_support/egl/thread_state.h

Issue 1714883002: command_buffer_gles2: Implement EGL default Display as a global object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@command_buffer_gles2-multiple-contexts
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/gles2_conform_support/egl/test_support.cc ('k') | gpu/gles2_conform_support/egl/thread_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/gles2_conform_support/egl/thread_state.h
diff --git a/gpu/gles2_conform_support/egl/thread_state.h b/gpu/gles2_conform_support/egl/thread_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..963ac5c615cf0ced9b907601f0e67b433c053b1d
--- /dev/null
+++ b/gpu/gles2_conform_support/egl/thread_state.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_GLES2_CONFORM_SUPPORT_EGL_STATE_H_
+#define GPU_GLES2_CONFORM_SUPPORT_EGL_STATE_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include <EGL/egl.h>
+
+namespace egl {
+
+class Context;
+class Display;
+class Surface;
+
+// Thread-local API state of EGL.
+class ThreadState {
+ public:
+ // Factory getter for the class. Should only be called by the API layer, and
+ // then passed through Display in order to avoid lock issues.
+ static ThreadState* Get();
+ static void ReleaseThread();
+
+ Surface* current_surface() const { return current_surface_.get(); }
+ Context* current_context() const { return current_context_.get(); }
+
+ template <typename T>
+ T ReturnError(EGLint error, T return_value) {
+ error_code_ = error;
+ return return_value;
+ }
+ template <typename T>
+ T ReturnSuccess(T return_value) {
+ error_code_ = EGL_SUCCESS;
+ return return_value;
+ }
+ EGLint ConsumeErrorCode();
+
+ Display* GetDefaultDisplay();
+ Display* GetDisplay(EGLDisplay);
+
+ // RAII class for ensuring that ThreadState current context
+ // is reflected in the gfx:: and gles:: global variables.
+ class AutoCurrentContextRestore {
+ public:
+ AutoCurrentContextRestore(ThreadState*);
+ ~AutoCurrentContextRestore();
+ void SetCurrent(Surface*, Context*);
+
+ private:
+ ThreadState* thread_state_;
+ DISALLOW_COPY_AND_ASSIGN(AutoCurrentContextRestore);
+ };
+
+ private:
+ ThreadState();
+ ~ThreadState();
+ void SetCurrent(Surface*, Context*);
+
+ EGLint error_code_;
+ scoped_refptr<Surface> current_surface_;
+ scoped_refptr<Context> current_context_;
+ DISALLOW_COPY_AND_ASSIGN(ThreadState);
+};
+
+} // namespace egl
+
+#endif
« no previous file with comments | « gpu/gles2_conform_support/egl/test_support.cc ('k') | gpu/gles2_conform_support/egl/thread_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698