Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: gpu/command_buffer/service/path_manager.h

Issue 169403005: command_buffer: Implement path rendering functions for CHROMIUM_path_rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nv-pr-02-texgen
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
vmiura 2015/06/19 21:55:22 Now -> 2015
Kimmo Kinnunen 2015/06/23 12:03:10 Done.
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 private:
45 // Mapping between client id and service id.
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 template <typename RangeIterator>
56 static GLuint RangeSize(const RangeIterator& it) {
57 return it->second.last_client_id - it->first + 1;
58 }
59 template <typename RangeIterator>
60 static GLuint FirstClientId(const RangeIterator& it) {
61 return it->first;
62 }
63 template <typename RangeIterator>
64 static GLuint FirstServiceId(const RangeIterator& it) {
65 return it->second.first_service_id;
66 }
67 template <typename RangeIterator>
68 static GLuint LastServiceId(const RangeIterator& it) {
69 return FirstServiceId(it) + RangeSize(it) - 1;
70 }
71 static GLuint LastClientId(PathRangeMap::const_iterator& it) {
72 return it->second.last_client_id;
73 }
74 // Note: this one can be assigned to.
75 static GLuint& LastClientId(PathRangeMap::iterator& it) {
76 return it->second.last_client_id;
77 }
78
79 PathRangeMap path_map_;
80
81 DISALLOW_COPY_AND_ASSIGN(PathManager);
82 };
83
84 } // namespace gles2
85 } // namespace gpu
86
87 #endif // GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698