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