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 "SkPath.h" 13#include "SkRect.h" 14#include "SkStrokeRec.h" 15 16class GrPath : public GrGpuResource { 17public: 18 SK_DECLARE_INST_COUNT(GrPath); 19 20 /** 21 * Initialize to a path with a fixed stroke. Stroke must not be hairline. 22 */ 23 GrPath(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) 24 : INHERITED(gpu, kCached_LifeCycle), 25 fSkPath(skPath), 26 fStroke(stroke), 27 fBounds(skPath.getBounds()) { 28 } 29 30 static void ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrUniqueKey* key); 31 static uint64_t ComputeStrokeKey(const SkStrokeRec&); 32 33 bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) { 34 return fSkPath == path && fStroke.hasEqualEffect(stroke); 35 } 36 37 const SkRect& getBounds() const { return fBounds; } 38 39 const SkStrokeRec& getStroke() const { return fStroke; } 40 41protected: 42 SkPath fSkPath; 43 SkStrokeRec fStroke; 44 SkRect fBounds; 45 46private: 47 typedef GrGpuResource INHERITED; 48}; 49 50#endif 51