1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrPath_DEFINED 9 #define GrPath_DEFINED 10 11 #include "GrGpuResource.h" 12 #include "GrPathRendering.h" 13 #include "GrStyle.h" 14 #include "SkPath.h" 15 #include "SkRect.h" 16 17 class GrShape; 18 19 class GrPath : public GrGpuResource { 20 public: 21 /** 22 * Initialize to a path with a fixed stroke. Stroke must not be hairline. 23 */ 24 GrPath(GrGpu* gpu, const SkPath& skPath, const GrStyle& style) 25 : INHERITED(gpu) 26 , fBounds(SkRect::MakeEmpty()) 27 , fFillType(GrPathRendering::kWinding_FillType) 28 #ifdef SK_DEBUG 29 , fSkPath(skPath) 30 , fStyle(style) 31 #endif 32 { 33 } 34 35 static void ComputeKey(const GrShape&, GrUniqueKey* key, bool* outIsVolatile); 36 37 const SkRect& getBounds() const { return fBounds; } 38 39 GrPathRendering::FillType getFillType() const { return fFillType; } 40 #ifdef SK_DEBUG 41 bool isEqualTo(const SkPath& path, const GrStyle& style) const; 42 #endif 43 44 protected: 45 // Subclass should init these. 46 SkRect fBounds; 47 GrPathRendering::FillType fFillType; 48 #ifdef SK_DEBUG 49 SkPath fSkPath; 50 GrStyle fStyle; 51 #endif 52 53 private: 54 const char* getResourceType() const override { return "Path Data"; } 55 typedef GrGpuResource INHERITED; 56 }; 57 58 #endif 59