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
3 // found in the LICENSE file.
5 #ifndef GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_
6 #define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
12 #include "gpu/command_buffer/client/gpu_control.h"
13 #include "gpu/command_buffer/service/command_buffer_service.h"
14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
15 #include "gpu/command_buffer/service/gpu_scheduler.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gl/gl_context.h"
18 #include "ui/gl/gl_surface.h"
21 class CommandBufferService
;
25 class TransferBufferManagerInterface
;
29 class GLES2Implementation
;
42 class Display
: private gpu::GpuControl
{
44 explicit Display(EGLNativeDisplayType display_id
);
47 void SetCreateOffscreen(int width
, int height
) {
48 create_offscreen_
= true;
49 create_offscreen_width_
= width
;
50 create_offscreen_height_
= height
;
53 bool is_initialized() const { return is_initialized_
; }
57 bool IsValidConfig(EGLConfig config
);
59 EGLConfig
* configs
, EGLint config_size
, EGLint
* num_config
);
60 bool GetConfigs(EGLConfig
* configs
, EGLint config_size
, EGLint
* num_config
);
61 bool GetConfigAttrib(EGLConfig config
, EGLint attribute
, EGLint
* value
);
64 bool IsValidNativeWindow(EGLNativeWindowType win
);
65 bool IsValidSurface(EGLSurface surface
);
66 EGLSurface
CreateWindowSurface(EGLConfig config
,
67 EGLNativeWindowType win
,
68 const EGLint
* attrib_list
);
69 void DestroySurface(EGLSurface surface
);
70 void SwapBuffers(EGLSurface surface
);
73 bool IsValidContext(EGLContext ctx
);
74 EGLContext
CreateContext(EGLConfig config
,
76 const EGLint
* attrib_list
);
77 void DestroyContext(EGLContext ctx
);
78 bool MakeCurrent(EGLSurface draw
, EGLSurface read
, EGLContext ctx
);
80 // GpuControl implementation.
81 gpu::Capabilities
GetCapabilities() override
;
82 int32_t CreateImage(ClientBuffer buffer
,
85 unsigned internalformat
) override
;
86 void DestroyImage(int32_t id
) override
;
87 int32_t CreateGpuMemoryBufferImage(size_t width
,
89 unsigned internalformat
,
90 unsigned usage
) override
;
91 uint32
InsertSyncPoint() override
;
92 uint32
InsertFutureSyncPoint() override
;
93 void RetireSyncPoint(uint32 sync_point
) override
;
94 void SignalSyncPoint(uint32 sync_point
,
95 const base::Closure
& callback
) override
;
96 void SignalQuery(uint32 query
, const base::Closure
& callback
) override
;
97 void SetSurfaceVisible(bool visible
) override
;
98 uint32
CreateStreamTexture(uint32 texture_id
) override
;
99 void SetLock(base::Lock
*) override
;
100 bool IsGpuChannelLost() override
;
101 gpu::CommandBufferNamespace
GetNamespaceID() const override
;
102 uint64_t GetCommandBufferID() const override
;
105 EGLNativeDisplayType display_id_
;
107 bool is_initialized_
;
109 // elg::Display is used for comformance tests and command_buffer_gles. We only
110 // need the exit manager for the command_buffer_gles library.
111 // TODO(hendrikw): Find a cleaner solution for this.
112 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
113 scoped_ptr
<base::AtExitManager
> exit_manager_
;
114 #endif // COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY
116 bool create_offscreen_
;
117 int create_offscreen_width_
;
118 int create_offscreen_height_
;
120 scoped_refptr
<gpu::TransferBufferManagerInterface
> transfer_buffer_manager_
;
121 scoped_ptr
<gpu::CommandBufferService
> command_buffer_
;
122 scoped_ptr
<gpu::GpuScheduler
> gpu_scheduler_
;
123 scoped_ptr
<gpu::gles2::GLES2Decoder
> decoder_
;
124 scoped_refptr
<gfx::GLContext
> gl_context_
;
125 scoped_refptr
<gfx::GLSurface
> gl_surface_
;
126 scoped_ptr
<gpu::gles2::GLES2CmdHelper
> gles2_cmd_helper_
;
127 scoped_ptr
<gpu::TransferBuffer
> transfer_buffer_
;
129 // TODO(alokp): Support more than one config, surface, and context.
130 scoped_ptr
<Config
> config_
;
131 scoped_ptr
<Surface
> surface_
;
132 scoped_ptr
<gpu::gles2::GLES2Implementation
> context_
;
134 DISALLOW_COPY_AND_ASSIGN(Display
);
139 #endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_