OLD | NEW |
(Empty) | |
| 1 |
| 2 /* |
| 3 * Copyright 2014 Google Inc. |
| 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. |
| 7 */ |
| 8 |
| 9 #ifndef GrAADistanceFieldPathRenderer_DEFINED |
| 10 #define GrAADistanceFieldPathRenderer_DEFINED |
| 11 |
| 12 #include "GrAllocPool.h" |
| 13 #include "GrAtlas.h" |
| 14 #include "GrPathRenderer.h" |
| 15 #include "GrRect.h" |
| 16 |
| 17 #include "SkChecksum.h" |
| 18 |
| 19 class GrContext; |
| 20 class GrPlot; |
| 21 |
| 22 class GrAADistanceFieldPathRenderer : public GrPathRenderer { |
| 23 public: |
| 24 GrAADistanceFieldPathRenderer(GrContext* context) |
| 25 : fContext(context) |
| 26 , fAtlas(NULL) { |
| 27 } |
| 28 |
| 29 virtual ~GrAADistanceFieldPathRenderer(); |
| 30 |
| 31 virtual bool canDrawPath(const SkPath& path, |
| 32 const SkStrokeRec& stroke, |
| 33 const GrDrawTarget* target, |
| 34 bool antiAlias) const SK_OVERRIDE; |
| 35 |
| 36 protected: |
| 37 virtual StencilSupport onGetStencilSupport(const SkPath&, |
| 38 const SkStrokeRec&, |
| 39 const GrDrawTarget*) const SK_OVE
RRIDE; |
| 40 |
| 41 virtual bool onDrawPath(const SkPath& path, |
| 42 const SkStrokeRec& stroke, |
| 43 GrDrawTarget* target, |
| 44 bool antiAlias) SK_OVERRIDE; |
| 45 |
| 46 private: |
| 47 struct PathData { |
| 48 uint32_t fGenID; |
| 49 GrPlot* fPlot; |
| 50 SkRect fBounds; |
| 51 SkIPoint16 fAtlasLocation; |
| 52 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); |
| 53 |
| 54 static inline const uint32_t& GetKey(const PathData& data) { |
| 55 return data.fGenID; |
| 56 } |
| 57 |
| 58 static inline uint32_t Hash(uint32_t key) { |
| 59 return SkChecksum::Murmur3(&key, sizeof(key)); |
| 60 } |
| 61 }; |
| 62 typedef SkTInternalLList<PathData> PathDataList; |
| 63 |
| 64 GrContext* fContext; |
| 65 GrAtlas* fAtlas; |
| 66 GrAtlas::ClientPlotUsage fPlotUsage; |
| 67 SkTDynamicHash<PathData, uint32_t> fPathCache; |
| 68 PathDataList fPathList; |
| 69 |
| 70 bool internalDrawPath(const SkPath& path, const PathData* pathData, GrDrawTa
rget* target); |
| 71 PathData* addPathToAtlas(const SkPath& path, const SkStrokeRec& stroke, bool
antiAlias); |
| 72 bool freeUnusedPlot(); |
| 73 |
| 74 typedef GrPathRenderer INHERITED; |
| 75 }; |
| 76 |
| 77 #endif |
OLD | NEW |