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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_GLES2_CONFORM_SUPPORT_EGL_STATE_H_
6 #define GPU_GLES2_CONFORM_SUPPORT_EGL_STATE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include <EGL/egl.h>
11
12 namespace egl {
13
14 class Context;
15 class Display;
16 class Surface;
17
18 // Thread-local API state of EGL.
19 class ThreadState {
20 public:
21 // Factory getter for the class. Should only be called by the API layer, and
22 // then passed through Display in order to avoid lock issues.
23 static ThreadState* Get();
24 static void ReleaseThread();
25
26 Surface* current_surface() const { return current_surface_.get(); }
27 Context* current_context() const { return current_context_.get(); }
28
29 template <typename T>
30 T ReturnError(EGLint error, T return_value) {
31 error_code_ = error;
32 return return_value;
33 }
34 template <typename T>
35 T ReturnSuccess(T return_value) {
36 error_code_ = EGL_SUCCESS;
37 return return_value;
38 }
39 EGLint ConsumeErrorCode();
40
41 Display* GetDefaultDisplay();
42 Display* GetDisplay(EGLDisplay);
43
44 // RAII class for ensuring that ThreadState current context
45 // is reflected in the gfx:: and gles:: global variables.
46 class AutoCurrentContextRestore {
47 public:
48 AutoCurrentContextRestore(ThreadState*);
49 ~AutoCurrentContextRestore();
50 void SetCurrent(Surface*, Context*);
51
52 private:
53 ThreadState* thread_state_;
54 DISALLOW_COPY_AND_ASSIGN(AutoCurrentContextRestore);
55 };
56
57 private:
58 ThreadState();
59 ~ThreadState();
60 void SetCurrent(Surface*, Context*);
61
62 EGLint error_code_;
63 scoped_refptr<Surface> current_surface_;
64 scoped_refptr<Context> current_context_;
65 DISALLOW_COPY_AND_ASSIGN(ThreadState);
66 };
67
68 } // namespace egl
69
70 #endif
OLDNEW
« 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