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

Side by Side Diff: src/core/SkTDPQueue.h

Issue 1120023003: Refugee from Dead Machine 13: New version of the convex AA tessellator Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 7 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
« no previous file with comments | « samplecode/SampleAnimator.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTDPQueue_DEFINED 8 #ifndef SkTDPQueue_DEFINED
9 #define SkTDPQueue_DEFINED 9 #define SkTDPQueue_DEFINED
10 10
11 #include "SkTDArray.h" 11 #include "SkTDArray.h"
12 12
13 /** 13 /**
14 * This class implements a priority queue. T is the type of the elements in the queue. LESS is a 14 * This class implements a priority queue. T is the type of the elements in the queue. LESS is a
15 * function that compares two Ts and returns true if the first is higher priorit y than the second. 15 * function that compares two Ts and returns true if the first is higher priorit y than the second.
16 * 16 *
17 * Optionally objects may know their index into the priority queue. The queue wi ll update the index 17 * Optionally objects may know their index into the priority queue. The queue wi ll update the index
18 * as the objects move through the queue. This is enabled by using a non-NULL fu nction for INDEX. 18 * as the objects move through the queue. This is enabled by using a non-NULL fu nction for INDEX.
19 * When an INDEX function is provided random deletes from the queue are allowed using remove(). 19 * When an INDEX function is provided random deletes from the queue are allowed using remove().
20 * Additionally, the * priority is allowed to change as long as priorityDidChang e() is called 20 * Additionally, the priority is allowed to change as long as priorityDidChange( ) is called
21 * afterwards. In debug builds the index will be set to -1 before an element is removed from the 21 * afterwards. In debug builds the index will be set to -1 before an element is removed from the
22 * queue. 22 * queue.
23 */ 23 */
24 template <typename T, 24 template <typename T,
25 bool (*LESS)(const T&, const T&), 25 bool (*LESS)(const T&, const T&),
26 int* (*INDEX)(const T&) = (int* (*)(const T&))NULL> 26 int* (*INDEX)(const T&) = (int* (*)(const T&))NULL>
27 class SkTDPQueue : public SkNoncopyable { 27 class SkTDPQueue : public SkNoncopyable {
28 public: 28 public:
29 SkTDPQueue() {} 29 SkTDPQueue() {}
30 30
31 /** Number of items in the queue. */ 31 /** Number of items in the queue. */
32 int count() const { return fArray.count(); } 32 int count() const { return fArray.count(); }
33 33
34 void setReserve(int reserve) { fArray.setReserve(reserve); }
35 void rewind() { fArray.rewind(); }
36
34 /** Gets the next item in the queue without popping it. */ 37 /** Gets the next item in the queue without popping it. */
35 const T& peek() const { return fArray[0]; } 38 const T& peek() const { return fArray[0]; }
36 T& peek() { return fArray[0]; } 39 T& peek() { return fArray[0]; }
37 40
38 /** Removes the next item. */ 41 /** Removes the next item. */
39 void pop() { 42 void pop() {
40 this->validate(); 43 this->validate();
41 SkDEBUGCODE(if (SkToBool(INDEX)) { *INDEX(fArray[0]) = -1; }) 44 SkDEBUGCODE(if (SkToBool(INDEX)) { *INDEX(fArray[0]) = -1; })
42 if (1 == fArray.count()) { 45 if (1 == fArray.count()) {
43 fArray.pop(); 46 fArray.pop();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 189 }
187 #endif 190 #endif
188 } 191 }
189 192
190 SkTDArray<T> fArray; 193 SkTDArray<T> fArray;
191 194
192 typedef SkNoncopyable INHERITED; 195 typedef SkNoncopyable INHERITED;
193 }; 196 };
194 197
195 #endif 198 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleAnimator.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698