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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_
10 #include "base/basictypes.h"
11 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "gpu/gpu_export.h"
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
{
24 // Must call before destruction.
25 void Destroy(bool have_context
);
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
);
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;
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;
41 // Removes a closed interval of paths [first_client_id, last_client_id].
42 void RemovePaths(GLuint first_client_id
, GLuint last_client_id
);
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
;
53 typedef std::map
<GLuint
, PathRangeDescription
> PathRangeMap
;
56 // Checks for consistency inside the book-keeping structures. Used as
57 // DCHECK pre/post condition in mutating functions.
58 bool CheckConsistency();
60 PathRangeMap path_map_
;
62 DISALLOW_COPY_AND_ASSIGN(PathManager
);
68 #endif // GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_