OLD | NEW |
---|---|
(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 ThreadState(); | |
27 ~ThreadState(); | |
Sami Väisänen
2016/02/19 14:10:15
If lifetime management happens through Get and Rel
Kimmo Kinnunen
2016/02/22 06:43:08
Done.
| |
28 | |
29 Surface* current_surface() const { return current_surface_.get(); } | |
30 Context* current_context() const { return current_context_.get(); } | |
Sami Väisänen
2016/02/19 14:10:15
return value is not const Context*, so I'm not sur
Kimmo Kinnunen
2016/02/22 06:43:08
So the returned objects are not part of the logica
| |
31 | |
32 template <typename T> | |
33 T ReturnError(EGLint error, T return_value) { | |
34 error_code_ = error; | |
35 return return_value; | |
36 } | |
37 template <typename T> | |
38 T ReturnSuccess(T return_value) { | |
39 error_code_ = EGL_SUCCESS; | |
40 return return_value; | |
41 } | |
42 EGLint ConsumeErrorCode(); | |
43 | |
44 Display* GetDefaultDisplay(); | |
45 Display* GetDisplay(EGLDisplay); | |
46 void SetCurrent(Surface*, Context*); | |
47 void ApplyCurrentContext(); | |
48 | |
49 class AutoApplyCurrentContext { | |
50 public: | |
51 AutoApplyCurrentContext(ThreadState*); | |
52 ~AutoApplyCurrentContext(); | |
53 | |
54 private: | |
55 ThreadState* thread_state_; | |
56 }; | |
Sami Väisänen
2016/02/19 14:10:15
if this is a RAII type, maybe disallow copyctor an
Kimmo Kinnunen
2016/02/22 06:43:08
Done.
| |
57 | |
58 private: | |
59 EGLint error_code_; | |
60 scoped_refptr<Surface> current_surface_; | |
61 scoped_refptr<Context> current_context_; | |
62 DISALLOW_COPY_AND_ASSIGN(ThreadState); | |
63 }; | |
64 | |
65 } // namespace egl | |
66 | |
67 #endif | |
OLD | NEW |