1 // Copyright 2021 Google LLC. 2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3 4 #ifndef SortTypes_DEFINED 5 #define SortTypes_DEFINED 6 7 #include "include/gpu/GrTypes.h" 8 9 enum class Shape { 10 kRect, 11 kOval 12 }; 13 14 // This is strictly used to check if we get the order of draw operations we expected. It is 15 // pretty much the same as painters order though. 16 class ID { 17 public: ID(int id)18 explicit ID(int id) : fID(id) { 19 SkASSERT(id != -1); 20 } 21 Invalid()22 static ID Invalid() { 23 return ID(); 24 } 25 isValid()26 bool isValid() const { return fID != -1; } 27 28 bool operator==(ID other) const { return fID == other.fID; } 29 toInt()30 int toInt() const { return fID; } 31 32 private: ID()33 ID() : fID(-1) {} 34 35 int fID; 36 }; 37 38 // This class just serves to strictly differentiate between painter's order and the sort/draw Zs 39 class PaintersOrder { 40 public: PaintersOrder()41 PaintersOrder() : fPaintersOrder(0) {} 42 PaintersOrder(uint32_t paintersOrder)43 explicit PaintersOrder(uint32_t paintersOrder) : fPaintersOrder(paintersOrder) { 44 SkASSERT(paintersOrder != 0); 45 } 46 Invalid()47 static PaintersOrder Invalid() { 48 return PaintersOrder(); 49 } 50 isValid()51 bool isValid() const { return fPaintersOrder != 0; } 52 toUInt()53 uint32_t toUInt() const { return fPaintersOrder; } 54 55 private: 56 uint32_t fPaintersOrder = 0; 57 }; 58 59 #endif 60