3 * Copyright 2014 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #ifndef GrAADistanceFieldPathRenderer_DEFINED
10 #define GrAADistanceFieldPathRenderer_DEFINED
12 #include "GrBatchAtlas.h"
13 #include "GrPathRenderer.h"
16 #include "SkChecksum.h"
17 #include "SkTDynamicHash.h"
21 class GrAADistanceFieldPathRenderer : public GrPathRenderer {
23 GrAADistanceFieldPathRenderer(GrContext* context);
24 virtual ~GrAADistanceFieldPathRenderer();
26 virtual bool canDrawPath(const GrDrawTarget*,
27 const GrPipelineBuilder*,
28 const SkMatrix& viewMatrix,
31 bool antiAlias) const SK_OVERRIDE;
34 virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
35 const GrPipelineBuilder*,
37 const SkStrokeRec&) const SK_OVERRIDE;
39 virtual bool onDrawPath(GrDrawTarget*,
42 const SkMatrix& viewMatrix,
45 bool antiAlias) SK_OVERRIDE;
51 // rendered size for stored path (32x32 max, 64x64 max, 128x128 max)
53 bool operator==(const Key& other) const {
54 return other.fGenID == fGenID && other.fDimension == fDimension;
59 GrBatchAtlas::AtlasID fID;
61 SkIPoint16 fAtlasLocation;
62 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData);
64 static inline const Key& GetKey(const PathData& data) {
68 static inline uint32_t Hash(Key key) {
69 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), sizeof(key));
73 static void HandleEviction(GrBatchAtlas::AtlasID, void*);
75 typedef SkTInternalLList<PathData> PathDataList;
79 SkTDynamicHash<PathData, PathData::Key> fPathCache;
80 PathDataList fPathList;
82 typedef GrPathRenderer INHERITED;
84 friend class AADistanceFieldPathBatch;