OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 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. |
| 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TRANSFORM_FEEDBACK_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_TRANSFORM_FEEDBACK_MANAGER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "gpu/command_buffer/service/gl_utils.h" |
| 13 #include "gpu/command_buffer/service/indexed_buffer_binding_host.h" |
| 14 #include "gpu/gpu_export.h" |
| 15 |
| 16 namespace gfx { |
| 17 struct GLVersionInfo; |
| 18 }; |
| 19 |
| 20 namespace gpu { |
| 21 namespace gles2 { |
| 22 |
| 23 class Buffer; |
| 24 class TransformFeedbackManager; |
| 25 |
| 26 // Info about TransformFeedbacks currently in the system. |
| 27 class GPU_EXPORT TransformFeedback : public IndexedBufferBindingHost { |
| 28 public: |
| 29 TransformFeedback(TransformFeedbackManager* manager, GLuint service_id); |
| 30 |
| 31 // All the following functions do state update and call the underlying GL |
| 32 // function. All validations have been done already and the GL function is |
| 33 // guaranteed to succeed. |
| 34 void DoBindTransformFeedback( |
| 35 const gfx::GLVersionInfo& gl_version_info, GLenum target); |
| 36 void DoBeginTransformFeedback(GLenum primitive_mode); |
| 37 void DoEndTransformFeedback(); |
| 38 void DoPauseTransformFeedback(); |
| 39 void DoResumeTransformFeedback(); |
| 40 |
| 41 void MarkAsDeleted() { |
| 42 deleted_ = true; |
| 43 } |
| 44 |
| 45 GLuint service_id() const { |
| 46 return service_id_; |
| 47 } |
| 48 |
| 49 bool deleted() const { |
| 50 return deleted_; |
| 51 } |
| 52 |
| 53 bool active() const { |
| 54 return active_; |
| 55 } |
| 56 |
| 57 bool paused() const { |
| 58 return paused_; |
| 59 } |
| 60 |
| 61 GLenum primitive_mode() const { |
| 62 return primitive_mode_; |
| 63 } |
| 64 |
| 65 private: |
| 66 ~TransformFeedback() override; |
| 67 |
| 68 // The manager that owns this Buffer. |
| 69 TransformFeedbackManager* manager_; |
| 70 |
| 71 GLuint service_id_; |
| 72 |
| 73 bool deleted_; |
| 74 |
| 75 bool active_; |
| 76 bool paused_; |
| 77 |
| 78 GLenum primitive_mode_; |
| 79 }; |
| 80 |
| 81 // This class keeps tracks of the transform feedbacks and their states. |
| 82 class GPU_EXPORT TransformFeedbackManager { |
| 83 public: |
| 84 TransformFeedbackManager(GLuint max_transform_feedback_separate_attribs); |
| 85 ~TransformFeedbackManager(); |
| 86 |
| 87 // Must call before destruction. |
| 88 void Destroy(bool have_context); |
| 89 |
| 90 // Creates a TransformFeedback from the given client/service IDs and |
| 91 // insert it into the list. |
| 92 TransformFeedback* CreateTransformFeedback( |
| 93 GLuint client_id, GLuint service_id); |
| 94 |
| 95 TransformFeedback* GetTransformFeedback(GLuint client_id); |
| 96 |
| 97 // Removes a TransformFeedback info for the given client ID. |
| 98 void RemoveTransformFeedback(GLuint client_id); |
| 99 |
| 100 void RemoveBoundBuffer(Buffer* buffer); |
| 101 |
| 102 GLuint max_transform_feedback_separate_attribs() const { |
| 103 return max_transform_feedback_separate_attribs_; |
| 104 } |
| 105 |
| 106 bool have_context() const { |
| 107 return have_context_; |
| 108 } |
| 109 |
| 110 private: |
| 111 // Info for each transform feedback in the system. |
| 112 base::hash_map<GLuint, |
| 113 scoped_refptr<TransformFeedback> > transform_feedbacks_; |
| 114 |
| 115 GLuint max_transform_feedback_separate_attribs_; |
| 116 |
| 117 bool have_context_; |
| 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(TransformFeedbackManager); |
| 120 }; |
| 121 |
| 122 } // namespace gles2 |
| 123 } // namespace gpu |
| 124 |
| 125 #endif // GPU_COMMAND_BUFFER_SERVICE_TRANSFORM_FEEDBACK_MANAGER_H_ |
OLD | NEW |