Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / gpu / gles2_conform_support / egl / display.h
blob5ca1ba0b2bd4293f9cb2e7835c8653c5095eb1ef
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_
8 #include <EGL/egl.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"
20 namespace gpu {
21 class CommandBufferService;
22 class GpuControl;
23 class GpuScheduler;
24 class TransferBuffer;
25 class TransferBufferManagerInterface;
27 namespace gles2 {
28 class GLES2CmdHelper;
29 class GLES2Implementation;
30 } // namespace gles2
31 } // namespace gpu
33 namespace egl {
35 class Config;
36 class Surface;
38 class Display : private gpu::GpuControl {
39 public:
40 explicit Display(EGLNativeDisplayType display_id);
41 virtual ~Display();
43 void SetCreateOffscreen(int width, int height) {
44 create_offscreen_ = true;
45 create_offscreen_width_ = width;
46 create_offscreen_height_ = height;
49 bool is_initialized() const { return is_initialized_; }
50 bool Initialize();
52 // Config routines.
53 bool IsValidConfig(EGLConfig config);
54 bool ChooseConfigs(
55 EGLConfig* configs, EGLint config_size, EGLint* num_config);
56 bool GetConfigs(EGLConfig* configs, EGLint config_size, EGLint* num_config);
57 bool GetConfigAttrib(EGLConfig config, EGLint attribute, EGLint* value);
59 // Surface routines.
60 bool IsValidNativeWindow(EGLNativeWindowType win);
61 bool IsValidSurface(EGLSurface surface);
62 EGLSurface CreateWindowSurface(EGLConfig config,
63 EGLNativeWindowType win,
64 const EGLint* attrib_list);
65 void DestroySurface(EGLSurface surface);
66 void SwapBuffers(EGLSurface surface);
68 // Context routines.
69 bool IsValidContext(EGLContext ctx);
70 EGLContext CreateContext(EGLConfig config,
71 EGLContext share_ctx,
72 const EGLint* attrib_list);
73 void DestroyContext(EGLContext ctx);
74 bool MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx);
76 // GpuControl implementation.
77 virtual gpu::Capabilities GetCapabilities() OVERRIDE;
78 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(size_t width,
79 size_t height,
80 unsigned internalformat,
81 unsigned usage,
82 int32* id) OVERRIDE;
83 virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE;
84 virtual uint32 InsertSyncPoint() OVERRIDE;
85 virtual uint32 InsertFutureSyncPoint() OVERRIDE;
86 virtual void RetireSyncPoint(uint32 sync_point) OVERRIDE;
87 virtual void SignalSyncPoint(uint32 sync_point,
88 const base::Closure& callback) OVERRIDE;
89 virtual void SignalQuery(uint32 query,
90 const base::Closure& callback) OVERRIDE;
91 virtual void SetSurfaceVisible(bool visible) OVERRIDE;
92 virtual void Echo(const base::Closure& callback) OVERRIDE;
93 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
95 private:
96 EGLNativeDisplayType display_id_;
98 bool is_initialized_;
99 bool create_offscreen_;
100 int create_offscreen_width_;
101 int create_offscreen_height_;
103 scoped_ptr<gpu::TransferBufferManagerInterface> transfer_buffer_manager_;
104 scoped_ptr<gpu::CommandBufferService> command_buffer_;
105 scoped_ptr<gpu::GpuScheduler> gpu_scheduler_;
106 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_;
107 scoped_refptr<gfx::GLContext> gl_context_;
108 scoped_refptr<gfx::GLSurface> gl_surface_;
109 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_;
110 scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
112 // TODO(alokp): Support more than one config, surface, and context.
113 scoped_ptr<Config> config_;
114 scoped_ptr<Surface> surface_;
115 scoped_ptr<gpu::gles2::GLES2Implementation> context_;
117 DISALLOW_COPY_AND_ASSIGN(Display);
120 } // namespace egl
122 #endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_