OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 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_PATH_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "gpu/command_buffer/service/gl_utils.h" |
| 12 #include "gpu/gpu_export.h" |
| 13 |
| 14 namespace gpu { |
| 15 namespace gles2 { |
| 16 |
| 17 // This class keeps track of paths and their client and service ids |
| 18 // so we can correctly clear them. |
| 19 class GPU_EXPORT PathManager { |
| 20 public: |
| 21 PathManager(); |
| 22 ~PathManager(); |
| 23 |
| 24 // Must call before destruction. |
| 25 void Destroy(bool have_context); |
| 26 |
| 27 // Creates a path mapping between closed intervals |
| 28 // [first_client_id, last_client_id] -> [first_service_id, ...]. |
| 29 void CreatePathRange(GLuint first_client_id, |
| 30 GLuint last_client_id, |
| 31 GLuint first_service_id); |
| 32 |
| 33 // Returns true if any path exists in the closed interval |
| 34 // [first_client_id, last_client_id]. |
| 35 bool HasPathsInRange(GLuint first_client_id, GLuint last_client_id) const; |
| 36 |
| 37 // Gets the path id corresponding the client path id. |
| 38 // Returns false if no such service path id was not found. |
| 39 bool GetPath(GLuint client_id, GLuint* service_id) const; |
| 40 |
| 41 // Removes a closed interval of paths [first_client_id, last_client_id]. |
| 42 void RemovePaths(GLuint first_client_id, GLuint last_client_id); |
| 43 |
| 44 // Mapping between client id and service id. |
| 45 // Should be used only by the implementation. |
| 46 struct PathRangeDescription { |
| 47 PathRangeDescription(GLuint last_client, GLuint first_service) |
| 48 : last_client_id(last_client), first_service_id(first_service) {} |
| 49 GLuint last_client_id; |
| 50 GLuint first_service_id; |
| 51 typedef GLuint ServiceIdType; |
| 52 }; |
| 53 typedef std::map<GLuint, PathRangeDescription> PathRangeMap; |
| 54 |
| 55 private: |
| 56 // Checks for consistency inside the book-keeping structures. Used as |
| 57 // DCHECK pre/post condition in mutating functions. |
| 58 bool CheckConsistency(); |
| 59 |
| 60 PathRangeMap path_map_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(PathManager); |
| 63 }; |
| 64 |
| 65 } // namespace gles2 |
| 66 } // namespace gpu |
| 67 |
| 68 #endif // GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_ |
OLD | NEW |