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

Side by Side Diff: src/gpu/GrPathRange.h

Issue 1116123003: Improve caching of dashed paths in GrStencilAndCoverPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr-01
Patch Set: . Created 5 years, 7 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
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 GrPathRange_DEFINED 8 #ifndef GrPathRange_DEFINED
9 #define GrPathRange_DEFINED 9 #define GrPathRange_DEFINED
10 10
11 #include "GrGpuResource.h" 11 #include "GrGpuResource.h"
12 #include "SkRefCnt.h" 12 #include "SkRefCnt.h"
13 #include "SkStrokeRec.h"
14 #include "SkTArray.h" 13 #include "SkTArray.h"
15 14
16 class SkPath; 15 class SkPath;
17 class SkDescriptor; 16 class SkDescriptor;
18 17
19 /** 18 /**
20 * Represents a contiguous range of GPU path objects, all with a common stroke. 19 * Represents a contiguous range of GPU path objects.
21 * This object is immutable with the exception that individual paths may be 20 * This object is immutable with the exception that individual paths may be
22 * initialized lazily. 21 * initialized lazily.
23 */ 22 */
24 23
25 class GrPathRange : public GrGpuResource { 24 class GrPathRange : public GrGpuResource {
26 public: 25 public:
27 SK_DECLARE_INST_COUNT(GrPathRange); 26 SK_DECLARE_INST_COUNT(GrPathRange);
28 27
29 enum PathIndexType { 28 enum PathIndexType {
30 kU8_PathIndexType, //!< uint8_t 29 kU8_PathIndexType, //!< uint8_t
(...skipping 20 matching lines...) Expand all
51 virtual int getNumPaths() = 0; 50 virtual int getNumPaths() = 0;
52 virtual void generatePath(int index, SkPath* out) = 0; 51 virtual void generatePath(int index, SkPath* out) = 0;
53 virtual bool isEqualTo(const SkDescriptor&) const { return false; } 52 virtual bool isEqualTo(const SkDescriptor&) const { return false; }
54 virtual ~PathGenerator() {} 53 virtual ~PathGenerator() {}
55 }; 54 };
56 55
57 /** 56 /**
58 * Initialize a lazy-loaded path range. This class will generate an SkPath a nd call 57 * Initialize a lazy-loaded path range. This class will generate an SkPath a nd call
59 * onInitPath() for each path within the range before it is drawn for the fi rst time. 58 * onInitPath() for each path within the range before it is drawn for the fi rst time.
60 */ 59 */
61 GrPathRange(GrGpu*, PathGenerator*, const SkStrokeRec& stroke); 60 GrPathRange(GrGpu*, PathGenerator*);
62 61
63 /** 62 /**
64 * Initialize an eager-loaded path range. The subclass is responsible for en suring all 63 * Initialize an eager-loaded path range. The subclass is responsible for en suring all
65 * the paths are initialized up front. 64 * the paths are initialized up front.
66 */ 65 */
67 GrPathRange(GrGpu*, int numPaths, const SkStrokeRec& stroke); 66 GrPathRange(GrGpu*, int numPaths);
68 67
69 virtual bool isEqualTo(const SkDescriptor& desc) const { 68 virtual bool isEqualTo(const SkDescriptor& desc) const {
70 return NULL != fPathGenerator.get() && fPathGenerator->isEqualTo(desc); 69 return NULL != fPathGenerator.get() && fPathGenerator->isEqualTo(desc);
71 } 70 }
72 71
73 int getNumPaths() const { return fNumPaths; } 72 int getNumPaths() const { return fNumPaths; }
74 const SkStrokeRec& getStroke() const { return fStroke; }
75 const PathGenerator* getPathGenerator() const { return fPathGenerator.get(); } 73 const PathGenerator* getPathGenerator() const { return fPathGenerator.get(); }
76 74
77 protected: 75 protected:
78 // Initialize a path in the range before drawing. This is only called when 76 // Initialize a path in the range before drawing. This is only called when
79 // fPathGenerator is non-null. The child class need not call didChangeGpuMem orySize(), 77 // fPathGenerator is non-null. The child class need not call didChangeGpuMem orySize(),
80 // GrPathRange will take care of that after the call is complete. 78 // GrPathRange will take care of that after the call is complete.
81 virtual void onInitPath(int index, const SkPath&) const = 0; 79 virtual void onInitPath(int index, const SkPath&) const = 0;
82 80
83 private: 81 private:
84 // Notify when paths will be drawn in case this is a lazy-loaded path range. 82 // Notify when paths will be drawn in case this is a lazy-loaded path range.
85 friend class GrGpu; 83 friend class GrGpu;
86 void willDrawPaths(const void* indices, PathIndexType, int count) const; 84 void willDrawPaths(const void* indices, PathIndexType, int count) const;
87 template<typename IndexType> void willDrawPaths(const void* indices, int cou nt) const; 85 template<typename IndexType> void willDrawPaths(const void* indices, int cou nt) const;
88 86
89 mutable SkAutoTUnref<PathGenerator> fPathGenerator; 87 mutable SkAutoTUnref<PathGenerator> fPathGenerator;
90 mutable SkTArray<uint8_t, true /*MEM_COPY*/> fGeneratedPaths; 88 mutable SkTArray<uint8_t, true /*MEM_COPY*/> fGeneratedPaths;
91 const int fNumPaths; 89 const int fNumPaths;
92 const SkStrokeRec fStroke;
93 90
94 typedef GrGpuResource INHERITED; 91 typedef GrGpuResource INHERITED;
95 }; 92 };
96 93
97 #endif 94 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698