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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/path_manager.h
diff --git a/gpu/command_buffer/service/path_manager.h b/gpu/command_buffer/service/path_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..a78ce4f061f769967c0f64a2454ad3c0a9425097
--- /dev/null
+++ b/gpu/command_buffer/service/path_manager.h
@@ -0,0 +1,117 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_
+#define GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "gpu/command_buffer/service/gl_utils.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+namespace gles2 {
+
+// This class keeps track of paths and their client and service ids
+// so we can correctly clear them.
+class GPU_EXPORT PathManager {
+ public:
+ PathManager();
+ ~PathManager();
+
+ // Must call before destruction.
+ void Destroy(bool have_context);
+
+ // Creates a path mapping between closed intervals
+ // [first_client_id, last_client_id] -> [first_service_id, ...].
+ void CreatePathRange(GLuint first_client_id,
+ GLuint last_client_id,
+ GLuint first_service_id);
+
+ // Returns true if any path exists in the closed interval
+ // [first_client_id, last_client_id].
+ bool HasPathsInRange(GLuint first_client_id, GLuint last_client_id) const;
+
+ // Gets the path id corresponding the client path id.
+ // Returns false if no such service path id was not found.
+ bool GetPath(GLuint client_id, GLuint* service_id) const;
+
+ // Removes a closed interval of paths [first_client_id, last_client_id].
+ void RemovePaths(GLuint first_client_id, GLuint last_client_id);
+
+ private:
+ // Mapping between client id and service id.
+ // Should be used only by the implementation.
+ struct PathRangeDescription {
+ PathRangeDescription(GLuint last_client, GLuint first_service)
+ : last_client_id(last_client), first_service_id(first_service) {}
+ GLuint last_client_id;
+ GLuint first_service_id;
+ typedef GLuint ServiceIdType;
+ };
+ typedef std::map<GLuint, PathRangeDescription> PathRangeMap;
+
+ template <typename RangeIterator>
+ static GLuint RangeSize(const RangeIterator& it) {
+ return it->second.last_client_id - it->first + 1;
+ }
+ template <typename RangeIterator>
+ static GLuint FirstClientId(const RangeIterator& it) {
+ return it->first;
+ }
+ template <typename RangeIterator>
+ static GLuint FirstServiceId(const RangeIterator& it) {
+ return it->second.first_service_id;
+ }
+ template <typename RangeIterator>
+ static GLuint LastServiceId(const RangeIterator& it) {
+ return FirstServiceId(it) + RangeSize(it) - 1;
+ }
+ static GLuint LastClientId(PathManager::PathRangeMap::const_iterator& it) {
+ return it->second.last_client_id;
+ }
+ // Note: this one can be assigned to.
+ static GLuint& LastClientId(PathManager::PathRangeMap::iterator& it) {
+ return it->second.last_client_id;
+ }
+
+ template <typename T>
+ struct IteratorSelector {
+ typedef typename T::iterator iterator;
+ };
+ template <typename T>
+ struct IteratorSelector<const T> {
+ typedef typename T::const_iterator iterator;
+ };
+
+ // Returns the range position that contains |client_id| or
+ // |PathRangeMap::iterator::end()| if |client_id| is not found.
+ template <typename MapType>
+ static typename IteratorSelector<MapType>::iterator GetContainingRange(
+ MapType& path_map,
+ GLuint client_id);
+
+ // Returns the range position that contains |client_id|. If that is
+ // not available, returns the range that has smallest
+ // |first_client_id| that is bigger than |client_id|. Returns
+ // |PathRangeMap::iterator::end()| if there is no such range.
+ template <typename MapType>
+ static typename IteratorSelector<MapType>::iterator GetContainingOrNextRange(
+ MapType& path_map,
+ GLuint client_id);
+
+ // Checks for consistency inside the book-keeping structures. Used as
+ // DCHECK pre/post condition in mutating functions.
+ bool CheckConsistency();
+
+ PathRangeMap path_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(PathManager);
+};
+
+} // namespace gles2
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_PATH_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698