OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ | 5 #ifndef GPU_GLES2_CONFORM_TEST_CONTEXT_H_ |
6 #define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ | 6 #define GPU_GLES2_CONFORM_TEST_CONTEXT_H_ |
7 | |
8 #include <EGL/egl.h> | |
9 #include <stddef.h> | |
10 #include <stdint.h> | |
11 | 7 |
12 #include "base/macros.h" | 8 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/ref_counted.h" |
14 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 10 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
15 #include "gpu/command_buffer/client/gpu_control.h" | 11 #include "gpu/command_buffer/client/gpu_control.h" |
16 #include "gpu/command_buffer/service/command_buffer_service.h" | 12 #include "gpu/command_buffer/service/command_buffer_service.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
18 #include "gpu/command_buffer/service/gpu_scheduler.h" | 14 #include "gpu/command_buffer/service/gpu_scheduler.h" |
19 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
20 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
| 17 #include "ui/gl/gl_context.h" |
21 #include "ui/gl/gl_surface.h" | 18 #include "ui/gl/gl_surface.h" |
| 19 #include "ui/gl/gl_surface.h" |
| 20 #include <EGL/egl.h> |
22 | 21 |
23 namespace gpu { | 22 namespace gpu { |
24 class CommandBufferService; | 23 class CommandBufferService; |
25 class GpuControl; | 24 class GpuControl; |
26 class GpuScheduler; | 25 class GpuScheduler; |
27 class TransferBuffer; | 26 class TransferBuffer; |
28 class TransferBufferManagerInterface; | 27 class TransferBufferManagerInterface; |
29 | 28 |
30 namespace gles2 { | 29 namespace gles2 { |
31 class GLES2CmdHelper; | 30 class GLES2CmdHelper; |
32 class GLES2Implementation; | 31 class GLES2Interface; |
33 } // namespace gles2 | 32 } // namespace gles2 |
34 } // namespace gpu | 33 } // namespace gpu |
35 | 34 |
36 namespace egl { | 35 namespace egl { |
| 36 class Display; |
| 37 class Surface; |
| 38 class Config; |
37 | 39 |
38 class Config; | 40 class Context : public base::RefCountedThreadSafe<Context>, |
39 class Surface; | 41 private gpu::GpuControl { |
| 42 public: |
| 43 Context(Display* display, const Config* config); |
| 44 bool is_current_in_some_thread() const { return is_current_in_some_thread_; } |
| 45 void SetDestroyed(Surface* current_surface_if_own); |
| 46 void FlushAndSwapBuffers(Surface* current_surface); |
| 47 void MakeCurrentRelease(Surface* current_surface); |
| 48 bool MakeCurrentSwitchSurface(Surface* current_surface, Surface* new_surface); |
| 49 bool MakeCurrent(Surface* new_surface); |
| 50 gfx::GLContext* gl_context() const; |
| 51 gpu::gles2::GLES2Interface* client_gl_context() const; |
40 | 52 |
41 class Display : private gpu::GpuControl { | 53 static bool ValidateAttributeList(const EGLint* attrib_list); |
42 public: | |
43 explicit Display(EGLNativeDisplayType display_id); | |
44 ~Display() override; | |
45 | |
46 void SetCreateOffscreen(int width, int height) { | |
47 create_offscreen_ = true; | |
48 create_offscreen_width_ = width; | |
49 create_offscreen_height_ = height; | |
50 } | |
51 | |
52 bool is_initialized() const { return is_initialized_; } | |
53 bool Initialize(); | |
54 | |
55 // Config routines. | |
56 bool IsValidConfig(EGLConfig config); | |
57 bool ChooseConfigs( | |
58 EGLConfig* configs, EGLint config_size, EGLint* num_config); | |
59 bool GetConfigs(EGLConfig* configs, EGLint config_size, EGLint* num_config); | |
60 bool GetConfigAttrib(EGLConfig config, EGLint attribute, EGLint* value); | |
61 | |
62 // Surface routines. | |
63 bool IsValidNativeWindow(EGLNativeWindowType win); | |
64 bool IsValidSurface(EGLSurface surface); | |
65 EGLSurface CreateWindowSurface(EGLConfig config, | |
66 EGLNativeWindowType win, | |
67 const EGLint* attrib_list); | |
68 void DestroySurface(EGLSurface surface); | |
69 void SwapBuffers(EGLSurface surface); | |
70 | |
71 // Context routines. | |
72 bool IsValidContext(EGLContext ctx); | |
73 EGLContext CreateContext(EGLConfig config, | |
74 EGLContext share_ctx, | |
75 const EGLint* attrib_list); | |
76 void DestroyContext(EGLContext ctx); | |
77 bool MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx); | |
78 | 54 |
79 // GpuControl implementation. | 55 // GpuControl implementation. |
80 gpu::Capabilities GetCapabilities() override; | 56 gpu::Capabilities GetCapabilities() override; |
81 int32_t CreateImage(ClientBuffer buffer, | 57 int32_t CreateImage(ClientBuffer buffer, |
82 size_t width, | 58 size_t width, |
83 size_t height, | 59 size_t height, |
84 unsigned internalformat) override; | 60 unsigned internalformat) override; |
85 void DestroyImage(int32_t id) override; | 61 void DestroyImage(int32_t id) override; |
86 int32_t CreateGpuMemoryBufferImage(size_t width, | 62 int32_t CreateGpuMemoryBufferImage(size_t width, |
87 size_t height, | 63 size_t height, |
88 unsigned internalformat, | 64 unsigned internalformat, |
89 unsigned usage) override; | 65 unsigned usage) override; |
90 void SignalQuery(uint32_t query, const base::Closure& callback) override; | 66 void SignalQuery(uint32_t query, const base::Closure& callback) override; |
91 void SetLock(base::Lock*) override; | 67 void SetLock(base::Lock*) override; |
92 bool IsGpuChannelLost() override; | 68 bool IsGpuChannelLost() override; |
93 void EnsureWorkVisible() override; | 69 void EnsureWorkVisible() override; |
94 gpu::CommandBufferNamespace GetNamespaceID() const override; | 70 gpu::CommandBufferNamespace GetNamespaceID() const override; |
95 uint64_t GetCommandBufferID() const override; | 71 uint64_t GetCommandBufferID() const override; |
96 int32_t GetExtraCommandBufferData() const override; | 72 int32_t GetExtraCommandBufferData() const override; |
97 uint64_t GenerateFenceSyncRelease() override; | 73 uint64_t GenerateFenceSyncRelease() override; |
98 bool IsFenceSyncRelease(uint64_t release) override; | 74 bool IsFenceSyncRelease(uint64_t release) override; |
99 bool IsFenceSyncFlushed(uint64_t release) override; | 75 bool IsFenceSyncFlushed(uint64_t release) override; |
100 bool IsFenceSyncFlushReceived(uint64_t release) override; | 76 bool IsFenceSyncFlushReceived(uint64_t release) override; |
101 void SignalSyncToken(const gpu::SyncToken& sync_token, | 77 void SignalSyncToken(const gpu::SyncToken& sync_token, |
102 const base::Closure& callback) override; | 78 const base::Closure& callback) override; |
103 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; | 79 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; |
104 | 80 |
105 private: | 81 private: |
106 EGLNativeDisplayType display_id_; | 82 friend class base::RefCountedThreadSafe<Context>; |
| 83 ~Context() override; |
| 84 void Cleanup(); |
| 85 void MarkContextLost(); |
| 86 bool WasContextLost() const; |
| 87 bool IsCompatibleSurface(gfx::GLSurface* gl_surface); |
107 | 88 |
108 bool is_initialized_; | 89 Display* display_; |
109 | 90 const Config* config_; |
110 bool create_offscreen_; | 91 bool is_current_in_some_thread_; |
111 int create_offscreen_width_; | |
112 int create_offscreen_height_; | |
113 uint64_t next_fence_sync_release_; | |
114 | |
115 scoped_refptr<gpu::TransferBufferManagerInterface> transfer_buffer_manager_; | |
116 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 92 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
| 93 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; |
| 94 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
117 scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; | 95 scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; |
118 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | |
119 scoped_refptr<gfx::GLContext> gl_context_; | |
120 scoped_refptr<gfx::GLSurface> gl_surface_; | |
121 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; | |
122 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | 96 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
123 | 97 |
124 // TODO(alokp): Support more than one config, surface, and context. | 98 scoped_refptr<gfx::GLContext> gl_context_; |
125 scoped_ptr<Config> config_; | |
126 scoped_ptr<Surface> surface_; | |
127 scoped_ptr<gpu::gles2::GLES2Implementation> context_; | |
128 | 99 |
129 DISALLOW_COPY_AND_ASSIGN(Display); | 100 scoped_ptr<gpu::gles2::GLES2Interface> client_gl_context_; |
| 101 DISALLOW_COPY_AND_ASSIGN(Context); |
130 }; | 102 }; |
131 | 103 |
132 } // namespace egl | 104 } // namespace egl |
133 | 105 |
134 #endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ | 106 #endif // GPU_GLES2_CONFORM_TEST_CONTEXT_H_ |
OLD | NEW |