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

Side by Side Diff: include/core/SkPathRef.h

Issue 1114353004: Implement vertex buffer caching in the tessellated path renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Win32 build fix; remove unused fn Created 5 years, 4 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
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkPathRef_DEFINED 9 #ifndef SkPathRef_DEFINED
10 #define SkPathRef_DEFINED 10 #define SkPathRef_DEFINED
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 static SkPathRef* CreateFromBuffer(SkRBuffer* buffer); 174 static SkPathRef* CreateFromBuffer(SkRBuffer* buffer);
175 175
176 /** 176 /**
177 * Rollsback a path ref to zero verbs and points with the assumption that th e path ref will be 177 * Rollsback a path ref to zero verbs and points with the assumption that th e path ref will be
178 * repopulated with approximately the same number of verbs and points. A new path ref is created 178 * repopulated with approximately the same number of verbs and points. A new path ref is created
179 * only if necessary. 179 * only if necessary.
180 */ 180 */
181 static void Rewind(SkAutoTUnref<SkPathRef>* pathRef); 181 static void Rewind(SkAutoTUnref<SkPathRef>* pathRef);
182 182
183 virtual ~SkPathRef() { 183 virtual ~SkPathRef();
184 SkDEBUGCODE(this->validate();)
185 sk_free(fPoints);
186
187 SkDEBUGCODE(fPoints = NULL;)
188 SkDEBUGCODE(fVerbs = NULL;)
189 SkDEBUGCODE(fVerbCnt = 0x9999999;)
190 SkDEBUGCODE(fPointCnt = 0xAAAAAAA;)
191 SkDEBUGCODE(fPointCnt = 0xBBBBBBB;)
192 SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;)
193 SkDEBUGCODE(fEditorsAttached = 0x7777777;)
194 }
195
196 int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; } 184 int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; }
197 int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; } 185 int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; }
198 int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeigh ts.count(); } 186 int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeigh ts.count(); }
199 187
200 /** 188 /**
201 * Returns a pointer one beyond the first logical verb (last verb in memory order). 189 * Returns a pointer one beyond the first logical verb (last verb in memory order).
202 */ 190 */
203 const uint8_t* verbs() const { SkDEBUGCODE(this->validate();) return fVerbs; } 191 const uint8_t* verbs() const { SkDEBUGCODE(this->validate();) return fVerbs; }
204 192
205 /** 193 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 */ 232 */
245 uint32_t writeSize() const; 233 uint32_t writeSize() const;
246 234
247 /** 235 /**
248 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the 236 * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
249 * same ID then they have the same verbs and points. However, two path refs may have the same 237 * same ID then they have the same verbs and points. However, two path refs may have the same
250 * contents but different genIDs. 238 * contents but different genIDs.
251 */ 239 */
252 uint32_t genID() const; 240 uint32_t genID() const;
253 241
242 struct GenIDChangeListener {
243 virtual ~GenIDChangeListener() {}
244 virtual void onChange() = 0;
245 };
246
247 void addGenIDChangeListener(GenIDChangeListener* listener);
248
254 SkDEBUGCODE(void validate() const;) 249 SkDEBUGCODE(void validate() const;)
255 250
256 private: 251 private:
257 enum SerializationOffsets { 252 enum SerializationOffsets {
258 kIsFinite_SerializationShift = 25, // requires 1 bit 253 kIsFinite_SerializationShift = 25, // requires 1 bit
259 kIsOval_SerializationShift = 24, // requires 1 bit 254 kIsOval_SerializationShift = 24, // requires 1 bit
260 kSegmentMask_SerializationShift = 0 // requires 4 bits 255 kSegmentMask_SerializationShift = 0 // requires 4 bits
261 }; 256 };
262 257
263 SkPathRef() { 258 SkPathRef() {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 friend SkPathRef* sk_create_empty_pathref(); 416 friend SkPathRef* sk_create_empty_pathref();
422 417
423 void setIsOval(bool isOval) { fIsOval = isOval; } 418 void setIsOval(bool isOval) { fIsOval = isOval; }
424 419
425 SkPoint* getPoints() { 420 SkPoint* getPoints() {
426 SkDEBUGCODE(this->validate();) 421 SkDEBUGCODE(this->validate();)
427 fIsOval = false; 422 fIsOval = false;
428 return fPoints; 423 return fPoints;
429 } 424 }
430 425
426 void callGenIDChangeListeners();
427
431 enum { 428 enum {
432 kMinSize = 256, 429 kMinSize = 256,
433 }; 430 };
434 431
435 mutable SkRect fBounds; 432 mutable SkRect fBounds;
436 mutable uint8_t fBoundsIsDirty; 433 mutable uint8_t fBoundsIsDirty;
437 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid 434 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
438 435
439 SkBool8 fIsOval; 436 SkBool8 fIsOval;
440 uint8_t fSegmentMask; 437 uint8_t fSegmentMask;
441 438
442 SkPoint* fPoints; // points to begining of the allocation 439 SkPoint* fPoints; // points to begining of the allocation
443 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards) 440 uint8_t* fVerbs; // points just past the end of the allocation (v erbs grow backwards)
444 int fVerbCnt; 441 int fVerbCnt;
445 int fPointCnt; 442 int fPointCnt;
446 size_t fFreeSpace; // redundant but saves computation 443 size_t fFreeSpace; // redundant but saves computation
447 SkTDArray<SkScalar> fConicWeights; 444 SkTDArray<SkScalar> fConicWeights;
448 445
449 enum { 446 enum {
450 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. 447 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs.
451 }; 448 };
452 mutable uint32_t fGenerationID; 449 mutable uint32_t fGenerationID;
453 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. 450 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
454 451
452 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne d
453
455 friend class PathRefTest_Private; 454 friend class PathRefTest_Private;
456 typedef SkRefCnt INHERITED; 455 typedef SkRefCnt INHERITED;
457 }; 456 };
458 457
459 #endif 458 #endif
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPathRef.cpp » ('j') | src/core/SkPathRef.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698