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

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

Powered by Google App Engine
This is Rietveld 408576698