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_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
7 | 7 |
8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "gpu/command_buffer/client/gpu_control.h" | 11 #include "gpu/command_buffer/client/gpu_control.h" |
12 #include "gpu/command_buffer/service/feature_info.h" | 12 #include "gpu/command_buffer/service/feature_info.h" |
13 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 | 16 |
17 class GLContext; | 17 class GLContext; |
18 class GLShareGroup; | 18 class GLShareGroup; |
19 class GLSurface; | 19 class GLSurface; |
20 | 20 |
21 } | 21 } |
22 | 22 |
23 namespace gpu { | 23 namespace gpu { |
24 | 24 |
25 class CommandBufferService; | 25 class CommandBufferService; |
26 class GpuControlService; | |
27 class GpuMemoryBufferFactory; | |
28 class GpuScheduler; | 26 class GpuScheduler; |
29 class TransferBuffer; | 27 class TransferBuffer; |
30 | 28 |
31 namespace gles2 { | 29 namespace gles2 { |
32 | 30 |
33 class ContextGroup; | 31 class ContextGroup; |
34 class MailboxManager; | 32 class MailboxManager; |
35 class GLES2Decoder; | 33 class GLES2Decoder; |
36 class GLES2CmdHelper; | 34 class GLES2CmdHelper; |
37 class GLES2Implementation; | 35 class GLES2Implementation; |
38 class ImageFactory; | |
39 class ImageManager; | 36 class ImageManager; |
40 class ShareGroup; | 37 class ShareGroup; |
41 | 38 |
42 }; | 39 }; |
43 | 40 |
44 class GLManager : private GpuControl { | 41 class GLManager : private GpuControl { |
45 public: | 42 public: |
46 struct Options { | 43 struct Options { |
47 Options(); | 44 Options(); |
48 // The size of the backbuffer. | 45 // The size of the backbuffer. |
49 gfx::Size size; | 46 gfx::Size size; |
50 // If not null will share resources with this context. | 47 // If not null will share resources with this context. |
51 GLManager* share_group_manager; | 48 GLManager* share_group_manager; |
52 // If not null will share a mailbox manager with this context. | 49 // If not null will share a mailbox manager with this context. |
53 GLManager* share_mailbox_manager; | 50 GLManager* share_mailbox_manager; |
54 // If not null will create a virtual manager based on this context. | 51 // If not null will create a virtual manager based on this context. |
55 GLManager* virtual_manager; | 52 GLManager* virtual_manager; |
56 // Whether or not glBindXXX generates a resource. | 53 // Whether or not glBindXXX generates a resource. |
57 bool bind_generates_resource; | 54 bool bind_generates_resource; |
58 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. | 55 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. |
59 bool lose_context_when_out_of_memory; | 56 bool lose_context_when_out_of_memory; |
60 // Whether or not it's ok to lose the context. | 57 // Whether or not it's ok to lose the context. |
61 bool context_lost_allowed; | 58 bool context_lost_allowed; |
62 // Image manager to be used. | |
63 gles2::ImageManager* image_manager; | |
64 // GpuMemoryBuffer factory to be used. | |
65 GpuMemoryBufferFactory* gpu_memory_buffer_factory; | |
66 }; | 59 }; |
67 GLManager(); | 60 GLManager(); |
68 virtual ~GLManager(); | 61 virtual ~GLManager(); |
69 | 62 |
70 void Initialize(const Options& options); | 63 void Initialize(const Options& options); |
71 void Destroy(); | 64 void Destroy(); |
72 | 65 |
73 void MakeCurrent(); | 66 void MakeCurrent(); |
74 | 67 |
75 void SetSurface(gfx::GLSurface* surface); | 68 void SetSurface(gfx::GLSurface* surface); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE; | 109 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE; |
117 | 110 |
118 private: | 111 private: |
119 void PumpCommands(); | 112 void PumpCommands(); |
120 bool GetBufferChanged(int32 transfer_buffer_id); | 113 bool GetBufferChanged(int32 transfer_buffer_id); |
121 void SetupBaseContext(); | 114 void SetupBaseContext(); |
122 | 115 |
123 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 116 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
124 scoped_refptr<gfx::GLShareGroup> share_group_; | 117 scoped_refptr<gfx::GLShareGroup> share_group_; |
125 scoped_ptr<CommandBufferService> command_buffer_; | 118 scoped_ptr<CommandBufferService> command_buffer_; |
126 scoped_ptr<GpuControlService> gpu_control_service_; | |
127 scoped_ptr<gles2::GLES2Decoder> decoder_; | 119 scoped_ptr<gles2::GLES2Decoder> decoder_; |
128 scoped_ptr<GpuScheduler> gpu_scheduler_; | 120 scoped_ptr<GpuScheduler> gpu_scheduler_; |
129 scoped_refptr<gfx::GLSurface> surface_; | 121 scoped_refptr<gfx::GLSurface> surface_; |
130 scoped_refptr<gfx::GLContext> context_; | 122 scoped_refptr<gfx::GLContext> context_; |
131 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; | 123 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; |
132 scoped_ptr<TransferBuffer> transfer_buffer_; | 124 scoped_ptr<TransferBuffer> transfer_buffer_; |
133 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; | 125 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; |
134 bool context_lost_allowed_; | 126 bool context_lost_allowed_; |
135 | 127 |
136 // Client GpuControl implementation. | 128 // Client GpuControl implementation. |
137 GpuMemoryBufferFactory* gpu_memory_buffer_factory_; | 129 base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer> gpu_memory_buffers_; |
138 base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer> memory_buffers_; | |
139 | 130 |
140 // Used on Android to virtualize GL for all contexts. | 131 // Used on Android to virtualize GL for all contexts. |
141 static int use_count_; | 132 static int use_count_; |
142 static scoped_refptr<gfx::GLShareGroup>* base_share_group_; | 133 static scoped_refptr<gfx::GLShareGroup>* base_share_group_; |
143 static scoped_refptr<gfx::GLSurface>* base_surface_; | 134 static scoped_refptr<gfx::GLSurface>* base_surface_; |
144 static scoped_refptr<gfx::GLContext>* base_context_; | 135 static scoped_refptr<gfx::GLContext>* base_context_; |
145 }; | 136 }; |
146 | 137 |
147 } // namespace gpu | 138 } // namespace gpu |
148 | 139 |
149 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 140 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
OLD | NEW |