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_CLIENT_SHARE_GROUP_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ |
7 | 7 |
| 8 #include <GLES2/gl2.h> |
8 #include "../client/ref_counted.h" | 9 #include "../client/ref_counted.h" |
| 10 #include "../common/gles2_cmd_format.h" |
| 11 #include "../common/scoped_ptr.h" |
9 #include "gles2_impl_export.h" | 12 #include "gles2_impl_export.h" |
10 | 13 |
11 namespace gpu { | 14 namespace gpu { |
12 namespace gles2 { | 15 namespace gles2 { |
13 | 16 |
| 17 class GLES2Implementation; |
| 18 class ProgramInfoManager; |
| 19 |
| 20 // Base class for IdHandlers |
| 21 class IdHandlerInterface { |
| 22 public: |
| 23 IdHandlerInterface() { } |
| 24 virtual ~IdHandlerInterface() { } |
| 25 |
| 26 // Free everything. |
| 27 virtual void Destroy(GLES2Implementation* gl_impl) = 0; |
| 28 |
| 29 // Makes some ids at or above id_offset. |
| 30 virtual void MakeIds( |
| 31 GLES2Implementation* gl_impl, |
| 32 GLuint id_offset, GLsizei n, GLuint* ids) = 0; |
| 33 |
| 34 // Frees some ids. |
| 35 virtual bool FreeIds( |
| 36 GLES2Implementation* gl_impl, GLsizei n, const GLuint* ids) = 0; |
| 37 |
| 38 // Marks an id as used for glBind functions. id = 0 does nothing. |
| 39 virtual bool MarkAsUsedForBind(GLuint id) = 0; |
| 40 }; |
| 41 |
14 // ShareGroup manages shared resources for contexts that are sharing resources. | 42 // ShareGroup manages shared resources for contexts that are sharing resources. |
15 class GLES2_IMPL_EXPORT ShareGroup | 43 class GLES2_IMPL_EXPORT ShareGroup |
16 : public gpu::RefCountedThreadSafe<ShareGroup> { | 44 : public gpu::RefCountedThreadSafe<ShareGroup> { |
17 public: | 45 public: |
18 typedef scoped_refptr<ShareGroup> Ref; | 46 typedef scoped_refptr<ShareGroup> Ref; |
19 | 47 |
20 ShareGroup(); | 48 ShareGroup(bool share_resources, bool bind_generates_resource); |
21 ~ShareGroup(); | 49 ~ShareGroup(); |
22 | 50 |
| 51 void SetGLES2ImplementationForDestruction(GLES2Implementation* gl_impl); |
| 52 |
| 53 bool sharing_resources() const { |
| 54 return sharing_resources_; |
| 55 } |
| 56 |
| 57 bool bind_generates_resource() const { |
| 58 return bind_generates_resource_; |
| 59 } |
| 60 |
23 bool Initialize(); | 61 bool Initialize(); |
24 | 62 |
| 63 IdHandlerInterface* GetIdHandler(int namespace_id) const { |
| 64 return id_handlers_[namespace_id].get(); |
| 65 } |
| 66 |
| 67 ProgramInfoManager* program_info_manager() { |
| 68 return program_info_manager_.get(); |
| 69 } |
| 70 |
25 private: | 71 private: |
| 72 scoped_ptr<IdHandlerInterface> id_handlers_[id_namespaces::kNumIdNamespaces]; |
| 73 scoped_ptr<ProgramInfoManager> program_info_manager_; |
| 74 |
| 75 // Whether or not this context is sharing resources. |
| 76 bool sharing_resources_; |
| 77 bool bind_generates_resource_; |
| 78 |
| 79 GLES2Implementation* gles2_; |
| 80 |
26 DISALLOW_COPY_AND_ASSIGN(ShareGroup); | 81 DISALLOW_COPY_AND_ASSIGN(ShareGroup); |
27 }; | 82 }; |
28 | 83 |
29 } // namespace gles2 | 84 } // namespace gles2 |
30 } // namespace gpu | 85 } // namespace gpu |
31 | 86 |
32 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ | 87 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ |
OLD | NEW |