Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: src/gpu/batches/GrAADistanceFieldPathRenderer.h

Issue 2064753003: Remove style application from GrPathRenderer subclasses (Closed) Base URL: https://chromium.googlesource.com/skia.git@pathshape
Patch Set: Remove random style from DF batch test create, since it now only allows simple fill Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrStyle.h ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrAADistanceFieldPathRenderer_DEFINED 8 #ifndef GrAADistanceFieldPathRenderer_DEFINED
9 #define GrAADistanceFieldPathRenderer_DEFINED 9 #define GrAADistanceFieldPathRenderer_DEFINED
10 10
11 #include "GrBatchAtlas.h" 11 #include "GrBatchAtlas.h"
12 #include "GrPathRenderer.h" 12 #include "GrPathRenderer.h"
13 #include "GrRect.h" 13 #include "GrRect.h"
14 #include "GrShape.h"
14 15
15 #include "SkChecksum.h" 16 #include "SkChecksum.h"
16 #include "SkTDynamicHash.h" 17 #include "SkTDynamicHash.h"
17 18
18 class GrContext; 19 class GrContext;
19 20
20 class GrAADistanceFieldPathRenderer : public GrPathRenderer { 21 class GrAADistanceFieldPathRenderer : public GrPathRenderer {
21 public: 22 public:
22 GrAADistanceFieldPathRenderer(); 23 GrAADistanceFieldPathRenderer();
23 virtual ~GrAADistanceFieldPathRenderer(); 24 virtual ~GrAADistanceFieldPathRenderer();
24 25
25 private: 26 private:
26 StencilSupport onGetStencilSupport(const GrShape&) const override { 27 StencilSupport onGetStencilSupport(const GrShape&) const override {
27 return GrPathRenderer::kNoSupport_StencilSupport; 28 return GrPathRenderer::kNoSupport_StencilSupport;
28 } 29 }
29 30
30 bool onCanDrawPath(const CanDrawPathArgs&) const override; 31 bool onCanDrawPath(const CanDrawPathArgs&) const override;
31 32
32 bool onDrawPath(const DrawPathArgs&) override; 33 bool onDrawPath(const DrawPathArgs&) override;
33 34
34 struct PathData { 35 struct ShapeData {
35 class Key { 36 class Key {
36 public: 37 public:
37 // default ctor needed for new of uninitialized PathData 38 Key() {}
38 // since fStroke has no default ctor 39 Key(const Key& that) { *this = that; }
39 Key() 40 Key(const GrShape& shape, uint32_t dim) { this->set(shape, dim); }
40 : fGenID(0)
41 , fDimension(0)
42 , fStroke(SkStrokeRec::kFill_InitStyle) {}
43 Key(uint32_t genID, uint32_t dim, const SkStrokeRec& stroke)
44 : fGenID(genID)
45 , fDimension(dim)
46 , fStroke(stroke) {}
47 41
48 bool operator==(const Key& other) const { 42 Key& operator=(const Key& that) {
49 return other.fGenID == fGenID && other.fDimension == fDimension && 43 fKey.reset(that.fKey.count());
50 fStroke.hasEqualEffect(other.fStroke); 44 memcpy(fKey.get(), that.fKey.get(), fKey.count() * sizeof(uint32 _t));
45 return *this;
51 } 46 }
52 47
48 void set(const GrShape& shape, uint32_t dim) {
49 // Shapes' keys are for their pre-style geometry, but by now we shouldn't have any
50 // relevant styling information.
51 SkASSERT(shape.style().isSimpleFill());
52 SkASSERT(shape.hasUnstyledKey());
53 int shapeKeySize = shape.unstyledKeySize();
54 fKey.reset(1 + shapeKeySize);
55 fKey[0] = dim;
56 shape.writeUnstyledKey(&fKey[1]);
57 }
58
59 bool operator==(const Key& that) const {
60 return fKey.count() == that.fKey.count() &&
61 0 == memcmp(fKey.get(), that.fKey.get(), sizeof(uint32_t ) * fKey.count());
62 }
63
64 int count32() const { return fKey.count(); }
65 const uint32_t* data() const { return fKey.get(); }
66
53 private: 67 private:
54 uint32_t fGenID; 68 // The key is composed of the dimensions of the DF generated for the path (32x32 max,
55 // rendered size for stored path (32x32 max, 64x64 max, 128x128 max) 69 // 64x64 max, 128x128 max) and the GrShape's key.
56 uint32_t fDimension; 70 SkAutoSTArray<24, uint32_t> fKey;
57 // stroking information
58 SkStrokeRec fStroke;
59 }; 71 };
60 Key fKey; 72 Key fKey;
61 SkScalar fScale; 73 SkScalar fScale;
62 GrBatchAtlas::AtlasID fID; 74 GrBatchAtlas::AtlasID fID;
63 SkRect fBounds; 75 SkRect fBounds;
64 SkIPoint16 fAtlasLocation; 76 SkIPoint16 fAtlasLocation;
65 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); 77 SK_DECLARE_INTERNAL_LLIST_INTERFACE(ShapeData);
66 78
67 static inline const Key& GetKey(const PathData& data) { 79 static inline const Key& GetKey(const ShapeData& data) {
68 return data.fKey; 80 return data.fKey;
69 } 81 }
70 82
71 static inline uint32_t Hash(Key key) { 83 static inline uint32_t Hash(Key key) {
72 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), sizeof(key)); 84 return SkChecksum::Murmur3(key.data(), sizeof(uint32_t) * key.count3 2());
73 } 85 }
74 }; 86 };
75 87
76 static void HandleEviction(GrBatchAtlas::AtlasID, void*); 88 static void HandleEviction(GrBatchAtlas::AtlasID, void*);
77 89
78 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; 90 typedef SkTDynamicHash<ShapeData, ShapeData::Key> ShapeCache;
79 typedef SkTInternalLList<PathData> PathDataList; 91 typedef SkTInternalLList<ShapeData> ShapeDataList;
80 92
81 GrBatchAtlas* fAtlas; 93 GrBatchAtlas* fAtlas;
82 PathCache fPathCache; 94 ShapeCache fShapeCache;
83 PathDataList fPathList; 95 ShapeDataList fShapeList;
84 96
85 typedef GrPathRenderer INHERITED; 97 typedef GrPathRenderer INHERITED;
86 98
87 friend class AADistanceFieldPathBatch; 99 friend class AADistanceFieldPathBatch;
88 friend struct PathTestStruct; 100 friend struct PathTestStruct;
89 }; 101 };
90 102
91 #endif 103 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrStyle.h ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698