OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SUPPORT_EGL_DISPLAY_H_ |
6 #define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ | 6 #define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ |
7 | 7 |
8 #include <EGL/egl.h> | 8 #include <EGL/egl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | |
14 | 13 |
15 #include "base/macros.h" | 14 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
17 #include "base/synchronization/lock.h" | 16 #include "gpu/command_buffer/client/gpu_control.h" |
| 17 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 18 #include "gpu/command_buffer/service/command_executor.h" |
| 19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 20 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 21 #include "gpu/config/gpu_driver_bug_workarounds.h" |
| 22 #include "ui/gfx/native_widget_types.h" |
| 23 #include "ui/gl/gl_context.h" |
| 24 #include "ui/gl/gl_surface.h" |
| 25 |
| 26 namespace gpu { |
| 27 class CommandBufferService; |
| 28 class GpuControl; |
| 29 class CommandExecutor; |
| 30 class TransferBuffer; |
| 31 class TransferBufferManagerInterface; |
| 32 |
| 33 namespace gles2 { |
| 34 class GLES2CmdHelper; |
| 35 class GLES2Implementation; |
| 36 } // namespace gles2 |
| 37 } // namespace gpu |
18 | 38 |
19 namespace egl { | 39 namespace egl { |
20 | 40 |
21 class Config; | 41 class Config; |
22 class Context; | |
23 class Surface; | 42 class Surface; |
24 class ThreadState; | |
25 | 43 |
26 class Display { | 44 class Display : private gpu::GpuControl { |
27 public: | 45 public: |
28 explicit Display(); | 46 explicit Display(EGLNativeDisplayType display_id); |
29 ~Display(); | 47 ~Display() override; |
| 48 |
| 49 void SetCreateOffscreen(int width, int height) { |
| 50 create_offscreen_ = true; |
| 51 create_offscreen_width_ = width; |
| 52 create_offscreen_height_ = height; |
| 53 } |
30 | 54 |
31 bool is_initialized() const { return is_initialized_; } | 55 bool is_initialized() const { return is_initialized_; } |
32 | 56 bool Initialize(); |
33 void ReleaseCurrentForReleaseThread(ThreadState*); | |
34 | |
35 // A function for windowless GTF tests. | |
36 void SetNextCreateWindowSurfaceCreatesPBuffer(EGLint width, EGLint height); | |
37 | |
38 EGLBoolean Initialize(ThreadState* ts, EGLint* major, EGLint* minor); | |
39 EGLBoolean Terminate(ThreadState* ts); | |
40 const char* QueryString(ThreadState* ts, EGLint name); | |
41 | 57 |
42 // Config routines. | 58 // Config routines. |
43 EGLBoolean GetConfigAttrib(ThreadState* ts, | 59 bool IsValidConfig(EGLConfig config); |
44 EGLConfig cfg, | 60 bool ChooseConfigs( |
45 EGLint attribute, | 61 EGLConfig* configs, EGLint config_size, EGLint* num_config); |
46 EGLint* value); | 62 bool GetConfigs(EGLConfig* configs, EGLint config_size, EGLint* num_config); |
47 EGLBoolean ChooseConfig(ThreadState* ts, | 63 bool GetConfigAttrib(EGLConfig config, EGLint attribute, EGLint* value); |
48 const EGLint* attrib_list, | |
49 EGLConfig* configs, | |
50 EGLint config_size, | |
51 EGLint* num_config); | |
52 EGLBoolean GetConfigs(ThreadState*, | |
53 EGLConfig*, | |
54 EGLint config_size, | |
55 EGLint* num_config); | |
56 | 64 |
57 // Surface routines. | 65 // Surface routines. |
58 static bool IsValidNativeWindow(EGLNativeWindowType); | 66 bool IsValidNativeWindow(EGLNativeWindowType win); |
59 EGLSurface CreatePbufferSurface(ThreadState*, | 67 bool IsValidSurface(EGLSurface surface); |
60 EGLConfig, | 68 EGLSurface CreateWindowSurface(EGLConfig config, |
61 const EGLint* attrib_list); | |
62 EGLSurface CreateWindowSurface(ThreadState*, | |
63 EGLConfig, | |
64 EGLNativeWindowType win, | 69 EGLNativeWindowType win, |
65 const EGLint* attrib_list); | 70 const EGLint* attrib_list); |
66 EGLBoolean DestroySurface(ThreadState*, EGLSurface); | 71 void DestroySurface(EGLSurface surface); |
67 EGLBoolean SwapBuffers(ThreadState*, EGLSurface); | 72 void SwapBuffers(EGLSurface surface); |
68 | 73 |
69 // Context routines. | 74 // Context routines. |
70 EGLContext CreateContext(ThreadState*, | 75 bool IsValidContext(EGLContext ctx); |
71 EGLConfig, | 76 EGLContext CreateContext(EGLConfig config, |
72 EGLSurface share_ctx, | 77 EGLContext share_ctx, |
73 const EGLint* attrib_list); | 78 const EGLint* attrib_list); |
74 EGLBoolean DestroyContext(ThreadState*, EGLContext); | 79 void DestroyContext(EGLContext ctx); |
| 80 bool MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx); |
75 | 81 |
76 EGLBoolean ReleaseCurrent(ThreadState*); | 82 // GpuControl implementation. |
77 EGLBoolean MakeCurrent(ThreadState*, EGLSurface, EGLSurface, EGLContext); | 83 void SetGpuControlClient(gpu::GpuControlClient*) override; |
78 | 84 gpu::Capabilities GetCapabilities() override; |
79 uint64_t GenerateFenceSyncRelease(); | 85 int32_t CreateImage(ClientBuffer buffer, |
80 bool IsFenceSyncRelease(uint64_t release); | 86 size_t width, |
81 bool IsFenceSyncFlushed(uint64_t release); | 87 size_t height, |
82 bool IsFenceSyncFlushReceived(uint64_t release); | 88 unsigned internalformat) override; |
| 89 void DestroyImage(int32_t id) override; |
| 90 int32_t CreateGpuMemoryBufferImage(size_t width, |
| 91 size_t height, |
| 92 unsigned internalformat, |
| 93 unsigned usage) override; |
| 94 void SignalQuery(uint32_t query, const base::Closure& callback) override; |
| 95 void SetLock(base::Lock*) override; |
| 96 bool IsGpuChannelLost() override; |
| 97 void EnsureWorkVisible() override; |
| 98 gpu::CommandBufferNamespace GetNamespaceID() const override; |
| 99 gpu::CommandBufferId GetCommandBufferID() const override; |
| 100 int32_t GetExtraCommandBufferData() const override; |
| 101 uint64_t GenerateFenceSyncRelease() override; |
| 102 bool IsFenceSyncRelease(uint64_t release) override; |
| 103 bool IsFenceSyncFlushed(uint64_t release) override; |
| 104 bool IsFenceSyncFlushReceived(uint64_t release) override; |
| 105 void SignalSyncToken(const gpu::SyncToken& sync_token, |
| 106 const base::Closure& callback) override; |
| 107 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; |
83 | 108 |
84 private: | 109 private: |
85 void InitializeConfigsIfNeeded(); | 110 EGLNativeDisplayType display_id_; |
86 const Config* GetConfig(EGLConfig); | |
87 Surface* GetSurface(EGLSurface); | |
88 Context* GetContext(EGLContext); | |
89 EGLSurface DoCreatePbufferSurface(ThreadState* ts, | |
90 const Config* config, | |
91 EGLint width, | |
92 EGLint height); | |
93 | 111 |
94 base::Lock lock_; | 112 gpu::GpuPreferences gpu_preferences_; |
| 113 const gpu::GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
95 bool is_initialized_; | 114 bool is_initialized_; |
| 115 |
| 116 bool create_offscreen_; |
| 117 int create_offscreen_width_; |
| 118 int create_offscreen_height_; |
96 uint64_t next_fence_sync_release_; | 119 uint64_t next_fence_sync_release_; |
97 std::vector<scoped_refptr<Surface>> surfaces_; | |
98 std::vector<scoped_refptr<Context>> contexts_; | |
99 std::unique_ptr<Config> configs_[2]; | |
100 | 120 |
101 // GTF windowless support. | 121 scoped_refptr<gpu::TransferBufferManagerInterface> transfer_buffer_manager_; |
102 bool next_create_window_surface_creates_pbuffer_; | 122 std::unique_ptr<gpu::CommandBufferService> command_buffer_; |
103 EGLint window_surface_pbuffer_width_; | 123 std::unique_ptr<gpu::CommandExecutor> executor_; |
104 EGLint window_surface_pbuffer_height_; | 124 std::unique_ptr<gpu::gles2::GLES2Decoder> decoder_; |
| 125 scoped_refptr<gfx::GLContext> gl_context_; |
| 126 scoped_refptr<gfx::GLSurface> gl_surface_; |
| 127 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; |
| 128 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; |
| 129 |
| 130 // TODO(alokp): Support more than one config, surface, and context. |
| 131 std::unique_ptr<Config> config_; |
| 132 std::unique_ptr<Surface> surface_; |
| 133 std::unique_ptr<gpu::gles2::GLES2Implementation> context_; |
105 | 134 |
106 DISALLOW_COPY_AND_ASSIGN(Display); | 135 DISALLOW_COPY_AND_ASSIGN(Display); |
107 }; | 136 }; |
108 | 137 |
109 } // namespace egl | 138 } // namespace egl |
110 | 139 |
111 #endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ | 140 #endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ |
OLD | NEW |